Fixed bug with dropping gadget items interfering with games and being set in the wrong slot with the wrong name

This commit is contained in:
libraryaddict 2015-02-01 08:04:19 +13:00
parent 0c2054ac32
commit eccc2f2fb0

View File

@ -80,19 +80,21 @@ public abstract class ItemGadget extends Gadget
}
@EventHandler
public void orderThatChest(final PlayerDropItemEvent event)
public void orderThatChest(PlayerDropItemEvent event)
{
if (event.getItemDrop().getItemStack().getType() == GetDisplayMaterial())
if (IsActive(event.getPlayer()) && event.getItemDrop().getItemStack().getType() == GetDisplayMaterial())
{
final Player player = event.getPlayer();
Bukkit.getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
{
public void run()
{
if (event.getPlayer().isOnline())
if (player.isOnline())
{
event.getPlayer().getInventory().remove(GetDisplayMaterial());
event.getPlayer().getInventory().setItem(4, ItemStackFactory.Instance.CreateStack(GetDisplayMaterial(), GetDisplayData(), 1, F.item(GetName())));
UtilInv.Update(event.getPlayer());
player.getInventory().remove(GetDisplayMaterial());
player.getInventory().setItem(Manager.getActiveItemSlot(), ItemStackFactory.Instance.CreateStack(GetDisplayMaterial(), GetDisplayData(), 1, F.item(Manager.getInventoryManager().Get(player).getItemCount(GetName()) + " " + GetName())));
UtilInv.Update(player);
}
}
});