Fix saving and loading from files. This fixes CITIZENS-30.

This commit is contained in:
aPunch 2012-03-14 16:48:02 -05:00
parent 38e1955825
commit 5e34538bd6
2 changed files with 6 additions and 5 deletions

View File

@ -234,10 +234,11 @@ public class Citizens extends JavaPlugin {
} }
public void save() { public void save() {
config.save(); //config.load();
//saves.load();
for (NPC npc : npcManager) for (NPC npc : npcManager)
((CitizensNPC) npc).save(saves.getKey("npc." + npc.getId())); ((CitizensNPC) npc).save(saves.getKey("npc." + npc.getId()));
config.save();
saves.save(); saves.save();
} }
@ -249,8 +250,8 @@ public class Citizens extends JavaPlugin {
if (!key.keyExists("name")) if (!key.keyExists("name"))
throw new NPCLoadException("Could not find a name for the NPC with ID '" + id + "'."); throw new NPCLoadException("Could not find a name for the NPC with ID '" + id + "'.");
NPC npc = npcManager.createNPC(EntityType.valueOf(key.getString("traits.type").toUpperCase()), id, NPC npc = npcManager.createNPC(EntityType.valueOf(key.getString("traits.type").toUpperCase()), id, key
key.getString("name"), null); .getString("name"), null);
try { try {
((CitizensNPC) npc).load(key); ((CitizensNPC) npc).load(key);
} catch (NPCException ex) { } catch (NPCException ex) {

View File

@ -15,6 +15,7 @@ public class Settings {
} }
public void load() { public void load() {
config.load();
DataKey root = config.getKey(""); DataKey root = config.getKey("");
for (Setting setting : Setting.values()) { for (Setting setting : Setting.values()) {
if (!root.keyExists(setting.path)) { if (!root.keyExists(setting.path)) {
@ -23,7 +24,6 @@ public class Settings {
} else } else
setting.set(root.getRaw(setting.path)); setting.set(root.getRaw(setting.path));
} }
save();
} }
public void save() { public void save() {