Implemented per world setting to keep the spawn in memory or not.

By: Rigby <rigby@onarandombox.com>
This commit is contained in:
CraftBukkit/Spigot 2011-07-27 00:24:27 +01:00
parent 75eaae7e97
commit 6bc7228c46
2 changed files with 42 additions and 18 deletions

View file

@ -485,6 +485,7 @@ public final class CraftServer implements Server {
pluginManager.callEvent(new WorldInitEvent(internal.getWorld()));
System.out.print("Preparing start region for level " + (console.worlds.size() -1) + " (Seed: " + internal.getSeed() + ")");
if (internal.getWorld().getKeepSpawnInMemory()) {
short short1 = 196;
long i = System.currentTimeMillis();
for (int j = -short1; j <= short1; j += 16) {
@ -511,6 +512,7 @@ public final class CraftServer implements Server {
}
}
}
}
pluginManager.callEvent(new WorldLoadEvent(internal.getWorld()));
return internal.getWorld();
}

View file

@ -783,4 +783,26 @@ public class CraftWorld implements World {
public int getMaxHeight() {
return 128;
}
public boolean getKeepSpawnInMemory() {
return world.keepSpawnInMemory;
}
public void setKeepSpawnInMemory(boolean keepLoaded) {
world.keepSpawnInMemory = keepLoaded;
// Grab the worlds spawn chunk
ChunkCoordinates chunkcoordinates = this.world.getSpawn();
int chunkCoordX = chunkcoordinates.x >> 4;
int chunkCoordZ = chunkcoordinates.z >> 4;
// Cycle through the 25x25 Chunks around it to load/unload the chunks.
for (int x = -12; x <= 12; x++) {
for (int z = -12; z <= 12; z++) {
if (keepLoaded) {
loadChunk(chunkCoordX + x, chunkCoordZ + z);
} else {
unloadChunk(chunkCoordX + x, chunkCoordZ + z);
}
}
}
}
}