I try to stop the InventoryClickEvent for the players that aren't op, with set the InventoryClickEvent to cancel, but the code don't work, ALL players can't move items in their inventory, how I set that the op can move the items? The code: Code: @EventHandler public void onClickInventory(InventoryClickEvent event){ if(event.getWhoClicked().isOp()) { event.setCancelled(false); return; } if(!event.getWhoClicked().isOp()) { event.setCancelled(true); return; } }
Event.getWhoClicked does not return a player so try this, but make sure you learn from it! Btw it works! Code:java @EventHandler public void onClickInventory(InventoryClickEvent event){ Player player = Bukkit.getPlayer(event.getWhoClicked().getName()); if(!player.isOp()) { event.setCancelled(true); } }