mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-27 21:29:14 +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()) {
|
for (NPC npc : getAllNPCs()) {
|
||||||
if (!npc.isSpawned() || !npc.getBukkitEntity().getWorld().equals(event.getWorld()))
|
if (!npc.isSpawned() || !npc.getBukkitEntity().getWorld().equals(event.getWorld()))
|
||||||
continue;
|
continue;
|
||||||
storeForRespawn(npc);
|
boolean despawned = npc.despawn(DespawnReason.WORLD_UNLOAD);
|
||||||
npc.despawn(DespawnReason.WORLD_UNLOAD);
|
if (event.isCancelled() || !despawned) {
|
||||||
if (event.isCancelled())
|
for (ChunkCoord coord : toRespawn.keySet()) {
|
||||||
|
if (event.getWorld().getName().equals(coord.worldName))
|
||||||
|
respawnAllFromCoord(coord);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
storeForRespawn(npc);
|
||||||
Messaging.debug("Despawned", npc.getId() + "due to world unload at", event.getWorld().getName());
|
Messaging.debug("Despawned", npc.getId() + "due to world unload at", event.getWorld().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean update() {
|
public boolean update() {
|
||||||
if (target == null || target.dead) {
|
if (target == null || !target.getBukkitEntity().isValid()) {
|
||||||
cancelReason = CancelReason.TARGET_DIED;
|
cancelReason = CancelReason.TARGET_DIED;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user