1
0
mirror of https://e.coding.net/circlecloud/MenuProtect.git synced 2024-12-27 16:38:48 +00:00

添加物品移动事件的检测...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2015-11-30 17:00:21 +08:00
parent dfc198d43a
commit bea6e4867d

View File

@ -7,12 +7,10 @@ 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.InventoryMoveItemEvent;
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;
@ -28,7 +26,15 @@ public class ProtectListener implements Listener {
this.plugin = plugin;
}
@EventHandler
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInvMove(final InventoryMoveItemEvent e) {
final ItemStack ci = e.getItem();
if (MarkUtil.hasMark(ci)) {
e.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInvPickup(final InventoryPickupItemEvent e) {
final ItemStack ci = e.getItem().getItemStack();
if (MarkUtil.hasMark(ci)) {
@ -41,7 +47,7 @@ public class ProtectListener implements Listener {
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)) {
if (inv.getHolder() == null) {
return;
}
final int solt = e.getSlot();
@ -54,7 +60,7 @@ public class ProtectListener implements Listener {
}
}
@EventHandler
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerHandlerItem(final PlayerItemHeldEvent e) {
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
@ -78,7 +84,7 @@ public class ProtectListener implements Listener {
});
}
@EventHandler
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerPickup(final PlayerPickupItemEvent e) {
final ItemStack ci = e.getItem().getItemStack();
if (MarkUtil.hasMark(ci)) {