From fae95b758afa1abd781f55cc18c4d9c02fff3081 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Wed, 26 Jan 2022 12:29:03 +0000 Subject: [PATCH] Default gen/build heights based on minecraft version --- .../com/plotsquared/bukkit/BukkitPlatform.java | 10 ++++++++++ .../java/com/plotsquared/core/PlotPlatform.java | 14 ++++++++++++++ .../java/com/plotsquared/core/plot/PlotArea.java | 8 ++++---- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java index 61ba28413..cd7dc4c7f 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java @@ -238,6 +238,16 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl return this.version; } + @Override + public int versionMinHeight() { + return serverVersion()[1] >= 18 ? -64 : 0; + } + + @Override + public int versionMaxHeight() { + return serverVersion()[1] >= 18 ? 319 : 255; + } + @Override public @NonNull String serverImplementation() { return Bukkit.getVersion(); diff --git a/Core/src/main/java/com/plotsquared/core/PlotPlatform.java b/Core/src/main/java/com/plotsquared/core/PlotPlatform.java index 491431b6c..3ef79df52 100644 --- a/Core/src/main/java/com/plotsquared/core/PlotPlatform.java +++ b/Core/src/main/java/com/plotsquared/core/PlotPlatform.java @@ -98,6 +98,20 @@ public interface PlotPlatform

extends LocaleHolder { */ int[] serverVersion(); + /** + * Gets the default minimum world height for the version of Minecraft that the server is running. + * + * @return minimum world height + */ + int versionMinHeight(); + + /** + * Gets the default maximum world height for the version of Minecraft that the server is running. + * + * @return maximum world height + */ + int versionMaxHeight(); + /** * Gets the server implementation name and version * diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java b/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java index 87a346c44..6c0867f4f 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java @@ -142,10 +142,10 @@ public abstract class PlotArea { private boolean homeAllowNonmember = false; private BlockLoc nonmemberHome; private BlockLoc defaultHome; - private int maxBuildHeight = 255; - private int minBuildHeight = 1; - private int maxGenHeight = 255; - private int minGenHeight = 0; + private int maxBuildHeight = PlotSquared.platform().versionMaxHeight(); + private int minBuildHeight = PlotSquared.platform().versionMinHeight() + 1; + private int maxGenHeight = PlotSquared.platform().versionMaxHeight(); + private int minGenHeight = PlotSquared.platform().versionMinHeight(); private GameMode gameMode = GameModes.CREATIVE; private Map prices = new HashMap<>(); private List schematics = new ArrayList<>();