Don't overwrite saves file if it failed to load

This commit is contained in:
fullwall 2012-09-04 19:59:46 +08:00
parent f75b33dfce
commit 76e954f2f2
2 changed files with 9 additions and 2 deletions

View File

@ -194,6 +194,12 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
config = new Settings(getDataFolder());
setupStorage();
if (!saves.load()) {
saves = null;
Messaging.severeF("Unable to load saves, disabling...");
getServer().getPluginManager().disablePlugin(this);
return;
}
npcRegistry = new CitizensNPCRegistry(saves);
traitFactory = new CitizensTraitFactory();
@ -270,6 +276,8 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
}
public void save() {
if (saves == null)
return;
for (NPC npc : npcRegistry)
((CitizensNPC) npc).save(saves.getKey("npc." + npc.getId()));
@ -292,7 +300,6 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
// TODO: refactor
private void setupNPCs() {
saves.load();
int created = 0, spawned = 0;
for (DataKey key : saves.getKey("npc").getIntegerSubKeys()) {
int id = Integer.parseInt(key.name());

View File

@ -35,7 +35,7 @@ public class CitizensHumanNPC extends CitizensNPC implements Equipable {
// set the head yaw in another tick - if done immediately,
// minecraft will not update it.
}
}, 1);
}, 5);
handle.getBukkitEntity().setSleepingIgnored(true);
return handle;
}