org.bukkit.event.block.BlockExplodeEvent Java Examples
The following examples show how to use
org.bukkit.event.block.BlockExplodeEvent.
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: ChunkListener.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
public ChunkListener() { if (Settings.IMP.TICK_LIMITER.ENABLED) { PluginManager plm = Bukkit.getPluginManager(); Plugin plugin = Fawe.<FaweBukkit>imp().getPlugin(); plm.registerEvents(this, plugin); try { Fawe.debug("Detected " + BlockExplodeEvent.class); plm.registerEvents(new ChunkListener_8Plus(this), plugin); } catch (Throwable ignore) {} TaskManager.IMP.repeat(new Runnable() { @Override public void run() { rateLimit--; physicsFreeze = false; itemFreeze = false; lastZ = Integer.MIN_VALUE; physSkip = 0; physCancelPair = Long.MIN_VALUE; physCancel = false; counter.clear(); for (Long2ObjectMap.Entry<Boolean> entry : badChunks.long2ObjectEntrySet()) { long key = entry.getLongKey(); int x = MathMan.unpairIntX(key); int z = MathMan.unpairIntY(key); counter.put(key, badLimit); } badChunks.clear(); } }, Settings.IMP.TICK_LIMITER.INTERVAL); } }
Example #4
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 #5
Source File: BukkitPlotListener.java From PlotMe-Core with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onBlockExplode(BlockExplodeEvent event) { Location location = BukkitUtil.adapt(event.getBlock().getLocation()); PlotMapInfo pmi = manager.getMap(location); if (pmi != null && pmi.isDisableExplosion()) { event.setCancelled(true); } else { PlotId id = manager.getPlotId(location); if (id == null) { event.setCancelled(true); } } }
Example #6
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 #7
Source File: EventForwarder.java From BlueMap with MIT License | 4 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onBlockChange(BlockExplodeEvent evt) { onBlockChange(evt.getBlock().getLocation()); }
Example #8
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 #9
Source File: LongRangeExplosionMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void blockExplode(BlockExplodeEvent event) { render(event.getBlock().getLocation()); }
Example #10
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); } }
Example #11
Source File: PlantsListener.java From ExoticGarden with GNU General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBlockExplode(BlockExplodeEvent e) { e.blockList().removeAll(getAffectedBlocks(e.blockList())); }
Example #12
Source File: GuildHeartProtectionHandler.java From FunnyGuilds with Apache License 2.0 | 4 votes |
@EventHandler public void onBlockExplode(BlockExplodeEvent event) { if (isGuildHeart(event.getBlock())) { event.setCancelled(true); } }