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

This commit is contained in:
Rigby 2011-07-27 00:24:27 +01:00 committed by EvilSeph
parent 6ae23e3f03
commit 4117d6b65e
5 changed files with 48 additions and 22 deletions

View File

@ -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
}
}

View File

@ -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

View File

@ -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;

View File

@ -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 (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) {
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()) {
;
}
}
}
}

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);
}
}
}
}
}