mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-29 04:28:16 +01:00
Changes to world unloading
This commit is contained in:
parent
1a80036bd5
commit
cfefa87081
@ -252,10 +252,15 @@ public class EventListen implements Listener {
|
||||
for (NPC npc : getAllNPCs()) {
|
||||
if (!npc.isSpawned() || !npc.getBukkitEntity().getWorld().equals(event.getWorld()))
|
||||
continue;
|
||||
storeForRespawn(npc);
|
||||
npc.despawn(DespawnReason.WORLD_UNLOAD);
|
||||
if (event.isCancelled())
|
||||
boolean despawned = npc.despawn(DespawnReason.WORLD_UNLOAD);
|
||||
if (event.isCancelled() || !despawned) {
|
||||
for (ChunkCoord coord : toRespawn.keySet()) {
|
||||
if (event.getWorld().getName().equals(coord.worldName))
|
||||
respawnAllFromCoord(coord);
|
||||
}
|
||||
return;
|
||||
}
|
||||
storeForRespawn(npc);
|
||||
Messaging.debug("Despawned", npc.getId() + "due to world unload at", event.getWorld().getName());
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
|
||||
|
||||
@Override
|
||||
public boolean update() {
|
||||
if (target == null || target.dead) {
|
||||
if (target == null || !target.getBukkitEntity().isValid()) {
|
||||
cancelReason = CancelReason.TARGET_DIED;
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user