[Solved] Nullpointer... Why?

Discussion in 'Plugin Development' started by np98765, Aug 24, 2012.

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


    I recently reorganized SimpleActions; all commands in their command executor class.

    When I tried to run it, I got:

    [SEVERE] Error occurred while enabling SimpleActions v1.6 (Is it up to date?)
    at com.lavacraftserver.SimpleActions.SimpleActions.onEnable(SimpleActions.java:17)
    So I went back and checked. Line 17 of the onEnable was:

    getCommand("bomb").setExecutor(new Bomb(this));
    So I moved it. Recompiled, re-ran, got the same error, this time on line 22:

    getCommand("gamemode").setExecutor(new Gamemode(this));

    onEnable (open)

    public void onEnable() {
    getLogger().info("SimpleActions has been enabled!");
    getCommand("cry").setExecutor(new Cry(this));
    getCommand("explode").setExecutor(new Explode(this));
    getCommand("fakedeop").setExecutor(new FakeDeop(this));
    getCommand("fakeop").setExecutor(new FakeOp(this));
    getCommand("fireball").setExecutor(new Fireball(this));
    getCommand("gamemode").setExecutor(new Gamemode(this));
    getCommand("givexp").setExecutor(new GiveXP(this));
    getCommand("heal").setExecutor(new Heal(this));
    getCommand("hug").setExecutor(new Hug(this));
    getCommand("ignite").setExecutor(new Ignite(this));
    getCommand("lol").setExecutor(new Lol(this));
    getCommand("murder").setExecutor(new Murder(this));
    getCommand("pm").setExecutor(new PM(this));
    getCommand("poke").setExecutor(new Poke(this));
    getCommand("slap").setExecutor(new Slap(this));
    getCommand("soar").setExecutor(new Soar(this));
    getCommand("sword").setExecutor(new Sword(this));
    getCommand("zap").setExecutor(new Zap(this));
    getCommand("bomb").setExecutor(new Bomb(this));

    Can anyone give any input as to why this is happening? If needed, I'll post the classes here -- Just didn't want to clog this post even more. :p

  2. Offline


    Does the command exist in the plugin.yml file? Does the class exist? Perhaps even the command you're using is already registered?
  3. Offline


    1) Yes, all commands are registered from before -- I'll check for typos again...
    2) Yep, the class certainly exists
    3) Already registered... ? Where do you mean?

    Think I found the problem.
  4. Offline


    Add this before you set the executor and see what the output is:

    if (getCommand("bomb") != null) {
        System.out.println("Bomb command is not null");
    } else {
        System.out.println("Bomb command is null!");
  5. Offline


    Ok, solved. I am so stupid sometimes...

    I told it to get "gamemode", but I never defined "gamemode", only "gm". -_-

    I'm an idiot ^^ (see above) :p

    Question about aliases... Where do I add them? plugin.yml? Can I use getCommand("gamemode").setAliases(list of strings) ?

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


    Ya under description you do something like:

    aliases: [gm, derp, herp]

    I think that's right.
  7. Offline


    Ok, thanks. Wasn't sure if I had to do both, or if just defining them in the plugin.yml was enough... Or if there were issues with something xD

    Thanks again!
Thread Status:
Not open for further replies.

Share This Page