What would be the best way to stop a player from adding an item to a dispenser, with a hopper or with dragging it in from your inventory.
Make an InventoryClickEvent and check if e.getInventory() == Inventory.DISPENSER. Then cancel the event Something like that. I'm not on my IDE but that's basically it.
I worked with this in my IDE and I came up with this: Code (Text): //Cancel InventoryClickEvent if Inventory type is a dispenser public void noAdd(InventoryClickEvent ice){ if(ice.getClickedInventory().getType() == InventoryType.DISPENSER){ ice.setCancelled(true); } } However if this doesn't work it would be with this line: (Never tried to work with cancelling an ICE before) Code (Text): ice.setCancelled(true); Let me know if this works!
You have to set the clicked item to null (or '0') and then add the item thry clicked with back to their inventory