Solved null return error.

Discussion in 'Spigot Plugin Help' started by _DuB_, Jun 30, 2016.

  1. So basically I am making a gui plugin and I want to return the code when player clicks a empty slot.

    Here is my code:
    Code (Text):
    if (e.getCurrentItem().getItemMeta() == null) return;
    Error:
    http://prntscr.com/bmyds6
     
  2. Also
    Code (Text):
    e.getCurrentItem()
    could be null so you have firstly to check:
    Code (Text):
    if (e.getCurrentItem == null) return;
    Then:
    Code (Text):
    if (e.getCurrentItem().getItemMeta() == null) return;
     
    • Like Like x 1
  3. Thanks it works fine now :)
     
    • Agree Agree x 1