Correct despawn/removal order for compatibility

Version 2, the "don't include formatting fixes for some reason" edition
This commit is contained in:
mcmonkey4eva 2016-12-01 03:40:34 -08:00
parent f8d2e4ec1c
commit c4f5c2f727
1 changed files with 3 additions and 3 deletions

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);
}
@ -255,4 +255,4 @@ public class CitizensNPCRegistry implements NPCRegistry {
} catch (Exception e) {
}
}
}
}