Class AbstractCommand

  • All Implemented Interfaces:
    Command

    public abstract class AbstractCommand
    extends java.lang.Object
    implements Command
    Base implementation of Command that stores name and aliases.

    Example:

     Command echo = new AbstractCommand("echo", "e") {
         @Override
         public Object execute(CommandSession session, String[] args) {
             session.out().println(String.join(" ", args));
             return null;
         }
     };
     
    Since:
    4.0
    See Also:
    Command
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractCommand​(java.lang.String name, java.lang.String... aliases)
      Creates a new command with the given name and optional aliases.
    • Constructor Detail

      • AbstractCommand

        protected AbstractCommand​(java.lang.String name,
                                  java.lang.String... aliases)
        Creates a new command with the given name and optional aliases.
        Parameters:
        name - the primary command name
        aliases - optional alias names
    • Method Detail

      • name

        public java.lang.String name()
        Description copied from interface: Command
        Returns the primary name of this command.
        Specified by:
        name in interface Command
        Returns:
        the command name, never null
      • aliases

        public java.util.List<java.lang.String> aliases()
        Description copied from interface: Command
        Returns alternative names for this command.

        The default implementation returns an empty list.

        Specified by:
        aliases in interface Command
        Returns:
        the list of aliases, never null