Fix piston checks in subclaims (#1056)

This commit is contained in:
Frank van der Heijden 2020-10-11 21:21:43 -07:00 committed by GitHub
parent a34a0fecab
commit af25b289f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -534,7 +534,7 @@ public class BlockEventHandler implements Listener
{ {
Block invadedBlock = pistonBlock.getRelative(direction); Block invadedBlock = pistonBlock.getRelative(direction);
Claim invadedClaim = this.dataStore.getClaimAt(invadedBlock.getLocation(), false, pistonClaim); 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); event.setCancelled(true);
} }
@ -619,7 +619,7 @@ public class BlockEventHandler implements Listener
continue; continue;
// If owners are different, cancel. // 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); event.setCancelled(true);
return; return;
@ -666,7 +666,7 @@ public class BlockEventHandler implements Listener
lastClaim = claim; lastClaim = claim;
// If pushing this block will change ownership, cancel the event and take away the piston (for performance reasons). // 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); event.setCancelled(true);
if (GriefPrevention.instance.config_pistonExplosionSound) if (GriefPrevention.instance.config_pistonExplosionSound)

View File

@ -711,6 +711,15 @@ public class Claim
return GriefPrevention.lookupPlayerName(this.ownerID); 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 //whether or not a location is in a claim
//ignoreHeight = true means location UNDER the claim will return TRUE //ignoreHeight = true means location UNDER the claim will return TRUE
//excludeSubdivisions = true means that locations inside subdivisions of the claim will return FALSE //excludeSubdivisions = true means that locations inside subdivisions of the claim will return FALSE