Solved NullPointerException Using EnchantmentAPI

Discussion in 'Plugin Development' started by MCJoshua345, Jan 17, 2016.

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



    (I had to put these in pastebins because I was exceeding the character limit)

    Main Class:

    AlphaShopInventory Class:

    SharpnessPlusEnchantment Class (I don't think this would help in any way, but I'm going to post it anyways.):

    The plugin was running fine when suddenly I restart the server and I get this error. On server startup I get this error (Startup error below) after the plugin enables. I think the problem has something to do with the EnchantmentAPI (I'm using this). Oddly, this disables every single command in my plugin. What I get when I try to use one is "/" and then the command name, just like I defined the command in the plugin.yml but there is no code. All classes that I think may be related to this problem are above. I was getting this problem except with a different custom enchantment, but then I changed it and it "worked" again. Sometimes, I restart the server, don't get a error, but the same effects happen. This could just be MultiCraft deleting the lines, because on almost every startup, error or not, is says it skips lines apparently. I've tried reading the StackTrace, but I just can't find the problem with that line. I'm pretty sure (the only reason I'm not saying absolutely is because I'm getting a NullPointerException error with it.) there is nothing wrong with the line I'm getting problems with, nothing null at all. (The line I'm talking about is below under the "Possible problematic lines" section) So I hope you can help me. I'm sorry about any ignorance I may have or time I may waste. I tried to follow "How to make a Plugin Development Thread" as best as I could. Thanks for the help.

    What you can do to recreate the problem:
    Restarting the server.

    Possible problematic lines:
    Line 199 class AlphaShopInventory

    Error Messages:
    Startup Log (where the error is occuring):
    (Sorry its upside down I'm using a server host.)

    What you have tried:
    Double checking that this enchantment exists, copy/pasting the name of it, switching around the onEnable line order, and the registerClasses() line order. Reading the StackTrace.
  2. Offline


    17.01 15:54:26 [Server] INFO at com.infinity.survival.story.AlphaShopInventory.<clinit>( ~[?:?]
    17.01 15:54:26 [Server] INFO Caused by: java.lang.NullPointerException
    17.01 15:54:26 [Server] INFO java.lang.ExceptionInInitializerError
    199:EnchantmentAPI.getEnchantment("Alpha's Blessing").addToItem(dsword, 1);
    Your problem is that something is null on this line.

    Is EnchantmentAPI Null?
    Is the enchantment you get null?
    mine-care likes this.
  3. Offline


    EnchantmentAPI is not Null.
    I just triple checked. The enchantment is not null.
  4. Offline


    Do a null check in there.
  5. Offline


    How do I do that in a inventory?
    EDIT: Found out how.

    It turns out the reason was because I set the isEnabled part of the enchantments to false, to try to prevent people from getting them... so now i removed that line and it worked. Thanks @blok601 and @Zombie_Striker for your help. I really have to find a way to disable those enchantments without crashing the server...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jan 18, 2016
    blok601 likes this.
Thread Status:
Not open for further replies.

Share This Page