Help with GUI

Discussion in 'Spigot Plugin Development' started by TheFuzzyHead5, May 29, 2017.

  1. Okay.. so I have a dispenser GUI and a player is only allowed to place a certain item in the middle slot (I think it's ID is 4).

    ...now begs the question how do I do this.

    I have been trying this for a while: I have the InventoryClickEvent, and am checking the e.getAction(). I am then checking if the item is one of the allowed items (for this example lets say APPLE) then allowing it to be placed in.

    I'm having problems doing this and some pseudo code would work wonders <3
     
  2. Check slot, check item player wants to put in, if good item, allow else deny.
     
  3. If you are not sure what slot ID the middle slot is in the dispenser send a message to the player giving the slot ID, using this:
    Code (Text):
    Player#sendMessage(InventoryClickEvent#getSlot());
     
  4. Share your code, perhaps theres a mistake in it?
     
  5. Code (Text):
    if(slot != 3){
          event.setCancelled(true);
         return;
    }

    if(item is not good item){
    event.setCancelled(true);
         return;
    }

    item is good item, let the user do the stuff.
     
  6. share your whole code, i dont think anyone here would copy anything from you,
    Youll find that most of the times things dont work, its because of a mistake in the code... the code you pasted above should be right, how exacly do you compare your "good item" to a "bad item" ?