Solved Spamming Stacktraces

Discussion in 'Plugin Development' started by Plumstar, Nov 30, 2015.

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

    Plumstar

  2. Offline

    teej107

    DoggyCodeâ„¢ likes this.
  3. Offline

    sgavster

    Like @teej107 said, read your own stacktrace. That thread says how to do it, here, because I'm nice, these are the lines you need to read:


    HTML:
    5:06:13 PM Caused by: java.lang.NullPointerException
    5:06:13 PM at me.plumstar.lootmenu.LootMenu.onInteract(LootMenu.java:161) ~[?:?]
     
  4. Offline

    Zombie_Striker

  5. Offline

    Plumstar

    Ok, so I read the thread you posted above and I read the stacktrace and I came to this line. http://prntscr.com/98xp5y But I still don't see anything wrong? What am I missing
     
  6. Offline

    teej107

    @Plumstar Do you know what a NullPointerException is and what causes one to happen?
     
  7. Offline

    Plumstar

    It is when you try to use null where a object is supposed to be.
     
  8. Offline

    Zombie_Striker

    @Plumstar
    Correct, and since you know that is the line that is null, one or more of the following things must be null:
    • p
    • The Item in the hand (air)
    • The Item Meta (are you sure is has item meta)
    • Display name (unlikely)
     
  9. Offline

    teej107

    @Plumstar It'll help to read the Bukkit documentation for those methods.
     
  10. Offline

    Scimiguy

    You should be checking for both item, and its meta before using either of them to be honest
     
  11. Offline

    mcdorli

    Actually, it is probably the display name. The not-renamed items don't have one.
    @Plumstar Do a item.getItemMeta().hasDisplayName() check before the line
     
  12. Offline

    Zombie_Striker

    @mcdorli
    He should also check if it has itemmeta. He should also check to make sure the ItemInHand is not null (because he is not checking the type, or is he checking if its air). All you need is someone who has nothing in their hand to left click and he'll get errors galore.
     
  13. Offline

    mcdorli

    ItemStack#getItemMeta() returns a new ItemMeta, if the item doesn't have one.
     
    Zombie_Striker likes this.
Thread Status:
Not open for further replies.

Share This Page