Java Code Examples for org.bukkit.event.block.BlockPistonRetractEvent#getBlocks()
The following examples show how to use
org.bukkit.event.block.BlockPistonRetractEvent#getBlocks() .
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: 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 3
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 4
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 5
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 6
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 7
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 8
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 9
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 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: 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 12
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 13
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 14
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); } } } }