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 @Override
public void setDefaultNPCDataStore(NPCDataStore store) { public void setDefaultNPCDataStore(NPCDataStore store) {
if (store == null) {
throw new IllegalArgumentException("must be non-null");
}
if (saves != null) {
saves.storeAll(npcRegistry); saves.storeAll(npcRegistry);
saves.saveToDiskImmediate(); saves.saveToDiskImmediate();
despawnNPCs(); despawnNPCs();
}
this.saves = store; this.saves = store;
this.npcRegistry = new CitizensNPCRegistry(saves); this.npcRegistry = new CitizensNPCRegistry(saves);
} }