Fix an issue in Settings.

This commit is contained in:
fullwall 2012-05-27 16:30:27 +08:00
parent 1ae9bf3a47
commit 06ba12c22e

View File

@ -21,7 +21,7 @@ public class Settings {
for (Setting setting : Setting.values()) { for (Setting setting : Setting.values()) {
if (!root.keyExists(setting.path)) { if (!root.keyExists(setting.path)) {
Messaging.logF("Writing default setting: '%s'", setting.path); Messaging.logF("Writing default setting: '%s'", setting.path);
root.setRaw(setting.path, setting.value); setting.set(root);
} else } else
setting.load(root); setting.load(root);
} }
@ -52,7 +52,7 @@ public class Settings {
DEFAULT_LOOK_CLOSE("npc.default.look-close", false), DEFAULT_LOOK_CLOSE("npc.default.look-close", false),
DEFAULT_RANDOM_TALKER("npc.default.random-talker", true), DEFAULT_RANDOM_TALKER("npc.default.random-talker", true),
DEFAULT_TALK_CLOSE("npc.default.talk-close", false), DEFAULT_TALK_CLOSE("npc.default.talk-close", false),
DEFAULT_TEXT("npc.default.text.0", "Hi, I'm <npc>!") { DEFAULT_TEXT("npc.default.text.0", Lists.newArrayList("Hi, I'm <npc>!")) {
@Override @Override
public void load(DataKey root) { public void load(DataKey root) {
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<String>();
@ -60,6 +60,11 @@ public class Settings {
list.add(key.getString("")); list.add(key.getString(""));
value = list; value = list;
} }
@Override
public void set(DataKey root) {
root.setString("npc.default.text.0", "Hi, I'm <npc>!");
}
}, },
QUICK_SELECT("npc.selection.quick-select", false), QUICK_SELECT("npc.selection.quick-select", false),
SELECTION_ITEM("npc.selection.item", "280"), SELECTION_ITEM("npc.selection.item", "280"),
@ -104,8 +109,12 @@ public class Settings {
return value.toString(); return value.toString();
} }
protected void set(DataKey root) {
root.setRaw(path, value);
}
protected void load(DataKey root) { protected void load(DataKey root) {
this.value = root.getRaw(path); value = root.getRaw(path);
} }
} }
} }