Class CommandManager

java.lang.Object
de.rexlcloud.core.command.CommandManager

public class CommandManager extends Object
Registers console commands of modules; get it with CloudModule.getCommandManager().
public class MyCommands {
    @CommandMethod("greet <player>")
    @CommandDescription("Greets a player")
    public void greet(@Argument(value = "player", suggestions = "players") String player) {
        Console.info("Hello %s", player);
    }

    @Suggestion("players")
    public List<String> players() {
        return List.of("Notch", "jeb_");
    }
}

getCommandManager().registerCommands(this, new MyCommands());
  • Constructor Details

    • CommandManager

      protected CommandManager(de.rexlcloud.core.command.CommandRegistry commandRegistry)
      Internal: created by the master.
  • Method Details

    • registerCommands

      public void registerCommands(@NonNull @NonNull CloudModule cloudModule, @NonNull @NonNull Object object)
      Registers the CommandMethod, Suggestion, CommandPreProcessor and ObjectParser methods of an object.
      Parameters:
      cloudModule - the module, for unregistering its commands when it is disabled
      object - the object with the annotated methods
    • unregisterAllCommands

      public void unregisterAllCommands(@NonNull @NonNull CloudModule cloudModule)
      Removes all commands of a module.
    • unregisterCommands

      public void unregisterCommands(@NonNull @NonNull CloudModule cloudModule, @NonNull @NonNull Object object)
      Removes the commands of one object.
    • getRegisteredCommands

      public HashMap<CloudModule, ArrayList<Object>> getRegisteredCommands()
      The command objects each module registered.