From 1e29bd693670a5506032adbc8a47316264745f5d Mon Sep 17 00:00:00 2001 From: Mysticate Date: Fri, 29 Jan 2016 11:44:40 -0500 Subject: [PATCH] Made block define its own drops. --- .../game/arcade/game/games/bridge/Bridge.java | 38 +++++-------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java index 5031cddda..71ff2c643 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.UUID; import mineplex.core.common.Rank; import mineplex.core.common.util.C; @@ -23,7 +24,6 @@ import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilWorld; import mineplex.core.explosion.ExplosionEvent; -import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -1295,7 +1295,6 @@ public class Bridge extends TeamGame implements OreObsfucation } } - @SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void dropItem(BlockBreakEvent event) { @@ -1310,47 +1309,30 @@ public class Bridge extends TeamGame implements OreObsfucation if (event.getPlayer().getGameMode() == GameMode.CREATIVE) return; - Material drop = null; - byte data = (byte) 0; - + List drops = new ArrayList(); + for (Material mat : PLAYER_DROP_DELAY_MATERIALS) { if (event.getBlock().getType() == mat) { - drop = mat; - data = event.getBlock().getData(); + drops.addAll(event.getBlock().getDrops()); break; } } - if (drop == null) + if (drops.isEmpty()) return; - - switch (drop) - { - case DIAMOND_ORE: - { - drop = Material.DIAMOND; - data = (byte) 0; - } - case COAL_ORE: - { - drop = Material.COAL; - data = (byte) 0; - } - default: - { - - } - } event.setCancelled(true); event.getBlock().setType(Material.AIR); Location loc = event.getBlock().getLocation().clone().add(.5, .5, .5); - Item item = loc.getWorld().dropItem(loc, new ItemBuilder(drop, data).build()); - item.setMetadata("owner", new FixedMetadataValue(Manager.getPlugin(), event.getPlayer().getUniqueId())); + for (ItemStack item : drops) + { + Item drop = loc.getWorld().dropItem(loc, item); + drop.setMetadata("owner", new FixedMetadataValue(Manager.getPlugin(), event.getPlayer().getUniqueId())); + } } @EventHandler