public abstract class CommandManager<IT,I extends CommandIssuer,FT,MF extends MessageFormatter<FT>,CEC extends CommandExecutionContext<CEC,I>,CC extends ConditionContext<I>> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected CommandConditions<I,CEC,CC> |
conditions |
protected ExceptionHandler |
defaultExceptionHandler |
protected MF |
defaultFormatter |
protected int |
defaultHelpPerPage |
protected com.google.common.collect.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,co.aikar.commands.RootCommand> |
rootCommands |
protected Set<Locale> |
supportedLanguages |
protected boolean |
usePerIssuerLocale |
| Constructor and Description |
|---|
CommandManager() |
| Modifier and Type | Method and Description |
|---|---|
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 co.aikar.commands.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,
co.aikar.commands.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.
|
co.aikar.commands.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) |
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) |
co.aikar.commands.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 |
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() |
protected Map<String,co.aikar.commands.RootCommand> rootCommands
protected final CommandReplacements replacements
protected final CommandConditions<I extends CommandIssuer,CEC extends CommandExecutionContext<CEC,I>,CC extends ConditionContext<I>> conditions
protected ExceptionHandler defaultExceptionHandler
protected com.google.common.collect.Table<Class<?>,String,Object> dependencies
protected CommandHelpFormatter helpFormatter
protected boolean usePerIssuerLocale
protected List<IssuerLocaleChangedCallback<I extends CommandIssuer>> localeChangedCallbacks
protected Set<Locale> supportedLanguages
protected Map<MessageType,MF extends MessageFormatter<FT>> formatters
protected MF extends MessageFormatter<FT> defaultFormatter
protected int defaultHelpPerPage
protected Map<UUID,Locale> issuersLocale
public CommandManager()
public static CommandOperationContext getCurrentCommandOperationContext()
public static CommandIssuer getCurrentCommandIssuer()
public static CommandManager getCurrentCommandManager()
public MF setFormat(MessageType type, MF formatter)
public MF getFormat(MessageType type)
public void setFormat(MessageType type, FT... colors)
public void setFormat(MessageType type, int i, FT color)
public MF getDefaultFormatter()
public void setDefaultFormatter(MF defaultFormatter)
public CommandConditions<I,CEC,CC> getCommandConditions()
public abstract CommandContexts<?> getCommandContexts()
public abstract CommandCompletions<?> getCommandCompletions()
@Deprecated public CommandHelp generateCommandHelp(@NotNull @NotNull String command)
@Deprecated public CommandHelp generateCommandHelp(CommandIssuer issuer, @NotNull @NotNull String command)
@Deprecated public CommandHelp generateCommandHelp()
@Deprecated public CommandHelp generateCommandHelp(CommandIssuer issuer, co.aikar.commands.RootCommand rootCommand)
@Deprecated public int getDefaultHelpPerPage()
@Deprecated public void setDefaultHelpPerPage(int defaultHelpPerPage)
@Deprecated public void setHelpFormatter(CommandHelpFormatter helpFormatter)
@Deprecated public CommandHelpFormatter getHelpFormatter()
public abstract void registerCommand(BaseCommand command)
command - The command to registerpublic abstract boolean hasRegisteredCommands()
public abstract boolean isCommandIssuer(Class<?> type)
public abstract I getCommandIssuer(Object issuer)
public abstract co.aikar.commands.RootCommand createRootCommand(String cmd)
public abstract Locales getLocales()
public boolean usingPerIssuerLocale()
public boolean usePerIssuerLocale(boolean setting)
public ConditionContext createConditionContext(CommandIssuer issuer, String config)
public abstract CommandExecutionContext createCommandContext(RegisteredCommand command, CommandParameter parameter, CommandIssuer sender, List<String> args, int i, Map<String,Object> passedArgs)
public abstract CommandCompletionContext createCompletionContext(RegisteredCommand command, CommandIssuer sender, String input, String config, String[] args)
public CommandReplacements getCommandReplacements()
public boolean hasPermission(CommandIssuer issuer, String permission)
public co.aikar.commands.RootCommand getRootCommand(@NotNull @NotNull String cmd)
public co.aikar.commands.RootCommand obtainRootCommand(@NotNull @NotNull String cmd)
public RegisteredCommand createRegisteredCommand(BaseCommand command, String cmdName, Method method, String prefSubCommand)
public void setDefaultExceptionHandler(ExceptionHandler exceptionHandler)
ExceptionHandler that is called when an exception occurs while executing a command, if the command doesn't have it's own exception handler registered.exceptionHandler - the handler that should handle uncaught exceptionspublic ExceptionHandler getDefaultExceptionHandler()
protected boolean handleUncaughtException(BaseCommand scope, RegisteredCommand registeredCommand, CommandIssuer sender, List<String> args, Throwable t)
public void sendMessage(IT issuerArg, MessageType type, co.aikar.locales.MessageKeyProvider key, String... replacements)
public void sendMessage(CommandIssuer issuer, MessageType type, co.aikar.locales.MessageKeyProvider key, String... replacements)
public String formatMessage(CommandIssuer issuer, MessageType type, co.aikar.locales.MessageKeyProvider key, String... replacements)
public void onLocaleChange(IssuerLocaleChangedCallback<I> onChange)
public void notifyLocaleChange(I issuer, Locale oldLocale, Locale newLocale)
public Locale setIssuerLocale(IT issuer, Locale locale)
public Locale getIssuerLocale(CommandIssuer issuer)
public Set<Locale> getSupportedLanguages()
public void addSupportedLanguage(Locale locale)
locale - public <T> void registerDependency(Class<? extends T> clazz, T instance)
Dependency with the provided instance.clazz - the class the injector should look for when injectinginstance - the instance of the class that should be injectedIllegalStateException - when there is already an instance for the provided class registeredpublic <T> void registerDependency(Class<? extends T> clazz, String key, T instance)
Dependency with the provided instance.clazz - the class the injector should look for when injectingkey - the key which needs to be present if thatinstance - the instance of the class that should be injectedIllegalStateException - when there is already an instance for the provided class registered@Deprecated public void enableUnstableAPI(String api)
public String getCommandPrefix(CommandIssuer issuer)
Copyright © 2018. All rights reserved.