@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onTNTChain(EntityExplodeEvent event) { if(!this.tracker.isEnabled(event.getEntity().getWorld())) return; // Transfer ownership to chain-activated TNT if(event.getEntity() instanceof TNTPrimed) { Player owner = this.tracker.setOwner((TNTPrimed) event.getEntity(), null); if(owner != null) { for(Block block : event.blockList()) { if(block.getType() == Material.TNT) { this.tracker.setPlacer(block, owner); } } } } }
/** * Prevent the Nether spawn from being blown up * * @param e */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onExplosion(final EntityExplodeEvent e) { if (Settings.netherIslands) { // Not used in the new nether return; } // Find out what is exploding Entity expl = e.getEntity(); if (expl == null) { return; } // Check world if (!e.getEntity().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_nether") || e.getEntity().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_the_end")) { return; } Location spawn = e.getLocation().getWorld().getSpawnLocation(); Location loc = e.getLocation(); if (spawn.distance(loc) < Settings.netherSpawnRadius) { e.blockList().clear(); } }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void MobExplosion(EntityExplodeEvent e) { if (DEBUG) { plugin.getLogger().info(e.getEventName()); } // Only cover in the island world if (e.getEntity() == null || !Util.inWorld(e.getEntity())) { return; } if (mobSpawnInfo.containsKey(e.getEntity())) { // We know about this mob if (DEBUG) { plugin.getLogger().info("DEBUG: We know about this mob"); } if (!mobSpawnInfo.get(e.getEntity()).inIslandSpace(e.getLocation())) { // Cancel the explosion and block damage if (DEBUG) { plugin.getLogger().info("DEBUG: cancel flying mob explosion"); } e.blockList().clear(); e.setCancelled(true); } } }
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true) public void onEntityExplode(EntityExplodeEvent e) { Iterator<Block> blocks = e.blockList().iterator(); while (blocks.hasNext()) { Block block = blocks.next(); SlimefunItem item = BlockStorage.check(block); if (item != null) { blocks.remove(); if (!item.getID().equalsIgnoreCase("HARDENED_GLASS") && !item.getID().equalsIgnoreCase("WITHER_PROOF_OBSIDIAN") && !item.getID().equalsIgnoreCase("WITHER_PROOF_GLASS") && !item.getID().equalsIgnoreCase("FORCEFIELD_PROJECTOR") && !item.getID().equalsIgnoreCase("FORCEFIELD_RELAY")) { boolean success = true; if (SlimefunItem.blockhandler.containsKey(item.getID())) { success = SlimefunItem.blockhandler.get(item.getID()).onBreak(null, block, item, UnregisterReason.EXPLODE); } if (success) { BlockStorage.clearBlockInfo(block); block.setType(Material.AIR); } } } } }
/** * 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; } } }
@EventHandler public void onExplode(EntityExplodeEvent event) { if(event.getEntity() instanceof Creeper) { Entity e = event.getEntity(); if(e.hasMetadata("challenge")) { event.blockList().clear(); String[] meta = e.getMetadata("challenge").get(0).asString().split(", "); final String player = meta[1]; plugin.getChallenges().addKill(Bukkit.getPlayer(player)); Bukkit.getPlayer(player).setLevel(plugin.getChallenges().getKillsLeft(Bukkit.getPlayer(player))); if(plugin.getChallenges().getKillsLeft(Bukkit.getPlayer(player)) == 0) { plugin.getChallenges().finishChallenge(Bukkit.getPlayer(player), false); } } } }
@EventHandler public void onEntityExplode(EntityExplodeEvent event) { if (event.getEntity() != null) { if (event.getEntity().getType() == EntityType.PRIMED_TNT) { for (Block block : event.blockList()) { if (block.getType() == Material.TNT && getWhoPlaced(event.getEntity()) != null) { Location location = block.getLocation(); tntPlaced.put(location.getBlockX() + "," + location.getBlockY() + "," + location.getBlockZ(), getWhoPlaced(event.getEntity())); } } for (Entity entity : event.getEntity().getNearbyEntities(8, 8, 8)) { // F.debug("Found tnt"); if (entity instanceof TNTPrimed) { UUID playerUUID = getWhoPlaced(event.getEntity()); if(playerUUID != null) { Dispenser dispenser; // F.debug("found placer: " + Bukkit.getServer().getPlayer(playerUUID)); entity.setMetadata("source", new FixedMetadataValue(GamePlate.getInstance(), playerUUID)); } } } } } }
@EventHandler(priority = EventPriority.NORMAL) public void onBlockDestroy(EntityExplodeEvent event) { try { if (_config.RegenerateExplodedBlocks && _zone.isInside(event.getEntity().getLocation())) { HashMap<Location, BlockContainer> _blocks = new HashMap<Location, BlockContainer>(); for (Block b : event.blockList()) { BlockContainer bc = new BlockContainer(); bc.TypeId = b.getTypeId(); bc.TypeData = b.getData(); _blocks.put(b.getLocation(), bc); } BlockRestore restore = new BlockRestore(_world, _blocks); Executors.newSingleThreadScheduledExecutor().schedule(restore, _config.DelayBeforeRegeneration, TimeUnit.MILLISECONDS); } } catch (Exception ex) { logger.info("onblock destroy in Infestation raised an exception, it's ok!"); } }
@EventHandler(ignoreCancelled = true) public void onEntityExplode(EntityExplodeEvent event) { for (Block block : new ArrayList<>(event.blockList())) { if (block.getType().equals(Material.TNT)) { continue; } boolean cancel = this.post(event, block, block.getState(), this.applyAir(block), null, false); if (cancel) { event.blockList().remove(block); } } }
/** * Filters EntityExplodeEvent. It will remove from the blocks to break list blocks that can't be destroyed. * * <p>Applies to: block, block break.<p/> */ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onBlockExplode(EntityExplodeEvent event) { Match match = Cardinal.getMatch(event.getWorld()); if (match == null) { return; } Collection<AppliedRegion> regions = get(match, ApplyType.BLOCK, ApplyType.BLOCK_BREAK); Iterator<Block> blockIterator = event.blockList().iterator(); while (blockIterator.hasNext()) { Block evaluating = blockIterator.next(); for (AppliedRegion reg : regions) { if (apply(reg, evaluating.getLocation(), null, event, event, evaluating/* TODO: tnt tracker, pass player*/)) { if (event.isCancelled()) { event.setCancelled(false); blockIterator.remove(); } break; } } } }
@EventHandler(priority = EventPriority.HIGH) public void onEntityExplode(EntityExplodeEvent e) { Iterator<Block> iter = e.blockList().iterator(); while (iter.hasNext()) { Block b = iter.next(); if (plugin.getAllowedInventories().contains(b.getType())) { Sign s = findShopSign(b); if (s != null && ShopType.getType(s).isProtectedFromExplosions()) { iter.remove(); } } else if (b.getState() instanceof Sign && findShopChest(b) != null) { iter.remove(); } } }
@EventHandler(ignoreCancelled = false) public void onEntityExplode(cn.nukkit.event.entity.EntityExplodeEvent event) { if (canIgnore(PlayerInteractEvent.getHandlerList())) { return; } List<Block> blocks = new ArrayList<Block>(); for (cn.nukkit.block.Block nukkitBlock : event.getBlockList()) { blocks.add(PokkitBlock.toBukkit(nukkitBlock)); } EntityExplodeEvent bukkitEvent = new EntityExplodeEvent(PokkitEntity.toBukkit(event.getEntity()), PokkitLocation.toBukkit(event.getPosition()), blocks, (float) event.getYield()); callCancellable(event, bukkitEvent); }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onEntityExplode(EntityExplodeEvent event) { List<Block> blocks = event.blockList(); if (!blocks.isEmpty()) { World world = blocks.get(0).getWorld(); PluginConfig worldConfig = plugin.getConfig(world); if (plugin.isEnabled(world) && worldConfig.getBoolean(Config.FEATURE_DUNGEONS_PROTECTED)) { Iterator<Block> iterator = blocks.iterator(); while (iterator.hasNext()) { Block block = iterator.next(); if (this.isProtected(block.getLocation())) { iterator.remove(); } } } } }
@EventHandler(priority = EventPriority.MONITOR) public void onEntityExplode(EntityExplodeEvent event) { if (!event.isCancelled()) { Player player = TntTracker.getWhoPlaced(event.getEntity()) != null && Bukkit.getOfflinePlayer(TntTracker.getWhoPlaced(event.getEntity())).isOnline() ? Bukkit.getPlayer(TntTracker.getWhoPlaced(event.getEntity())) : null; if (player != null) { for (Block block : event.blockList()) { if (filter == null || filter.evaluate(player, block).equals(FilterState.ALLOW)) { if (region == null || region.contains(new BlockRegion(null, block.getLocation().toVector().add(new Vector(0.5, 0.5, 0.5))))) { for (ItemStack drop : this.drops) { GameHandler.getGameHandler().getMatchWorld().dropItemNaturally(block.getLocation(), drop); } if (this.experience != 0) { ExperienceOrb xp = GameHandler.getGameHandler().getMatchWorld().spawn(block.getLocation(), ExperienceOrb.class); xp.setExperience(this.experience); } block.setType(replace); } } } } } }
@EventHandler(priority = EventPriority.MONITOR) public void onEntityExplode(EntityExplodeEvent event) { for (Block block : event.blockList()) { for (Player player : Bukkit.getOnlinePlayers()) { Location location = block.getLocation(); location.setY(location.getY() + 1); Location playerLoc = player.getLocation(); if (playerLoc.getBlockX() == location.getBlockX() && playerLoc.getBlockY() == location.getBlockY() && playerLoc.getBlockZ() == location.getBlockZ()) { Description description = null; if (player.getLocation().add(new Vector(0, 1, 0)).getBlock().getType().equals(Material.LADDER)) { description = Description.OFF_A_LADDER; } else if (player.getLocation().add(new Vector(0, 1, 0)).getBlock().getType().equals(Material.VINE)) { description = Description.OFF_A_VINE; } else if (player.getLocation().getBlock().getType().equals(Material.WATER) || player.getLocation().getBlock().getType().equals(Material.STATIONARY_WATER)) { description = Description.OUT_OF_THE_WATER; } else if (player.getLocation().getBlock().getType().equals(Material.LAVA) || player.getLocation().getBlock().getType().equals(Material.STATIONARY_LAVA)) { description = Description.OUT_OF_THE_LAVA; } OfflinePlayer damager = (TntTracker.getWhoPlaced(event.getEntity()) != null ? Bukkit.getOfflinePlayer(TntTracker.getWhoPlaced(event.getEntity())) : null); Bukkit.getServer().getPluginManager().callEvent(new TrackerDamageEvent(player, damager, damager != null && damager.getPlayer() != null ? ((Player) damager).getItemInHand() : new ItemStack(Material.AIR), Cause.TNT, description, Type.SPLEEFED)); } } } }
@EventHandler(priority = EventPriority.HIGH) public void onEntityExplode(EntityExplodeEvent e) { if (e.isCancelled()){ return; } List<Block> toRemove = new ArrayList<>(); for (Block b:e.blockList()) { Location l = b.getLocation(); Region r = RedProtect.get().rm.getTopRegion(l); if (r == null && !RPConfig.getGlobalFlagBool(l.getWorld().getName()+".entity-block-damage")){ toRemove.add(b); } } if (!toRemove.isEmpty()){ e.blockList().removeAll(toRemove); } }
@EventHandler(priority = EventPriority.HIGH) public void onEntityExplode(final EntityExplodeEvent event) { final List<Block> destroyed = event.blockList(); final Iterator<Block> it = destroyed.iterator(); while (it.hasNext()) { final Block block = it.next(); // Ok so an explosion happens near a portal block // Find the nearest gate! final WorldCoord blockCoord = new WorldCoord(block); final Gate nearestGate = Gates.gateFromAll(blockCoord); // If a gate block, remove from explosion if (nearestGate != null) { it.remove(); } } }
/** * Prevents block damage due to explosions from beacon fireballs * Will still hurt players, so that needs to be handled elsewhere * @param e */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onExplosion(final EntityExplodeEvent e) { // Find out what is exploding Entity expl = e.getEntity(); if (expl == null) { return; } // Check world if (!e.getEntity().getWorld().equals(getBeaconzWorld())) { return; } if (projectiles.containsKey(expl.getUniqueId())) { e.blockList().clear(); projectiles.remove(expl.getUniqueId()); } }
/** * Protects the underlying beacon from any damage * @param event */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled=true) public void onExplode(EntityExplodeEvent event) { if (DEBUG) getLogger().info("DEBUG: " + event.getEventName()); World world = event.getLocation().getWorld(); if (!world.equals(getBeaconzWorld())) { return; } // Check if the block is a beacon or the surrounding pyramid and remove it from the damaged blocks Iterator<Block> it = event.blockList().iterator(); while (it.hasNext()) { if (getRegister().isBeacon(it.next())) { it.remove(); } } }
/** * Protects the beacon defenses from any damage * @param event */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled=true) public void onExplode(EntityExplodeEvent event) { //getLogger().info("DEBUG: " + event.getEventName()); World world = event.getLocation().getWorld(); if (!world.equals(getBeaconzWorld())) { return; } // Remove any blocks that are defensive Iterator<Block> it = event.blockList().iterator(); while(it.hasNext()) { Block b = it.next(); if (getRegister().isAboveBeacon(b.getLocation())) { // TODO: Check if it is the highest block it.remove(); } } }
@Override public void eventTrigger(Event event) { if(event.getEventName().equalsIgnoreCase("playerjoinevent")){ } else if(event.getEventName().equalsIgnoreCase("playerentityinteractevent")){ eh.onPlayerInteract((PlayerInteractEntityEvent)event); } else if(event.getEventName().equalsIgnoreCase("worldloadevent")){ eh.onWorldLoad((WorldLoadEvent)event); } else if(event.getEventName().equalsIgnoreCase("EntityDamageEvent")){ eh.onEntityDamage((EntityDamageEvent)event); } else if(event.getEventName().equalsIgnoreCase("EntityDamageByEntityEvent")){ eh.onEntityDamage((EntityDamageByEntityEvent)event); } else if(event.getEventName().equalsIgnoreCase("entityexplodeevent")){ eh.onEntityExplode((EntityExplodeEvent)event); } else if(event.getEventName().equalsIgnoreCase("asyncplayerchatevent")){ eh.onPlayerChat((AsyncPlayerChatEvent)event); } }
@EventHandler public void onEntityExplode(EntityExplodeEvent event) { Lot lot = this.module.getLotManager().getLot(event.getEntity().getLocation()); Town town = this.module.getLotManager().getTown(event.getEntity().getLocation()); if(lot != null || town != null) { event.setYield(0); event.setCancelled(true); return; } for(Block block : event.blockList()) { Lot l = this.module.getLotManager().getLot(block.getLocation()); Town t = this.module.getLotManager().getTown(block.getLocation()); if(l != null || t != null) { event.setYield(0); event.setCancelled(true); break; } } }
@EventHandler public void fragBallExplode(EntityExplodeEvent e) { e.setCancelled(true); for(Block block : e.blockList()) { if(block.getRelative(BlockFace.UP).getType() == Material.AIR && block.getType().isSolid()) { FallingBlock fallingBlock = block.getWorld().spawnFallingBlock(block.getLocation().add(0, 1, 0), block.getType(), block.getData()); double x = (block.getLocation().getX() - e.getLocation().getX()) / 3, y = 1, z = (block.getLocation().getZ() - e.getLocation().getZ()) / 3; fallingBlock.setVelocity(new Vector(x, y, z).normalize()); fallingBlock.setMetadata("explode", new FixedMetadataValue(plugin, false)); fallingBlock.setDropItem(false); e.setYield(0F); } } }
@EventHandler(ignoreCancelled = true) public void onEntityExplodeEvent(EntityExplodeEvent event) { AttackType attackType = AttackType.UNKNOWN; Entity attacker = event.getEntity(); if (attacker instanceof TNTPrimed) { attackType = AttackType.TNT; } else if (attacker instanceof Creeper) { attackType = AttackType.CREEPER; } else if (attacker instanceof Fireball) { if (((Fireball) attacker).getShooter() instanceof Ghast) { attackType = AttackType.GHAST; } } if (plugin.getChestSettings().allowDestroyBy(attackType)) { return; } for (Iterator<Block> it = event.blockList().iterator(); it.hasNext();) { Block block = it.next(); if (isProtected(block)) { it.remove(); } } }
/** * Prevent the Nether spawn from being blown up * * @param e */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onExplosion(final EntityExplodeEvent e) { if (Settings.newNether) { // Not used in the new nether return; } // Find out what is exploding Entity expl = e.getEntity(); if (expl == null) { return; } // Check world if (!e.getEntity().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_nether") || e.getEntity().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_the_end")) { return; } Location spawn = e.getLocation().getWorld().getSpawnLocation(); Location loc = e.getLocation(); if (spawn.distance(loc) < Settings.netherSpawnRadius) { e.blockList().clear(); } }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void MobExplosion(EntityExplodeEvent e) { if (DEBUG) { plugin.getLogger().info(e.getEventName()); } // Only cover in the island world if (e.getEntity() == null || !IslandGuard.inWorld(e.getEntity())) { return; } if (mobSpawnInfo.containsKey(e.getEntity().getUniqueId())) { // We know about this mob if (DEBUG) { plugin.getLogger().info("DEBUG: We know about this mob"); } if (!mobSpawnInfo.get(e.getEntity().getUniqueId()).inIslandSpace(e.getLocation())) { // Cancel the explosion and block damage if (DEBUG) { plugin.getLogger().info("DEBUG: cancel flying mob explosion"); } e.blockList().clear(); e.setCancelled(true); } } }
@EventHandler public void onEntityExplode(final EntityExplodeEvent event) { final int oniX = oniLocation.getBlockX(); final int oniY = oniLocation.getBlockY(); final int oniZ = oniLocation.getBlockZ(); final Iterator<Block> iter = event.blockList().iterator(); while (iter.hasNext()) { final Block block = iter.next(); final int blockX = block.getX(); final int blockY = block.getY(); final int blockZ = block.getZ(); if (blockX >= oniX - 10 && blockX <= oniX + 10 && blockZ >= oniZ - 10 && blockZ <= oniZ + 10 && blockY > oniY - 10) { iter.remove(); } } }
@EventHandler(priority = EventPriority.MONITOR) public void onBlockExplode(EntityExplodeEvent event) { if(!event.isCancelled()) { List<Block> blocks = event.blockList(); if(blocks.size() > 0) { Location loc = blocks.get(0).getLocation(); for(Game game : gm.getGames()) { for(Arena a : game.getArenas()) { if(a.containsBlock(loc)) { blocks.clear(); return; } } } } } }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onEntityExplode(EntityExplodeEvent event) { IEntity entity = plugin.wrapEntity(event.getEntity()); if (manager.isPlotWorld(entity)) { PlotMapInfo pmi = manager.getMap(entity.getLocation()); if (pmi != null && pmi.isDisableExplosion()) { event.setCancelled(true); } else { PlotId id = manager.getPlotId(entity.getLocation()); if (id == null) { event.setCancelled(true); } } } }
@EventHandler(ignoreCancelled = true) public void onEntityExplode(EntityExplodeEvent explodeEvent) { Location location = explodeEvent.getLocation(); //if it's NOT in the managed world, let it splode (or let other plugins worry about it) Region region = Region.fromLocation(location); if (region == null) return; //otherwise if it's close to a region post Location regionCenter = region.getCenter(); regionCenter.setY(ConfigData.managedWorld.getHighestBlockYAt(regionCenter)); if (regionCenter.distanceSquared(location) < 225) //225 = 15 * 15 explodeEvent.blockList().clear(); //All the noise and terror, none of the destruction (whew!). //NOTE! Why not distance? Because distance squared is cheaper and will be good enough for this. }
/** * Handle EntityExplode events that involve modifying the event. * * @param event The event to modify */ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onEnitityExplode(EntityExplodeEvent event) { Entity entity = event.getEntity(); if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) { return; } // We can make this assumption because we (should) be the only ones using this exact metadata Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString()); if (!UserManager.hasPlayerDataKey(player)) { return; } MiningManager miningManager = UserManager.getPlayer(player).getMiningManager(); if (miningManager.canUseBlastMining()) { miningManager.blastMiningDropProcessing(event.getYield(), event.blockList()); event.setYield(0); } }
@EventHandler public void onEntityExplode(EntityExplodeEvent event) { String world = event.getEntity().getWorld().getUID().toString(); Integer x, z; ArrayList<Block> temparraylist = new ArrayList<>(); temparraylist.addAll(event.blockList()); for (Block b : temparraylist) { x = b.getLocation().getChunk().getX(); z = b.getLocation().getChunk().getZ(); if (QuickChecks.isWorldChunkClaimed(serverdata.get("worldmap").get(world), x, z, "cla")) { String pvillage = ((HashMap) ((HashMap) serverdata.get("worldmap").get(world).get(x)).get(z)).get("cla").toString(); if (serverdata.get("villages").get(pvillage).containsKey("expl")) { if (serverdata.get("villages").get(pvillage).get("expl").equals("off") || ((HashMap) ((HashMap) serverdata.get("worldmap").get(world).get(x)).get(z)).containsKey("str")) { event.blockList().remove(b); } } else if (Config.getString("Village Settings.Toggle Settings.Explosions Enabled").equals("off") || ((HashMap) ((HashMap) serverdata.get("worldmap").get(world).get(x)).get(z)).containsKey("str")) { event.blockList().remove(b); } } } }
@EventHandler(ignoreCancelled = true) public void onEntityExplode(EntityExplodeEvent event) { if (event == null || ChunkManager.getInstance().getDisabledWorlds().contains(event.getLocation().getWorld().getName())) { return; // do not do anything in case explosions get cancelled } final Entity detonator = event.getEntity(); if (detonator == null || detonator.hasMetadata("ObbyEntity")) { return; } if (event.getLocation().getBlock().hasMetadata("ObbyEntity")) { return; } if (event.getYield() <= 0) { return; } ChunkManager.getInstance().handleExplosion(event); }
@EventHandler public void onTntExplode(EntityExplodeEvent event){ if(Minigame.getCurrentMinigame()!=null){ switch(Minigame.getCurrentMinigame().getMap().getType()){ case CIRCLE_OF_BOOM: event.blockList().clear(); break; case KEY_QUEST: break; case WATER_THE_MONUMENT: break; default: break; } } }
/** * Entity explode event handler<br> * Make death chests explosion proof if chest-protection is enabled * @param event */ @EventHandler public void onEntityExplode(EntityExplodeEvent event) { // if chest-protection is not enabled in config, do nothing and return if (!plugin.getConfig().getBoolean("chest-protection")) { return; } // iterate through all blocks in explosion event and remove those that are DeathChestBlocks ArrayList<Block> blocks = new ArrayList<Block>(event.blockList()); for (Block block : blocks) { if (DeathChestBlock.isDeathChestBlock(block)) { event.blockList().remove(block); } } }
@EventHandler public synchronized void onExplosion(EntityExplodeEvent event) { Plot p = plugin.getPlot(event.getLocation()); //if the plot is unclaimed or the town has destruction off, cancel the terrain damage. if(p == null || !p.getTown().isDestructionOn()) { event.blockList().clear(); return; } List<Block> blocklist = event.blockList(); for(int i = 0; i < blocklist.size(); i++) { Block b = blocklist.get(i); //OPTION: Could be better if system check if the plot town is the besieged town. //if the block's plot is unclaimed or the block is a container, exclude that block from terrain damage. if(plugin.getPlot(new PlotLocation(b.getLocation())) == null || b.getState() instanceof InventoryHolder) blocklist.remove(i--); else blockBreak(p.getTown()); //increase restorefee } }
public RemoteEnderDragon(int inID, RemoteEnderDragonEntity inEntity, EntityManager inManager) { super(inID, RemoteEntityType.EnderDragon, inManager); this.m_entity = inEntity; Bukkit.getPluginManager().registerEvents(new Listener() { @EventHandler public void onEntityExplode(EntityExplodeEvent event) { if(event.getEntity() instanceof EnderDragon) { if(event.getEntity() == getBukkitEntity() && !shouldDestroyBlocks()) event.setCancelled(true); } else if(event.getEntity() instanceof ComplexEntityPart) { if(((ComplexEntityPart)event.getEntity()).getParent() == getBukkitEntity() && !shouldDestroyBlocks()) event.setCancelled(true); } } }, this.m_manager.getPlugin() ); }