aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorwillkroboth <[email protected]>2022-09-24 01:19:05 -0400
committerGitHub <[email protected]>2022-09-24 06:19:05 +0100
commit4d52f1d247c3819e6fe6235648dc8bd3538b4713 (patch)
tree86d686eecec221f476e33dc55dce31cb710a113a
parent6736f390a22a9997a66dfaf1189dca393b52b744 (diff)
downloadPaper-4d52f1d247c3819e6fe6235648dc8bd3538b4713.tar.gz
Paper-4d52f1d247c3819e6fe6235648dc8bd3538b4713.zip
Add method isTickingWorlds to Bukkit (#8316)
Co-authored-by: Shane Freeder <[email protected]> Also, restores un/loading worlds mid tick. This will not be officially supported API contract that such a routine is safe, and these restrictions may be restored in the future.
-rw-r--r--patches/api/0383-Add-method-isTickingWorlds-to-Bukkit.patch117
-rw-r--r--patches/api/0384-Add-WardenAngerChangeEvent.patch (renamed from patches/api/0383-Add-WardenAngerChangeEvent.patch)0
-rw-r--r--patches/api/0385-Nameable-Banner-API.patch (renamed from patches/api/0384-Nameable-Banner-API.patch)0
-rw-r--r--patches/api/0386-Add-Player-getFishHook.patch (renamed from patches/api/0385-Add-Player-getFishHook.patch)0
-rw-r--r--patches/api/0387-More-Teleport-API.patch (renamed from patches/api/0386-More-Teleport-API.patch)0
-rw-r--r--patches/api/0388-Add-EntityPortalReadyEvent.patch (renamed from patches/api/0387-Add-EntityPortalReadyEvent.patch)0
-rw-r--r--patches/api/0389-Custom-Chat-Completion-Suggestions-API.patch (renamed from patches/api/0388-Custom-Chat-Completion-Suggestions-API.patch)0
-rw-r--r--patches/api/0390-Collision-API.patch (renamed from patches/api/0389-Collision-API.patch)0
-rw-r--r--patches/api/0391-Block-Ticking-API.patch (renamed from patches/api/0390-Block-Ticking-API.patch)0
-rw-r--r--patches/api/0392-Add-NamespacedKey-biome-methods.patch (renamed from patches/api/0391-Add-NamespacedKey-biome-methods.patch)0
-rw-r--r--patches/api/0393-Add-custom-destroyerIdentity-to-sendBlockDamage.patch (renamed from patches/api/0392-Add-custom-destroyerIdentity-to-sendBlockDamage.patch)0
-rw-r--r--patches/api/0394-Also-load-resources-from-LibraryLoader.patch (renamed from patches/api/0393-Also-load-resources-from-LibraryLoader.patch)0
-rw-r--r--patches/api/0395-Added-byte-array-serialization-deserialization-for-P.patch (renamed from patches/api/0394-Added-byte-array-serialization-deserialization-for-P.patch)0
-rw-r--r--patches/api/0396-Add-a-consumer-parameter-to-ProjectileSource-launchP.patch (renamed from patches/api/0395-Add-a-consumer-parameter-to-ProjectileSource-launchP.patch)0
-rw-r--r--patches/api/0397-Expose-codepoint-limit-in-YamlConfigOptions-and-incr.patch (renamed from patches/api/0396-Expose-codepoint-limit-in-YamlConfigOptions-and-incr.patch)0
-rw-r--r--patches/server/0899-Throw-exception-on-world-create-while-being-ticked.patch22
-rw-r--r--patches/server/0907-Don-t-broadcast-messages-to-command-blocks.patch4
17 files changed, 136 insertions, 7 deletions
diff --git a/patches/api/0383-Add-method-isTickingWorlds-to-Bukkit.patch b/patches/api/0383-Add-method-isTickingWorlds-to-Bukkit.patch
new file mode 100644
index 0000000000..19074e3763
--- /dev/null
+++ b/patches/api/0383-Add-method-isTickingWorlds-to-Bukkit.patch
@@ -0,0 +1,117 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: BuildTools <[email protected]>
+Date: Fri, 19 Aug 2022 16:11:51 -0400
+Subject: [PATCH] Add method isTickingWorlds() to Bukkit.
+
+
+diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
+index 840aaf9e8fc828b5a7ea02252038c6524680f2e0..b5a7d6ab4e458843f2e163bf06b5668627012f91 100644
+--- a/src/main/java/org/bukkit/Bukkit.java
++++ b/src/main/java/org/bukkit/Bukkit.java
+@@ -753,12 +753,26 @@ public final class Bukkit {
+ return server.getWorlds();
+ }
+
++ // Paper start
++ /**
++ * Gets whether the worlds are being ticked right not or not.
++ *
++ * @return true if the worlds are being ticked, false otherwise.
++ */
++ public static boolean isTickingWorlds(){
++ return server.isTickingWorlds();
++ }
++ // Paper end
++
+ /**
+ * Creates or loads a world with the given name using the specified
+ * options.
+ * <p>
+ * If the world is already loaded, it will just return the equivalent of
+ * getWorld(creator.name()).
++ * <p>
++ * Do note that un/loading worlds mid-tick may have potential side effects, we strongly recommend
++ * ensuring that you're not loading worlds midtick by checking {@link Bukkit#isTickingWorlds()}
+ *
+ * @param creator the options to use when creating the world
+ * @return newly created or loaded world
+@@ -770,6 +784,9 @@ public final class Bukkit {
+
+ /**
+ * Unloads a world with the given name.
++ * <p>
++ * Do note that un/loading worlds mid-tick may have potential side effects, we strongly recommend
++ * ensuring that you're not loading worlds midtick by checking {@link Bukkit#isTickingWorlds()}
+ *
+ * @param name Name of the world to unload
+ * @param save whether to save the chunks before unloading
+@@ -781,6 +798,9 @@ public final class Bukkit {
+
+ /**
+ * Unloads the given world.
++ * <p>
++ * Do note that un/loading worlds mid-tick may have potential side effects, we strongly recommend
++ * ensuring that you're not loading worlds midtick by checking {@link Bukkit#isTickingWorlds()}
+ *
+ * @param world the world to unload
+ * @param save whether to save the chunks before unloading
+diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
+index da5cab4246bd253fcc4e4d9574bdae1867ebb5ab..1982fc2d7f1cb80d3e324ee283211b251a976c6e 100644
+--- a/src/main/java/org/bukkit/Server.java
++++ b/src/main/java/org/bukkit/Server.java
+@@ -622,34 +622,55 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
+ @NotNull
+ public List<World> getWorlds();
+
++ // Paper start
++ /**
++ * Gets whether the worlds are being ticked right not or not.
++ *
++ * @return true if the worlds are being ticked, false otherwise.
++ */
++ public boolean isTickingWorlds();
++ // Paper end
++
+ /**
+ * Creates or loads a world with the given name using the specified
+ * options.
+ * <p>
+ * If the world is already loaded, it will just return the equivalent of
+ * getWorld(creator.name()).
++ * <p>
++ * Do note that un/loading worlds mid-tick may have potential side effects, we strongly recommend
++ * ensuring that you're not loading worlds midtick by checking {@link Bukkit#isTickingWorlds()}
+ *
+ * @param creator the options to use when creating the world
+ * @return newly created or loaded world
++ * @throws IllegalStateException when {@link #isTickingWorlds() isTickingWorlds} is true
+ */
+ @Nullable
+ public World createWorld(@NotNull WorldCreator creator);
+
+ /**
+ * Unloads a world with the given name.
++ * <p>
++ * Do note that un/loading worlds mid-tick may have potential side effects, we strongly recommend
++ * ensuring that you're not loading worlds midtick by checking {@link Bukkit#isTickingWorlds()}
+ *
+ * @param name Name of the world to unload
+ * @param save whether to save the chunks before unloading
+ * @return true if successful, false otherwise
++ * @throws IllegalStateException when {@link #isTickingWorlds() isTickingWorlds} is true
+ */
+ public boolean unloadWorld(@NotNull String name, boolean save);
+
+ /**
+ * Unloads the given world.
++ * <p>
++ * Do note that un/loading worlds mid-tick may have potential side effects, we strongly recommend
++ * ensuring that you're not loading worlds midtick by checking {@link Bukkit#isTickingWorlds()}
+ *
+ * @param world the world to unload
+ * @param save whether to save the chunks before unloading
+ * @return true if successful, false otherwise
++ * @throws IllegalStateException when {@link #isTickingWorlds() isTickingWorlds} is true
+ */
+ public boolean unloadWorld(@NotNull World world, boolean save);
+
diff --git a/patches/api/0383-Add-WardenAngerChangeEvent.patch b/patches/api/0384-Add-WardenAngerChangeEvent.patch
index acf45b5314..acf45b5314 100644
--- a/patches/api/0383-Add-WardenAngerChangeEvent.patch
+++ b/patches/api/0384-Add-WardenAngerChangeEvent.patch
diff --git a/patches/api/0384-Nameable-Banner-API.patch b/patches/api/0385-Nameable-Banner-API.patch
index eba196daaf..eba196daaf 100644
--- a/patches/api/0384-Nameable-Banner-API.patch
+++ b/patches/api/0385-Nameable-Banner-API.patch
diff --git a/patches/api/0385-Add-Player-getFishHook.patch b/patches/api/0386-Add-Player-getFishHook.patch
index 9c96c813ae..9c96c813ae 100644
--- a/patches/api/0385-Add-Player-getFishHook.patch
+++ b/patches/api/0386-Add-Player-getFishHook.patch
diff --git a/patches/api/0386-More-Teleport-API.patch b/patches/api/0387-More-Teleport-API.patch
index 98b380b070..98b380b070 100644
--- a/patches/api/0386-More-Teleport-API.patch
+++ b/patches/api/0387-More-Teleport-API.patch
diff --git a/patches/api/0387-Add-EntityPortalReadyEvent.patch b/patches/api/0388-Add-EntityPortalReadyEvent.patch
index 4b1b1f1e1f..4b1b1f1e1f 100644
--- a/patches/api/0387-Add-EntityPortalReadyEvent.patch
+++ b/patches/api/0388-Add-EntityPortalReadyEvent.patch
diff --git a/patches/api/0388-Custom-Chat-Completion-Suggestions-API.patch b/patches/api/0389-Custom-Chat-Completion-Suggestions-API.patch
index 0afdd4aa9a..0afdd4aa9a 100644
--- a/patches/api/0388-Custom-Chat-Completion-Suggestions-API.patch
+++ b/patches/api/0389-Custom-Chat-Completion-Suggestions-API.patch
diff --git a/patches/api/0389-Collision-API.patch b/patches/api/0390-Collision-API.patch
index 84c0fd74ca..84c0fd74ca 100644
--- a/patches/api/0389-Collision-API.patch
+++ b/patches/api/0390-Collision-API.patch
diff --git a/patches/api/0390-Block-Ticking-API.patch b/patches/api/0391-Block-Ticking-API.patch
index 7c077405ca..7c077405ca 100644
--- a/patches/api/0390-Block-Ticking-API.patch
+++ b/patches/api/0391-Block-Ticking-API.patch
diff --git a/patches/api/0391-Add-NamespacedKey-biome-methods.patch b/patches/api/0392-Add-NamespacedKey-biome-methods.patch
index fc1f5c4d7e..fc1f5c4d7e 100644
--- a/patches/api/0391-Add-NamespacedKey-biome-methods.patch
+++ b/patches/api/0392-Add-NamespacedKey-biome-methods.patch
diff --git a/patches/api/0392-Add-custom-destroyerIdentity-to-sendBlockDamage.patch b/patches/api/0393-Add-custom-destroyerIdentity-to-sendBlockDamage.patch
index 31fa2bff14..31fa2bff14 100644
--- a/patches/api/0392-Add-custom-destroyerIdentity-to-sendBlockDamage.patch
+++ b/patches/api/0393-Add-custom-destroyerIdentity-to-sendBlockDamage.patch
diff --git a/patches/api/0393-Also-load-resources-from-LibraryLoader.patch b/patches/api/0394-Also-load-resources-from-LibraryLoader.patch
index 9843c45af2..9843c45af2 100644
--- a/patches/api/0393-Also-load-resources-from-LibraryLoader.patch
+++ b/patches/api/0394-Also-load-resources-from-LibraryLoader.patch
diff --git a/patches/api/0394-Added-byte-array-serialization-deserialization-for-P.patch b/patches/api/0395-Added-byte-array-serialization-deserialization-for-P.patch
index 9c197fc52f..9c197fc52f 100644
--- a/patches/api/0394-Added-byte-array-serialization-deserialization-for-P.patch
+++ b/patches/api/0395-Added-byte-array-serialization-deserialization-for-P.patch
diff --git a/patches/api/0395-Add-a-consumer-parameter-to-ProjectileSource-launchP.patch b/patches/api/0396-Add-a-consumer-parameter-to-ProjectileSource-launchP.patch
index bec7a5d015..bec7a5d015 100644
--- a/patches/api/0395-Add-a-consumer-parameter-to-ProjectileSource-launchP.patch
+++ b/patches/api/0396-Add-a-consumer-parameter-to-ProjectileSource-launchP.patch
diff --git a/patches/api/0396-Expose-codepoint-limit-in-YamlConfigOptions-and-incr.patch b/patches/api/0397-Expose-codepoint-limit-in-YamlConfigOptions-and-incr.patch
index 7fe0223346..7fe0223346 100644
--- a/patches/api/0396-Expose-codepoint-limit-in-YamlConfigOptions-and-incr.patch
+++ b/patches/api/0397-Expose-codepoint-limit-in-YamlConfigOptions-and-incr.patch
diff --git a/patches/server/0899-Throw-exception-on-world-create-while-being-ticked.patch b/patches/server/0899-Throw-exception-on-world-create-while-being-ticked.patch
index c7ac48bd91..6c91627e34 100644
--- a/patches/server/0899-Throw-exception-on-world-create-while-being-ticked.patch
+++ b/patches/server/0899-Throw-exception-on-world-create-while-being-ticked.patch
@@ -45,22 +45,34 @@ index 4d920031300a9801debc2eb39a4d3cb9d8fbb330..f1e14f7850c0a64128839285f09e2aa3
this.profiler.popPush("connection");
MinecraftTimings.connectionTimer.startTiming(); // Spigot
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
-index c75e3cd197bee7caeef3a55b2746c15de3c0c3e4..61b9d44e4edc4cb6ffbd8bf99e8e098bcc9957b3 100644
+index c75e3cd197bee7caeef3a55b2746c15de3c0c3e4..19a98e502b4ba49485fa3e51c48309a06ded5a9d 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
-@@ -1139,6 +1139,7 @@ public final class CraftServer implements Server {
+@@ -855,6 +855,11 @@ public final class CraftServer implements Server {
+ return new ArrayList<World>(this.worlds.values());
+ }
+
++ @Override
++ public boolean isTickingWorlds() {
++ return console.isIteratingOverLevels;
++ }
++
+ public DedicatedPlayerList getHandle() {
+ return this.playerList;
+ }
+@@ -1139,6 +1144,7 @@ public final class CraftServer implements Server {
@Override
public World createWorld(WorldCreator creator) {
Preconditions.checkState(this.console.getAllLevels().iterator().hasNext(), "Cannot create additional worlds on STARTUP");
-+ Preconditions.checkState(!this.console.isIteratingOverLevels, "Cannot create a world while worlds are being ticked"); // Paper
++ //Preconditions.checkState(!this.console.isIteratingOverLevels, "Cannot create a world while worlds are being ticked"); // Paper - Cat - Temp disable. We'll see how this goes.
Validate.notNull(creator, "Creator may not be null");
String name = creator.name();
-@@ -1263,6 +1264,7 @@ public final class CraftServer implements Server {
+@@ -1263,6 +1269,7 @@ public final class CraftServer implements Server {
@Override
public boolean unloadWorld(World world, boolean save) {
-+ Preconditions.checkState(!this.console.isIteratingOverLevels, "Cannot unload a world while worlds are being ticked"); // Paper
++ //Preconditions.checkState(!this.console.isIteratingOverLevels, "Cannot unload a world while worlds are being ticked"); // Paper - Cat - Temp disable. We'll see how this goes.
if (world == null) {
return false;
}
diff --git a/patches/server/0907-Don-t-broadcast-messages-to-command-blocks.patch b/patches/server/0907-Don-t-broadcast-messages-to-command-blocks.patch
index 7ce8867778..95330c3de3 100644
--- a/patches/server/0907-Don-t-broadcast-messages-to-command-blocks.patch
+++ b/patches/server/0907-Don-t-broadcast-messages-to-command-blocks.patch
@@ -20,10 +20,10 @@ index c0195f73cd2c8721e882c681eaead65471710081..861b348f73867af3199f1cc0dab1ddd4
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 61b9d44e4edc4cb6ffbd8bf99e8e098bcc9957b3..3c9ba17cd0f016a21f56c6b6f8861c512734637a 100644
+index 19a98e502b4ba49485fa3e51c48309a06ded5a9d..df0472f275b4fa3a1088db84712a39ea0257f17e 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
-@@ -1758,7 +1758,7 @@ public final class CraftServer implements Server {
+@@ -1763,7 +1763,7 @@ public final class CraftServer implements Server {
// Paper end
Set<CommandSender> recipients = new HashSet<>();
for (Permissible permissible : this.getPluginManager().getPermissionSubscriptions(permission)) {