mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-30 22:53:24 +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());
|
config = new Settings(getDataFolder());
|
||||||
|
|
||||||
setupStorage();
|
setupStorage();
|
||||||
|
if (!saves.load()) {
|
||||||
|
saves = null;
|
||||||
|
Messaging.severeF("Unable to load saves, disabling...");
|
||||||
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
npcRegistry = new CitizensNPCRegistry(saves);
|
npcRegistry = new CitizensNPCRegistry(saves);
|
||||||
traitFactory = new CitizensTraitFactory();
|
traitFactory = new CitizensTraitFactory();
|
||||||
@ -270,6 +276,8 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
|
if (saves == null)
|
||||||
|
return;
|
||||||
for (NPC npc : npcRegistry)
|
for (NPC npc : npcRegistry)
|
||||||
((CitizensNPC) npc).save(saves.getKey("npc." + npc.getId()));
|
((CitizensNPC) npc).save(saves.getKey("npc." + npc.getId()));
|
||||||
|
|
||||||
@ -292,7 +300,6 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
|||||||
|
|
||||||
// TODO: refactor
|
// TODO: refactor
|
||||||
private void setupNPCs() {
|
private void setupNPCs() {
|
||||||
saves.load();
|
|
||||||
int created = 0, spawned = 0;
|
int created = 0, spawned = 0;
|
||||||
for (DataKey key : saves.getKey("npc").getIntegerSubKeys()) {
|
for (DataKey key : saves.getKey("npc").getIntegerSubKeys()) {
|
||||||
int id = Integer.parseInt(key.name());
|
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,
|
// set the head yaw in another tick - if done immediately,
|
||||||
// minecraft will not update it.
|
// minecraft will not update it.
|
||||||
}
|
}
|
||||||
}, 1);
|
}, 5);
|
||||||
handle.getBukkitEntity().setSleepingIgnored(true);
|
handle.getBukkitEntity().setSleepingIgnored(true);
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user