From dbc2d60ce08812cd55fc5bab7b6bd4bd8a71c77f Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Tue, 20 Sep 2022 01:28:22 +0100 Subject: [PATCH] Make WorldCreator#keepSpawnLoaded return the WorldCreator (Fixes #8321) (#8371) * Make WorldCreator#keepSpawnLoaded return the WorldCreator (Fixes #8321) Thought that I fixed this before push/merge, apparently not, hence, fix the return type and add mitigation for this. * Fix patch/build * Rebuild patches --- .../0378-WorldCreator-keepSpawnLoaded.patch | 9 ++++--- ...0944-Configurable-chat-thread-limit.patch} | 0 ...-of-WorldCreator-keepSpawnLoaded-ret.patch | 25 +++++++++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) rename patches/server/{0943-Configurable-chat-thread-limit.patch => 0944-Configurable-chat-thread-limit.patch} (100%) create mode 100644 patches/server/0945-Mitigate-effects-of-WorldCreator-keepSpawnLoaded-ret.patch diff --git a/patches/api/0378-WorldCreator-keepSpawnLoaded.patch b/patches/api/0378-WorldCreator-keepSpawnLoaded.patch index 239a61f5a..c148a391f 100644 --- a/patches/api/0378-WorldCreator-keepSpawnLoaded.patch +++ b/patches/api/0378-WorldCreator-keepSpawnLoaded.patch @@ -5,7 +5,7 @@ Subject: [PATCH] WorldCreator#keepSpawnLoaded diff --git a/src/main/java/org/bukkit/WorldCreator.java b/src/main/java/org/bukkit/WorldCreator.java -index cbdcac688afb7c13dd7058fa522bbd2c5adc445e..355f9f27d29c65efebf099a72c37892a309edef1 100644 +index cbdcac688afb7c13dd7058fa522bbd2c5adc445e..dc92ce261b9e67979da3f82cb75292ff980ad87e 100644 --- a/src/main/java/org/bukkit/WorldCreator.java +++ b/src/main/java/org/bukkit/WorldCreator.java @@ -22,6 +22,7 @@ public class WorldCreator { @@ -16,7 +16,7 @@ index cbdcac688afb7c13dd7058fa522bbd2c5adc445e..355f9f27d29c65efebf099a72c37892a /** * Creates an empty WorldCreationOptions for the given world name -@@ -573,4 +574,29 @@ public class WorldCreator { +@@ -573,4 +574,32 @@ public class WorldCreator { return result; } @@ -38,10 +38,13 @@ index cbdcac688afb7c13dd7058fa522bbd2c5adc445e..355f9f27d29c65efebf099a72c37892a + * configuration, otherwise, will act as an override towards this setting + * + * @param keepSpawnLoaded the new value ++ * @return This object, for chaining + */ -+ public void keepSpawnLoaded(@NotNull net.kyori.adventure.util.TriState keepSpawnLoaded) { ++ @NotNull ++ public WorldCreator keepSpawnLoaded(@NotNull net.kyori.adventure.util.TriState keepSpawnLoaded) { + java.util.Objects.requireNonNull(keepSpawnLoaded, "keepSpawnLoaded"); + this.keepSpawnLoaded = keepSpawnLoaded; ++ return this; + } + + // Paper end diff --git a/patches/server/0943-Configurable-chat-thread-limit.patch b/patches/server/0944-Configurable-chat-thread-limit.patch similarity index 100% rename from patches/server/0943-Configurable-chat-thread-limit.patch rename to patches/server/0944-Configurable-chat-thread-limit.patch diff --git a/patches/server/0945-Mitigate-effects-of-WorldCreator-keepSpawnLoaded-ret.patch b/patches/server/0945-Mitigate-effects-of-WorldCreator-keepSpawnLoaded-ret.patch new file mode 100644 index 000000000..b571f18f1 --- /dev/null +++ b/patches/server/0945-Mitigate-effects-of-WorldCreator-keepSpawnLoaded-ret.patch @@ -0,0 +1,25 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Shane Freeder +Date: Mon, 19 Sep 2022 00:13:02 +0100 +Subject: [PATCH] Mitigate effects of WorldCreator#keepSpawnLoaded ret type + change + +TODO: Remove in 1.21? + +diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java +index 27646d963bd1158f3fe0a9c0593a312404f0e7b0..128113e64731be9c0a4008ffb0a1eae78e221c47 100644 +--- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java ++++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java +@@ -434,6 +434,12 @@ public class Commodore + { + desc = getOriginalOrRewrite(desc); + } ++ if (owner.equals("org/bukkit/WorldCreator") && name.equals("keepSpawnLoaded") && desc.equals("(Lnet/kyori/adventure/util/TriState;)V")) { ++ super.visitMethodInsn(opcode, owner, name, "(Lnet/kyori/adventure/util/TriState;)Lorg/bukkit/WorldCreator;", itf); ++ // new method has a return, so, make sure we pop it ++ super.visitInsn(Opcodes.POP); ++ return; ++ } + // Paper end + + if ( modern )