org.bukkit.event.block.BlockPistonRetractEvent Java Examples
The following examples show how to use
org.bukkit.event.block.BlockPistonRetractEvent.
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: BlockPistonListener.java From IridiumSkyblock with GNU General Public License v2.0 | 6 votes |
@EventHandler public void onBlockPistonReact(BlockPistonRetractEvent 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; for (Block retractedBlock : event.getBlocks()) { final Location retractedBlockLocation = retractedBlock.getLocation(); if (!island.isInIsland(retractedBlockLocation)) { event.setCancelled(true); return; } } } catch (Exception e) { IridiumSkyblock.getInstance().sendErrorMessage(e); } }
Example #2
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 #3
Source File: BukkitPlotListener.java From PlotMe-Core with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onBlockPistonRetract(BlockPistonRetractEvent event) { BukkitWorld world = BukkitUtil.adapt(event.getBlock().getWorld()); if (manager.isPlotWorld(world)) { List<Block> blocks = event.getBlocks(); for (Block moved : blocks) { PlotId id = manager.getPlotId(new Location(world, BukkitUtil.locationToVector(moved.getLocation()))); if (id == null) { event.setCancelled(true); } else { event.setCancelled(api.isPlotLocked(id)); } } } }
Example #4
Source File: IslandGuard.java From askyblock with GNU General Public License v2.0 | 6 votes |
@EventHandler(priority=EventPriority.LOW) public void onEvent(BlockPistonRetractEvent 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 #5
Source File: ShopItemListener.java From ShopChest with MIT License | 6 votes |
@EventHandler(priority = EventPriority.HIGH) public void onPistonRetract(BlockPistonRetractEvent e) { 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); for (Player p : Bukkit.getOnlinePlayers()) { Shop shop = shopUtils.getShop(belowNewBlock.getLocation()); if (shop.getItem() != null) { shop.getItem().resetForPlayer(p); } } } } }
Example #6
Source File: CoreObjective.java From CardinalPGM with MIT License | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPistonRetract(BlockPistonRetractEvent event) { if (event.isSticky()) { for (Block block : event.getBlocks()) { if (core.contains(block) && partOfObjective(block)) { event.setCancelled(true); } } } }
Example #7
Source File: DestroyableObjective.java From CardinalPGM with MIT License | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPistonRetract(BlockPistonRetractEvent event) { for (Block block : event.getBlocks()) { if (monument.contains(block) && partOfObjective(block)) { event.setCancelled(true); } } }
Example #8
Source File: BlockEventRegion.java From CardinalPGM with MIT License | 5 votes |
@EventHandler public void onBlockPistonRetract(BlockPistonRetractEvent event) { 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 #9
Source File: BlockBreakRegion.java From CardinalPGM with MIT License | 5 votes |
@EventHandler public void onBlockPistonRetract(BlockPistonRetractEvent 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); } } }
Example #10
Source File: BlockPlaceRegion.java From CardinalPGM with MIT License | 5 votes |
@EventHandler public void onBlockPistonRetract(BlockPistonRetractEvent event) { 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 #11
Source File: BuildHeight.java From CardinalPGM with MIT License | 5 votes |
@EventHandler public void onBlockPistonRetract(BlockPistonRetractEvent event) { for (Block block : event.getBlocks()) { if (block.getRelative(event.getDirection()).getY() >= height) { event.setCancelled(true); } } }
Example #12
Source File: WoolObjective.java From CardinalPGM with MIT License | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onPistonRetract(BlockPistonRetractEvent event) { if (!event.isCancelled()) { for (Block block : event.getBlocks()) { if (block.equals(place.getBlock()) || block.equals(place.getBlock().getRelative(event.getDirection().getOppositeFace()))) { event.setCancelled(true); } } } }
Example #13
Source File: GuildHeartProtectionHandler.java From FunnyGuilds with Apache License 2.0 | 5 votes |
@EventHandler public void onPistonRetract(BlockPistonRetractEvent event) { for (Block block : event.getBlocks()) { if (isGuildHeart(block)) { event.setCancelled(true); } } }
Example #14
Source File: BlockPhysicsListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onPistonRetract(BlockPistonRetractEvent e) { if (e.isSticky()) { 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 #15
Source File: BlockListener.java From civcraft with GNU General Public License v2.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onBlockPistonRetractEvent(BlockPistonRetractEvent event) { if (!allowPistonAction(event.getRetractLocation())) { event.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: LWCBlockListener.java From Modern-LWC with MIT License | 5 votes |
@EventHandler public void onBlockPistonRetract(BlockPistonRetractEvent 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 #18
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 #19
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 #20
Source File: CancellableChunkEvents.java From ClaimChunk with MIT License | 4 votes |
@EventHandler public void onPistonExtend(BlockPistonRetractEvent e) { if (e != null) { ChunkEventHelper.handlePistonRetractEvent(e); } }
Example #21
Source File: ChunkEventHelper.java From ClaimChunk with MIT License | 4 votes |
public static void handlePistonRetractEvent(@Nonnull BlockPistonRetractEvent e) { handlePistonEvent(e.getBlock(), e.getBlocks(), e.getDirection(), e); }
Example #22
Source File: CarbonBlockPistonRetractEvent.java From Carbon with GNU Lesser General Public License v3.0 | 4 votes |
public static HandlerList getHandlerList() { return BlockPistonRetractEvent.getHandlerList(); }
Example #23
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 #24
Source File: BlockTracker.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPistonRetract(BlockPistonRetractEvent event) { handleMove(event.getBlocks(), event.getDirection()); }
Example #25
Source File: BlockTransformListener.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
@EventWrapper public void onBlockPistonRetract(final BlockPistonRetractEvent event) { this.onPistonMove(event, event.getBlocks(), new HashMap<Block, BlockState>()); }
Example #26
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 #27
Source File: BlockEventRegion.java From CardinalPGM with MIT License | 4 votes |
@EventHandler public void onBlockPiston(BlockPistonRetractEvent event) { if (filter.evaluate(event.getBlock(), event).equals(FilterState.DENY) && region.contains(new BlockRegion(null, event.getBlock().getLocation().toVector()))) { event.setCancelled(true); } }
Example #28
Source File: BlockTracker.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPistonRetract(BlockPistonRetractEvent event) { handleMove(event.getBlocks(), event.getDirection()); }
Example #29
Source File: BlockTransformListener.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
@EventWrapper public void onBlockPistonRetract(final BlockPistonRetractEvent event) { this.onPistonMove(event, event.getBlocks(), new HashMap<Block, BlockState>()); }