Java 类org.bukkit.event.entity.EntityExplodeEvent 实例源码

项目:Warzone    文件:ExplosiveListener.java   
@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);
                }
            }
        }
    }
}
项目:bskyblock    文件:NetherEvents.java   
/**
 * 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();
    }
}
项目:bskyblock    文件:FlyingMobEvents.java   
@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);
        }
    }
}
项目:Slimefun4-Chinese-Version    文件:ToolListener.java   
@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);
                }
            }
        }
    }

}
项目:ProjectAres    文件:DestroyableMatchModule.java   
/**
 * 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;
        }
    }
}
项目:AsgardAscension    文件:ChallengeListener.java   
@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);
            }
        }
    }
}
项目:GamePlate    文件:TntTracker.java   
@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));
                        }
                    }
                }
            }
        }
    }
项目:world-of-icerealm    文件:Infestation.java   
@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!");
    }

}
项目:Arcade2    文件:BlockTransformListeners.java   
@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);
        }
    }
}
项目:Cardinal    文件:AppliedModule.java   
/**
 * 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;
      }
    }
  }

}
项目:TradeShop    文件:ShopProtectionHandler.java   
@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();
        }
    }
}
项目:Pokkit    文件:EntityEvents.java   
@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);
}
项目:BloodMoon    文件:DungeonListener.java   
@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();
                }
            }
        }
    }
}
项目:Cardinal-Plus    文件:Blockdrops.java   
@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);
                    }
                }
            }
        }
    }
}
项目:Cardinal-Plus    文件:SpleefTracker.java   
@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));
            }
        }
    }
}
项目:RedProtect    文件:RPGlobalListener.java   
@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);
    }
}
项目:AncientGates    文件:PluginBlockListener.java   
@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();
        }
    }
}
项目:beaconz    文件:BeaconProjectileDefenseListener.java   
/**
 * 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());
    }
}
项目:beaconz    文件:BeaconProtectionListener.java   
/**
 * 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();
        }
    }
}
项目:beaconz    文件:BeaconPassiveDefenseListener.java   
/**
 * 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();
        }
    }
}
项目:gFeatures    文件:gFactions.java   
@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);
    }
}
项目:Peacecraft    文件:LotsListener.java   
@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;
        }
    }
}
项目:SurvivalGamesX    文件:BlockListener.java   
@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);
        }
    }
}
项目:Slimefun4    文件:ToolListener.java   
@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);
                }
            }
        }
    }

}
项目:BlockLocker    文件:BlockDestroyListener.java   
@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();
        }
    }
}
项目:acidisland    文件:NetherPortals.java   
/**
 * 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();
    }
}
项目:acidisland    文件:FlyingMobEvents.java   
@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);
        }
    }
}
项目:5min2live    文件:OniManager.java   
@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();
        }
    }
}
项目:UltimateSurvivalGames    文件:ResetListener.java   
@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;
                    }
                }
            }
        }   
    }
}
项目:askyblock    文件:NetherPortals.java   
/**
 * 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();
    }
}
项目:askyblock    文件:FlyingMobEvents.java   
@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);
        }
    }
}
项目:PlotMe-Core    文件:BukkitPlotListener.java   
@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);
            }
        }
    }
}
项目:PopulationDensity    文件:EntityEventHandler.java   
@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.
}
项目:McMMOPlus    文件:EntityListener.java   
/**
 * 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);
    }
}
项目:Empirecraft    文件:OnEntityExplode.java   
@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);
            }
        }
    }
}
项目:ObsidianDestroyer    文件:EntityExplodeListener.java   
@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);
}
项目:TCMinigames    文件:BlockListener.java   
@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;

        }
    }
}
项目:SavageDeathChest    文件:BlockEventListener.java   
/**
 * 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);
        }
    }
}
项目:NewNations    文件:NationsBlockListener.java   
@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
    }
}
项目:EndHQ-Libraries    文件:RemoteEnderDragon.java   
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()
    );
}