mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 18:45:29 +01:00
Attempt to fix configuration loading
This commit is contained in:
parent
7687b80ffc
commit
4e245cff4f
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user