co.aikar.commands

## Class CommandManager<IT,I extends CommandIssuer,FT,MF extends MessageFormatter<FT>,CEC extends CommandExecutionContext<CEC,I>,CC extends ConditionContext<I>>

- java.lang.Object
- - co.aikar.commands.CommandManager<IT,I,FT,MF,CEC,CC>

    public abstract class CommandManager<IT,I extends CommandIssuer,FT,MF extends MessageFormatter<FT>,CEC extends CommandExecutionContext<CEC,I>,CC extends ConditionContext<I>>
    extends Object

### Field Summary

Fields
`protected CommandConditions<I,CEC,CC>` `conditions`
`protected ExceptionHandler` `defaultExceptionHandler`
`protected MF` `defaultFormatter`
`protected int` `defaultHelpPerPage`
`protected co.aikar.util.Table<Class<?>,String,Object>` `dependencies`
`protected Map<MessageType,MF>` `formatters`
`protected CommandHelpFormatter` `helpFormatter`
`protected Map<UUID,Locale>` `issuersLocale`
`protected List<IssuerLocaleChangedCallback<I>>` `localeChangedCallbacks`
`protected CommandReplacements` `replacements`
`protected Map<String,RootCommand>` `rootCommands`
`protected Set<Locale>` `supportedLanguages`
`protected boolean` `usePerIssuerLocale`

### Constructor Summary

Constructors
Constructor and Description
`CommandManager()`

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods
`void` `addSupportedLanguage(Locale locale)` Adds a new locale to the list of automatic Locales to load Message Bundles for.
`abstract CommandExecutionContext` `createCommandContext(RegisteredCommand command, CommandParameter parameter, CommandIssuer sender, List<String> args, int i, Map<String,Object> passedArgs)`
`abstract CommandCompletionContext` `createCompletionContext(RegisteredCommand command, CommandIssuer sender, String input, String config, String[] args)`
`ConditionContext` `createConditionContext(CommandIssuer issuer, String config)`
`RegisteredCommand` `createRegisteredCommand(BaseCommand command, String cmdName, Method method, String prefSubCommand)`
`abstract RootCommand` `createRootCommand(String cmd)`
`void` `enableUnstableAPI(String api)` Deprecated. Use this with caution! If you enable and use Unstable API's, your next compile using ACF may require you to update your implementation to those unstable API's
`String` `formatMessage(CommandIssuer issuer, MessageType type, co.aikar.locales.MessageKeyProvider key, String... replacements)`
`CommandHelp` `generateCommandHelp()` Deprecated. Unstable API
`CommandHelp` `generateCommandHelp(CommandIssuer issuer, RootCommand rootCommand)` Deprecated. Unstable API
`CommandHelp` `generateCommandHelp(CommandIssuer issuer, @NotNull String command)` Deprecated. Unstable API
`CommandHelp` `generateCommandHelp(@NotNull String command)` Deprecated. Unstable API
`abstract CommandCompletions<?>` `getCommandCompletions()` Gets the command completions manager
`CommandConditions<I,CEC,CC>` `getCommandConditions()`
`abstract CommandContexts<?>` `getCommandContexts()` Gets the command contexts manager
`abstract I` `getCommandIssuer(Object issuer)`
`String` `getCommandPrefix(CommandIssuer issuer)`
`CommandReplacements` `getCommandReplacements()` Lets you add custom string replacements that can be applied to annotation values, to reduce duplication/repetition of common values such as permission nodes and command prefixes.
`static CommandIssuer` `getCurrentCommandIssuer()`
`static CommandManager` `getCurrentCommandManager()`
`static CommandOperationContext` `getCurrentCommandOperationContext()`
`ExceptionHandler` `getDefaultExceptionHandler()` Gets the current default exception handler, might be null.
`MF` `getDefaultFormatter()`
`int` `getDefaultHelpPerPage()` Deprecated. Unstable API
`MF` `getFormat(MessageType type)`
`CommandHelpFormatter` `getHelpFormatter()` Deprecated. Unstable API
`Locale` `getIssuerLocale(CommandIssuer issuer)`
`abstract Locales` `getLocales()` Returns a Locales Manager to add and modify language tables for your commands.
`abstract Collection<RootCommand>` `getRegisteredRootCommands()`
`RootCommand` `getRootCommand(@NotNull String cmd)`
`Set<Locale>` `getSupportedLanguages()` Gets a list of all currently supported languages for this manager.
`protected boolean` `handleUncaughtException(BaseCommand scope, RegisteredCommand registeredCommand, CommandIssuer sender, List<String> args, Throwable t)`
`boolean` `hasPermission(CommandIssuer issuer, String permission)`
`abstract boolean` `hasRegisteredCommands()`
`abstract boolean` `isCommandIssuer(Class<?> type)`
`boolean` `isLoggingUnhandledExceptions()`
`void` `log(co.aikar.commands.LogLevel level, String message)`
`abstract void` `log(co.aikar.commands.LogLevel level, String message, Throwable throwable)`
`void` `notifyLocaleChange(I issuer, Locale oldLocale, Locale newLocale)`
`RootCommand` `obtainRootCommand(@NotNull String cmd)`
`void` `onLocaleChange(IssuerLocaleChangedCallback<I> onChange)`
`abstract void` `registerCommand(BaseCommand command)` Registers a command with ACF
`<T> void` `registerDependency(Class<? extends T> clazz, String key, T instance)` Registers an instance of a class to be registered as an injectable dependency. The command manager will attempt to inject all fields in a command class that are annotated with `Dependency` with the provided instance.
`<T> void` `registerDependency(Class<? extends T> clazz, T instance)` Registers an instance of a class to be registered as an injectable dependency. The command manager will attempt to inject all fields in a command class that are annotated with `Dependency` with the provided instance.
`void` `sendMessage(CommandIssuer issuer, MessageType type, co.aikar.locales.MessageKeyProvider key, String... replacements)`
`void` `sendMessage(IT issuerArg, MessageType type, co.aikar.locales.MessageKeyProvider key, String... replacements)`
`void` `setDefaultExceptionHandler(ExceptionHandler exceptionHandler)` Sets the default `ExceptionHandler` that is called when an exception occurs while executing a command, if the command doesn't have it's own exception handler registered.
`void` `setDefaultExceptionHandler(ExceptionHandler exceptionHandler, boolean logExceptions)` Sets the default `ExceptionHandler` that is called when an exception occurs while executing a command, if the command doesn't have it's own exception handler registered, and lets you control if ACF should also log the exception still.
`void` `setDefaultFormatter(MF defaultFormatter)`
`void` `setDefaultHelpPerPage(int defaultHelpPerPage)` Deprecated. Unstable API
`void` `setFormat(MessageType type, FT... colors)`
`void` `setFormat(MessageType type, int i, FT color)`
`MF` `setFormat(MessageType type, MF formatter)`
`void` `setHelpFormatter(CommandHelpFormatter helpFormatter)` Deprecated. Unstable API
`Locale` `setIssuerLocale(IT issuer, Locale locale)`
`boolean` `usePerIssuerLocale(boolean setting)`
`boolean` `usingPerIssuerLocale()`

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

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

### Field Detail

#### rootCommands

    protected Map<String,RootCommand> rootCommands

#### replacements

    protected final CommandReplacements replacements

#### conditions

    protected final CommandConditions<I extends CommandIssuer,CEC extends CommandExecutionContext<CEC,I>,CC extends ConditionContext<I>> conditions

#### defaultExceptionHandler

    protected ExceptionHandler defaultExceptionHandler

#### dependencies

    protected co.aikar.util.Table<Class<?>,String,Object> dependencies

#### helpFormatter

    protected CommandHelpFormatter helpFormatter

#### usePerIssuerLocale

    protected boolean usePerIssuerLocale

#### localeChangedCallbacks

    protected List<IssuerLocaleChangedCallback<I extends CommandIssuer>> localeChangedCallbacks

#### supportedLanguages

    protected Set<Locale> supportedLanguages

#### formatters

    protected Map<MessageType,MF extends MessageFormatter<FT>> formatters

#### defaultFormatter

    protected MF extends MessageFormatter<FT> defaultFormatter

#### defaultHelpPerPage

    protected int defaultHelpPerPage

#### issuersLocale

    protected Map<UUID,Locale> issuersLocale

### Constructor Detail

#### CommandManager

    public CommandManager()

### Method Detail

#### getCurrentCommandOperationContext

    public static CommandOperationContext getCurrentCommandOperationContext()

#### getCurrentCommandIssuer

    public static CommandIssuer getCurrentCommandIssuer()

#### getCurrentCommandManager

    public static CommandManager getCurrentCommandManager()

#### setFormat

    public MF setFormat(MessageType type,
                        MF formatter)

#### getFormat

    public MF getFormat(MessageType type)

#### setFormat

    public void setFormat(MessageType type,
                          FT... colors)

#### setFormat

    public void setFormat(MessageType type,
                          int i,
                          FT color)

#### getDefaultFormatter

    public MF getDefaultFormatter()

#### setDefaultFormatter

    public void setDefaultFormatter(MF defaultFormatter)

#### getCommandConditions

    public CommandConditions<I,CEC,CC> getCommandConditions()

#### getCommandContexts

    public abstract CommandContexts<?> getCommandContexts()

Gets the command contexts manager

Returns:
  Command Contexts

#### getCommandCompletions

    public abstract CommandCompletions<?> getCommandCompletions()

Gets the command completions manager

Returns:
  Command Completions

#### generateCommandHelp

    @Deprecated
    public CommandHelp generateCommandHelp(@NotNull
                                                       @NotNull String command)

Deprecated. Unstable API

#### generateCommandHelp

    @Deprecated
    public CommandHelp generateCommandHelp(CommandIssuer issuer,
                                                       @NotNull
                                                       @NotNull String command)

Deprecated. Unstable API

#### generateCommandHelp

    @Deprecated
    public CommandHelp generateCommandHelp()

Deprecated. Unstable API

#### generateCommandHelp

    @Deprecated
    public CommandHelp generateCommandHelp(CommandIssuer issuer,
                                                       RootCommand rootCommand)

Deprecated. Unstable API

#### getDefaultHelpPerPage

    @Deprecated
    public int getDefaultHelpPerPage()

Deprecated. Unstable API

#### setDefaultHelpPerPage

    @Deprecated
    public void setDefaultHelpPerPage(int defaultHelpPerPage)

Deprecated. Unstable API

#### setHelpFormatter

    @Deprecated
    public void setHelpFormatter(CommandHelpFormatter helpFormatter)

Deprecated. Unstable API

#### getHelpFormatter

    @Deprecated
    public CommandHelpFormatter getHelpFormatter()

Deprecated. Unstable API

#### registerCommand

    public abstract void registerCommand(BaseCommand command)

Registers a command with ACF

Parameters:
  `command` - The command to register

#### hasRegisteredCommands

    public abstract boolean hasRegisteredCommands()

#### isCommandIssuer

    public abstract boolean isCommandIssuer(Class<?> type)

#### getCommandIssuer

    public abstract I getCommandIssuer(Object issuer)

#### createRootCommand

    public abstract RootCommand createRootCommand(String cmd)

#### getLocales

    public abstract Locales getLocales()

Returns a Locales Manager to add and modify language tables for your commands.

Returns:

#### usingPerIssuerLocale

    public boolean usingPerIssuerLocale()

#### usePerIssuerLocale

    public boolean usePerIssuerLocale(boolean setting)

#### createConditionContext

    public ConditionContext createConditionContext(CommandIssuer issuer,
                                                   String config)

#### createCommandContext

    public abstract CommandExecutionContext createCommandContext(RegisteredCommand command,
                                                                 CommandParameter parameter,
                                                                 CommandIssuer sender,
                                                                 List<String> args,
                                                                 int i,
                                                                 Map<String,Object> passedArgs)

#### createCompletionContext

    public abstract CommandCompletionContext createCompletionContext(RegisteredCommand command,
                                                                     CommandIssuer sender,
                                                                     String input,
                                                                     String config,
                                                                     String[] args)

#### log

    public abstract void log(co.aikar.commands.LogLevel level,
                             String message,
                             Throwable throwable)

#### log

    public void log(co.aikar.commands.LogLevel level,
                    String message)

#### getCommandReplacements

    public CommandReplacements getCommandReplacements()

Lets you add custom string replacements that can be applied to annotation values, to reduce duplication/repetition of common values such as permission nodes and command prefixes. Any replacement registered starts with a % So for ex @CommandPermission("%staff")

Returns:
  Replacements Manager

#### hasPermission

    public boolean hasPermission(CommandIssuer issuer,
                                 String permission)

#### getRootCommand

    public RootCommand getRootCommand(@NotNull
                                      @NotNull String cmd)

#### obtainRootCommand

    public RootCommand obtainRootCommand(@NotNull
                                         @NotNull String cmd)

#### getRegisteredRootCommands

    public abstract Collection<RootCommand> getRegisteredRootCommands()

#### createRegisteredCommand

    public RegisteredCommand createRegisteredCommand(BaseCommand command,
                                                     String cmdName,
                                                     Method method,
                                                     String prefSubCommand)

#### setDefaultExceptionHandler

    public void setDefaultExceptionHandler(ExceptionHandler exceptionHandler)

Sets the default `ExceptionHandler` that is called when an exception occurs while executing a command, if the command doesn't have it's own exception handler registered.

Parameters:
  `exceptionHandler` - the handler that should handle uncaught exceptions. May not be null if logExceptions is false

#### setDefaultExceptionHandler

    public void setDefaultExceptionHandler(ExceptionHandler exceptionHandler,
                                           boolean logExceptions)

Sets the default `ExceptionHandler` that is called when an exception occurs while executing a command, if the command doesn't have it's own exception handler registered, and lets you control if ACF should also log the exception still.

If you disable logging, you need to log it yourself in your handler.

Parameters:
  `exceptionHandler` - the handler that should handle uncaught exceptions. May not be null if logExceptions is false
  `logExceptions` - Whether or not to log exceptions.

#### isLoggingUnhandledExceptions

    public boolean isLoggingUnhandledExceptions()

#### getDefaultExceptionHandler

    public ExceptionHandler getDefaultExceptionHandler()

Gets the current default exception handler, might be null.

Returns:
  the default exception handler

#### handleUncaughtException

    protected boolean handleUncaughtException(BaseCommand scope,
                                              RegisteredCommand registeredCommand,
                                              CommandIssuer sender,
                                              List<String> args,
                                              Throwable t)

#### sendMessage

    public void sendMessage(IT issuerArg,
                            MessageType type,
                            co.aikar.locales.MessageKeyProvider key,
                            String... replacements)

#### sendMessage

    public void sendMessage(CommandIssuer issuer,
                            MessageType type,
                            co.aikar.locales.MessageKeyProvider key,
                            String... replacements)

#### formatMessage

    public String formatMessage(CommandIssuer issuer,
                                MessageType type,
                                co.aikar.locales.MessageKeyProvider key,
                                String... replacements)

#### onLocaleChange

    public void onLocaleChange(IssuerLocaleChangedCallback<I> onChange)

#### notifyLocaleChange

    public void notifyLocaleChange(I issuer,
                                   Locale oldLocale,
                                   Locale newLocale)

#### setIssuerLocale

    public Locale setIssuerLocale(IT issuer,
                                  Locale locale)

#### getIssuerLocale

    public Locale getIssuerLocale(CommandIssuer issuer)

#### getSupportedLanguages

    public Set<Locale> getSupportedLanguages()

Gets a list of all currently supported languages for this manager. These locales will be automatically loaded from

Returns:

#### addSupportedLanguage

    public void addSupportedLanguage(Locale locale)

Adds a new locale to the list of automatic Locales to load Message Bundles for. All bundles loaded under the previous supported languages will now automatically load for this new locale too.

Parameters:
  `locale` -

#### registerDependency

    public <T> void registerDependency(Class<? extends T> clazz,
                                       T instance)

Registers an instance of a class to be registered as an injectable dependency.
The command manager will attempt to inject all fields in a command class that are annotated with `Dependency` with the provided instance.

Parameters:
  `clazz` - the class the injector should look for when injecting
  `instance` - the instance of the class that should be injected
Throws:
  `IllegalStateException` - when there is already an instance for the provided class registered

#### registerDependency

    public <T> void registerDependency(Class<? extends T> clazz,
                                       String key,
                                       T instance)

Registers an instance of a class to be registered as an injectable dependency.
The command manager will attempt to inject all fields in a command class that are annotated with `Dependency` with the provided instance.

Parameters:
  `clazz` - the class the injector should look for when injecting
  `key` - the key which needs to be present if that
  `instance` - the instance of the class that should be injected
Throws:
  `IllegalStateException` - when there is already an instance for the provided class registered

#### enableUnstableAPI

    @Deprecated
    public void enableUnstableAPI(String api)

Deprecated. Use this with caution! If you enable and use Unstable API's, your next compile using ACF may require you to update your implementation to those unstable API's

#### getCommandPrefix

    public String getCommandPrefix(CommandIssuer issuer)