Solved NPE on itemstacks.gettype().equals(Material.flint_and_steel)

Discussion in 'Plugin Development' started by welsar55, Mar 14, 2013.

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

    welsar55

    i have no clue why this makes a error
    Code:
                        for(ItemStack itemstacks : pinv.getContents())
                        {
                            if(itemstacks.getType().equals(Material.FLINT_AND_STEEL))
                            {
                                if(itemstacks.getDurability() != 0)
                                {
                                    itemstacks.setDurability((short) (itemstacks.getDurability() - 1));
                                }
                            }
                        }
    the codes points to line 93
    Code:
    if(itemstacks.getType().equals(Material.FLINT_AND_STEEL))
    any clue why that is giving a NPE?
     
  2. Offline

    ZeusAllMighty11

    Code:
    if(itemstacks.getType() != null && itemstacks.getType().equals(Material.FLINT_AND_STEEL)){
     
    }
    
     
  3. Offline

    welsar55

    ah ty that worked
     
Thread Status:
Not open for further replies.

Share This Page