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() {
config.save();
//config.load();
//saves.load();
for (NPC npc : npcManager)
((CitizensNPC) npc).save(saves.getKey("npc." + npc.getId()));
config.save();
saves.save();
}
@ -249,8 +250,8 @@ public class Citizens extends JavaPlugin {
if (!key.keyExists("name"))
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,
key.getString("name"), null);
NPC npc = npcManager.createNPC(EntityType.valueOf(key.getString("traits.type").toUpperCase()), id, key
.getString("name"), null);
try {
((CitizensNPC) npc).load(key);
} catch (NPCException ex) {

View File

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