@Override public MCLocation getRetractedLocation() { return new BukkitMCLocation(event.getRetractLocation()); } }
public BlockPistonRetractKey(BlockPistonRetractEvent event) { piston = event.getBlock(); retract = event.getRetractLocation().getBlock(); }
private void onPistonRetract(final BlockPistonRetractEvent event) { final List<Block> blocks; if (retractHasBlocks) { blocks = event.getBlocks(); } else { @SuppressWarnings("deprecation") final Location retLoc = event.getRetractLocation(); if (retLoc == null) { blocks = null; } else { final Block retBlock = retLoc.getBlock(); final long flags = BlockProperties.getBlockFlags(retBlock.getType()); if ((flags & F_MOVABLE_IGNORE) == 0L && (flags & F_MOVABLE) != 0L) { blocks = new ArrayList<Block>(1); blocks.add(retBlock); } else { blocks = null; } } } // TODO: Special cases (don't push upwards on retract, with the resulting location being a solid block). final Block pistonBlock = event.getBlock(); final BlockFace direction = getRetractDirection(pistonBlock, event.getDirection()); tracker.addPistonBlocks(pistonBlock.getRelative(direction.getOppositeFace()), direction, blocks); }
blocks = new ArrayList<>(event.getBlocks()); } catch (NoSuchMethodError e) { blocks = Lists.newArrayList(event.getRetractLocation().getBlock()); if (piston.getType() == Material.MOVING_PISTON) { direction = new PistonExtensionMaterial(Material.STICKY_PISTON, piston.getData()).getFacing();
@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); } }