mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-16 07:35:32 +01:00
Paper seems to prefer despawning immediately
This commit is contained in:
parent
0586f2ab89
commit
aaa45ea72e
@ -172,43 +172,41 @@ public class EventListen implements Listener {
|
|||||||
}
|
}
|
||||||
if (toDespawn.isEmpty())
|
if (toDespawn.isEmpty())
|
||||||
return;
|
return;
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
|
ChunkCoord coord = new ChunkCoord(event.getChunk());
|
||||||
@Override
|
boolean loadChunk = false;
|
||||||
public void run() {
|
for (NPC npc : toDespawn) {
|
||||||
ChunkCoord coord = new ChunkCoord(event.getChunk());
|
if (!npc.despawn(DespawnReason.CHUNK_UNLOAD)) {
|
||||||
boolean loadChunk = false;
|
if (!(event instanceof Cancellable)) {
|
||||||
for (NPC npc : toDespawn) {
|
|
||||||
if (!npc.despawn(DespawnReason.CHUNK_UNLOAD)) {
|
|
||||||
if (!(event instanceof Cancellable)) {
|
|
||||||
loadChunk = true;
|
|
||||||
toRespawn.put(coord, npc);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
((Cancellable) event).setCancelled(true);
|
|
||||||
if (Messaging.isDebugging()) {
|
|
||||||
Messaging.debug("Cancelled chunk unload at [" + coord.x + "," + coord.z + "]");
|
|
||||||
}
|
|
||||||
respawnAllFromCoord(coord, event);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
toRespawn.put(coord, npc);
|
|
||||||
if (Messaging.isDebugging()) {
|
if (Messaging.isDebugging()) {
|
||||||
Messaging.debug("Despawned id", npc.getId(),
|
Messaging.debug("Reloading chunk because", npc.getId(), "couldn't despawn");
|
||||||
"due to chunk unload at [" + coord.x + "," + coord.z + "]");
|
}
|
||||||
|
loadChunk = true;
|
||||||
|
toRespawn.put(coord, npc);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
((Cancellable) event).setCancelled(true);
|
||||||
|
if (Messaging.isDebugging()) {
|
||||||
|
Messaging.debug("Cancelled chunk unload at [" + coord.x + "," + coord.z + "]");
|
||||||
|
}
|
||||||
|
respawnAllFromCoord(coord, event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
toRespawn.put(coord, npc);
|
||||||
|
if (Messaging.isDebugging()) {
|
||||||
|
Messaging.debug("Despawned id", npc.getId(),
|
||||||
|
"due to chunk unload at [" + coord.x + "," + coord.z + "]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (loadChunk) {
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!event.getChunk().isLoaded()) {
|
||||||
|
event.getChunk().load();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (loadChunk) {
|
}, 10);
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
|
}
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (!event.getChunk().isLoaded()) {
|
|
||||||
event.getChunk().load();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
Loading…
Reference in New Issue
Block a user