Transferring commands to Command Executor class (Help?)

Discussion in 'Plugin Development' started by TheLazeboy, May 3, 2013.

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

    TheLazeboy

    This is a simple question, how do I begin and transfer commands from my main class to MyCommandExecutor class? I do have multiple commands (as to why I would be using this).
     
  2. Offline

    Burnett1

    Make a new class let it implement CommandExecutor and the add your onCommand. In your main class do getCommand("COMMANDNAME").setExecutor(new Classname(this));
     
  3. Offline

    TheLazeboy

    I already did that for one, but what about the commands now in the MyCommandExecutor class? How do I separate them? Where do I use the onCommand(...)? How often do I use the onCommand(...)?
     
  4. Offline

    chasechocolate

    Only once, but for multiple commands, simply perform multiple if-statements.
     
  5. Offline

    Burnett1

    Code:
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
           
            Player p = (Player) sender;
           
            if(cmd.getName().equalsIgnoreCase("command")){
                //check for more stuff.
            }
           
            if(cmd.getName().equalsIgnoreCase("another")){
                //do more checks.
            }
               
            return false;
        }
     
Thread Status:
Not open for further replies.

Share This Page