diff --git a/src/main/java/net/citizensnpcs/Citizens.java b/src/main/java/net/citizensnpcs/Citizens.java index c1f8397ed..3a4f9a7f6 100644 --- a/src/main/java/net/citizensnpcs/Citizens.java +++ b/src/main/java/net/citizensnpcs/Citizens.java @@ -142,8 +142,7 @@ public class Citizens extends JavaPlugin { return; } - config = new Settings(this.getDataFolder()); - config.load(); + config = new Settings(getDataFolder()); // NPC storage String type = Setting.STORAGE_TYPE.asString(); @@ -245,7 +244,7 @@ public class Citizens extends JavaPlugin { public void reload() throws NPCLoadException { Editor.leaveAll(); - config.load(); + config.reload(); npcManager.safeRemove(); setupNPCs(); diff --git a/src/main/java/net/citizensnpcs/Settings.java b/src/main/java/net/citizensnpcs/Settings.java index 1b8c412eb..91a0f0606 100644 --- a/src/main/java/net/citizensnpcs/Settings.java +++ b/src/main/java/net/citizensnpcs/Settings.java @@ -10,21 +10,31 @@ import net.citizensnpcs.api.util.YamlStorage; import net.citizensnpcs.util.Messaging; public class Settings { + private final DataKey root; + public Settings(File folder) { config = new YamlStorage(folder + File.separator + "config.yml", "Citizens Configuration"); - } + root = config.getKey(""); - public void load() { config.load(); - DataKey root = config.getKey(""); for (Setting setting : Setting.values()) { if (!root.keyExists(setting.path)) { Messaging.log("Writing default setting: '" + setting.path + "'"); - root.setRaw(setting.path, setting.get()); - } else { + root.setRaw(setting.path, setting.value); + } else setting.set(root.getRaw(setting.path)); - } } + + save(); + } + + public void reload() { + config.load(); + for (Setting setting : Setting.values()) + if (root.keyExists(setting.path)) + setting.set(root.getRaw(setting.path)); + + save(); } public void save() { @@ -88,10 +98,6 @@ public class Settings { return value.toString(); } - private Object get() { - return value; - } - private void set(Object value) { this.value = value; }