mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-24 11:38:26 +01:00
Attempt to fix configuration loading
This commit is contained in:
parent
e9994ba445
commit
c4c46a80d7
@ -142,8 +142,7 @@ public class Citizens extends JavaPlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
config = new Settings(this.getDataFolder());
|
config = new Settings(getDataFolder());
|
||||||
config.load();
|
|
||||||
|
|
||||||
// NPC storage
|
// NPC storage
|
||||||
String type = Setting.STORAGE_TYPE.asString();
|
String type = Setting.STORAGE_TYPE.asString();
|
||||||
@ -245,7 +244,7 @@ public class Citizens extends JavaPlugin {
|
|||||||
|
|
||||||
public void reload() throws NPCLoadException {
|
public void reload() throws NPCLoadException {
|
||||||
Editor.leaveAll();
|
Editor.leaveAll();
|
||||||
config.load();
|
config.reload();
|
||||||
npcManager.safeRemove();
|
npcManager.safeRemove();
|
||||||
setupNPCs();
|
setupNPCs();
|
||||||
|
|
||||||
|
@ -10,21 +10,31 @@ import net.citizensnpcs.api.util.YamlStorage;
|
|||||||
import net.citizensnpcs.util.Messaging;
|
import net.citizensnpcs.util.Messaging;
|
||||||
|
|
||||||
public class Settings {
|
public class Settings {
|
||||||
|
private final DataKey root;
|
||||||
|
|
||||||
public Settings(File folder) {
|
public Settings(File folder) {
|
||||||
config = new YamlStorage(folder + File.separator + "config.yml", "Citizens Configuration");
|
config = new YamlStorage(folder + File.separator + "config.yml", "Citizens Configuration");
|
||||||
}
|
root = config.getKey("");
|
||||||
|
|
||||||
public void load() {
|
|
||||||
config.load();
|
config.load();
|
||||||
DataKey root = config.getKey("");
|
|
||||||
for (Setting setting : Setting.values()) {
|
for (Setting setting : Setting.values()) {
|
||||||
if (!root.keyExists(setting.path)) {
|
if (!root.keyExists(setting.path)) {
|
||||||
Messaging.log("Writing default setting: '" + setting.path + "'");
|
Messaging.log("Writing default setting: '" + setting.path + "'");
|
||||||
root.setRaw(setting.path, setting.get());
|
root.setRaw(setting.path, setting.value);
|
||||||
} else {
|
} else
|
||||||
setting.set(root.getRaw(setting.path));
|
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() {
|
public void save() {
|
||||||
@ -88,10 +98,6 @@ public class Settings {
|
|||||||
return value.toString();
|
return value.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object get() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void set(Object value) {
|
private void set(Object value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user