Fix piston checks in subclaims (#1056)

This commit is contained in:
Frank van der Heijden authored and GitHub committed 2020-10-11 21:21:43 -07:00
1 parent a34a0fecab
commit af25b289f4
2 files changed
+12 -3

No files matched your search

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