Multiple Commands

Discussion in 'Plugin Development' started by javoris767, Dec 16, 2012.

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


    Hello, I'm making a plugin that will be like Factions, but a different theme. Basically I'm gonna have preset clans and I'm wondering if this is a way to shorten the amount of code. I'm gonna be using stuff like /nrpg join <clan> /nrpg members <clan> /nrpg info <clan> and stuff like that x-x

    Anyway to like put the args in different classes or something o-O

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


    you can have a CommandExecutor, that uses if..else if....else to filter out the first argument and pass it on to the next object to handle the command
  3. Offline

    ZeusAllMighty11 Retired Staff

    I don't think you can put arguments in different classes...

    why not just create methods and put those in different classes?

    Then when a command is used, execute the method
  4. Offline


  5. Offline


    How I would do it, Remember args[0] would be the first argument of your command then args[1] would be the clan the player chooses to check.
    Always remember the arguments start with 0!

    public boolean onCommands(CommandSender sender, Command cmd, String label, String[] args){
            if (cmd.getName().equalsIgnoreCase("nrpg")){
                if (args.length < 1){
                   //not enough arguments
                } else if (args[0].equalsIgnoreCase("join")){
                    //nrpg join
                } else if (args[0].equalsIgnoreCase("members")){
                    //nrpg members
                } else if (args[0].equalsIgnoreCase("info")){
                    //nrpg info
                return true;
            return false;
Thread Status:
Not open for further replies.

Share This Page