From af25b289f4e3d6bd1608c0dd1d651b714c632b92 Mon Sep 17 00:00:00 2001 From: Frank van der Heijden <22407829+FrankHeijden@users.noreply.github.com> Date: Sun, 11 Oct 2020 21:21:43 -0700 Subject: [PATCH] Fix piston checks in subclaims (#1056) --- .../ryanhamshire/GriefPrevention/BlockEventHandler.java | 6 +++--- src/main/java/me/ryanhamshire/GriefPrevention/Claim.java | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java b/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java index a9cdba7..78c45ef 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java @@ -534,7 +534,7 @@ public class BlockEventHandler implements Listener { Block invadedBlock = pistonBlock.getRelative(direction); Claim invadedClaim = this.dataStore.getClaimAt(invadedBlock.getLocation(), false, pistonClaim); - if (invadedClaim != null && (pistonClaim == null || !Objects.equals(pistonClaim.ownerID, invadedClaim.ownerID))) + if (invadedClaim != null && (pistonClaim == null || !Objects.equals(pistonClaim.getOwnerID(), invadedClaim.getOwnerID()))) { event.setCancelled(true); } @@ -619,7 +619,7 @@ public class BlockEventHandler implements Listener continue; // If owners are different, cancel. - if (pistonClaim == null || !Objects.equals(pistonClaim.ownerID, claim.ownerID)) + if (pistonClaim == null || !Objects.equals(pistonClaim.getOwnerID(), claim.getOwnerID())) { event.setCancelled(true); return; @@ -666,7 +666,7 @@ public class BlockEventHandler implements Listener lastClaim = claim; // If pushing this block will change ownership, cancel the event and take away the piston (for performance reasons). - if (pistonClaim == null || !Objects.equals(pistonClaim.ownerID, claim.ownerID)) + if (pistonClaim == null || !Objects.equals(pistonClaim.getOwnerID(), claim.getOwnerID())) { event.setCancelled(true); if (GriefPrevention.instance.config_pistonExplosionSound) diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/Claim.java b/src/main/java/me/ryanhamshire/GriefPrevention/Claim.java index ad154ae..4cf9cf2 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/Claim.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/Claim.java @@ -711,6 +711,15 @@ public class Claim return GriefPrevention.lookupPlayerName(this.ownerID); } + public UUID getOwnerID() + { + if (this.parent != null) + { + return this.parent.ownerID; + } + return this.ownerID; + } + //whether or not a location is in a claim //ignoreHeight = true means location UNDER the claim will return TRUE //excludeSubdivisions = true means that locations inside subdivisions of the claim will return FALSE