Merge pull request #146 in MIN/mineplex from bugfix/bridges-ore-stealing to develop

* commit 'b45e00796d66cf8aeb39510e0bd23bc5bd59327b':
  Fixed explosions dropping right items.
  Made block define its own drops.
  Removed an nunnecesarry method
  Fixed items not dropping their regular counterpart.
This commit is contained in:
Shaun Bennett 2016-01-30 01:45:00 -06:00
commit 52b6779a4f

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;
@ -1137,7 +1137,7 @@ public class Bridge extends TeamGame implements OreObsfucation
// Reveal ore that are inside the explosion
_ore.Explosion(event);
NautHashMap<Block, Material> lootDrops = new NautHashMap<Block, Material>();
NautHashMap<Block, HashSet<ItemStack>> lootDrops = new NautHashMap<Block, HashSet<ItemStack>>();
// Handle block ownership for explosion
if (event.getOwner() != null)
@ -1152,16 +1152,9 @@ public class Bridge extends TeamGame implements OreObsfucation
cur.getType() == Material.DIAMOND_ORE)
{
event.GetBlocks().remove(cur);
lootDrops.put(cur, new HashSet<ItemStack>());
switch (cur.getType())
{
case DIAMOND_ORE:
lootDrops.put(cur, Material.DIAMOND);
case COAL_ORE:
lootDrops.put(cur, Material.COAL);
default:
lootDrops.put(cur, cur.getType());
}
lootDrops.get(cur).addAll(cur.getDrops());
}
}
}
@ -1176,20 +1169,14 @@ public class Bridge extends TeamGame implements OreObsfucation
block.setType(Material.AIR);
Location drop = block.getLocation().clone().add(.5, .5, .5);
Item item = block.getWorld().dropItem(drop, new ItemStack(lootDrops.remove(block)));
for (ItemStack stack : lootDrops.remove(block))
{
Item item = block.getWorld().dropItem(drop, stack);
item.setMetadata("owner", new FixedMetadataValue(Manager.getPlugin(), event.getOwner().getUniqueId()));
}
}
}, 1);
}
@EventHandler(priority = EventPriority.MONITOR)
public void OreReveal(BlockBreakEvent event)
{
if (event.isCancelled())
return;
_ore.BlockBreak(event);
}, 1);
}
@EventHandler(priority = EventPriority.LOW)
@ -1314,7 +1301,6 @@ public class Bridge extends TeamGame implements OreObsfucation
}
}
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void dropItem(BlockBreakEvent event)
{
@ -1329,20 +1315,18 @@ 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;
event.setCancelled(true);
@ -1350,8 +1334,11 @@ public class Bridge extends TeamGame implements OreObsfucation
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