Creating subcommands in a subcommand

Discussion in 'Plugin Development' started by Muod, Dec 14, 2013.

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

    Muod

    I have a plugin with a main class and a class called UICommands. I made it so I can have a command per class. Like if I wanted /ui join, their would be a class called join.
    UICommands contains stuff like
    Code:
      private void loadCommands()
      {
        this.commands.put("join", new Join());
        this.commands.put("leave", new Leave());
      }
    Then in Join it would be like
    Code:
    public class Join
    implements SubCommand
    {
    public boolean onCommand(Player player, String[] args)
    {
        String pname = player.getName();
      return true;
    }
     
    public String help(Player p)
    {
      return ChatColor.GOLD + "/ui join " + ChatColor.DARK_RED + " - " + ChatColor.YELLOW + "allows you to join an arena. ";
    }
    }
    I want it so in the Join class It will create a submethod so you can do /ui join {SOMETHING}
     
  2. Offline

    The_Doctor_123

    So, are you asking how to create an interface called "SubCommand"?
     
  3. Offline

    Muod

    The_Doctor_123 , No no no no. I have one called SubCommand,
    Code:
    public abstract interface SubCommand
    {
      public abstract boolean onCommand(Player paramPlayer, String[] paramArrayOfString);
     
      public abstract String help(Player paramPlayer);
    }
    
    I need a code to go into Join.class/java that would make a subcommand IN the join class . What ever you put in the join class will happen when you do /ui join. I want to do /ui join zombie
     
  4. Offline

    The_Doctor_123

    Muod
    Err.. you mean like this?
    Code:java
    1. if (args.length > 1)
    2. {
    3. joinInstance.onCommand((Player) sender, Arrays.copyOfRange(args, 1, args.length - 1))
    4. }
    5. else
    6. {
    7. joinInstance.help((Player) sender);
    8. }
     
  5. Offline

    Muod

    The_Doctor_123, Something like that that goes in the Join class. It says if they do /ui join zombie, then ETC
     
  6. Offline

    The_Doctor_123

    Muod
    Erm, but Join implements SubCommand.. The code I gave you would go in the regular onCommand() method.
     
Thread Status:
Not open for further replies.

Share This Page