Made block define its own drops.

This commit is contained in:
Mysticate 2016-01-29 11:44:40 -05:00
parent 447583aa2a
commit 1e29bd6936

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.C; 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.UtilTime;
import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilWorld;
import mineplex.core.explosion.ExplosionEvent; import mineplex.core.explosion.ExplosionEvent;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; 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) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void dropItem(BlockBreakEvent event) public void dropItem(BlockBreakEvent event)
{ {
@ -1310,47 +1309,30 @@ public class Bridge extends TeamGame implements OreObsfucation
if (event.getPlayer().getGameMode() == GameMode.CREATIVE) if (event.getPlayer().getGameMode() == GameMode.CREATIVE)
return; return;
Material drop = null; List<ItemStack> drops = new ArrayList<ItemStack>();
byte data = (byte) 0;
for (Material mat : PLAYER_DROP_DELAY_MATERIALS) for (Material mat : PLAYER_DROP_DELAY_MATERIALS)
{ {
if (event.getBlock().getType() == mat) if (event.getBlock().getType() == mat)
{ {
drop = mat; drops.addAll(event.getBlock().getDrops());
data = event.getBlock().getData();
break; break;
} }
} }
if (drop == null) if (drops.isEmpty())
return; 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.setCancelled(true);
event.getBlock().setType(Material.AIR); event.getBlock().setType(Material.AIR);
Location loc = event.getBlock().getLocation().clone().add(.5, .5, .5); Location loc = event.getBlock().getLocation().clone().add(.5, .5, .5);
Item item = loc.getWorld().dropItem(loc, new ItemBuilder(drop, data).build()); for (ItemStack item : drops)
item.setMetadata("owner", new FixedMetadataValue(Manager.getPlugin(), event.getPlayer().getUniqueId())); {
Item drop = loc.getWorld().dropItem(loc, item);
drop.setMetadata("owner", new FixedMetadataValue(Manager.getPlugin(), event.getPlayer().getUniqueId()));
}
} }
@EventHandler @EventHandler