Null check registry on disable

This commit is contained in:
fullwall 2022-03-10 03:17:27 +08:00
parent 908e678135
commit d00678b208
1 changed files with 5 additions and 3 deletions

View File

@ -139,11 +139,13 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
}
private void despawnNPCs(boolean save) {
for (NPCRegistry reg : Iterables.concat(Arrays.asList(npcRegistry), citizensBackedRegistries)) {
for (NPCRegistry registry : Iterables.concat(Arrays.asList(npcRegistry), citizensBackedRegistries)) {
if (registry == null)
continue;
if (save) {
reg.saveToStore();
registry.saveToStore();
}
reg.despawnNPCs(DespawnReason.RELOAD);
registry.despawnNPCs(DespawnReason.RELOAD);
}
}