diff options
author | Rigby <rigby@onarandombox.com> | 2011-07-27 00:24:27 +0100 |
---|---|---|
committer | EvilSeph <evilseph@gmail.com> | 2011-08-05 15:52:38 -0400 |
commit | 4117d6b65e22adbb0221113b089d6d6528fa33f2 (patch) | |
tree | f3b037414a28e723e65d27a76ae0063ea60ea799 /src/main/java/org | |
parent | 6ae23e3f033e8dcbf49d4d7067062d322a9a3c7f (diff) | |
download | craftbukkit-4117d6b65e22adbb0221113b089d6d6528fa33f2.tar craftbukkit-4117d6b65e22adbb0221113b089d6d6528fa33f2.tar.gz craftbukkit-4117d6b65e22adbb0221113b089d6d6528fa33f2.tar.lz craftbukkit-4117d6b65e22adbb0221113b089d6d6528fa33f2.tar.xz craftbukkit-4117d6b65e22adbb0221113b089d6d6528fa33f2.zip |
Implemented per world setting to keep the spawn in memory or not.
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/CraftServer.java | 40 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/CraftWorld.java | 22 |
2 files changed, 43 insertions, 19 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index c4a87b80..670490d0 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -485,29 +485,31 @@ 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() + ")"); - short short1 = 196; - long i = System.currentTimeMillis(); - for (int j = -short1; j <= short1; j += 16) { - for (int k = -short1; k <= short1; k += 16) { - long l = System.currentTimeMillis(); - - if (l < i) { - i = l; - } + if (internal.getWorld().getKeepSpawnInMemory()) { + short short1 = 196; + long i = System.currentTimeMillis(); + for (int j = -short1; j <= short1; j += 16) { + for (int k = -short1; k <= short1; k += 16) { + long l = System.currentTimeMillis(); + + if (l < i) { + i = l; + } - if (l > i + 1000L) { - int i1 = (short1 * 2 + 1) * (short1 * 2 + 1); - int j1 = (j + short1) * (short1 * 2 + 1) + k + 1; + if (l > i + 1000L) { + int i1 = (short1 * 2 + 1) * (short1 * 2 + 1); + int j1 = (j + short1) * (short1 * 2 + 1) + k + 1; - System.out.println("Preparing spawn area for " + name + ", " + (j1 * 100 / i1) + "%"); - i = l; - } + System.out.println("Preparing spawn area for " + name + ", " + (j1 * 100 / i1) + "%"); + i = l; + } - ChunkCoordinates chunkcoordinates = internal.getSpawn(); - internal.chunkProviderServer.getChunkAt(chunkcoordinates.x + j >> 4, chunkcoordinates.z + k >> 4); + ChunkCoordinates chunkcoordinates = internal.getSpawn(); + internal.chunkProviderServer.getChunkAt(chunkcoordinates.x + j >> 4, chunkcoordinates.z + k >> 4); - while (internal.doLighting()) { - ; + while (internal.doLighting()) { + ; + } } } } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 74e48d62..8cf3dd1b 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -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); + } + } + } + } } |