diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java index e229adcdc..964a03d3f 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java @@ -608,7 +608,7 @@ public class PlayerEventListener implements Listener { this.tmpTeleport = true; return; } - int border = area.getBorder(); + int border = area.getBorder(true); int x1; if (x2 > border && this.tmpTeleport) { if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_BORDER)) { @@ -703,7 +703,7 @@ public class PlayerEventListener implements Listener { this.tmpTeleport = true; return; } - int border = area.getBorder(); + int border = area.getBorder(true); int z1; if (z2 > border && this.tmpTeleport) { if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_BORDER)) { diff --git a/Core/src/main/java/com/plotsquared/core/command/Claim.java b/Core/src/main/java/com/plotsquared/core/command/Claim.java index de35e7bb1..c118d4cb0 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Claim.java +++ b/Core/src/main/java/com/plotsquared/core/command/Claim.java @@ -193,7 +193,7 @@ public class Claim extends SubCommand { } } if (!player.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_BORDER)) { - int border = area.getBorder(); + int border = area.getBorder(false); if (border != Integer.MAX_VALUE && plot.getDistanceFromOrigin() > border && !force) { player.sendMessage(TranslatableCaption.of("border.denied")); return false; diff --git a/Core/src/main/java/com/plotsquared/core/plot/Plot.java b/Core/src/main/java/com/plotsquared/core/plot/Plot.java index 4cd4b18ad..67e05c909 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/Plot.java +++ b/Core/src/main/java/com/plotsquared/core/plot/Plot.java @@ -2638,6 +2638,11 @@ public class Plot { return false; } + /** + * Get the maximum distance of the plot from x=0, z=0. + * + * @return max block distance from 0,0 + */ public int getDistanceFromOrigin() { Location bot = getManager().getPlotBottomLocAbs(id); Location top = getManager().getPlotTopLocAbs(id); @@ -2651,7 +2656,7 @@ public class Plot { * Expands the world border to include this plot if it is beyond the current border. */ public void updateWorldBorder() { - int border = this.area.getBorder(); + int border = this.area.getBorder(false); if (border == Integer.MAX_VALUE) { return; } 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 d27758761..2f151ce6a 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java @@ -147,6 +147,7 @@ public abstract class PlotArea implements ComponentLike { private Map prices = new HashMap<>(); private List schematics = new ArrayList<>(); private boolean worldBorder = false; + private int borderSize = 1; private boolean useEconomy = false; private int hash; private CuboidRegion region; @@ -356,6 +357,7 @@ public abstract class PlotArea implements ComponentLike { this.plotChat = config.getBoolean("chat.enabled"); this.forcingPlotChat = config.getBoolean("chat.forced"); this.worldBorder = config.getBoolean("world.border"); + this.borderSize = config.getInt("world.border_size"); this.maxBuildHeight = config.getInt("world.max_height"); this.minBuildHeight = config.getInt("world.min_height"); this.minGenHeight = config.getInt("world.min_gen_height"); @@ -489,6 +491,7 @@ public abstract class PlotArea implements ComponentLike { options.put("event.spawn.custom", this.isSpawnCustom()); options.put("event.spawn.breeding", this.isSpawnBreeding()); options.put("world.border", this.hasWorldBorder()); + options.put("world.border_size", this.getBorderSize()); options.put("home.default", "side"); String position = config.getString( "home.nonmembers", @@ -937,7 +940,9 @@ public abstract class PlotArea implements ComponentLike { * Get the plot border distance for a world
* * @return The border distance or Integer.MAX_VALUE if no border is set + * @deprecated Use {@link PlotArea#getBorder(boolean)} */ + @Deprecated(forRemoval = true, since = "TODO") public int getBorder() { final Integer meta = (Integer) getMeta("worldBorder"); if (meta != null) { @@ -951,6 +956,27 @@ public abstract class PlotArea implements ComponentLike { return Integer.MAX_VALUE; } + /** + * Get the plot border distance for a world, specifying whether the returned value should include the world.border-size + * value. This is a player-traversable area, where plots cannot be claimed + * + * @param getExtended If the extra border given by world.border-size should be included + * @return Border distance of Integer.MAX_VALUE if no border is set + * @since TODO + */ + public int getBorder(boolean getExtended) { + final Integer meta = (Integer) getMeta("worldBorder"); + if (meta != null) { + int border = meta + 1; + if (border == 0) { + return Integer.MAX_VALUE; + } else { + return getExtended ? border + borderSize : border; + } + } + return Integer.MAX_VALUE; + } + /** * Setup the plot border for a world (usually done when the world is created). */ @@ -1210,6 +1236,16 @@ public abstract class PlotArea implements ComponentLike { return worldBorder; } + /** + * Get the "extra border" size of the plot area. + * + * @return Plot area extra border size + * @since TODO + */ + public int getBorderSize() { + return borderSize; + } + /** * Get whether plot signs are allowed or not. *