Help with dispenser stuff

Discussion in 'Spigot Plugin Development' started by Creepermanthe3rd, Apr 27, 2017.

  1. 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.
  2. 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.
    • Agree Agree x 1
  3. 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){
    However if this doesn't work it would be with this line: (Never tried to work with cancelling an ICE before)
    Code (Text):
    Let me know if this works!
    #3 Waldxn, Apr 27, 2017
    Last edited: Apr 27, 2017
  4. You have to set the clicked item to null (or '0') and then add the item thry clicked with back to their inventory