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 <46540330+willkroboth@users.noreply.github.com> +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. + *
+ * If the world is already loaded, it will just return the equivalent of + * getWorld(creator.name()). ++ *
++ * 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. ++ *
++ * 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. ++ *
++ * 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
+ * If the world is already loaded, it will just return the equivalent of
+ * getWorld(creator.name()).
++ *
++ * 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.
++ *
++ * 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.
++ *
++ * 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
similarity index 100%
rename from patches/api/0383-Add-WardenAngerChangeEvent.patch
rename to patches/api/0384-Add-WardenAngerChangeEvent.patch
diff --git a/patches/api/0384-Nameable-Banner-API.patch b/patches/api/0385-Nameable-Banner-API.patch
similarity index 100%
rename from patches/api/0384-Nameable-Banner-API.patch
rename to 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
similarity index 100%
rename from patches/api/0385-Add-Player-getFishHook.patch
rename to 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
similarity index 100%
rename from patches/api/0386-More-Teleport-API.patch
rename to patches/api/0387-More-Teleport-API.patch
diff --git a/patches/api/0387-Add-EntityPortalReadyEvent.patch b/patches/api/0388-Add-EntityPortalReadyEvent.patch
similarity index 100%
rename from patches/api/0387-Add-EntityPortalReadyEvent.patch
rename to 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
similarity index 100%
rename from patches/api/0388-Custom-Chat-Completion-Suggestions-API.patch
rename to 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
similarity index 100%
rename from patches/api/0389-Collision-API.patch
rename to patches/api/0390-Collision-API.patch
diff --git a/patches/api/0390-Block-Ticking-API.patch b/patches/api/0391-Block-Ticking-API.patch
similarity index 100%
rename from patches/api/0390-Block-Ticking-API.patch
rename to 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
similarity index 100%
rename from patches/api/0391-Add-NamespacedKey-biome-methods.patch
rename to 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
similarity index 100%
rename from patches/api/0392-Add-custom-destroyerIdentity-to-sendBlockDamage.patch
rename to 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
similarity index 100%
rename from patches/api/0393-Also-load-resources-from-LibraryLoader.patch
rename to 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
similarity index 100%
rename from patches/api/0394-Added-byte-array-serialization-deserialization-for-P.patch
rename to 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
similarity index 100%
rename from patches/api/0395-Add-a-consumer-parameter-to-ProjectileSource-launchP.patch
rename to 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
similarity index 100%
rename from patches/api/0396-Expose-codepoint-limit-in-YamlConfigOptions-and-incr.patch
rename to 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