Prevent headless pistons deleting walls

This commit is contained in:
Traks 2022-07-01 01:15:15 +02:00
parent 4d4d2ab087
commit a9f68eb351
1 changed files with 14 additions and 0 deletions

View File

@ -890,6 +890,13 @@ public class BlockEventListener implements Listener {
return;
}
}
if (block.getType() == Material.MOVING_PISTON
&& event.getBlocks().isEmpty()
&& location.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ()).isPlotArea()) {
// Headless sticky pistons can delete the block in front of them
// when retracting. Prevent this.
event.setCancelled(true);
}
return;
}
Plot plot = area.getOwnedPlot(location);
@ -913,6 +920,13 @@ public class BlockEventListener implements Listener {
return;
}
}
if (block.getType() == Material.MOVING_PISTON
&& event.getBlocks().isEmpty()
&& !plot.equals(area.getOwnedPlot(location.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())))) {
// Headless sticky pistons can delete the block in front of them
// when retracting. Prevent this.
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)