Bukkit Command Event Handlers

Discussion in 'Plugin Development' started by Unempl0yedNinja, May 27, 2015.

Thread Status:
Not open for further replies.
  1. Ok so im creating a plugin where I use different commands in another class and they do stuff. Now the problem i'm having is kinda 2 things.

    1.) I have tried to register the command on enable with this:
    this.getCommand("suspend").setExecutor(new commands());
    and then use:
    public boolean onCommand1(CommandSender sender, Command cmd, String commandLabel, String [] args){
    As well as making the commands class implement CommandExecutor

    This works perfectly if i only have one command. When i try to add another, the method name is already taken so i change this, however now it wont register this command.

    2.) I have also tried to register the command as an event with this on enable:
    this.getServer().getPluginManager().registerEvents(new commands(), this);
    and then using this event handler:
    @EventHandler
    public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {

    This does not work at all and doesn't even fire the event.

    So i guess my question is how do you make an event handler for multiple commands, or is there another way it should be done.

    Any help would be great, thank!
     
  2. Offline

    timtower Administrator Administrator Moderator

    @Unempl0yedNinja 1. The method name of an executor has to be onCommand
    2. A command isn't an event.
    You can set the same executor for multiple commands just fine.
     
Thread Status:
Not open for further replies.

Share This Page