Custom yaml file not setting values

Discussion in 'Plugin Development' started by Assist, Aug 25, 2013.

Thread Status:
Not open for further replies.
  1. I feel like a noob for posting another thread, but I'm on a rush. I have a custom yml file, and it's loading file, but for some odd reason it's not setting values in it. All debugs are being print in the console.

    First method.
    Code:java
    1. public void createMap(String id, Player user) throws EmptyClipboardException {
    2. clazz.getLogger().info("0");
    3. Selection sel = WorldEditUtil.getWorldEdit().getSelection(user);
    4.  
    5. if (sel != null) {
    6. clazz.getLogger().info("1");
    7. Location l1 = new Location(user.getWorld(), sel.getNativeMinimumPoint().getBlockX(), sel.getNativeMinimumPoint().getBlockY(), sel.getNativeMinimumPoint().getBlockZ());
    8. Location l2 = new Location(user.getWorld(), sel.getNativeMaximumPoint().getBlockX(), sel.getNativeMaximumPoint().getBlockY(), sel.getNativeMaximumPoint().getBlockZ());
    9.  
    10. Map map = new Map(clazz);
    11. map.setPosition(id, l1, 1);
    12. map.setPosition(id, l2, 2);
    13.  
    14. map.setEnabled(id, true);
    15. }
    16. }

    setPosition method in Map class.
    Code:java
    1. public void setPosition(String id, Location l, int pos) {
    2. FileConfiguration file = new RegionFile(clazz).getCustomConfig();
    3.  
    4. file.set(id + ".region.p" + pos + ".w", l.getWorld().getName());
    5. file.set(id + ".region.p" + pos + ".x", Integer.valueOf(l.getBlockX()));
    6. file.set(id + ".region.p" + pos + ".y", Integer.valueOf(l.getBlockY()));
    7. file.set(id + ".region.p" + pos + ".z", Integer.valueOf(l.getBlockZ()));
    8.  
    9. new RegionFile(clazz).saveCustomConfig();
    10. clazz.getLogger().info("2");
    11. }

    RegionFile reloadCustomConfig() method.
    Code:java
    1. public void reloadCustomConfig() {
    2. clazz.getLogger().info("3");
    3. if (customConfigFile == null) {
    4. customConfigFile = new File(clazz.getDataFolder(), "map.yml");
    5. }
    6.  
    7. clazz.getLogger().info("4");
    8. customConfig = YamlConfiguration.loadConfiguration(customConfigFile);
    9. clazz.getLogger().info("5");
    10. saveCustomConfig();
    11. }

    Just another yml file, but for some reason it's not setting (or in this case, saving) anything in it. Also the getCustomConfig() just returns a FileConfiguration variable.

    Any ideas?
     
  2. Offline

    fireblast709

    In the second snippet, you load a config to the variable file, set a few points, and then save a completely new config instance (so the one you call saveCustomConfig() on, never had any points set)
     
Thread Status:
Not open for further replies.

Share This Page