Fix players without permission to modify inventories inserting items

This commit is contained in:
Jikoo
2016-03-01 12:22:26 -05:00
parent 2d7522554c
commit 17b0cb6efe
2 changed files with 9 additions and 2 deletions

View File

@@ -20,6 +20,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
public class OpenInvInventoryListener implements Listener { public class OpenInvInventoryListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
@@ -32,4 +33,11 @@ public class OpenInvInventoryListener implements Listener {
} }
// } // }
} }
@EventHandler(priority = EventPriority.NORMAL)
public void onInventoryDrag(InventoryDragEvent event) {
if (!OpenInv.inventoryAccess.check(event.getInventory(), event.getWhoClicked())) {
event.setCancelled(true);
}
}
} }

View File

@@ -48,8 +48,7 @@ public class AnySilentChest implements IAnySilentChest {
if (world.getType(new BlockPosition(x, y + 1, z)).l() || hasOcelotOnTop(world, x, y, z)) if (world.getType(new BlockPosition(x, y + 1, z)).l() || hasOcelotOnTop(world, x, y, z))
return true; return true;
BlockPosition position = new BlockPosition(x, y, z); int id = Block.getId(world.getType(new BlockPosition(x, y, z)).getBlock());
int id = Block.getId(world.getType(position).getBlock());
// If block next to chest is chest and has a block or ocelot on top // If block next to chest is chest and has a block or ocelot on top
if (isBlockedChest(world, id, x - 1, y, z)) if (isBlockedChest(world, id, x - 1, y, z))