@EventHandler public void onPistonExtend(BlockPistonExtendEvent event) { if (!event.isCancelled()) { FilterResult filterResult = evaluator.evaluate(); if (filterResult == FilterResult.DENY) { for (Region region : regions) { if (region.contains(event.getBlock().getLocation().clone().add(event.getDirection().getModX(), event.getDirection().getModY(), event.getDirection().getModZ()))) { event.setCancelled(true); return; } else { for (Block block : event.getBlocks()) { if (region.contains(event.getBlock().getLocation().clone().add(event.getDirection().getModX(), event.getDirection().getModY(), event.getDirection().getModZ())) || region.contains(block.getLocation().clone().add(event.getDirection().getModX(), event.getDirection().getModY(), event.getDirection().getModZ()))) { event.setCancelled(true); return; } } } } } } }
@EventHandler(priority = EventPriority.LOW) public void onPistonExtend(BlockPistonExtendEvent e) { if (DEBUG) { plugin.getLogger().info(e.getEventName()); } Location pistonLoc = e.getBlock().getLocation(); if (Settings.allowPistonPush || !Util.inWorld(pistonLoc)) { //plugin.getLogger().info("DEBUG: Not in world"); return; } Island island = plugin.getIslands().getProtectedIslandAt(pistonLoc); if (island == null || !island.onIsland(pistonLoc)) { //plugin.getLogger().info("DEBUG: Not on is island protection zone"); return; } // We need to check where the blocks are going to go, not where they are for (Block b : e.getBlocks()) { if (!island.onIsland(b.getRelative(e.getDirection()).getLocation())) { //plugin.getLogger().info("DEBUG: Block is outside protected area"); e.setCancelled(true); return; } } }
/** * This handler only checks to see if the event should be cancelled. It does not change the * state of any Destroyables. */ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void testBlockChange(BlockTransformEvent event) { if(this.match.getWorld() != event.getWorld() || !this.anyDestroyableAffected(event)) { return; } // This is a temp fix until there is a tracker for placed minecarts (only dispensed are tracked right now) if((event.getCause() instanceof EntityExplodeEvent && ((EntityExplodeEvent) event.getCause()).getEntity() instanceof ExplosiveMinecart) || event.getCause() instanceof BlockPistonExtendEvent || event.getCause() instanceof BlockPistonRetractEvent) { event.setCancelled(true); return; } for(Destroyable destroyable : this.destroyables) { String reasonKey = destroyable.testBlockChange(event.getOldState(), event.getNewState(), ParticipantBlockTransformEvent.getPlayerState(event)); if(reasonKey != null) { event.setCancelled(true, new TranslatableComponent(reasonKey)); return; } } }
/** * Stop block movement in the following piston extension scenarios: * 1. Build allow or null -> build deny * 2. Destroy allow or null -> destroy deny * 3. Build deny -> null or build allow * 4. Destroy deny -> null or destroy allow * @param oldRegion The region the block is moving from * @param newRegion The region the block is moving to * @param event The piston event */ private void checkExtend(CuboidRegion oldRegion, CuboidRegion newRegion, BlockPistonExtendEvent event) { // Build allow or null -> build deny if ( (oldRegion == null || oldRegion.allows("build")) && (newRegion != null && !newRegion.allows("build")) ) { event.setCancelled(true); } // Destroy allow or null -> destroy deny if ( (oldRegion == null || oldRegion.allows("destroy")) && (newRegion != null && !newRegion.allows("destroy")) ) { event.setCancelled(true); } // Build deny -> null or build allow if ( (oldRegion != null && !oldRegion.allows("build")) && (newRegion == null || newRegion.allows("build")) ) { event.setCancelled(true); } // Destroy deny -> null or destroy allow if ( (oldRegion != null && !oldRegion.allows("destroy")) && (newRegion == null || newRegion.allows("destroy")) ) { event.setCancelled(true); } }
/** * On reflection I realized you could just push smoothstone into an unedited chunk layer and increase overall drops * for a world. So to counter-balance, on each extension we track the location of the blocks and increment their Y * counters. * * @param event */ @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPistonExtend(BlockPistonExtendEvent event) { Block source = event.getBlock(); Block extension = event.getBlock().getRelative(event.getDirection()); for (Block b : event.getBlocks()) { Block next = b.getRelative(event.getDirection()); if (next.equals(source) || next.equals(extension)) { continue; } plugin.getTracking().trackBreak(next.getLocation()); } plugin.getTracking().trackBreak(source.getLocation()); if (!source.equals(extension)) { plugin.getTracking().trackBreak(extension.getLocation()); } }
@EventHandler(priority = EventPriority.HIGH) public void onBlockPistonExtend(final BlockPistonExtendEvent event) { if (event.isCancelled()) return; for (final Block block : event.getBlocks()) { // Ok so a block is pushed into a frame block // Find the nearest gate! final WorldCoord blockCoord = new WorldCoord(block); final Gate nearestGate = Gates.gateFromFrameAndSurround(blockCoord); if (nearestGate != null) { event.setCancelled(true); return; } } }
/** * Prevents blocks from being piston pushed into this height * @param event */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled=true) public void onPistonPush(BlockPistonExtendEvent event) { // Only case about blocks being pushed up if (!event.getDirection().equals(BlockFace.UP)) { return; } World world = event.getBlock().getWorld(); if (!world.equals(getBeaconzWorld())) { //getLogger().info("DEBUG: not right world"); return; } for (Block b : event.getBlocks()) { if (b.getRelative(event.getDirection()).getY() == BLOCK_HEIGHT) { event.setCancelled(true); } } }
/** * Prevents blocks from being piston pushed above a beacon or a piston being used to remove beacon blocks * @param event */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled=true) public void onPistonPush(BlockPistonExtendEvent event) { World world = event.getBlock().getWorld(); if (!world.equals(getBeaconzWorld())) { return; } for (Block b : event.getBlocks()) { // If any block is part of a beacon cancel it if (getRegister().isBeacon(b)) { event.setCancelled(true); return; } Block testBlock = b.getRelative(event.getDirection()); BeaconObj beacon = getRegister().getBeaconAt(testBlock.getX(),testBlock.getZ()); if (beacon != null && beacon.getY() < testBlock.getY()) { event.setCancelled(true); } } }
/** * Prevents blocks from being piston pushed above a beacon or a piston being used to remove beacon blocks * @param event */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled=true) public void onPistonPush(BlockPistonExtendEvent event) { World world = event.getBlock().getWorld(); if (!world.equals(getBeaconzWorld())) { //getLogger().info("DEBUG: not right world"); return; } for (Block b : event.getBlocks()) { Block whereItWillBe = b.getRelative(event.getDirection()); if (getRegister().isAboveBeacon(whereItWillBe.getLocation())) { event.setCancelled(true); return; } } }
@EventHandler public void onBlockPistonExtend(BlockPistonExtendEvent event) { Lot from = this.module.getLotManager().getLot(event.getBlock().getLocation()); Town fromTown = this.module.getLotManager().getTown(event.getBlock().getLocation()); for(Block block : event.getBlocks()) { Block toBlock = block.getRelative(event.getDirection()); Lot blockFrom = this.module.getLotManager().getLot(block.getLocation()); Town blockFromTown = this.module.getLotManager().getTown(block.getLocation()); Lot blockTo = this.module.getLotManager().getLot(toBlock.getLocation()); Town blockToTown = this.module.getLotManager().getTown(toBlock.getLocation()); if((from != null && blockTo == null) || (from == null && blockTo != null) || from != blockTo || (fromTown != null && blockToTown == null) || (fromTown == null && blockToTown != null) || fromTown != blockToTown || (blockFrom != null && blockTo == null) || (blockFrom == null && blockTo != null) || blockFrom != blockTo || (blockFromTown != null && blockToTown == null) || (blockFromTown == null && blockToTown != null) || blockFromTown != blockToTown) { event.setCancelled(true); } } }
@EventHandler(priority = EventPriority.LOW) public void onPistonExtend(BlockPistonExtendEvent e) { if (DEBUG) { plugin.getLogger().info(e.getEventName()); } Location pistonLoc = e.getBlock().getLocation(); if (Settings.allowPistonPush || !inWorld(pistonLoc)) { //plugin.getLogger().info("DEBUG: Not in world"); return; } Island island = plugin.getGrid().getProtectedIslandAt(pistonLoc); if (island == null || !island.onIsland(pistonLoc)) { //plugin.getLogger().info("DEBUG: Not on is island protection zone"); return; } // We need to check where the blocks are going to go, not where they are for (Block b : e.getBlocks()) { if (!island.onIsland(b.getRelative(e.getDirection()).getLocation())) { //plugin.getLogger().info("DEBUG: Block is outside protected area"); e.setCancelled(true); return; } } }
@EventHandler(priority=EventPriority.LOW) public void onEvent(BlockPistonExtendEvent event) { if (!Settings.allowTNTPushing) { // Check world if (!inWorld(event.getBlock())) { return; } for (Block block: event.getBlocks()) { if (block.getType() == Material.TNT) { event.setCancelled(true); break; } } } /* JAVA 8 if (event.getBlocks()..stream().anyMatch(it->it.getType()==Material.TNT)) event.setCancelled(true); */ }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onBlockPistonExtend(BlockPistonExtendEvent event) { BukkitWorld world = BukkitUtil.adapt(event.getBlock().getWorld()); if (manager.isPlotWorld(world)) { BlockFace face = event.getDirection(); for (Block block : event.getBlocks()) { PlotId id = manager.getPlotId(new Location(world, BukkitUtil.locationToVector( block.getLocation().add(face.getModX(), face.getModY(), face.getModZ())))); if (id == null) { event.setCancelled(true); } } } }
/** * Monitor BlockPistonExtend events. * * @param event The event to monitor */ @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onBlockPistonExtend(BlockPistonExtendEvent event) { if (!EventUtils.shouldProcessEvent(event.getBlock(), true)) { return; } BlockFace direction = event.getDirection(); Block futureEmptyBlock = event.getBlock().getRelative(direction); // Block that would be air after piston is finished if (futureEmptyBlock.getType() == Material.AIR) { return; } List<Block> blocks = event.getBlocks(); for (Block b : blocks) { if (BlockUtils.shouldBeWatched(b.getState()) && mcMMO.getPlaceStore().isTrue(b)) { b.getRelative(direction).setMetadata(mcMMO.blockMetadataKey, mcMMO.metadataValue); } } // Needed because blocks sometimes don't move when two pistons push towards each other new PistonTrackerTask(blocks, direction, futureEmptyBlock).runTaskLater(plugin, 2); }
@EventHandler(ignoreCancelled = true) public void onPistonExtend(BlockPistonExtendEvent e) { // Workaround start - BlockPistonEvent's are sometime called multiple times if(!pistonUtil.canExtend(e.getBlock())) { return; } pistonUtil.extend(e.getBlock()); // Workaround end if(!plugin.isWorldWhitelisted(e.getBlock().getWorld()) || e.getBlock().getRelative(e.getDirection()).getType() == Material.AIR) { return; } java.util.List<Block> blocks = e.getBlocks(); for(int i = blocks.size() - 1; i >= 0; i--) { Block block = blocks.get(i); if(plugin.isWhitelisted(block.getType()) && plugin.isBlackListed(block)) { plugin.unBlackList(block); plugin.blackList(block.getRelative(e.getDirection())); } } }
@EventHandler(priority = EventPriority.HIGH) public void onBlockPlaceForMonument(BlockChangeEvent event) { //Rixor.debug("monu1", "monu"); Client client = event.getClient(); if(event.getCause() instanceof BlockPlaceEvent) { List<MonumentObjective> monuments = event.getMap().getMonuments(); for(MonumentObjective monument : monuments) { if(monument.isLocation(event.getNewState().getLocation()) && monument.getTeam() == client.getTeam() || monument.isDestroyed()) { event.setCancelled(true); client.getPlayer().sendMessage(ChatColor.RED + "You may not break this monument!"); return; } } } else if (event.getCause() instanceof BlockPistonExtendEvent || event.getCause() instanceof BlockPistonRetractEvent){ event.setCancelled(true); return; } }
@EventHandler public void pistonExtend(BlockPistonExtendEvent event){ ZoneWorld world = plugin.getWorld(event.getBlock().getWorld()); Location loc = event.getBlock().getLocation(); Lot lot = world.findLot(new Point(loc.getBlockX(), loc.getBlockZ())); if (lot == null) { return; } Set<Integer> owner = lot.getOwners(); for(Block b : event.getBlocks()){ for(Integer i : owner){ TregminePlayer p = plugin.getPlayerOffline(i); if(!p.hasBlockPermission(b.getLocation(), false)){ event.setCancelled(true); } } } }
@EventHandler (ignoreCancelled = true) public void onBlockPistonExtend(BlockPistonExtendEvent event) { Iterator<Block> it = event.getBlocks().iterator(); PersistentQuadtree pq = Util.getQuadtree(event.getBlock()); Block block = event.getBlock(); while (it.hasNext()) { block = it.next(); if (! block.isEmpty() && pq.contains(block.getX(), block.getY(), block.getZ())) { event.setCancelled(true); return; } } // last empty space block = block.getRelative(event.getDirection()); if (pq.contains(block.getX(), block.getY(), block.getZ())) { event.setCancelled(true); } }
@EventHandler public void WitherCreationViaExploit(BlockPistonExtendEvent event){ List<Block> blocks; try{ blocks = event.getBlocks(); } catch(Exception e){ blocks = null; } if(blocks != null && blocks.size() > 0){ for(int i = 0; i < blocks.size(); i++){ Material type = blocks.get(i).getType(); if(type == Material.SOUL_SAND){ if(isNearWitherSkull(blocks.get(i))){ event.setCancelled(true); } } } } }
@EventHandler(priority = EventPriority.MONITOR) public void onBlockPistonExtend(BlockPistonExtendEvent event) { if (event.isCancelled()) { return; } BlockUpdate.Update(event.getBlocks()); }
@EventHandler public void onBlockPistonExtend(BlockPistonExtendEvent e) { //Check if there are cauldrons on activity on pushed blocks for(Block block : e.getBlocks()) { Location loc = block.getLocation(); for(UUID uuid : plugin.caulLoc.keySet()) { Location caul = plugin.caulLoc.get(uuid); if(caul.getBlock().getLocation().distance(loc) == 0) { e.setCancelled(true); return; } } } }
@EventHandler(priority=EventPriority.LOW) public void onEvent(BlockPistonExtendEvent event) { if (!Settings.allowTNTPushing) { // Check world if (!Util.inWorld(event.getBlock())) return; if (event.getBlocks().stream().anyMatch(it -> it.getType() == Material.TNT)) event.setCancelled(true); } }
@EventHandler public void onPistonExtend(BlockPistonExtendEvent e) { for (Block b : e.getBlocks()) { if (BlockStorage.hasBlockInfo(b)) { e.setCancelled(true); return; } } }
@EventWrapper public void onBlockPistonExtend(final BlockPistonExtendEvent event) { Map<Block, BlockState> newStates = new HashMap<>(); // Add the arm of the piston, which will extend into the adjacent block. PistonExtensionMaterial pistonExtension = new PistonExtensionMaterial(Material.PISTON_EXTENSION); pistonExtension.setFacingDirection(event.getDirection()); BlockState pistonExtensionState = event.getBlock().getRelative(event.getDirection()).getState(); pistonExtensionState.setType(pistonExtension.getItemType()); pistonExtensionState.setData(pistonExtension); newStates.put(event.getBlock(), pistonExtensionState); this.onPistonMove(event, event.getBlocks(), newStates); }
@EventHandler public void onPiston(BlockPistonExtendEvent e) { if(BuildModule.getInstance().isBuilding(e.getBlock())) { e.setCancelled(true); } }
@EventHandler public void onPiston(BlockPistonExtendEvent e) { if (NexusModule.getInstance().containsNexus((e.getBlocks()))) { e.setCancelled(true); } }
@SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onBlockPistonExtend(BlockPistonExtendEvent e) { if (cm.disablePMM && VersionUtils.isAtLeast(VersionUtils.V1_8)) { // 使用typeid是为了兼容1.8以下的服务端 for (Block b : e.getBlocks()) { if (b.getTypeId() == 165) { // 165 - SLIME_BLOCK e.setCancelled(true); return; } } } }
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onPistonExtend(final BlockPistonExtendEvent event) { for(final Block block : event.getBlocks()) { if(block.getType() == FoundDiamondsListener.SEARCH_TYPE) { this.foundLocations.add(block.getLocation().toString()); } } }
@EventHandler public void onBlockPistonExtend(BlockPistonExtendEvent event) { if (event.getBlock().getRelative(event.getDirection()).getY() >= height){ event.setCancelled(true); } else { for (Block block : event.getBlocks()) { if (block.getRelative(event.getDirection()).getY() >= height) { event.setCancelled(true); } } } }
@EventHandler public void onBlockPistonExtend(BlockPistonExtendEvent event) { for (Block block : event.getBlocks()) { CuboidRegion oldRegion = regionHandler.getApplicableRegion(block.getLocation()); CuboidRegion newRegion = regionHandler.getApplicableRegion(block.getRelative(event.getDirection()).getLocation()); checkExtend(oldRegion, newRegion, event); } }
/** * Filters BlockPistonExtendEvent. * <p>Will filter as block removing the old position, and placing a block in the new position.</p> * * <p>Applies to: block, block place and block break.<p/> */ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onBlockPistonExtend(BlockPistonExtendEvent event) { Match match = Cardinal.getMatch(event.getWorld()); if (match == null) { return; } Collection<AppliedRegion> regions = get(match, ApplyType.BLOCK, ApplyType.BLOCK_PLACE, ApplyType.BLOCK_BREAK); Block pistonHead = event.getBlock().getRelative(event.getDirection()); // Try place the piston head for (AppliedRegion reg : regions) { if (!reg.getType().equals(ApplyType.BLOCK_BREAK) && reg.contains(pistonHead.getLocation())) { FilterState result = reg.evaluate(event, Material.PISTON_EXTENSION); if (!result.toBoolean()) { event.setCancelled(true); return; } else if (result.hasResult()) { break; } } } for (Block block : event.getBlocks()) { if (!tryPistonMove(regions, block, event)) { event.setCancelled(true); return; } } }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPistonExtend(BlockPistonExtendEvent event) { World world = event.getBlock().getWorld(); PluginConfig worldConfig = plugin.getConfig(world); if (plugin.isEnabled(world) && worldConfig.getBoolean(Config.FEATURE_DUNGEONS_PROTECTED)) { for (Block moved : event.getBlocks()) { if (this.isProtected(moved.getLocation())) { event.setCancelled(true); return; } } } }
@EventHandler(priority = EventPriority.NORMAL) public void onExtendEvent(BlockPistonExtendEvent event) { // Strangely enough, this also fires when sticky pistons attempt to pull blocks. if (this.plugin.getWorldGuardIntegration().isInIgnoredRegion(new BukkitBlock(event.getBlock()))) { return; } UUID owner = this.plugin.getApi().getOwnerUUID(new BukkitBlock(event.getBlock())); if (owner != null) { UUID blockOwner; for (Block b : event.getBlocks()) { blockOwner = this.plugin.getApi().getOwnerUUID(new BukkitBlock(b)); if (blockOwner == null) { continue; } if (blockOwner.equals(owner)) { continue; } if (this.plugin.getApi().hasFriendship(blockOwner, owner)) { continue; } event.getBlock().getWorld().playEffect(b.getLocation(), Effect.MOBSPAWNER_FLAMES, 0); event.getBlock().getWorld().playEffect(event.getBlock().getLocation(), Effect.SMOKE, 4); event.getBlock().getWorld().playEffect(event.getBlock().getLocation(), Effect.CLICK1, 0); event.setCancelled(true); return; } } }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onBlockPistonExtend(BlockPistonExtendEvent event) { RollbackAgent.checkBlockChange(event.getBlock().getLocation(), event.getBlock().getState(), event); for (Block b : event.getBlocks()) { RollbackAgent.checkBlockChange(b.getLocation(), b.getState(), event); } }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void pistonDestroyBed(BlockPistonExtendEvent e) { if (config.get("lobby").getBool()) return; bedBreak(e.getBlock()); for(Block b : e.getBlocks()) { bedBreak(b); } }
@EventHandler public void onBlockPistonExtend(BlockPistonExtendEvent event) { for (Block block : event.getBlocks()) { if (block.getRelative(event.getDirection()).getY() >= height) { event.setCancelled(true); } } }
@EventHandler public void onBlockPistonExtend(BlockPistonExtendEvent event) { for (Block block : event.getBlocks()) { if (region.contains(block.getRelative(event.getDirection()).getLocation().toVector()) && filter.evaluate(block, event).equals(FilterState.DENY)) { event.setCancelled(true); } } }