mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-15 07:01:36 +08:00
SPIGOT-3747: Add API for force loaded chunks
This commit is contained in:
parent
a408f3751e
commit
2bc7d1df25
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user