[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


    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...

            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


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


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

    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


    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


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

    This should fix it :)
  6. Offline


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

Share This Page