Slot ID

Discussion in 'Plugin Development' started by Assult, Oct 27, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Assult

    Anyone know the ID of the Helmet slot in the normal Inventory?
     
  2. Offline

    RealDope

  3. Offline

    sgavster

    103
    [​IMG]Edit: ninjad T_T
     
    Assult likes this.
  4. Offline

    Assult

    Thank you all

    Can anyone tell me why this isnt working?
    Code:java
    1. @EventHandler
    2. public void onClick(InventoryClickEvent e){
    3. if(e.getSlotType() == SlotType.ARMOR){
    4. if(e.getSlot() == 103){
    5. e.setCancelled(true);
    6. }
    7. }
    8.  
    9. }


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  5. Offline

    sgavster

    Assult
    Are your events registered? And also make sure that e.getSlot() isn't null ;)
     
  6. Offline

    RealDope

    Not working? How so? An error? Or it just doesn't cancel?

    Add debug messages to see if it makes it past the the conditionals. You shouldn't need the SlotType.ARMOR check.
     
  7. Offline

    Assult

    The event is registered, I added a system.out.println to check, What do you mean e.getSlot() isnt null?
     
  8. Offline

    sgavster

    Assult
    if(e.getSlot() != null) {
    //code
    }
     
  9. Offline

    Assult

    That throws an error The operator != is undefined..
     
  10. sgavster
    Integer can't be null.

    Assult
    You said you added a debug line, how far did it go? Also try printing out the slot.
     
  11. Offline

    Assult

    Does'nt cancle
     
  12. Offline

    sgavster

    Code:
    if (e.getSlotType().equals(slotnumber) && !e.getCurrentItem().getType().equals(Material.AIR)) {
     
  13. Offline

    Assult

    I fixed it
    Its not slot 103, its 39
     
Thread Status:
Not open for further replies.

Share This Page