mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-29 12:37:37 +01:00
Don't overwrite saves file if it failed to load
This commit is contained in:
parent
f75b33dfce
commit
76e954f2f2
@ -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());
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user