/** * Gets the location where the possible moving block might be if the * retracting piston is sticky. * * @return The possible location of the possibly moving block. */ public Location getRetractLocation() { return getBlock().getRelative(getDirection(), 2).getLocation(); }
/** * Monitor BlockPistonRetract events. * * @param event The event to watch */ @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onBlockPistonRetract(BlockPistonRetractEvent event) { /* WORLD BLACKLIST CHECK */ if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld())) return; // Get opposite direction so we get correct block BlockFace direction = event.getDirection(); Block movedBlock = event.getBlock().getRelative(direction); mcMMO.getPlaceStore().setTrue(movedBlock); for (Block block : event.getBlocks()) { movedBlock = block.getRelative(direction); mcMMO.getPlaceStore().setTrue(movedBlock); } }
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); }
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true) public void onBlockPistonRetract(BlockPistonRetractEvent event) { Block b = event.getBlock(); Location loc = b.getLocation(); BlockFace dir; try { /* Workaround Bukkit bug = http://leaky.bukkit.org/issues/1227 */ dir = event.getDirection(); } catch (ClassCastException ccx) { dir = BlockFace.NORTH; } String wn = getWorld(loc.getWorld()).getName(); int x = loc.getBlockX(), y = loc.getBlockY(), z = loc.getBlockZ(); sscache.invalidateSnapshot(wn, x, y, z); if(onpiston) mapManager.touch(wn, x, y, z, "pistonretract"); for(int i = 0; i < 2; i++) { x += dir.getModX(); y += dir.getModY(); z += dir.getModZ(); sscache.invalidateSnapshot(wn, x, y, z); mapManager.touch(wn, x, y, z, "pistonretract"); } }
if(!GriefPrevention.instance.claimsEnabledForWorld(event.getBlock().getWorld())) return; Claim pistonClaim = this.dataStore.getClaimAt(event.getBlock().getLocation(), false, null); if(pistonClaim == null && !event.getBlocks().isEmpty()) Block block = event.getBlock(); Location pistonLocation = block.getLocation(); Claim pistonClaim = this.dataStore.getClaimAt(pistonLocation, false, null);
public BlockPistonRetractKey(BlockPistonRetractEvent event) { piston = event.getBlock(); retract = event.getRetractLocation().getBlock(); }
EventDebounce.Entry entry = pistonRetractDebounce.getIfNotPresent(new BlockPistonRetractKey(event), event); if (entry != null) { Block piston = event.getBlock(); Cause cause = create(piston); Events.fireBulkEventToCancel(event, new BreakBlockEvent(event, cause, event.getBlock().getWorld(), blocks, Material.AIR)); if (originalSize != blocks.size()) { event.setCancelled(true);
Block piston = event.getBlock();
/** * Gets the location where the possible moving block might be if the * retracting piston is sticky. * * @return The possible location of the possibly moving block. */ public Location getRetractLocation() { return getBlock().getRelative(getDirection(), 2).getLocation(); }
@EventHandler(ignoreCancelled = true) public void onPistonRetract(BlockPistonRetractEvent event) { String block = event.getBlock().getLocation().toString(); if (plugin.getGeneralKeeper().getSonicPistons().contains(block)) { event.setCancelled(true); plugin.getGeneralKeeper().getSonicListener().setExtension(event.getBlock()); } } }
@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 void onPistonRetract(BlockPistonRetractEvent event) { Block piston = event.getBlock(); BlockFace direction = event.getDirection(); Block nextBlock = piston.getRelative(direction, -2); // Direction is if (event.getBlock().getLocation().getWorld().getName().equals("world")) { tempchunk = "chunk"; else if (event.getBlock().getLocation().getWorld().getName().equals("world_nether")) { tempchunk = "netherchunk";
@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); } }