From 0fdc74ab56495d3ccca5bf7ba3b2753bb89323ee Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Wed, 6 May 2026 22:18:05 +0800 Subject: [PATCH 1/2] Retain bonus chest setting on regen world --- .../compatibility/WorldCompatibility.java | 21 +++++++++++++++++++ .../multiverse/core/world/WorldManager.java | 1 + 2 files changed, 22 insertions(+) diff --git a/src/main/java/org/mvplugins/multiverse/core/utils/compatibility/WorldCompatibility.java b/src/main/java/org/mvplugins/multiverse/core/utils/compatibility/WorldCompatibility.java index badfef902..5ec4cf496 100644 --- a/src/main/java/org/mvplugins/multiverse/core/utils/compatibility/WorldCompatibility.java +++ b/src/main/java/org/mvplugins/multiverse/core/utils/compatibility/WorldCompatibility.java @@ -18,10 +18,12 @@ public final class WorldCompatibility { private static final Try SAVE_WITH_FLUSH_METHOD; private static final boolean HAS_GET_COORDINATE_SCALE_METHOD; + private static final boolean HAS_HAS_BONUS_CHEST_METHOD; static { SAVE_WITH_FLUSH_METHOD = ReflectHelper.tryGetMethod(World.class, "save", boolean.class); HAS_GET_COORDINATE_SCALE_METHOD = ReflectHelper.hasMethod(World.class, "getCoordinateScale"); + HAS_HAS_BONUS_CHEST_METHOD = ReflectHelper.hasMethod(World.class, "hasBonusChest"); } /** @@ -65,6 +67,25 @@ public static double getCoordinateScale(World world) { }; } + /** + * Checks if the world has a bonus chest. + *
+ * On PaperMC 1.21.5+, this can be obtained directly from the API. On older versions, it always returns false as + * bonus chest is not supported. + * + * @param world The world to check + * @return True if the world has a bonus chest, false otherwise + * + * @since 5.7 + */ + @ApiStatus.AvailableSince("5.7") + public static boolean hasBonusChest(World world) { + if (HAS_HAS_BONUS_CHEST_METHOD) { + return world.hasBonusChest(); + } + return false; + } + private WorldCompatibility() { throw new UnsupportedOperationException("This is a utility class and cannot be instantiated"); } diff --git a/src/main/java/org/mvplugins/multiverse/core/world/WorldManager.java b/src/main/java/org/mvplugins/multiverse/core/world/WorldManager.java index 90ca017b9..de71677f8 100644 --- a/src/main/java/org/mvplugins/multiverse/core/world/WorldManager.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/WorldManager.java @@ -880,6 +880,7 @@ public Attempt regenWorld(@NotNull Re CreateWorldOptions createWorldOptions = CreateWorldOptions.worldName(world.getName()) .biome(world.getBiome()) + .bonusChest(world.getBukkitWorld().map(WorldCompatibility::hasBonusChest).getOrElse(false)) .environment(world.getEnvironment()) .generateStructures(world.canGenerateStructures().getOrElse(true)) .generator(world.getGenerator()) From 504f17eb1a3e9d34f9649f641acaf86b01e0426e Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Wed, 6 May 2026 22:21:36 +0800 Subject: [PATCH 2/2] Bump mockbukkit to version that supports bonus chest --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 826c1288d..bb56e4a1c 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ repositories { configure(apiDependencies) { serverApiVersion = '1.21.11-R0.1-SNAPSHOT' mockBukkitServerApiVersion = '1.21' - mockBukkitVersion = '4.109.0' + mockBukkitVersion = '4.110.0' } dependencies {