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