SPIGOT-3747: Add API for force loaded chunks

This commit is contained in:
md_5 2018-12-27 12:44:50 +11:00
parent a408f3751e
commit 2bc7d1df25
2 changed files with 32 additions and 0 deletions

View File

@ -147,6 +147,16 @@ public class CraftChunk implements Chunk {
return getWorld().unloadChunk(getX(), getZ(), save, safe);
}
@Override
public boolean isForceLoaded() {
return getWorld().isChunkForceLoaded(getX(), getZ());
}
@Override
public void setForceLoaded(boolean forced) {
getWorld().setChunkForceLoaded(getX(), getZ(), forced);
}
public ChunkSnapshot getChunkSnapshot() {
return getChunkSnapshot(true, false, false);
}

View File

@ -2,6 +2,7 @@ package org.bukkit.craftbukkit;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.Futures;
import it.unimi.dsi.fastutil.longs.LongSet;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
@ -278,6 +279,27 @@ public class CraftWorld implements World {
((CraftChunk) getChunkAt(chunk.getX(), chunk.getZ())).getHandle().bukkitChunk = chunk;
}
@Override
public boolean isChunkForceLoaded(int x, int z) {
return getHandle().isForceLoaded(x, z);
}
@Override
public void setChunkForceLoaded(int x, int z, boolean forced) {
getHandle().setForceLoaded(x, z, forced);
}
@Override
public Collection<Chunk> getForceLoadedChunks() {
Set<Chunk> chunks = new HashSet<>();
for (long coord : getHandle().ag()) { // PAIL
chunks.add(getChunkAt(ChunkCoordIntPair.a(coord), ChunkCoordIntPair.b(coord)));
}
return Collections.unmodifiableCollection(chunks);
}
public WorldServer getHandle() {
return world;
}