From ede44685164ed102fd6c93a8908d9e00b8eb1684 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 --- .../api/WorldCreator-keepSpawnLoaded.patch | 5 +++- ...-of-WorldCreator-keepSpawnLoaded-ret.patch | 25 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 patches/server/Mitigate-effects-of-WorldCreator-keepSpawnLoaded-ret.patch diff --git a/patches/api/WorldCreator-keepSpawnLoaded.patch b/patches/api/WorldCreator-keepSpawnLoaded.patch index 0de7196c3e..b6bdced6e5 100644 --- a/patches/api/WorldCreator-keepSpawnLoaded.patch +++ b/patches/api/WorldCreator-keepSpawnLoaded.patch @@ -38,10 +38,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * 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/Mitigate-effects-of-WorldCreator-keepSpawnLoaded-ret.patch b/patches/server/Mitigate-effects-of-WorldCreator-keepSpawnLoaded-ret.patch new file mode 100644 index 0000000000..7793bd365e --- /dev/null +++ b/patches/server/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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java ++++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java +@@ -0,0 +0,0 @@ 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 )