org.bukkit.event.block.BlockPistonExtendEvent Java Examples
The following examples show how to use
org.bukkit.event.block.BlockPistonExtendEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DestroyableMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
/** * 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; } } }
Example #2
Source File: BukkitPlotListener.java From PlotMe-Core with GNU General Public License v3.0 | 6 votes |
@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); } } } }
Example #3
Source File: IslandGuard.java From askyblock with GNU General Public License v2.0 | 6 votes |
@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); */ }
Example #4
Source File: IslandGuard.java From askyblock with GNU General Public License v2.0 | 6 votes |
@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; } } }
Example #5
Source File: ShopItemListener.java From ShopChest with MIT License | 6 votes |
@EventHandler(priority = EventPriority.HIGH) public void onPistonExtend(BlockPistonExtendEvent e) { // If the piston would only move itself Block airAfterPiston = e.getBlock().getRelative(e.getDirection()); Block belowAir = airAfterPiston.getRelative(BlockFace.DOWN); if (shopUtils.isShop(belowAir.getLocation())) { e.setCancelled(true); return; } for (Block b : e.getBlocks()) { Block newBlock = b.getRelative(e.getDirection()); Block belowNewBlock = newBlock.getRelative(BlockFace.DOWN); if (shopUtils.isShop(belowNewBlock.getLocation())) e.setCancelled(true); } }
Example #6
Source File: BlockPistonListener.java From IridiumSkyblock with GNU General Public License v2.0 | 6 votes |
@EventHandler public void onBlockPistonExtend(BlockPistonExtendEvent event) { try { final Block block = event.getBlock(); final Location location = block.getLocation(); final IslandManager islandManager = IridiumSkyblock.getIslandManager(); final Island island = islandManager.getIslandViaLocation(location); if (island == null) return; final BlockFace face = event.getDirection(); for (Block extendedBlock : event.getBlocks()) { final Location extendedBlockLocation = extendedBlock.getLocation(); final int[] offset = offsets.get(face); extendedBlockLocation.add(offset[0], offset[1], offset[2]); if (!island.isInIsland(extendedBlockLocation)) { event.setCancelled(true); return; } } } catch (Exception e) { IridiumSkyblock.getInstance().sendErrorMessage(e); } }
Example #7
Source File: LoggingManager.java From Survival-Games with GNU General Public License v3.0 | 5 votes |
public void blockChange(BlockPistonExtendEvent e){ if(e.isCancelled())return; for(Block b: e.getBlocks()){ logBlockCreated(b); } i.put("BPISTION", i.get("BPISTION")+1); }
Example #8
Source File: CoreObjective.java From CardinalPGM with MIT License | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPistonPush(BlockPistonExtendEvent event) { for (Block block : event.getBlocks()) { if (core.contains(block) && partOfObjective(block)) { event.setCancelled(true); } } }
Example #9
Source File: DestroyableObjective.java From CardinalPGM with MIT License | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPistonPush(BlockPistonExtendEvent event) { for (Block block : event.getBlocks()) { if (monument.contains(block) && partOfObjective(block)) { event.setCancelled(true); } } }
Example #10
Source File: BlockEventRegion.java From CardinalPGM with MIT License | 5 votes |
@EventHandler public void onBlockPistonExtend(BlockPistonExtendEvent event) { if (region.contains(event.getBlock().getRelative(event.getDirection()).getLocation().toVector()) && filter.evaluate(event.getBlock().getRelative(event.getDirection()), event).equals(FilterState.DENY)) { event.setCancelled(true); } else { for (Block block : event.getBlocks()) { if ((region.contains(block.getLocation().toVector()) && filter.evaluate(block, event).equals(FilterState.DENY)) || (region.contains(block.getRelative(event.getDirection()).getLocation().toVector()) && filter.evaluate(block.getRelative(event.getDirection()), event).equals(FilterState.DENY))) { event.setCancelled(true); break; } } } }
Example #11
Source File: BlockPlaceRegion.java From CardinalPGM with MIT License | 5 votes |
@EventHandler public void onBlockPistonExtend(BlockPistonExtendEvent event) { if (region.contains(event.getBlock().getRelative(event.getDirection()).getLocation().toVector()) && filter.evaluate(event.getBlock().getRelative(event.getDirection()), event).equals(FilterState.DENY)) { event.setCancelled(true); } else { for (Block block : event.getBlocks()) { if (region.contains(block.getRelative(event.getDirection()).getLocation().toVector()) && filter.evaluate(block.getRelative(event.getDirection()), event).equals(FilterState.DENY)) { event.setCancelled(true); break; } } } }
Example #12
Source File: BuildHeight.java From CardinalPGM with MIT License | 5 votes |
@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); } } } }
Example #13
Source File: WoolObjective.java From CardinalPGM with MIT License | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onPistonPush(BlockPistonExtendEvent event) { if (!event.isCancelled()) { if (event.getBlock().getRelative(event.getDirection()).equals(place.getBlock())) { event.setCancelled(true); } else { for (Block block : event.getBlocks()) { if (block.equals(place.getBlock()) || block.equals(place.getBlock().getRelative(event.getDirection().getOppositeFace()))) { event.setCancelled(true); } } } } }
Example #14
Source File: GuildHeartProtectionHandler.java From FunnyGuilds with Apache License 2.0 | 5 votes |
@EventHandler public void onPistonExtend(BlockPistonExtendEvent event) { for (Block block : event.getBlocks()) { if (isGuildHeart(block)) { event.setCancelled(true); } } }
Example #15
Source File: BlockPhysicsListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onPistonExtend(BlockPistonExtendEvent e) { for (Block b : e.getBlocks()) { if (BlockStorage.hasBlockInfo(b) || (b.getRelative(e.getDirection()).getType() == Material.AIR && BlockStorage.hasBlockInfo(b.getRelative(e.getDirection())))) { e.setCancelled(true); return; } } }
Example #16
Source File: ExprPushedBlocks.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent(BlockPistonExtendEvent.class, BlockPistonRetractEvent.class)) { Skript.error("The moved blocks are only usable in piston extend and retract events", ErrorQuality.SEMANTIC_ERROR); return false; } return true; }
Example #17
Source File: BlockTransformListener.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@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); }
Example #18
Source File: LWCBlockListener.java From Modern-LWC with MIT License | 5 votes |
@EventHandler public void onBlockPistonExtend(BlockPistonExtendEvent event) { if (!LWC.ENABLED || event.isCancelled()) { return; } LWC lwc = this.plugin.getLWC(); for (Block block : event.getBlocks()) { Protection protection = lwc.findProtection(block); if (protection != null) { event.setCancelled(true); return; } } }
Example #19
Source File: LagCompensator.java From Hawk with GNU General Public License v3.0 | 5 votes |
@EventHandler public void pistonExtend(BlockPistonExtendEvent e) { World world = e.getBlock().getWorld(); BlockFace bf = e.getDirection(); Vector offset = new Vector(0, 0, 0); switch (bf) { case UP: offset.setY(1); break; case DOWN: offset.setY(-1); break; case EAST: offset.setX(1); break; case WEST: offset.setX(-1); break; case NORTH: offset.setZ(-1); break; case SOUTH: offset.setZ(1); } long currTime = System.currentTimeMillis(); pistonPushes.add(new PistonPush(world, e.getBlock().getLocation().toVector().add(offset), bf, currTime)); for(Block b : e.getBlocks()) { pistonPushes.add(new PistonPush(world, b.getLocation().toVector().add(offset), bf, currTime)); } }
Example #20
Source File: BlockTransformListener.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
@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); }
Example #21
Source File: DestroyableMatchModule.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
/** * 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, TranslatableComponent.of(reasonKey)); return; } } }
Example #22
Source File: ExprPushedBlocks.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override @Nullable protected Block[] get(Event e) { return (e instanceof BlockPistonExtendEvent) ? ((BlockPistonExtendEvent) e).getBlocks().toArray(new Block[0]) : ((BlockPistonRetractEvent) e).getBlocks().toArray(new Block[0]); }
Example #23
Source File: BlockListener.java From civcraft with GNU General Public License v2.0 | 4 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onBlockPistonExtendEvent(BlockPistonExtendEvent event) { /* UGH. If we extend into 'air' it doesnt count them as blocks... * we need to check air to prevent breaking of item frames... */ final int PISTON_EXTEND_LENGTH = 13; Block currentBlock = event.getBlock().getRelative(event.getDirection()); for (int i = 0; i < PISTON_EXTEND_LENGTH; i++) { if(ItemManager.getId(currentBlock) == CivData.AIR) { if (!allowPistonAction(currentBlock.getLocation())) { event.setCancelled(true); return; } } currentBlock = currentBlock.getRelative(event.getDirection()); } if (War.isWarTime()) { event.setCancelled(true); return; } // if (event.getBlocks().size() == 0) { // Block extendInto = event.getBlock().getRelative(event.getDirection()); // if (!allowPistonAction(extendInto.getLocation())) { // event.setCancelled(true); // return; // } // } coord.setFromLocation(event.getBlock().getLocation()); FarmChunk fc = CivGlobal.getFarmChunk(coord); if (fc == null) { event.setCancelled(true); } for (Block block : event.getBlocks()) { if (!allowPistonAction(block.getLocation())) { event.setCancelled(true); break; } } }
Example #24
Source File: CancellableChunkEvents.java From ClaimChunk with MIT License | 4 votes |
@EventHandler public void onPistonExtend(BlockPistonExtendEvent e) { if (e != null) { ChunkEventHelper.handlePistonExtendEvent(e); } }
Example #25
Source File: ChunkEventHelper.java From ClaimChunk with MIT License | 4 votes |
public static void handlePistonExtendEvent(@Nonnull BlockPistonExtendEvent e) { handlePistonEvent(e.getBlock(), e.getBlocks(), e.getDirection(), e); }
Example #26
Source File: CoreMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void breakCheck(final BlockTransformEvent event) { if(event.getWorld() != this.match.getWorld()) return; ParticipantState player = ParticipantBlockTransformEvent.getPlayerState(event); Vector blockVector = BlockUtils.center(event.getNewState()).toVector(); for(Core core : this.cores) { if(!core.hasLeaked() && core.getCasingRegion().contains(blockVector)) { if(event.getNewState().getType() == Material.AIR) { if(player != null) { Competitor team = player.getParty(); if(team == core.getOwner()) { event.setCancelled(true, new TranslatableComponent("match.core.damageOwn")); } else if (event.getOldState().getData().equals(core.getMaterial())) { this.match.getPluginManager().callEvent(new CoreBlockBreakEvent(core, player, event.getOldState())); core.touch(player); // Note: team may not have touched a broken core if a different team broke it if(!core.isCompleted(team) && !core.hasTouched(team)) { this.match.getPluginManager().callEvent(new GoalStatusChangeEvent(core)); } } } else if(event.getCause() instanceof EntityExplodeEvent) { // this is a temp fix until there is a tracker for placed minecarts (only dispensed are tracked right now) if(((EntityExplodeEvent) event.getCause()).getEntity() instanceof ExplosiveMinecart) { event.setCancelled(true); } } else if(event.getCause() instanceof BlockPistonRetractEvent) { event.setCancelled(true); } } else if(event.getCause() instanceof BlockPistonExtendEvent) { event.setCancelled(true); } else if(event.getCause() instanceof BlockDispenseEvent) { event.setCancelled(true); } break; } } }
Example #27
Source File: BlockTracker.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPistonExtend(BlockPistonExtendEvent event) { handleMove(event.getBlocks(), event.getDirection()); }
Example #28
Source File: CarbonBlockPistonExtendEvent.java From Carbon with GNU Lesser General Public License v3.0 | 4 votes |
public static HandlerList getHandlerList() { return BlockPistonExtendEvent.getHandlerList(); }
Example #29
Source File: CoreMatchModule.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void breakCheck(final BlockTransformEvent event) { if (event.getWorld() != this.match.getWorld()) return; ParticipantState player = ParticipantBlockTransformEvent.getPlayerState(event); Vector blockVector = BlockVectors.center(event.getNewState()).toVector(); for (Core core : this.cores) { if (!core.hasLeaked() && core.getCasingRegion().contains(blockVector)) { if (event.getNewState().getType() == Material.AIR) { if (player != null) { Competitor team = player.getParty(); if (team == core.getOwner()) { event.setCancelled(true, TranslatableComponent.of("core.damageOwn")); } else if (event.getOldState().getData().equals(core.getMaterial())) { this.match.callEvent(new CoreBlockBreakEvent(core, player, event.getOldState())); core.touch(player); // Note: team may not have touched a broken core if a different team broke it if (!core.isCompleted(team) && !core.hasTouched(team)) { this.match.callEvent(new GoalStatusChangeEvent(this.match, core)); } } } else if (event.getCause() instanceof EntityExplodeEvent) { // this is a temp fix until there is a tracker for placed minecarts (only dispensed are // tracked right now) if (((EntityExplodeEvent) event.getCause()).getEntity() instanceof ExplosiveMinecart) { event.setCancelled(true); } } else if (event.getCause() instanceof BlockPistonRetractEvent) { event.setCancelled(true); } } else if (event.getCause() instanceof BlockPistonExtendEvent) { event.setCancelled(true); } else if (event.getCause() instanceof BlockDispenseEvent) { event.setCancelled(true); } break; } } }
Example #30
Source File: BlockEventRegion.java From CardinalPGM with MIT License | 4 votes |
@EventHandler public void onBlockPiston(BlockPistonExtendEvent event) { if (filter.evaluate(event.getBlock(), event).equals(FilterState.DENY) && region.contains(new BlockRegion(null, event.getBlock().getLocation().toVector()))) { event.setCancelled(true); } }