WorldCreator#keepSpawnLoaded (#7673)

This commit is contained in:
Shane Freeder 2022-04-20 10:26:09 +01:00 committed by GitHub
parent c7d4c0188e
commit 4ecc338e09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 66 additions and 0 deletions

View File

@ -0,0 +1,48 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sat, 3 Jul 2021 21:18:41 +0100
Subject: [PATCH] WorldCreator#keepSpawnLoaded
diff --git a/src/main/java/org/bukkit/WorldCreator.java b/src/main/java/org/bukkit/WorldCreator.java
index 9fab6eed92c27ec9dd123171f5c4e1e7cda723e4..1386ba7fd6466965d700db9493e009c186c07d43 100644
--- a/src/main/java/org/bukkit/WorldCreator.java
+++ b/src/main/java/org/bukkit/WorldCreator.java
@@ -22,6 +22,7 @@ public class WorldCreator {
private boolean generateStructures = true;
private String generatorSettings = "";
private boolean hardcore = false;
+ private net.kyori.adventure.util.TriState keepSpawnLoaded = net.kyori.adventure.util.TriState.NOT_SET; // Paper
/**
* Creates an empty WorldCreationOptions for the given world name
@@ -560,4 +561,29 @@ public class WorldCreator {
return result;
}
+
+ // Paper start
+
+ /**
+ * Returns the current intent to keep the world loaded, @see {@link WorldCreator#keepSpawnLoaded(net.kyori.adventure.util.TriState)}
+ *
+ * @return the current tristate value
+ */
+ @NotNull
+ public net.kyori.adventure.util.TriState keepSpawnLoaded() {
+ return keepSpawnLoaded;
+ }
+
+ /**
+ * Controls if a world should be kept loaded or not, default (NOT_SET) will use the servers standard
+ * configuration, otherwise, will act as an override towards this setting
+ *
+ * @param keepSpawnLoaded the new value
+ */
+ public void keepSpawnLoaded(@NotNull net.kyori.adventure.util.TriState keepSpawnLoaded) {
+ java.util.Objects.requireNonNull(keepSpawnLoaded, "keepSpawnLoaded");
+ this.keepSpawnLoaded = keepSpawnLoaded;
+ }
+
+ // Paper end
}

View File

@ -0,0 +1,18 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sat, 3 Jul 2021 21:18:28 +0100
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 16d3f2dce44fc374ec3ab5882135d06113681fb6..ba4578fb4a2d861a6ffbb0ec022db31d9d7cc2be 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1256,6 +1256,7 @@ public final class CraftServer implements Server {
internal.setSpawnSettings(true, true);
// Paper - move up
+ internal.keepSpawnInMemory = creator.keepSpawnLoaded().toBooleanOrElse(internal.getWorld().getKeepSpawnInMemory()); // Paper
this.getServer().prepareLevels(internal.getChunkSource().chunkMap.progressListener, internal);
internal.entityManager.tick(); // SPIGOT-6526: Load pending entities so they are available to the API