NullPointerException while checking the lore

Discussion in 'Plugin Development' started by Freack100, Nov 7, 2013.

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

    Freack100

    Hello comunity,
    I know that I'm new here but I need your help!
    I'm working on a Gun Game plugin and it won't let me delete specific items.
    Code:java
    1.  
    2. private void delGameItems(Player p)
    3. {
    4. Inventory inv = p.getInventory();
    5.  
    6. for(ItemStack is : inv){
    7. if(is != null && ! is.equals(Material.AIR)){
    8. if (is.hasItemMeta()) {
    9. ItemMeta itemmeta = is.getItemMeta();
    10. List<String> lore = itemmeta.getLore();
    11. if(lore.contains("[GunGame]")){
    12. inv.removeItem(is);
    13. }
    14. }
    15.  
    16. }
    17. }
    18. }
    19.  

    What is wrong with that?
     
  2. Offline

    clienthax

    lore can be null, you should check if it has lore with hasLore()
     
Thread Status:
Not open for further replies.

Share This Page