Hello, Recently me and my friend was making a new plugin but suddenly we got an error. we tried to fix that error but it doesn't works, can anyone help? ERROR: http://pastebin.com/4gub2bd5 CODE: http://pastebin.com/3jEaMPtY (if you can't find the line, this is the line: " if (((e.getAction() == Action.RIGHT_CLICK_AIR) || (e.getAction() == Action.RIGHT_CLICK_BLOCK)) && (p.getItemInHand().getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Kits Shop"))) ") Best wishes, Eyal. ( btw: I dont know if this is the right forum to ask help ;{ )
Code (Text): p.getItemInHand() will return null if the player is not holding an item in their hand. Just do a null check first: Code (Text): if (((e.getAction() == Action.RIGHT_CLICK_AIR) || (e.getAction() == Action.RIGHT_CLICK_BLOCK)) && (p.getItemInHand() != null && p.getItemInHand().getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Kits Shop"))) ")
Let me guess without even looking at the error: Either your item is null or the items meta is null or the items display-name is null.
I think it might work ! Code (Text): if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIHGT_CLICK_BLOCK) { if(!(p.getItemInHand().hasItemMeta())) return; if(p.getItemInHand.getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Kit Shop")) { //More code here } }