Java Code Examples for org.bukkit.event.block.BlockExplodeEvent#blockList()
The following examples show how to use
org.bukkit.event.block.BlockExplodeEvent#blockList() .
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: LWCBlockListener.java From Modern-LWC with MIT License | 6 votes |
@EventHandler(priority = EventPriority.HIGH) public void onBlockExplode(BlockExplodeEvent event) { if (!LWC.ENABLED || event.isCancelled()) { return; } LWC lwc = plugin.getLWC(); for (Block block : event.blockList()) { Protection protection = plugin.getLWC().findProtection(block.getLocation()); if (protection != null) { boolean ignoreExplosions = Boolean .parseBoolean(lwc.resolveProtectionConfiguration(protection.getBlock(), "ignoreExplosions")); if (!(ignoreExplosions || protection.hasFlag(Flag.Type.ALLOWEXPLOSIONS))) { event.setCancelled(true); } } } }
Example 2
Source File: Compat18.java From RedProtect with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onBlockExplode(BlockExplodeEvent e) { RedProtect.get().logger.debug(LogLevel.DEFAULT, "Is BlockListener - BlockExplodeEvent event"); List<Block> toRemove = new ArrayList<>(); for (Block b : e.blockList()) { Region r = RedProtect.get().rm.getTopRegion(b.getLocation()); if (!cont.canWorldBreak(b)) { toRemove.add(b); continue; } if (r != null && !r.canFire()) { toRemove.add(b); } } if (!toRemove.isEmpty()) { e.blockList().removeAll(toRemove); } }
Example 3
Source File: BlockExplodeListener.java From ShopChest with MIT License | 5 votes |
@EventHandler public void onBlockExplode(BlockExplodeEvent e) { ArrayList<Block> bl = new ArrayList<>(e.blockList()); for (Block b : bl) { if (b.getType().equals(Material.CHEST) || b.getType().equals(Material.TRAPPED_CHEST)) { if (plugin.getShopUtils().isShop(b.getLocation())) e.blockList().remove(b); } } }
Example 4
Source File: SpigotListener.java From ObsidianDestroyer with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true) public void onEntityExplode(BlockExplodeEvent event) { if (event == null || ChunkManager.getInstance().getDisabledWorlds().contains(event.getBlock().getLocation().getWorld().getName())) { return; // do not do anything in case explosions get cancelled } final Block detonatorBlock = event.getBlock(); if (detonatorBlock == null) { return; } if (detonatorBlock.hasMetadata("ObbyEntity")) { return; } if (event.getYield() <= 0) { return; } // feeling batty?! Spawn a bat to tie onto the EntityExplodeEvent. try { Bat bat = (Bat) Bukkit.getWorld(detonatorBlock.getWorld().getName()).spawnEntity(detonatorBlock.getLocation(), EntityType.BAT); if (bat != null) { bat.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 100, 1), true); } // Construct a new event but don't call it. EntityExplodeEvent entityExplodeEvent = new EntityExplodeEvent(bat, event.getBlock().getLocation(), event.blockList(), event.getYield()); ChunkManager.getInstance().handleExplosion(entityExplodeEvent, event.getBlock().getLocation()); if (bat != null) { bat.remove(); // bye } } catch (Exception e) { ObsidianDestroyer.debug(e.toString()); } }
Example 5
Source File: BlockEventHandler.java From GriefDefender with MIT License | 4 votes |
@EventHandler(priority = EventPriority.LOWEST) public void onExplosionEvent(BlockExplodeEvent event) { final World world = event.getBlock().getLocation().getWorld(); if (!GDFlags.EXPLOSION_BLOCK || !GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID())) { return; } Block source = event.getBlock(); GDCauseStackManager.getInstance().pushCause(source); if (GriefDefenderPlugin.isSourceIdBlacklisted(Flags.EXPLOSION_BLOCK.toString(), source, world.getUID())) { return; } final GDPermissionUser user = CauseContextHelper.getEventUser(event.getBlock().getLocation(), PlayerTracker.Type.OWNER); GDTimings.EXPLOSION_EVENT.startTiming(); GDClaim targetClaim = null; final List<Block> filteredLocations = new ArrayList<>(); final String sourceId = GDPermissionManager.getInstance().getPermissionIdentifier(source); final int cancelBlockLimit = GriefDefenderPlugin.getGlobalConfig().getConfig().claim.explosionCancelBlockLimit; boolean denySurfaceExplosion = GriefDefenderPlugin.getActiveConfig(world.getUID()).getConfig().claim.explosionBlockSurfaceBlacklist.contains(sourceId); if (!denySurfaceExplosion) { denySurfaceExplosion = GriefDefenderPlugin.getActiveConfig(world.getUID()).getConfig().claim.explosionBlockSurfaceBlacklist.contains("any"); } for (Block block : event.blockList()) { final Location location = block.getLocation(); targetClaim = GriefDefenderPlugin.getInstance().dataStore.getClaimAt(location); if (denySurfaceExplosion && block.getWorld().getEnvironment() != Environment.NETHER && location.getBlockY() >= location.getWorld().getSeaLevel()) { filteredLocations.add(block); GDPermissionManager.getInstance().processEventLog(event, location, targetClaim, Flags.EXPLOSION_BLOCK.getPermission(), source, block, user, "explosion-surface", Tristate.FALSE); continue; } Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.EXPLOSION_BLOCK, source, block, user, true); if (result == Tristate.FALSE) { // Avoid lagging server from large explosions. if (event.blockList().size() > cancelBlockLimit) { event.setCancelled(true); break; } filteredLocations.add(block); } } if (event.isCancelled()) { event.blockList().clear(); } else if (!filteredLocations.isEmpty()) { event.blockList().removeAll(filteredLocations); } GDTimings.EXPLOSION_EVENT.stopTiming(); }
Example 6
Source File: TPContainerListener.java From Transport-Pipes with MIT License | 4 votes |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onBlockExplode(BlockExplodeEvent e) { for (Block b : e.blockList()) { notifyBlockUpdate(b, false); } }