Work around chunk unload change

This commit is contained in:
fullwall 2019-04-28 20:45:38 +08:00
parent b7d43bf13b
commit ca8d9c41ea
2 changed files with 12 additions and 3 deletions

View File

@ -146,7 +146,7 @@ public class EventListen implements Listener {
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onChunkUnload(ChunkUnloadEvent event) {
public void onChunkUnload(final ChunkUnloadEvent event) {
ChunkCoord coord = toCoord(event.getChunk());
Location loc = new Location(null, 0, 0, 0);
for (NPC npc : getAllNPCs()) {
@ -160,7 +160,17 @@ public class EventListen implements Listener {
try {
((Cancellable) event).setCancelled(true);
} catch (Throwable e) {
// TODO: event.getChunk().setForceLoaded(true);
// TODO: event.getChunk().setForceLoaded(true); ?
toRespawn.put(coord, npc);
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
@Override
public void run() {
if (!event.getChunk().isLoaded()) {
event.getChunk().load();
}
}
}, 10);
return;
}
if (Messaging.isDebugging()) {
Messaging.debug("Cancelled chunk unload at [" + coord.x + "," + coord.z + "]");

View File

@ -187,7 +187,6 @@ public class SkinPacketTracker {
if (location.distanceSquared(CACHE_LOCATION) > radius)
continue;
updateViewer(player);
}
}