Fix WorldCreator#keepSpawnLoaded

This commit is contained in:
Noah van der Aa 2024-04-25 19:57:27 +02:00
parent 768befec89
commit 04a25c2813
No known key found for this signature in database
GPG Key ID: 547D90BC6FF753CF
14 changed files with 35 additions and 41 deletions

View File

@ -5,21 +5,15 @@ Subject: [PATCH] WorldCreator#keepSpawnLoaded
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 2c4a52e9f5c6d8d70e390b1805949549fec891e0..2e54a42904cf4b8d0e30a464c18486cc8cce774a 100644
index 2c4a52e9f5c6d8d70e390b1805949549fec891e0..ad3f4fd07c4670dd3fc0da619c50bd095d9ad396 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1309,6 +1309,14 @@ public final class CraftServer implements Server {
internal.setSpawnSettings(true, true);
// Paper - Put world into worldlist before initing the world; move up
+ // Paper start
+ if (creator.keepSpawnLoaded().toBooleanOrElse(internal.getWorld().getKeepSpawnInMemory())) {
+ GameRules.IntegerValue rule = internal.getGameRules().getRule(GameRules.RULE_SPAWN_CHUNK_RADIUS);
+ rule.deserialize("0");
+ rule.onChanged(internal);
+ }
+ // Paper end
+
this.getServer().prepareLevels(internal.getChunkSource().chunkMap.progressListener, internal);
internal.entityManager.tick(); // SPIGOT-6526: Load pending entities so they are available to the API
@@ -1293,7 +1293,7 @@ public final class CraftServer implements Server {
}
// If set to not keep spawn in memory (changed from default) then adjust rule accordingly
- if (!creator.keepSpawnInMemory()) {
+ if (creator.keepSpawnLoaded() == net.kyori.adventure.util.TriState.FALSE) { // Paper
worlddata.getGameRules().getRule(GameRules.RULE_SPAWN_CHUNK_RADIUS).set(0, null);
}
ServerLevel internal = (ServerLevel) new ServerLevel(this.console, this.console.executor, worldSession, worlddata, worldKey, worlddimension, this.getServer().progressListenerFactory.create(worlddata.getGameRules().getInt(GameRules.RULE_SPAWN_CHUNK_RADIUS)),

View File

@ -45,7 +45,7 @@ index 79f7e0fb2f1aa6af441c6e09d2c443d7d4bb47ef..00457548d43e1d2143d1f6027593a117
this.profiler.popPush("connection");
MinecraftTimings.connectionTimer.startTiming(); // Spigot // Paper
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 2e54a42904cf4b8d0e30a464c18486cc8cce774a..adc2406c1e8ddb70bad7547d9947912462db899e 100644
index ad3f4fd07c4670dd3fc0da619c50bd095d9ad396..18dd7826fc227015e75f1b35b2c83a68416a305c 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -887,6 +887,11 @@ public final class CraftServer implements Server {
@ -68,7 +68,7 @@ index 2e54a42904cf4b8d0e30a464c18486cc8cce774a..adc2406c1e8ddb70bad7547d99479124
Preconditions.checkArgument(creator != null, "WorldCreator cannot be null");
String name = creator.name();
@@ -1331,6 +1337,7 @@ public final class CraftServer implements Server {
@@ -1323,6 +1329,7 @@ public final class CraftServer implements Server {
@Override
public boolean unloadWorld(World world, boolean save) {

View File

@ -20,10 +20,10 @@ index e40069d937de5fd00741ae6873abeecc46b93732..552f7ab11dc09fa69034f009235cb224
Date date = new Date();
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index adc2406c1e8ddb70bad7547d9947912462db899e..c52b211d515e8f36c87cfd058dc56b21b99fa74f 100644
index 18dd7826fc227015e75f1b35b2c83a68416a305c..deb0b66f52abdfcd6baba808f5e777ca6643f39b 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1900,7 +1900,7 @@ public final class CraftServer implements Server {
@@ -1892,7 +1892,7 @@ public final class CraftServer implements Server {
// Paper end
Set<CommandSender> recipients = new HashSet<>();
for (Permissible permissible : this.getPluginManager().getPermissionSubscriptions(permission)) {

View File

@ -228,7 +228,7 @@ index 49627a02cb15e94e7c3ddfe65aa663d982a34408..21d97c2b533a6528dd73c4e514d49273
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index c52b211d515e8f36c87cfd058dc56b21b99fa74f..275748326a0e8c0baee4f3da76315d4042793d9d 100644
index deb0b66f52abdfcd6baba808f5e777ca6643f39b..241ac7daac6bd10707ab8c3b2ebd423262e2d6cf 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -816,7 +816,7 @@ public final class CraftServer implements Server {

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Don't enforce icanhasbukkit default if alias block exists
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 275748326a0e8c0baee4f3da76315d4042793d9d..1cba3c4ce3682f2f91a3994f433ab937524c8a71 100644
index 241ac7daac6bd10707ab8c3b2ebd423262e2d6cf..7818c4720572fdd50925058ff77e7284cee9acfe 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -354,7 +354,11 @@ public final class CraftServer implements Server {

View File

@ -1251,7 +1251,7 @@ index 16f36d1bfe6458f9aa935cdc63066c082bc83f8e..638aeef75dc5f7ab8b8e050118a7c709
public void setLevelCallback(EntityInLevelCallback changeListener) {
this.levelCallback = changeListener;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 1cba3c4ce3682f2f91a3994f433ab937524c8a71..26f9c4eaf126eea2c6dce1be54b952417824e77b 100644
index 7818c4720572fdd50925058ff77e7284cee9acfe..bebccf63126be70bf7487361ba8a836131aaf524 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -310,6 +310,76 @@ public final class CraftServer implements Server {

View File

@ -39,7 +39,7 @@ index b00da578cb4ba037a540584738b3f866acfa9f88..2f62af670441d422133b18d00d9e5e5e
Iterator iterator1 = this.players.iterator();
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 26f9c4eaf126eea2c6dce1be54b952417824e77b..ee6f8680ea248c1915eb5d6f1922ffc232e23155 100644
index bebccf63126be70bf7487361ba8a836131aaf524..4806076159431403b5d8dae8472b9c3acd5ecb36 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1143,6 +1143,18 @@ public final class CraftServer implements Server {
@ -61,7 +61,7 @@ index 26f9c4eaf126eea2c6dce1be54b952417824e77b..ee6f8680ea248c1915eb5d6f1922ffc2
private void loadIcon() {
this.icon = new CraftIconCache(null);
try {
@@ -1530,6 +1542,13 @@ public final class CraftServer implements Server {
@@ -1522,6 +1534,13 @@ public final class CraftServer implements Server {
@Override
public boolean addRecipe(Recipe recipe) {
@ -75,7 +75,7 @@ index 26f9c4eaf126eea2c6dce1be54b952417824e77b..ee6f8680ea248c1915eb5d6f1922ffc2
CraftRecipe toAdd;
if (recipe instanceof CraftRecipe) {
toAdd = (CraftRecipe) recipe;
@@ -1559,6 +1578,11 @@ public final class CraftServer implements Server {
@@ -1551,6 +1570,11 @@ public final class CraftServer implements Server {
}
}
toAdd.addToCraftingManager();
@ -87,7 +87,7 @@ index 26f9c4eaf126eea2c6dce1be54b952417824e77b..ee6f8680ea248c1915eb5d6f1922ffc2
return true;
}
@@ -1739,10 +1763,23 @@ public final class CraftServer implements Server {
@@ -1731,10 +1755,23 @@ public final class CraftServer implements Server {
@Override
public boolean removeRecipe(NamespacedKey recipeKey) {

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Use correct seed on api world load
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index ee6f8680ea248c1915eb5d6f1922ffc232e23155..e745f34f57362b50b186446d0d9343339131e9b0 100644
index 4806076159431403b5d8dae8472b9c3acd5ecb36..f21f6773172d0bbf50c341e371d01faa50299f6f 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1365,7 +1365,7 @@ public final class CraftServer implements Server {

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Deprecate and replace methods with old StructureType
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index e745f34f57362b50b186446d0d9343339131e9b0..6553baadafba313230fce1cce6a776c7248045c3 100644
index f21f6773172d0bbf50c341e371d01faa50299f6f..2be50f69f4f839a51fda5d207ca41257ffc0c12d 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1978,6 +1978,11 @@ public final class CraftServer implements Server {
@@ -1970,6 +1970,11 @@ public final class CraftServer implements Server {
ServerLevel worldServer = ((CraftWorld) world).getHandle();
Location structureLocation = world.locateNearestStructure(location, structureType, radius, findUnexplored);
@ -20,7 +20,7 @@ index e745f34f57362b50b186446d0d9343339131e9b0..6553baadafba313230fce1cce6a776c7
BlockPos structurePosition = CraftLocation.toBlockPosition(structureLocation);
// Create map with trackPlayer = true, unlimitedTracking = true
@@ -1988,6 +1993,31 @@ public final class CraftServer implements Server {
@@ -1980,6 +1985,31 @@ public final class CraftServer implements Server {
return CraftItemStack.asBukkitCopy(stack);
}

View File

@ -707,7 +707,7 @@ index 2e96308696e131f3f013469a395e5ddda2c5d529..65a66e484c1c39c5f41d97db52f31c67
} catch (Throwable e) {
LOGGER.error("Failed to run bootstrapper for %s. This plugin will not be loaded.".formatted(provider.getSource()), e);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 6553baadafba313230fce1cce6a776c7248045c3..6ccf464b218b8eb01d770da31d1d8d717584d4f9 100644
index 2be50f69f4f839a51fda5d207ca41257ffc0c12d..7c2e1c8907ea5807973b1d3d05a05d646c723a7f 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1018,6 +1018,11 @@ public final class CraftServer implements Server {

View File

@ -5,10 +5,10 @@ Subject: [PATCH] improve BanList types
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 6ccf464b218b8eb01d770da31d1d8d717584d4f9..79662ba90f8ef4ffe77fa947c3f783dc43abf214 100644
index 7c2e1c8907ea5807973b1d3d05a05d646c723a7f..f325253bf93c4a5fbe333b12019eadc2025a509b 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2231,6 +2231,21 @@ public final class CraftServer implements Server {
@@ -2223,6 +2223,21 @@ public final class CraftServer implements Server {
};
}

View File

@ -21517,18 +21517,18 @@ index 7dae8d91b74cc7df0745f0c121e3bea09b8d0b6d..1e2530c9e5212b6d2bdbc94817beddb4
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 79662ba90f8ef4ffe77fa947c3f783dc43abf214..7620d91c08c9f50600f0fb47ae46269121ce15e9 100644
index f325253bf93c4a5fbe333b12019eadc2025a509b..04be155867b324e7b0744d4e900616e0a3d3c4a6 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1415,7 +1415,6 @@ public final class CraftServer implements Server {
// Paper end
@@ -1407,7 +1407,6 @@ public final class CraftServer implements Server {
// Paper - Put world into worldlist before initing the world; move up
this.getServer().prepareLevels(internal.getChunkSource().chunkMap.progressListener, internal);
- internal.entityManager.tick(); // SPIGOT-6526: Load pending entities so they are available to the API
this.pluginManager.callEvent(new WorldLoadEvent(internal.getWorld()));
return internal.getWorld();
@@ -1460,7 +1459,7 @@ public final class CraftServer implements Server {
@@ -1452,7 +1451,7 @@ public final class CraftServer implements Server {
}
handle.getChunkSource().close(save);
@ -21537,7 +21537,7 @@ index 79662ba90f8ef4ffe77fa947c3f783dc43abf214..7620d91c08c9f50600f0fb47ae462691
handle.convertable.close();
} catch (Exception ex) {
this.getLogger().log(Level.SEVERE, null, ex);
@@ -2496,7 +2495,7 @@ public final class CraftServer implements Server {
@@ -2488,7 +2487,7 @@ public final class CraftServer implements Server {
@Override
public boolean isPrimaryThread() {

View File

@ -1573,10 +1573,10 @@ index 1e2530c9e5212b6d2bdbc94817beddb4247dac73..82b4bd669c57b18fb0b443bcd9449502
private static final byte[] EMPTY_LIGHT = new byte[2048];
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 7620d91c08c9f50600f0fb47ae46269121ce15e9..7cd2dc1dc965e7f6496c270f14507543c8dbca74 100644
index 04be155867b324e7b0744d4e900616e0a3d3c4a6..4e22def65ce36e8281ab77ca2f136e274e7026eb 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2667,7 +2667,7 @@ public final class CraftServer implements Server {
@@ -2659,7 +2659,7 @@ public final class CraftServer implements Server {
public ChunkGenerator.ChunkData createChunkData(World world) {
Preconditions.checkArgument(world != null, "World cannot be null");
ServerLevel handle = ((CraftWorld) world).getHandle();

View File

@ -355,7 +355,7 @@ index af50a02bafb7c1db4569604d1e69f95daab6d2a5..541b99dc1361a6ebd40873e45a1acd12
return this.regionCache.getAndMoveToFirst(ChunkPos.asLong(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ()));
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 7cd2dc1dc965e7f6496c270f14507543c8dbca74..e3dba923822ed5bdb1e88132bed94257d5ea544f 100644
index 4e22def65ce36e8281ab77ca2f136e274e7026eb..9af27bf9edf3f4d0e2da49919495334381633867 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1366,9 +1366,7 @@ public final class CraftServer implements Server {