Solved getCommand().setExecutor() causing nullpointerexception

Discussion in 'Plugin Development' started by xorinzor, Aug 14, 2014.

Thread Status:
Not open for further replies.
  1. Hello,

    I'm trying to add a command to my plugin but for some reason the command isn't getting detected in the plugin.yml file, I checked it with and it passes so I don't think its incorrectly formatted.

    I've even tried changing commands that worked before into the new command and it doesn't seem to help.

    my plugin.yml:
    name: Warbuild
    author: xorinzor
    version: 1.0
    main: com.jorinvermeulen.warbuild.Warbuild
    depend: [BarAPI,TabAPI,WorldEdit,PlayEffect]
        aliases: wb
        description: This is a demo command
        usage: /warbuild
        permission: warbuild.terminal
        permission-message: You don't have the required permissions to access this command
        description: Define a new structure on the map
        usage: /structure
        permission: warbuild.terminalcommand
        permission-message: You don't have the required permissions to access this command
        description: Gives access to all warbuild commands
          warbuild.terminalcommand: true
          warbuild.mapbbuild: true
          description: Allows you to interact with the Warbuild server plugin
          default: op
    My main class:
    1. public class Warbuild extends JavaPlugin {
    2. /**
    3.   * eventhandler for the enabling of the plugin
    4.   */
    5. @Override
    6. public void onEnable() {
    7. instance = this;
    9. //Command listeners
    10. getCommand("warbuild").setExecutor(new WBCommandTest());
    11. getCommand("structure").setExecutor(new CreateStructure());
    12. }
    14. /**
    15.   * eventhandler for the disabling of the plugin
    16.   */
    17. @Override
    18. public void onDisable() {
    19. super.onDisable();
    21. Logger.LogInfo("Warbuild server has been shutdown");
    22. }
    23. }

    getCommand("structure") in this case is null (and thus causing the nullpointerexception) but I have no idea why.

    Any ideas?

    Nevermind, it seems even though yamllint reported no errors it was the ' in permission-message that was messing things up.

    Removing the ' solved it :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 9, 2016
  2. Offline


    xorinzor stacktrace?
    It seems you already solved it.
  3. the stacktrace was just pointing to getCommand("structure").setExecutor(new CreateStructure()); because getCommand("structure") was null, didn't contain any other useful information.

    It seems the plugin.yml just wasn't completely parsed (despite Bukkit not giving any error and just seemingly accepting the entire plugin.yml file, which I find a bit odd)
Thread Status:
Not open for further replies.

Share This Page