Could not pass event InventoryClickEvent

Discussion in 'Plugin Development' started by PlayinCOD2132, Mar 6, 2014.

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

    PlayinCOD2132

  2. Offline

    Gater12

    PlayinCOD2132
    The display name might be null (If it was not renamed in an anvil). Check if it's not null first before getting it.
     
  3. Offline

    Minesuchtiiii

    change:
    if (e.getCurrentItem().getItemMeta().getDisplayName()
    to
    if(e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase())
     
  4. Offline

    PlayinCOD2132

    Should it be: if (e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase())
    .contains("Default Kit")) {
    e.setCancelled(true);

    now?

    This code won't even allow me to click on the item in the inventory.

    I was curious about what this means, what do you mean by display name?

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

    Wizehh

    PlayinCOD2132
    PHP:
    // null check
    if (e.getClicked().getItemMeta() != null) {
        if (
    e.getClicked().getItemMeta().getDisplayName() != null) {
            if (
    e.getClicked().getItemMeta().getDisplayName().equalsIgnoreCase("foo")) {
                 
    // Execute
            
    }
        }
    }
     
  6. Offline

    PlayinCOD2132

    So what do I do next?
     
  7. Offline

    Wizehh

    Whatever you want to happen when the player clicks the item with the specified name.
     
  8. Offline

    PlayinCOD2132

    No I mean what do I do with that code?
     
  9. Offline

    Wizehh

    The code should go in your 'Menu.java' class, near line 101.
     
  10. Offline

    Minesuchtiiii

    I think the ItemMeta can'tbe null?!
    Because every item has got an item meta .. like "Stone Sword"
     
Thread Status:
Not open for further replies.

Share This Page