1
0
mirror of https://e.coding.net/circlecloud/MenuProtect.git synced 2024-11-21 10:48:46 +00:00

修复点击事件...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2015-11-30 16:51:20 +08:00
parent db1e3edb4e
commit dfc198d43a

View File

@ -4,10 +4,16 @@ import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryPickupItemEvent;
import org.bukkit.event.player.PlayerItemHeldEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.AnvilInventory;
import org.bukkit.inventory.CraftingInventory;
import org.bukkit.inventory.DoubleChestInventory;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
@ -30,22 +36,23 @@ public class ProtectListener implements Listener {
}
}
/*
* @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
* public void onItemClick(final InventoryClickEvent e) {
* final Player p = (Player) e.getWhoClicked();
* final ItemStack ci = e.getCurrentItem();
* final Inventory inv = e.getInventory();
* final int solt = e.getSlot();
* try {
* if (MarkUtil.hasMark(ci)) {
* inv.setItem(solt, new ItemStack(Material.AIR));
* p.closeInventory();
* }
* } catch (final Exception ex) {
* }
* }
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onItemClick(final InventoryClickEvent e) {
final Player p = (Player) e.getWhoClicked();
final ItemStack ci = e.getCurrentItem();
final Inventory inv = e.getInventory();
if (inv.getHolder() == null || !(inv instanceof PlayerInventory || inv instanceof CraftingInventory || inv instanceof AnvilInventory || inv instanceof DoubleChestInventory)) {
return;
}
final int solt = e.getSlot();
try {
if (MarkUtil.hasMark(ci)) {
inv.setItem(solt, new ItemStack(Material.AIR));
p.closeInventory();
}
} catch (final Exception ex) {
}
}
@EventHandler
public void onPlayerHandlerItem(final PlayerItemHeldEvent e) {