Fixed a protection bug with pistons + slime blocks.
This commit is contained in:
parent
07ea755b4d
commit
97c9347772
|
|
@ -471,15 +471,9 @@ public class BlockEventHandler implements Listener
|
|||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
public void onBlockPistonRetract (BlockPistonRetractEvent event)
|
||||
{
|
||||
//we only care about sticky pistons retracting
|
||||
if(!event.isSticky()) return;
|
||||
|
||||
//pulling up is always safe
|
||||
if(event.getDirection() == BlockFace.UP) return;
|
||||
|
||||
//if pulling "air", always safe
|
||||
if(event.getRetractLocation().getBlock().getType() == Material.AIR) return;
|
||||
|
||||
//don't track in worlds where claims are not enabled
|
||||
if(!GriefPrevention.instance.claimsEnabledForWorld(event.getBlock().getWorld())) return;
|
||||
|
||||
|
|
@ -494,28 +488,33 @@ public class BlockEventHandler implements Listener
|
|||
return;
|
||||
}
|
||||
|
||||
for(Block movedBlock : event.getBlocks())
|
||||
{
|
||||
//if pulled block isn't in the same land claim, cancel the event
|
||||
if(!pistonClaim.contains(event.getRetractLocation(), false, false))
|
||||
if(!pistonClaim.contains(movedBlock.getLocation(), false, false))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//otherwise, consider ownership of both piston and block
|
||||
else
|
||||
{
|
||||
//who owns the moving block, if anyone?
|
||||
String movingBlockOwnerName = "_";
|
||||
Claim movingBlockClaim = this.dataStore.getClaimAt(event.getRetractLocation(), false, null);
|
||||
if(movingBlockClaim != null) movingBlockOwnerName = movingBlockClaim.getOwnerName();
|
||||
|
||||
//who owns the piston, if anyone?
|
||||
String pistonOwnerName = "_";
|
||||
Location pistonLocation = event.getBlock().getLocation();
|
||||
Claim pistonClaim = this.dataStore.getClaimAt(pistonLocation, false, movingBlockClaim);
|
||||
Claim pistonClaim = this.dataStore.getClaimAt(pistonLocation, false, null);
|
||||
if(pistonClaim != null) pistonOwnerName = pistonClaim.getOwnerName();
|
||||
|
||||
String movingBlockOwnerName = "_";
|
||||
for(Block movedBlock : event.getBlocks())
|
||||
{
|
||||
//who owns the moving block, if anyone?
|
||||
Claim movingBlockClaim = this.dataStore.getClaimAt(movedBlock.getLocation(), false, pistonClaim);
|
||||
if(movingBlockClaim != null) movingBlockOwnerName = movingBlockClaim.getOwnerName();
|
||||
|
||||
//if there are owners for the blocks, they must be the same player
|
||||
//otherwise cancel the event
|
||||
if(!pistonOwnerName.equals(movingBlockOwnerName))
|
||||
|
|
@ -524,6 +523,7 @@ public class BlockEventHandler implements Listener
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//blocks are ignited ONLY by flint and steel (not by being near lava, open flames, etc), unless configured otherwise
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user