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
This commit is contained in:
Adam 2020-10-29 12:52:43 -04:00 committed by GitHub
parent 0ceb6f8e21
commit e1086c3206
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;