mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-08 03:22:19 +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,6 +485,7 @@ public final class CraftServer implements Server {
|
||||||
pluginManager.callEvent(new WorldInitEvent(internal.getWorld()));
|
pluginManager.callEvent(new WorldInitEvent(internal.getWorld()));
|
||||||
System.out.print("Preparing start region for level " + (console.worlds.size() -1) + " (Seed: " + internal.getSeed() + ")");
|
System.out.print("Preparing start region for level " + (console.worlds.size() -1) + " (Seed: " + internal.getSeed() + ")");
|
||||||
|
|
||||||
|
if (internal.getWorld().getKeepSpawnInMemory()) {
|
||||||
short short1 = 196;
|
short short1 = 196;
|
||||||
long i = System.currentTimeMillis();
|
long i = System.currentTimeMillis();
|
||||||
for (int j = -short1; j <= short1; j += 16) {
|
for (int j = -short1; j <= short1; j += 16) {
|
||||||
|
@ -511,6 +512,7 @@ public final class CraftServer implements Server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
pluginManager.callEvent(new WorldLoadEvent(internal.getWorld()));
|
pluginManager.callEvent(new WorldLoadEvent(internal.getWorld()));
|
||||||
return internal.getWorld();
|
return internal.getWorld();
|
||||||
}
|
}
|
||||||
|
|
|
@ -783,4 +783,26 @@ public class CraftWorld implements World {
|
||||||
public int getMaxHeight() {
|
public int getMaxHeight() {
|
||||||
return 128;
|
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