diff --git a/paper-api/src/main/java/org/bukkit/World.java b/paper-api/src/main/java/org/bukkit/World.java index 50f9f8408..a8b64f78b 100644 --- a/paper-api/src/main/java/org/bukkit/World.java +++ b/paper-api/src/main/java/org/bukkit/World.java @@ -2870,6 +2870,13 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient */ public boolean canGenerateStructures(); + /** + * Checks if the bonus chest is enabled. + * + * @return {@code true} if the bonus chest is enabled, {@code false} otherwise + */ + boolean hasBonusChest(); + /** * Gets whether the world is hardcore or not. * diff --git a/paper-api/src/main/java/org/bukkit/WorldCreator.java b/paper-api/src/main/java/org/bukkit/WorldCreator.java index 58e3e3e0e..e37e89d94 100644 --- a/paper-api/src/main/java/org/bukkit/WorldCreator.java +++ b/paper-api/src/main/java/org/bukkit/WorldCreator.java @@ -23,6 +23,7 @@ public class WorldCreator { private boolean generateStructures = true; private String generatorSettings = ""; private boolean hardcore = false; + private boolean bonusChest = false; private net.kyori.adventure.util.TriState keepSpawnLoaded = net.kyori.adventure.util.TriState.NOT_SET; // Paper /** @@ -123,6 +124,7 @@ public class WorldCreator { type = world.getWorldType(); generateStructures = world.canGenerateStructures(); hardcore = world.isHardcore(); + bonusChest = world.hasBonusChest(); this.keepSpawnLoaded = net.kyori.adventure.util.TriState.byBoolean(world.getKeepSpawnInMemory()); // Paper return this; @@ -146,6 +148,7 @@ public class WorldCreator { generateStructures = creator.generateStructures(); generatorSettings = creator.generatorSettings(); hardcore = creator.hardcore(); + bonusChest = creator.bonusChest(); keepSpawnLoaded = creator.keepSpawnLoaded(); // Paper return this; @@ -451,7 +454,7 @@ public class WorldCreator { /** * Gets whether the world will be hardcore or not. - * + *

* In a hardcore world the difficulty will be locked to hard. * * @return hardcore status @@ -460,6 +463,27 @@ public class WorldCreator { return hardcore; } + /** + * Sets whether a bonus chest should be generated or not. + * + * @param bonusChest indicating whether the bonus chest should be generated + * @return This object, for chaining + */ + @NotNull + public WorldCreator bonusChest(final boolean bonusChest) { + this.bonusChest = bonusChest; + return this; + } + + /** + * Gets whether the bonus chest feature is enabled. + * + * @return true if the bonus chest is enabled, false otherwise. + */ + public boolean bonusChest() { + return bonusChest; + } + /** * Sets whether the spawn chunks will be kept loaded.
* Setting this to false will also stop the spawn chunks from being generated diff --git a/paper-server/patches/sources/net/minecraft/world/level/GameRules.java.patch b/paper-server/patches/sources/net/minecraft/world/level/GameRules.java.patch index 0ef93c5f2..12d60c59e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/GameRules.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/GameRules.java.patch @@ -250,7 +250,7 @@ + // Paper start - expose FeatureElement wrapper for GameRules.Type. + // Chosen over simply adding this to the inheritance to avoid reobf issues with spigot... + public net.minecraft.world.flag.FeatureElement asFeatureElement() { -+ return net.minecraft.world.level.GameRules.Type.this::requiredFeatures; ++ return GameRules.Type.this::requiredFeatures; + } + // Paper end - expose FeatureElement wrapper for GameRules.Type. } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 676e2b789..ab781cb77 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1345,7 +1345,7 @@ public final class CraftServer implements Server { registryAccess = levelDataAndDimensions.dimensions().dimensionsRegistryAccess(); } else { LevelSettings levelSettings; - WorldOptions worldOptions = new WorldOptions(creator.seed(), creator.generateStructures(), false); + WorldOptions worldOptions = new WorldOptions(creator.seed(), creator.generateStructures(), creator.bonusChest()); WorldDimensions worldDimensions; DedicatedServerProperties.WorldDimensionData properties = new DedicatedServerProperties.WorldDimensionData(GsonHelper.parse((creator.generatorSettings().isEmpty()) ? "{}" : creator.generatorSettings()), creator.type().name().toLowerCase(Locale.ROOT)); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 285d94b42..4a4057440 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -1620,6 +1620,11 @@ public class CraftWorld extends CraftRegionAccessor implements World { return this.world.serverLevelData.worldGenOptions().generateStructures(); } + @Override + public boolean hasBonusChest() { + return this.world.serverLevelData.worldGenOptions().generateBonusChest(); + } + @Override public boolean isHardcore() { return this.world.getLevelData().isHardcore();