@EventHandler(ignoreCancelled = true) public void onHarvestPistonRetract(BlockPistonRetractEvent event) { if (!event.isSticky()) { return; } if (plugin.getConfig().getBoolean("preferences.nerf_pistons.only_tardis_worlds") && !event.getBlock().getWorld().getName().contains("TARDIS")) { return; } String block = event.getBlock().getRelative(getOppositeDirection(event.getDirection()), 2).getLocation().toString(); if (plugin.getGeneralKeeper().getProtectBlockMap().containsKey(block)) { event.setCancelled(true); } }
@EventHandler public void onPistonRetract(BlockPistonRetractEvent e) { if (e.isSticky()) { for (Block b : e.getBlocks()) { if (BlockStorage.hasBlockInfo(b)) { e.setCancelled(true); return; } else if(b.getRelative(e.getDirection()) == null && BlockStorage.hasBlockInfo(b.getRelative(e.getDirection()))) { e.setCancelled(true); return; } } } }
if (event.isSticky()) { Chunk pistonChunk = piston.getChunk(); Chunk blockChunk = nextBlock.getChunk();
@SuppressWarnings("deprecation") @EventHandler(ignoreCancelled = true) public void onBlockPistonRetract(BlockPistonRetractEvent event) { if (event.isSticky()) { EventDebounce.Entry entry = pistonRetractDebounce.getIfNotPresent(new BlockPistonRetractKey(event), event); if (entry != null) {
@EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) public void onBlockPistonRetract(BlockPistonRetractEvent event) { // if not a sticky piston, retraction should be fine if (!event.isSticky() || !Conf.pistonProtectionThroughDenyBuild) { return; } Location targetLoc = event.getRetractLocation(); Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(targetLoc)); // Check if the piston is moving in a faction's territory. This disables pistons entirely in faction territory. if (otherFaction.isNormal() && SavageFactions.plugin.getConfig().getBoolean("disable-pistons-in-territory", false)) { event.setCancelled(true); return; } // if potentially retracted block is just air/water/lava, no worries if (targetLoc.getBlock().isEmpty() || targetLoc.getBlock().isLiquid()) { return; } Faction pistonFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock())); if (!canPistonMoveBlock(pistonFaction, targetLoc)) { event.setCancelled(true); } }