IDEK NullPointer Exception

Discussion in 'Plugin Development' started by dbaum102, May 12, 2016.

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

    dbaum102

    Code:
    if(l.getType()==Material.AIR||l.getType()==null){return;}
    Only afected for some reasson when the item is a stack... the normal one item works...It works sometimes doesnt other wtf.
     
  2. Offline

    Zombie_Striker

    @dbaum102
    If the type is air, then the itemstack is null. If the type is null, the itemstack is null. Either way, for this to be true, this would have to throw an NPE.
     
  3. Offline

    dbaum102

    Thanks for the response, are you saying this is unnessary code?


    Edit:
    So i removed that line and now this next line is the NPE.
    Code:
    if(l.getType()==new ItemStack(Material.getMaterial(main.plugin.getConfig().getIntegerList("sell."+names[i].toLowerCase()+".idList").get(x+1)),main.plugin.getConfig().getIntegerList("sell."+names[i].toLowerCase()+".amountList").get(x+1), damage.get(x+1)).getType()){
    
     
    Last edited: May 12, 2016
  4. Offline

    Zombie_Striker

    @dbaum102
    This can be reduced to
    Code:
    if(l!=null && l.getType()== Material.getMaterial(main.plugin.getConfig().getIntegerList("sell."+names.toLowerCase()+".idList").get(x+1))){
     
  5. Offline

    dbaum102

    tyvm worked, it was just a little laggy and now its good :)
     
Thread Status:
Not open for further replies.

Share This Page