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.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<ItemStack> drops = new ArrayList<ItemStack>();
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