co.aikar.commands

## Class BaseCommand

- java.lang.Object
- - co.aikar.commands.BaseCommand

Direct Known Subclasses:
  ForwardingCommand

    public abstract class BaseCommand
    extends Object

A Base command is defined as a command group of related commands. A BaseCommand does not imply nor enforce that they use the same root command.

It is up to the end user how to organize their command. you could use 1 base command per command in your application.

Optionally (and encouraged), you can use the base command to represent a root command, and then each actionable command is a sub command

### Constructor Summary

Constructors
Constructor and Description
`BaseCommand()`
`BaseCommand(@Nullable String cmd)` Deprecated. Please switch to `CommandAlias` for defining all root commands.

### Method Summary

All Methods Instance Methods Concrete Methods Deprecated Methods
`boolean` `canExecute(CommandIssuer issuer, RegisteredCommand<?> cmd)` Deprecated. See `CommandConditions`
`void` `doHelp(CommandIssuer issuer, String... args)`
`void` `doHelp(Object issuer, String... args)`
`void` `execute(CommandIssuer issuer, String commandLabel, String[] args)`
`CommandHelp` `getCommandHelp()` Deprecated. Unstable API
`String` `getContextFlags(Class<?> cls)`
`CommandIssuer` `getCurrentCommandIssuer()` Gets the current command issuer.
`CommandManager` `getCurrentCommandManager()` Gets the current command manager.
`RegisteredCommand` `getDefaultRegisteredCommand()`
`ExceptionHandler` `getExceptionHandler()`
`String` `getExecCommandLabel()` Gets the root command name that the user actually typed
`String` `getExecSubcommand()` Gets the actual sub command name the user typed
`CommandOperationContext` `getLastCommandOperationContext()` Returns a reference to the last used CommandOperationContext.
`String` `getName()`
`String[]` `getOrigArgs()` Gets the actual args in string form the user typed
`List<RegisteredCommand>` `getRegisteredCommands()`
`Set<String>` `getRequiredPermissions()`
`boolean` `hasPermission(CommandIssuer issuer)`
`boolean` `hasPermission(Object issuer)`
`void` `help(CommandIssuer issuer, String[] args)`
`void` `help(Object issuer, String[] args)`
`boolean` `requiresPermission(String permission)`
`String` `setContextFlags(Class<?> cls, String flags)`
`BaseCommand` `setExceptionHandler(ExceptionHandler exceptionHandler)`
`void` `showCommandHelp()` Deprecated. Unstable API
`void` `showSyntax(CommandIssuer issuer, RegisteredCommand<?> cmd)`
`List<String>` `tabComplete(CommandIssuer issuer, String commandLabel, String[] args)` Gets tab completed data from the given command from the user.
`List<String>` `tabComplete(CommandIssuer issuer, String commandLabel, String[] args, boolean isAsync)` Gets the tab complete suggestions from a given command.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### BaseCommand

    public BaseCommand()

#### BaseCommand

    @Deprecated
    public BaseCommand(@Nullable
                                   @Nullable String cmd)

Deprecated. Please switch to `CommandAlias` for defining all root commands.
Constructor based defining of commands will be removed in the next version bump.

Parameters:
  `cmd` -

### Method Detail

#### getLastCommandOperationContext

    public CommandOperationContext getLastCommandOperationContext()

Returns a reference to the last used CommandOperationContext. This method is ThreadLocal, in that it can only be used on a thread that has executed a command

Returns:

#### getExecCommandLabel

    public String getExecCommandLabel()

Gets the root command name that the user actually typed

Returns:
  Name

#### getExecSubcommand

    public String getExecSubcommand()

Gets the actual sub command name the user typed

Returns:
  Name

#### getOrigArgs

    public String[] getOrigArgs()

Gets the actual args in string form the user typed

Returns:
  Args

#### execute

    public void execute(CommandIssuer issuer,
                        String commandLabel,
                        String[] args)

#### getCurrentCommandIssuer

    public CommandIssuer getCurrentCommandIssuer()

Gets the current command issuer.

Returns:
  The current command issuer.

#### getCurrentCommandManager

    public CommandManager getCurrentCommandManager()

Gets the current command manager.

Returns:
  The current command manager.

#### canExecute

    @Deprecated
    public boolean canExecute(CommandIssuer issuer,
                                          RegisteredCommand<?> cmd)

Deprecated. See `CommandConditions`
Please use command conditions for restricting execution

Parameters:
  `issuer` -
  `cmd` -
Returns:

#### tabComplete

    public List<String> tabComplete(CommandIssuer issuer,
                                    String commandLabel,
                                    String[] args)

Gets tab completed data from the given command from the user.

Parameters:
  `issuer` - The user who executed the tabcomplete.
  `commandLabel` - The label which is being used by the user.
  `args` - The arguments the user has typed so far.
Returns:
  All possibilities in the tab complete.

#### tabComplete

    public List<String> tabComplete(CommandIssuer issuer,
                                    String commandLabel,
                                    String[] args,
                                    boolean isAsync)
                             throws IllegalArgumentException

Gets the tab complete suggestions from a given command. This will automatically find anything which is valid for the specified command through the command's implementation.

Parameters:
  `issuer` - The issuer of the command.
  `commandLabel` - The command name as entered by the user instead of the ACF registered name.
  `args` - All arguments entered by the user.
  `isAsync` - Whether this is run off of the main thread.
Returns:
  The possibilities to tab complete in no particular order.
Throws:
  `IllegalArgumentException`

#### getCommandHelp

    @Deprecated
    public CommandHelp getCommandHelp()

Deprecated. Unstable API

#### showCommandHelp

    @Deprecated
    public void showCommandHelp()

Deprecated. Unstable API

#### help

    public void help(Object issuer,
                     String[] args)

#### help

    public void help(CommandIssuer issuer,
                     String[] args)

#### doHelp

    public void doHelp(Object issuer,
                       String... args)

#### doHelp

    public void doHelp(CommandIssuer issuer,
                       String... args)

#### showSyntax

    public void showSyntax(CommandIssuer issuer,
                           RegisteredCommand<?> cmd)

#### hasPermission

    public boolean hasPermission(Object issuer)

#### hasPermission

    public boolean hasPermission(CommandIssuer issuer)

#### getRequiredPermissions

    public Set<String> getRequiredPermissions()

#### requiresPermission

    public boolean requiresPermission(String permission)

#### getName

    public String getName()

#### getExceptionHandler

    public ExceptionHandler getExceptionHandler()

#### setExceptionHandler

    public BaseCommand setExceptionHandler(ExceptionHandler exceptionHandler)

#### getDefaultRegisteredCommand

    public RegisteredCommand getDefaultRegisteredCommand()

#### setContextFlags

    public String setContextFlags(Class<?> cls,
                                  String flags)

#### getContextFlags

    public String getContextFlags(Class<?> cls)

#### getRegisteredCommands

    public List<RegisteredCommand> getRegisteredCommands()