Bukkit's /help command

Discussion in 'Plugin Development' started by Kierrow, Nov 6, 2011.

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

    Kierrow

    Hi,

    as most of you know, the plugin Essentials sort of overrides Bukkit's intern /help command.
    I'd like to do that as well, also with other commands.

    How can I achieve this?

    -Kierrow
     
  2. You can register a CommandExecutor to a certain command label.
    In your onEnable() do this:
    Code:
    CommandExecutor executor = new MyHelpCommandExecutor();
    getCommand("help").setExecutor(executor);
    You'd have to make a class named MyHelpCommandExecutor which extends CommandExecutor.
    It has the onCommand() method.
    .... i think?

    Wait, you'd have to register it in the plugin.yml too.
    I think this will not go well.

    Let me know how it goes. :)

    Edit: maybe you don't have to register it at all
    Edit again: i guess try and do essentials.getCommand("help");

    Yeah, I tried it. Awesome.

    If you don't know how:

    get the essentials plugin like this
    Code:
    Plugin plugin getServer().getPluginManager().getPlugin("Essentials");
    if(plugin != null && plugin instanceof Essentials)
    {
            // plugin exists
           // and it is the one you have added as External JAR
            essentials = (Essentials) plugin;//type casting
    }
    then set the executor like i said
    Code:
    CommandExecutor executor = new MyHelpCommandExecutor();
    getCommand("help").setExecutor(executor);
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 21, 2016
  3. Offline

    Kierrow

    but there must be a way to get a callback on that command without having Essentials.
    I mean, they must have gotten it from somewhere as well...

    I'll just play around with it a little, see how it goes
     
  4. True,

    You could check out the Essentials plugin's source code.
    And take a look how they did it.

    You can google "minecraft essentials github"

    Just do this:
    Code:
    CommandExecutor executor = new MyHelpCommandExecutor();
    getCommand("help").setExecutor(executor);
    Register the help command in the plugin.yml (it seams to work fine, no conflicts)

    All that Essentials does is: Allow you to turn off the help command in the config file.
    I think Essentials does NOT do anything special to override Minecraft's/Bukkit's help command.

    Conclusion, just do it!

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

Share This Page