From e1086c32060f47254830e5448623c33bd9ba1b45 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 29 Oct 2020 12:52:43 -0400 Subject: [PATCH] Fix incorrect retract check and everywhere modes checking subclaim (#1083) * Retraction checked block behind piston when no blocks were moved * Everywhere modes are supposed to ignore subclaims, so piston claim should not be a subclaim --- .../me/ryanhamshire/GriefPrevention/BlockEventHandler.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java b/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java index 78c45ef..7beeca2 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java @@ -532,6 +532,9 @@ public class BlockEventHandler implements Listener // If no blocks are moving, quickly check if another claim's boundaries are violated. if (blocks.isEmpty()) { + // No block and retraction is always safe. + if (isRetract) return; + Block invadedBlock = pistonBlock.getRelative(direction); Claim invadedClaim = this.dataStore.getClaimAt(invadedBlock.getLocation(), false, pistonClaim); if (invadedClaim != null && (pistonClaim == null || !Objects.equals(pistonClaim.getOwnerID(), invadedClaim.getOwnerID()))) @@ -587,6 +590,9 @@ public class BlockEventHandler implements Listener return; } + // Ensure we have top level claim - piston ownership is only checked based on claim owner in everywhere mode. + while (pistonClaim != null && pistonClaim.parent != null) pistonClaim = pistonClaim.parent; + // Pushing down or pulling up is safe if all blocks are in line with the piston. if (minX == maxX && minZ == maxZ && direction == (isRetract ? BlockFace.UP : BlockFace.DOWN)) return;