org.bukkit.event.entity.EntityExplodeEvent Java Examples

The following examples show how to use org.bukkit.event.entity.EntityExplodeEvent. 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: ProtectionsTests.java    From Civs with GNU General Public License v3.0 6 votes vote down vote up
private void explodeInRegion(boolean throwException, Location regionLocation) throws SuccessException {
    RegionsTests.loadRegionTypeCobble();
    HashMap<UUID, String> people = new HashMap<>();
    people.put(TestUtil.player.getUniqueId(), Constants.OWNER);
    HashMap<String, String> effects = new HashMap<>();
    Region region = new Region("cobble", people,
            regionLocation,
            RegionsTests.getRadii(),
            effects,0);
    RegionManager.getInstance().addRegion(region);
    TNTPrimed tntPrimed = mock(TNTPrimed.class);
    ArrayList<Block> blockList = new ArrayList<>();
    if (throwException) {
        when(Bukkit.getServer().getScheduler()).thenThrow(new SuccessException());
    }
    EntityExplodeEvent event = new EntityExplodeEvent(tntPrimed,
            regionLocation.add(0, 1,0),
            blockList,
            (float) 2);
    if (throwException) {
        ProtectionHandler protectionHandler = new ProtectionHandler();
        protectionHandler.onEntityExplode(event);
    }
}
 
Example #2
Source File: SpleefTracker.java    From CardinalPGM with MIT License 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityExplode(EntityExplodeEvent event) {
    if (event.isCancelled() || GameHandler.getGameHandler().getMatch().getModules().getModule(TitleRespawn.class).isDeadUUID(event.getEntity().getUniqueId())) return;
    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).getInventory().getItemInMainHand() : new ItemStack(Material.AIR), Cause.TNT, description, Type.SPLEEFED));
            }
        }
    }
}
 
Example #3
Source File: Blockdrops.java    From CardinalPGM with MIT License 6 votes vote down vote up
@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) {
            List<Block> toRemove = new ArrayList<>();
            for (Block block : event.blockList()) {
                if (filter == null || filter.evaluate(player, block, event).equals(FilterState.ALLOW)) {
                    if (region == null || region.contains(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);
                        }
                        toRemove.add(block);
                        block.setType(replaceType);
                        block.setData((byte) replaceDamage);
                    }
                }
            }
            event.blockList().removeAll(toRemove);
        }
    }
}
 
Example #4
Source File: ControllableEnderDragonBase.java    From EntityAPI with GNU Lesser General Public License v3.0 6 votes vote down vote up
public ControllableEnderDragonBase(int id, EntityManager manager) {
    super(id, ControllableEntityType.ENDERDRAGON, manager);
    Bukkit.getPluginManager().registerEvents(new Listener() {

        @EventHandler
        public void onEntityExplode(EntityExplodeEvent event) {
            if (!shouldDestroyBlocks()) {
                Entity entity = event.getEntity();
                if (entity instanceof EnderDragon && entity.equals(getBukkitEntity())) {
                    event.setCancelled(true);
                } else if (entity instanceof ComplexEntityPart && ((ComplexEntityPart) entity).getParent().equals(getBukkitEntity())) {
                    event.setCancelled(true);
                }
            }
        }

    }, EntityAPI.getCore());
}
 
Example #5
Source File: WorldListener.java    From BedWars with GNU Lesser General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onExplode(EntityExplodeEvent event) {
    if (event.isCancelled()) {
        return;
    }

    final String explosionExceptionTypeName = Main.getConfigurator().config.getString("destroy-placed-blocks-by-explosion-except", null);
    final boolean destroyPlacedBlocksByExplosion = Main.getConfigurator().config.getBoolean("destroy-placed-blocks-by-explosion", true);

    for (String gameName : Main.getGameNames()) {
        Game game = Main.getGame(gameName);
        if (game.getStatus() == GameStatus.RUNNING || game.getStatus() == GameStatus.GAME_END_CELEBRATING) {
            if (GameCreator.isInArea(event.getLocation(), game.getPos1(), game.getPos2())) {
                if (destroyPlacedBlocksByExplosion) {
                    event.blockList().removeIf(block -> (explosionExceptionTypeName != null && !explosionExceptionTypeName.equals("") && block.getType().name().contains(explosionExceptionTypeName)) || !game.isBlockAddedDuringGame(block.getLocation()));
                } else {
                    event.blockList().clear();
                }
            }
        }
    }

}
 
Example #6
Source File: EntityExplodeListener.java    From ObsidianDestroyer with GNU General Public License v3.0 6 votes vote down vote up
@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.51) {
        return;
    }

    ChunkManager.getInstance().handleExplosion(event);
}
 
Example #7
Source File: ShopProtectionListener.java    From QuickShop-Reremake with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onExplode(EntityExplodeEvent e) {

    for (int i = 0, a = e.blockList().size(); i < a; i++) {
        final Block b = e.blockList().get(i);
        final Shop shop = getShopNature(b.getLocation(), true);

        if (shop == null) {
            continue;
        }
        if (plugin.getConfig().getBoolean("protect.explode")) {
            e.setCancelled(true);
        } else {
            plugin.log("Deleting shop "+shop+" request by block break (explode).");
            shop.delete();
        }
    }
}
 
Example #8
Source File: BukkitPlotListener.java    From PlotMe-Core with GNU General Public License v3.0 6 votes vote down vote up
@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);
            }
        }
    }
}
 
Example #9
Source File: FlyingMobEvents.java    From askyblock with GNU General Public License v2.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void MobExplosion(final 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())) {
        // 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);
        }
    }
}
 
Example #10
Source File: WorldListener.java    From BedWars with GNU Lesser General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onExplode(EntityExplodeEvent event) {
    if (event.isCancelled()) {
        return;
    }

    final String explosionExceptionTypeName = Main.getConfigurator().config.getString("destroy-placed-blocks-by-explosion-except", null);
    final boolean destroyPlacedBlocksByExplosion = Main.getConfigurator().config.getBoolean("destroy-placed-blocks-by-explosion", true);

    for (String gameName : Main.getGameNames()) {
        Game game = Main.getGame(gameName);
        if (game.getStatus() == GameStatus.RUNNING || game.getStatus() == GameStatus.GAME_END_CELEBRATING) {
            if (GameCreator.isInArea(event.getLocation(), game.getPos1(), game.getPos2())) {
                if (destroyPlacedBlocksByExplosion) {
                    event.blockList().removeIf(block -> (explosionExceptionTypeName != null && !explosionExceptionTypeName.equals("") && block.getType().name().contains(explosionExceptionTypeName)) || !game.isBlockAddedDuringGame(block.getLocation()));
                } else {
                    event.blockList().clear();
                }
            }
        }
    }

}
 
Example #11
Source File: NetherPortals.java    From askyblock with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Prevent the Nether spawn from being blown up
 * 
 * @param e - event
 */
@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();
    }
}
 
Example #12
Source File: DestroyableMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 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;
        }
    }
}
 
Example #13
Source File: ChunkEventHelper.java    From ClaimChunk with MIT License 6 votes vote down vote up
private static void cancelExplosionEvent(boolean hardCancel, @Nonnull EntityExplodeEvent e) {
    if (hardCancel) {
        // This explosion event occurred within a claimed chunk.
        e.setYield(0);
        e.setCancelled(true);
    } else {
        // This explosion occurred outside of a claimed chunk but it might
        // interfere with claimed blocks.
        final ChunkHandler CHUNK_HANDLER = ClaimChunk.getInstance().getChunkHandler();

        // Remove all of the blocks within claimed chunks from this event
        // so they are not destroyed.
        // Unfortunately, there is no way to remove specific entities from
        // the damage list, so entities will not be protected from
        // explosions by this method.
        e.blockList().removeIf(block -> CHUNK_HANDLER.isClaimed(block.getChunk()));
    }
}
 
Example #14
Source File: LWCEntityListener.java    From Modern-LWC with MIT License 6 votes vote down vote up
@EventHandler(priority = EventPriority.HIGH)
public void onEntityExplode(EntityExplodeEvent event) {
    if (!LWC.ENABLED || event.isCancelled()) {
        return;
    }

    LWC lwc = LWC.getInstance();

    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 #15
Source File: ExplosionsListener.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityExplode(EntityExplodeEvent e) {
    Iterator<Block> blocks = e.blockList().iterator();

    while (blocks.hasNext()) {
        Block block = blocks.next();

        String id = BlockStorage.checkID(block);
        if (id != null) {
            blocks.remove();

            // Hardened Glass and WitherProof blocks cannot be destroyed by explosions
            if (!id.equals(SlimefunItems.HARDENED_GLASS.getItemId()) && !SlimefunPlugin.getRegistry().getWitherProofBlocks().containsKey(id)) {
                boolean success = true;
                SlimefunItem sfItem = SlimefunItem.getByID(id);

                SlimefunBlockHandler blockHandler = SlimefunPlugin.getRegistry().getBlockHandlers().get(sfItem.getID());

                if (blockHandler != null) {
                    success = blockHandler.onBreak(null, block, sfItem, UnregisterReason.EXPLODE);
                }

                if (success) {
                    BlockStorage.clearBlockInfo(block);
                    block.setType(Material.AIR);
                }
            }
        }
    }
}
 
Example #16
Source File: TntTracker.java    From CardinalPGM with MIT License 5 votes vote down vote up
@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()));
                }
            }
        }
    }
}
 
Example #17
Source File: ChestProtectListener.java    From Shopkeepers with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
void onExplosion(EntityExplodeEvent event) {
	Iterator<Block> iter = event.blockList().iterator();
	while (iter.hasNext()) {
		Block block = iter.next();
		if (Utils.isChest(block.getType()) && plugin.getProtectedChests().isChestProtected(block, null)) {
			iter.remove();
		}
	}
}
 
Example #18
Source File: EntityExplodeListener.java    From IridiumSkyblock with GNU General Public License v2.0 5 votes vote down vote up
@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
    try {
        final Entity entity = event.getEntity();
        final Location location = entity.getLocation();
        final IslandManager islandManager = IridiumSkyblock.getIslandManager();
        if (!islandManager.isIslandWorld(location)) return;

        if (!IridiumSkyblock.getConfiguration().allowExplosions)
            event.setCancelled(true);
    } catch (Exception ex) {
        IridiumSkyblock.getInstance().sendErrorMessage(ex);
    }
}
 
Example #19
Source File: Tnt.java    From CardinalPGM with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityExplode(EntityExplodeEvent event) {
    if (GameHandler.getGameHandler().getMatch().isRunning() && event.getEntity() instanceof TNTPrimed) {
        if (!blockDamage) {
            event.blockList().clear();
        } else if (yield != 0.3){
            event.setYield((float)yield);
        }
        UUID player = TntTracker.getWhoPlaced(event.getEntity());
        for (Block block : event.blockList()) {
            if (block.getState() instanceof Dispenser) {
                Inventory inventory = ((Dispenser) block.getState()).getInventory();
                Location location = block.getLocation();
                double tntCount = 0;
                for (ItemStack itemstack : inventory.getContents()) {
                    if (itemstack != null && itemstack.getType() == Material.TNT) tntCount += itemstack.getAmount() * multiplier;
                    if (tntCount >= limit) {
                        tntCount = limit;
                        break;
                    }
                }
                inventory.remove(Material.TNT);
                if (tntCount > 0) {
                    Random random = new Random();
                    for (double i = tntCount; i > 0; i--) {
                        TNTPrimed tnt = event.getWorld().spawn(location, TNTPrimed.class);
                        Vector velocity = new Vector((1.5 * random.nextDouble()) - 0.75, (1.5 * random.nextDouble()) - 0.75, (1.5 * random.nextDouble()) - 0.75);
                        tnt.setVelocity(velocity);
                        tnt.setFuseTicks(random.nextInt(10) + 10);
                        if (player != null) {
                            tnt.setMetadata("source", new FixedMetadataValue(Cardinal.getInstance(), player));
                        }
                    }
                }
            }
        }
    }
}
 
Example #20
Source File: SpigotListener.java    From ObsidianDestroyer with GNU General Public License v3.0 5 votes vote down vote up
@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 #21
Source File: CEListener.java    From ce with GNU Lesser General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void EntityExplodeEvent(EntityExplodeEvent e) {

    if (e.getEntity() != null && e.getEntity().hasMetadata("ce.explosive")) {
        e.getEntity().remove();
        e.setCancelled(true);
    }

}
 
Example #22
Source File: FlagSplegg.java    From HeavySpleef with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
	Entity entity = event.getEntity();
	
	Game game = null;
	List<MetadataValue> metadatas = entity.getMetadata(TNT_METADATA_KEY);
	for (MetadataValue value : metadatas) {
		if (value.getOwningPlugin() != getHeavySpleef().getPlugin()) {
			continue;
		}
		
		game = (Game) value.value();
	}
	
	if (game != null) {
		List<Block> blocks = event.blockList();
		for (Block block : blocks) {
			if (!game.canSpleef(block)) {
				continue;
			}
			
			block.setType(Material.AIR);
		}
		
		blocks.clear();
	}
}
 
Example #23
Source File: ChestProtectListener.java    From ShopChest with MIT License 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onEntityExplode(EntityExplodeEvent 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 (shopUtils.isShop(b.getLocation())) e.blockList().remove(b);
        }
    }
}
 
Example #24
Source File: LivingEntityShopListener.java    From Shopkeepers with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
void onExplode(EntityExplodeEvent event) {
	if (plugin.isShopkeeper(event.getEntity())) {
		event.setCancelled(true);
		Log.debug("Cancelled event for living shop: " + event.getEventName());
	}
}
 
Example #25
Source File: BlockListener.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityExplode(EntityExplodeEvent e) {
    RedProtect.get().logger.debug(LogLevel.BLOCKS, "Is BlockListener - EntityExplodeEvent event");
    List<Block> toRemove = new ArrayList<>();

    Region or = RedProtect.get().rm.getTopRegion(e.getEntity().getLocation());
    for (Block b : e.blockList()) {
        if (b == null) {
            continue;
        }
        RedProtect.get().logger.debug(LogLevel.BLOCKS, "Blocks: " + b.getType().name());
        Location l = b.getLocation();
        Region r = RedProtect.get().rm.getTopRegion(l);
        if (r != null && !r.canFire() || !cont.canWorldBreak(b)) {
            RedProtect.get().logger.debug(LogLevel.BLOCKS, "canWorldBreak Called!");
            //e.setCancelled(true);
            toRemove.add(b);
            continue;
        }

        if (r == null) {
            continue;
        }

        if (r != or) {
            toRemove.add(b);
            continue;
        }

        if (e.getEntity() instanceof LivingEntity && !r.canMobLoot()) {
            toRemove.add(b);
        }
    }
    if (!toRemove.isEmpty()) {
        e.blockList().removeAll(toRemove);
    }
}
 
Example #26
Source File: GlobalProtectionListener.java    From DungeonsXL with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onEntityExplode(EntityExplodeEvent event) {
    List<Block> blocklist = event.blockList();
    for (Block block : blocklist) {
        if (plugin.getGlobalProtectionCache().isProtectedBlock(block)) {
            event.setCancelled(true);
        }
    }
}
 
Example #27
Source File: DWorldListener.java    From DungeonsXL with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onEntityExplode(EntityExplodeEvent event) {
    if (plugin.getGameWorld(event.getEntity().getWorld()) == null) {
        return;
    }
    if (event.getEntity() instanceof LivingEntity) {
        // Disable Creeper explosions in gameWorlds
        event.setCancelled(true);
    } else {// TODO respect block breaking game rules
        // Disable drops from TNT
        event.setYield(0);
    }
}
 
Example #28
Source File: ListenerCombatChecks.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
public void onEntityExplode(EntityExplodeEvent e) {
    Entity entity = e.getEntity();
    if(!(entity instanceof Creeper)) return;

    Creeper creeper = (Creeper) entity;
    checkEnemyDeathUntag(creeper);
}
 
Example #29
Source File: ExprExplodedBlocks.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) {
	if (!ScriptLoader.isCurrentEvent(EntityExplodeEvent.class)) {
		Skript.error("Exploded blocks can only be retrieved from an explode event.");
		return false;
	}
	return true;
}
 
Example #30
Source File: NetherTerraFormEvents.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onGhastExplode(EntityExplodeEvent event) {
    if (!plugin.getWorldManager().isSkyNether(event.getEntity().getWorld())) {
        return; // Bail out, not our problem
    }
    // TODO: 23/09/2015 - R4zorax: Perhaps enable this when island has a certain level?
    if (event.getEntity() instanceof Fireball) {
        Fireball fireball = (Fireball) event.getEntity();
        fireball.setIsIncendiary(false);
        fireball.setFireTicks(0);
        event.setCancelled(true);
    }
}