From 17b0cb6efef38acf175f613a01aeef7b8623b651 Mon Sep 17 00:00:00 2001 From: Jikoo Date: Tue, 1 Mar 2016 12:22:26 -0500 Subject: [PATCH] Fix players without permission to modify inventories inserting items --- src/com/lishid/openinv/OpenInvInventoryListener.java | 8 ++++++++ .../lishid/openinv/internal/v1_9_R1/AnySilentChest.java | 3 +-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/com/lishid/openinv/OpenInvInventoryListener.java b/src/com/lishid/openinv/OpenInvInventoryListener.java index 2cd6b7c6..c3a0a7cf 100644 --- a/src/com/lishid/openinv/OpenInvInventoryListener.java +++ b/src/com/lishid/openinv/OpenInvInventoryListener.java @@ -20,6 +20,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryDragEvent; public class OpenInvInventoryListener implements Listener { @EventHandler(priority = EventPriority.NORMAL) @@ -32,4 +33,11 @@ public void onInventoryClick(InventoryClickEvent event) { } // } } + + @EventHandler(priority = EventPriority.NORMAL) + public void onInventoryDrag(InventoryDragEvent event) { + if (!OpenInv.inventoryAccess.check(event.getInventory(), event.getWhoClicked())) { + event.setCancelled(true); + } + } } \ No newline at end of file diff --git a/src/com/lishid/openinv/internal/v1_9_R1/AnySilentChest.java b/src/com/lishid/openinv/internal/v1_9_R1/AnySilentChest.java index e87bfc05..ea73c6a8 100644 --- a/src/com/lishid/openinv/internal/v1_9_R1/AnySilentChest.java +++ b/src/com/lishid/openinv/internal/v1_9_R1/AnySilentChest.java @@ -48,8 +48,7 @@ public boolean IsAnyChestNeeded(Player p, int x, int y, int z) { if (world.getType(new BlockPosition(x, y + 1, z)).l() || hasOcelotOnTop(world, x, y, z)) return true; - BlockPosition position = new BlockPosition(x, y, z); - int id = Block.getId(world.getType(position).getBlock()); + int id = Block.getId(world.getType(new BlockPosition(x, y, z)).getBlock()); // If block next to chest is chest and has a block or ocelot on top if (isBlockedChest(world, id, x - 1, y, z))