Since when does (some JavaPlugin).getDescription() return null?

Discussion in 'Plugin Development' started by Kierrow, Dec 21, 2011.

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

    Kierrow

    So I'm having this problem, that I consider quite unusual since I have not done this for the first time.

    Btw, I'm using CraftBukkit build #1597.

    This is my issue:
    I have my JavaPlugin classes structured like this:
    JavaPlugin​
    -> MyPluginSuperclass​
    -> MyPluginClass​

    In "MyPluginSuperclass" I override both the onEnable and the onDisable methods,
    and I define this final field:

    Code:
    public final PluginDescriptionFile info;
    
    // [...]
    
    public MyPluginSuperclass() {
        info = this.getDescription();
    }
    So then later on in the 'onEnable' method, I use the 'info' object to instantiate another class.
    However, this.getDescription() appears to have returned null, so I get a NullPointerException.

    Is this a bug? - Or am I doing something wrong?

    Regards,
    Kierrow

    EDIT:
    My plugin.yml:

    Code:
    name: KierrowBase
    version: 0.0.12
    
    author: Kierrow
    
    main: net.kierrow.base.MyPluginClass
    load: STARTUP
     
  2. Offline

    Chiller

    Post your plugin.yml that is in the root
     
  3. Offline

    Kierrow

    Posted it.

    That won't help me, unfortunately.
    Plus, there's no such method in the Server class. - You must have mixed something up...

    And just to be clear, why would you need a decompiler?

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

    theguynextdoor

    What description is it suppose to be getting?
     
  5. Offline

    Kierrow

  6. Offline

    Chiller

    Try: public PluginDescriptionFile info;
    Instead of: public final PluginDescriptionFile info;
     
  7. You can't instantiate the PluginDescriptionFile in your constructor, it has to be done in/after your onEnable() afaik.
     
  8. Offline

    desht

    You can't call getDescription() in the constructor - that's too early. Your plugin.yml hasn't been loaded at that point. Move the call to onLoad() or onEnable() and you should be good.
     
Thread Status:
Not open for further replies.

Share This Page