[SEVERE] Could not pass event PLAYER_INTERACT to EnchantmentStore java.lang.NullPointerException

Discussion in 'Plugin Development' started by Derthmonuter, Feb 25, 2012.

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

    Derthmonuter

    This error is spamming the ever-loving hell out of my console.
    The plugin itself is running flawlessly though.

    I followed the "Caused by" bit of my error back to find the line of code causing all of this...

    Code:
            if (e.getClickedBlock().getType() == Material.BOOKSHELF && e.getAction() == Action.RIGHT_CLICK_BLOCK) {
                Player player = e.getPlayer();
    That first line is where the error is actually traced to, but I have a feeling the second line might also be doing something weird.
    Does anyone have any suggestions on how to fix this?
     
  2. Offline

    Gravity

    Is there more to the error? Please refer to this post for info on debugging stack-traces.
     
  3. Offline

    Derthmonuter

    Oops. Thanks, I'll read that and edit accordingly.
    EDITED

    Okay, I did some detective work. Looks like this is thrown whenever one of my users right left-clicks air.
    Any help now?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 24, 2016
  4. Offline

    GoalieGuy6

    The null pointer exception is thrown when a user clicks air because e.getClickedBlock() will return null in this case. Check if the the action is equal to Action.RIGHT_CLICK_BLOCK before calling e.getClickedBlock() and you should be fine.
     
  5. Offline

    XxPowerKingxX

    if (b.getType() == Material.AIR)
    return;


    This should fix it :)
     
  6. Offline

    Derthmonuter

    Thank you very much, this worked like a charm.
     
Thread Status:
Not open for further replies.

Share This Page