Skip to content

Commit

Permalink
WorldCreator#keepSpawnLoaded (#7673)
Browse files Browse the repository at this point in the history
  • Loading branch information
electronicboy committed Apr 20, 2022
1 parent c7d4c01 commit 4ecc338
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
48 changes: 48 additions & 0 deletions patches/api/0380-WorldCreator-keepSpawnLoaded.patch
@@ -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
}
18 changes: 18 additions & 0 deletions patches/server/0896-WorldCreator-keepSpawnLoaded.patch
@@ -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

0 comments on commit 4ecc338

Please sign in to comment.