Merge pull request #996 from mcmonkey4eva/master

Correct despawn/removal order, clean the codebase a lotta bit
This commit is contained in:
fullwall 2016-12-01 19:41:54 +08:00 committed by GitHub
commit 1ed5bf69c0

View File

@ -65,11 +65,11 @@ public class CitizensNPCRegistry implements NPCRegistry {
@Override
public void deregister(NPC npc) {
npc.despawn(DespawnReason.REMOVAL);
npcs.remove(npc);
if (saves != null) {
saves.clearData(npc);
}
npc.despawn(DespawnReason.REMOVAL);
}
@Override
@ -77,11 +77,11 @@ public class CitizensNPCRegistry implements NPCRegistry {
Iterator<NPC> itr = iterator();
while (itr.hasNext()) {
NPC npc = itr.next();
itr.remove();
npc.despawn(DespawnReason.REMOVAL);
for (Trait t : npc.getTraits()) {
t.onRemove();
}
itr.remove();
if (saves != null) {
saves.clearData(npc);
}