Changes to world unloading

This commit is contained in:
fullwall 2013-04-14 18:23:21 +08:00
parent 1a80036bd5
commit cfefa87081
2 changed files with 9 additions and 4 deletions

View File

@ -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());
}
}

View File

@ -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;
}