mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-09-26 06:13:09 +02:00
Correct despawn/removal order for compatibility
Version 2, the "don't include formatting fixes for some reason" edition
This commit is contained in:
parent
f8d2e4ec1c
commit
c4f5c2f727
@ -65,11 +65,11 @@ public class CitizensNPCRegistry implements NPCRegistry {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deregister(NPC npc) {
|
public void deregister(NPC npc) {
|
||||||
|
npc.despawn(DespawnReason.REMOVAL);
|
||||||
npcs.remove(npc);
|
npcs.remove(npc);
|
||||||
if (saves != null) {
|
if (saves != null) {
|
||||||
saves.clearData(npc);
|
saves.clearData(npc);
|
||||||
}
|
}
|
||||||
npc.despawn(DespawnReason.REMOVAL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -77,11 +77,11 @@ public class CitizensNPCRegistry implements NPCRegistry {
|
|||||||
Iterator<NPC> itr = iterator();
|
Iterator<NPC> itr = iterator();
|
||||||
while (itr.hasNext()) {
|
while (itr.hasNext()) {
|
||||||
NPC npc = itr.next();
|
NPC npc = itr.next();
|
||||||
itr.remove();
|
|
||||||
npc.despawn(DespawnReason.REMOVAL);
|
npc.despawn(DespawnReason.REMOVAL);
|
||||||
for (Trait t : npc.getTraits()) {
|
for (Trait t : npc.getTraits()) {
|
||||||
t.onRemove();
|
t.onRemove();
|
||||||
}
|
}
|
||||||
|
itr.remove();
|
||||||
if (saves != null) {
|
if (saves != null) {
|
||||||
saves.clearData(npc);
|
saves.clearData(npc);
|
||||||
}
|
}
|
||||||
@ -255,4 +255,4 @@ public class CitizensNPCRegistry implements NPCRegistry {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user