From c82e5c586d67973f9fe5f994880be34d67d3a2db Mon Sep 17 00:00:00 2001 From: destro174 <40720638+destro174@users.noreply.github.com> Date: Fri, 15 Apr 2022 09:37:58 +0200 Subject: [PATCH] Prevent claiming outside of the worldborder --- src/main/java/me/ryanhamshire/GriefPrevention/Claim.java | 7 +++++++ .../java/me/ryanhamshire/GriefPrevention/DataStore.java | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/Claim.java b/src/main/java/me/ryanhamshire/GriefPrevention/Claim.java index f060f2e..dcd9bb6 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/Claim.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/Claim.java @@ -26,6 +26,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.World.Environment; +import org.bukkit.WorldBorder; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.entity.Entity; @@ -767,4 +768,10 @@ public class Claim } return true; } + + public boolean isInsideBorder() { + WorldBorder worldBorder = this.getLesserBoundaryCorner().getWorld().getWorldBorder(); + return worldBorder.isInside(this.lesserBoundaryCorner) && worldBorder.isInside(this.greaterBoundaryCorner); + } + } diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/DataStore.java b/src/main/java/me/ryanhamshire/GriefPrevention/DataStore.java index e973461..d88af6c 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/DataStore.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/DataStore.java @@ -965,6 +965,13 @@ public abstract class DataStore return result; } + if (creatingPlayer != null && newClaim.isInsideBorder()) { + result.succeeded = false; + result.claim = null; + creatingPlayer.sendMiniMessage("You can't claim outside of the worldborder", null); // TODO MINIMESSAG + CONFIG + return result; + } + //if worldguard is installed, also prevent claims from overlapping any worldguard regions if (GriefPrevention.instance.config_claims_respectWorldGuard && this.worldGuard != null && creatingPlayer != null) {