From 864b12adbf1cb3c034f206d8cdde0c86fadd54d2 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 15 Mar 2016 00:20:40 +0000 Subject: [PATCH] make cannons explode chest items --- .../clans/siege/weapon/projectile/Crater.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java index 0d21e4e4b..12f6057d0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java @@ -9,9 +9,11 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.Chest; import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; +import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; import mineplex.core.common.util.UtilBlock; @@ -143,6 +145,8 @@ public class Crater implements Listener boolean air = distance <= _airChance || (Math.random() > (distance) / 3.65d); + if (block.getState() instanceof Chest) continue; + if (block.getType() == Material.AIR) continue; if (air) @@ -183,6 +187,26 @@ public class Crater implements Listener if (block.getType() == Material.AIR) continue; + if (block.getState() instanceof Chest) + { + Chest chest = (Chest) block.getState(); + + for (ItemStack item : chest.getBlockInventory().getContents()) + { + if (item == null) + { + continue; + } + + if (item.getType() == Material.AIR) + { + continue; + } + + _origin.getWorld().dropItemNaturally(_origin, item); + } + } + if ( distance > _airChance && Math.random() > .75 &&