int ticks = world.tickCount;
// Handle unload requests
final ConcurrentQueueSet<Long> unloadStage0 = this.unloadStage0;
if (!unloadStage0.isEmpty()) {
ImmutableSetMultimap<ChunkCoordIntPair, ForgeChunkManager.Ticket> persistentChunks = world.getPersistentChunks();
PlayerManager playerManager = world.getPlayerManager();
ChunkCoordIntPair chunkCoordIntPair = new ChunkCoordIntPair(0, 0);
Long key_;
int done = 0;
while (++done != 75 && (key_ = unloadStage0.take()) != null) {
long key = key_;
int x = (int) key;
int z = (int) (key >> 32);
chunkCoordIntPair.chunkXPos = x;
chunkCoordIntPair.chunkZPos = z;
Chunk chunk = (Chunk) chunks.getValueByKey(key);
if (chunk == null) {
continue;
}
synchronized (chunk) {
if (chunk.partiallyUnloaded || !chunk.queuedUnload || unloadingChunks.containsItem(key)) {
continue;
}
if (persistentChunks.containsKey(chunkCoordIntPair) || playerManager.getOrCreateChunkWatcher(x, z, false) != null || !fireBukkitUnloadEvent(chunk)) {
chunk.queuedUnload = false;
continue;
}
if (lastChunk == chunk) {
lastChunk = null;