Validate state

This commit is contained in:
fullwall 2019-01-18 01:56:47 +08:00
parent 71b8744060
commit 5447561d3d

View File

@ -381,9 +381,14 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
@Override
public void setDefaultNPCDataStore(NPCDataStore store) {
saves.storeAll(npcRegistry);
saves.saveToDiskImmediate();
despawnNPCs();
if (store == null) {
throw new IllegalArgumentException("must be non-null");
}
if (saves != null) {
saves.storeAll(npcRegistry);
saves.saveToDiskImmediate();
despawnNPCs();
}
this.saves = store;
this.npcRegistry = new CitizensNPCRegistry(saves);
}