summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/net/minecraft/server/ChunkProviderServer.java2
-rw-r--r--src/main/java/net/minecraft/server/MinecraftServer.java7
-rw-r--r--src/main/java/net/minecraft/server/World.java1
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftServer.java40
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftWorld.java22
5 files changed, 49 insertions, 23 deletions
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 0fa2b619..0b232fd1 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -49,7 +49,7 @@ public class ChunkProviderServer implements IChunkProvider {
int l = j * 16 + 8 - chunkcoordinates.z;
short short1 = 128;
- if (k < -short1 || k > short1 || l < -short1 || l > short1) {
+ if (k < -short1 || k > short1 || l < -short1 || l > short1 || !(this.world.keepSpawnInMemory)) { // CraftBukkit - added 'this.world.keepSpawnInMemory'
this.unloadQueue.add(i, j); // CraftBukkit
}
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index ee8dee66..a5d9d05c 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -232,8 +232,9 @@ public class MinecraftServer implements Runnable, ICommandListener {
// CraftBukkit start
for (int l = 0; l < this.worlds.size(); ++l) {
// if (l == 0 || this.propertyManager.getBoolean("allow-nether", true)) {
- WorldServer worldserver = this.worlds.get(l);
- log.info("Preparing start region for level " + l + " (Seed: " + worldserver.getSeed() + ")");
+ WorldServer worldserver = this.worlds.get(l);
+ log.info("Preparing start region for level " + l + " (Seed: " + worldserver.getSeed() + ")");
+ if (worldserver.getWorld().getKeepSpawnInMemory()) {
// CraftBukkit end
ChunkCoordinates chunkcoordinates = worldserver.getSpawn();
@@ -260,7 +261,7 @@ public class MinecraftServer implements Runnable, ICommandListener {
}
}
}
- // } // CraftBukkit
+ } // CraftBukkit
}
// CraftBukkit start
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index aacbef13..63ea1588 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -83,6 +83,7 @@ public class World implements IBlockAccess {
// CraftBukkit start
private final CraftWorld world;
public boolean pvpMode;
+ public boolean keepSpawnInMemory = true;
public ChunkGenerator generator;
Chunk lastChunkAccessed;
int lastXAccessed = Integer.MIN_VALUE;
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);
+ }
+ }
+ }
+ }
}