From 5447561d3d5de42f47c18f91cc473f603beda115 Mon Sep 17 00:00:00 2001 From: fullwall Date: Fri, 18 Jan 2019 01:56:47 +0800 Subject: [PATCH] Validate state --- main/src/main/java/net/citizensnpcs/Citizens.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/main/src/main/java/net/citizensnpcs/Citizens.java b/main/src/main/java/net/citizensnpcs/Citizens.java index ee62b082e..146058f63 100644 --- a/main/src/main/java/net/citizensnpcs/Citizens.java +++ b/main/src/main/java/net/citizensnpcs/Citizens.java @@ -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); }