fix permanent item removal and battle items in inventory
This commit is contained in:
parent
bc77605dcd
commit
bf4de4471a
@ -12,10 +12,17 @@ import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
/**
|
||||
* Created by William (WilliamTiger).
|
||||
@ -142,4 +149,51 @@ public class HotbarPageListener implements Listener
|
||||
|
||||
i.remove();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateInv(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FASTER)
|
||||
return;
|
||||
|
||||
for (Player player : UtilServer.GetPlayers())
|
||||
{
|
||||
if (player.getOpenInventory() == null)
|
||||
continue;
|
||||
|
||||
if (player.getOpenInventory().getTopInventory() == null)
|
||||
continue;
|
||||
|
||||
if (!player.getOpenInventory().getTopInventory().getName().equals("Hotbar Editor"))
|
||||
continue;
|
||||
|
||||
for (Material mat : new Material[]{Material.DIAMOND_SWORD, Material.BOW, Material.FISHING_ROD, Material.ARROW})
|
||||
{
|
||||
boolean founditem = false;
|
||||
for (ItemStack item : player.getOpenInventory().getTopInventory().getContents())
|
||||
{
|
||||
if (item != null && item.getType() == mat)
|
||||
{
|
||||
founditem = true;
|
||||
}
|
||||
}
|
||||
if (player.getItemOnCursor() != null)
|
||||
{
|
||||
if (player.getItemOnCursor().getType() == mat)
|
||||
founditem = true;
|
||||
}
|
||||
|
||||
if (!founditem)
|
||||
{
|
||||
player.getOpenInventory().getTopInventory().addItem(new ItemStack(mat));
|
||||
}
|
||||
|
||||
|
||||
if (UtilInv.contains(player, null, mat, (byte) 0, 1, false, true, false))
|
||||
{
|
||||
UtilInv.removeAll(player, mat, (byte) 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user