@FlugRost Going from the top of my head, I think you can get a collection of blocks that are destroyed from a EntityExplosionEvent (name might be off). You can iterate through the blocks and remove the appropriate ones from the collection. After that, just set the removed blocks to air.
Code: public class OnExplode implements Listener { private StadtPlugin plugin; public OnExplode(StadtPlugin plugin) { this.plugin = plugin; } @EventHandler public void onExplode(EntityExplodeEvent e){ if(!e.isCancelled()){ for(Block b : e.blockList()){ if(b.getType() == Material.CHEST){ ((Chest)b).getInventory().clear(); b.setType(Material.AIR); } } } } } I had try this, but it doesn't work. All items were dropping.
I would have loop throug the item and add them to à list. Once the chest explode, loop throug the entity of the world and if they appear in the first list, just remove them.
Code: public class OnExplode implements Listener { private StadtPlugin plugin; public OnExplode(StadtPlugin plugin) { this.plugin = plugin; } @EventHandler public void onExplode(EntityExplodeEvent e){ if(!e.isCancelled()){ for(Block b : e.blockList()){ if(b.getType() == Material.CHEST){ ((Chest)b).getInventory().clear(); b.setType(Material.AIR); plugin.getServer().getLogger().info("test"); } } } } } The server print "test". This is a good idea, but wouldn'd like to look for every entity.
mh OK. What do you think about this? Code: contens = new ArrayList<Item>(); World w = Bukkit.getWorld("world"); removeDrops(w.getChunkAt(b.getLocation())); removeDrops(w.getChunkAt(b.getLocation().clone().add(0,0,16))); removeDrops(w.getChunkAt(b.getLocation().clone().add(16,0,0))); removeDrops(w.getChunkAt(b.getLocation().clone().add(16,0,16))); removeDrops(w.getChunkAt(b.getLocation().clone().add(-16,0,0))); removeDrops(w.getChunkAt(b.getLocation().clone().add(-16,0,-16))); removeDrops(w.getChunkAt(b.getLocation().clone().add(0,0,-16))); removeDrops(w.getChunkAt(b.getLocation().clone().add(16,0,-16))); removeDrops(w.getChunkAt(b.getLocation().clone().add(-16,0,16))); private void removeDrops(Chunk chunk){ for(Entity ent : chunk.getEntities()){ if(ent.getType() == EntityType.DROPPED_ITEM){ ItemStack item = (ItemStack)ent; if(contens.contains(item)){ contens.remove(item); ent.remove(); } } } }