mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-05 02:22:12 +01:00
Implemented per world setting to keep the spawn in memory or not.
By: Rigby <rigby@onarandombox.com>
This commit is contained in:
parent
75eaae7e97
commit
6bc7228c46
2 changed files with 42 additions and 18 deletions
|
@ -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()) {
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue