diff --git a/docs/acf-bukkit/co/aikar/commands/BukkitCommandManager.html b/docs/acf-bukkit/co/aikar/commands/BukkitCommandManager.html index b26aa5a1..f4692f75 100644 --- a/docs/acf-bukkit/co/aikar/commands/BukkitCommandManager.html +++ b/docs/acf-bukkit/co/aikar/commands/BukkitCommandManager.html @@ -18,7 +18,7 @@ catch(err) { } //--> -var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10,"i11":10,"i12":10,"i13":10,"i14":10,"i15":10,"i16":10,"i17":10,"i18":42,"i19":10,"i20":10}; +var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10,"i11":10,"i12":10,"i13":10,"i14":10,"i15":10,"i16":10,"i17":10,"i18":10,"i19":42,"i20":10,"i21":10}; var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"],32:["t6","Deprecated Methods"]}; var altColor = "altColor"; var rowColor = "rowColor"; @@ -167,7 +167,7 @@ extends co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,
conditions, defaultExceptionHandler, defaultFormatter, defaultHelpPerPage, dependencies, formatters, issuersLocale, localeChangedCallbacks, replacements, rootCommands, supportedLanguages, usePerIssuerLocale
+conditions, defaultExceptionHandler, defaultFormatter, defaultHelpPerPage, dependencies, formatters, helpFormatter, issuersLocale, localeChangedCallbacks, replacements, rootCommands, supportedLanguages, usePerIssuerLocale
@@ -246,50 +246,54 @@ extends co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,getCommandIssuer(Object issuer)
StringgetCommandPrefix(co.aikar.commands.CommandIssuer issuer) BukkitLocalesgetLocales() org.bukkit.plugin.PlugingetPlugin() co.aikar.timings.lib.TimingManagergetTimings() booleanhasRegisteredCommands() booleanisCommandIssuer(Class<?> type) voidlog(co.aikar.commands.LogLevel level,
String message,
Throwable throwable) voidregisterCommand(co.aikar.commands.BaseCommand command) voidregisterCommand(co.aikar.commands.BaseCommand command,
boolean force) LocalesetPlayerLocale(org.bukkit.entity.Player player,
Locale locale) voidunregisterCommand(co.aikar.commands.BaseCommand command) voidunregisterCommand(BukkitRootCommand command)
voidunregisterCommands() booleanusePerIssuerLocale(boolean usePerIssuerLocale,
boolean autoDetectFromClient) addSupportedLanguage, enableUnstableAPI, formatMessage, generateCommandHelp, generateCommandHelp, generateCommandHelp, generateCommandHelp, getCommandConditions, getCommandReplacements, getCurrentCommandIssuer, getCurrentCommandManager, getCurrentCommandOperationContext, getDefaultExceptionHandler, getDefaultFormatter, getDefaultHelpPerPage, getFormat, getIssuerLocale, getRootCommand, getSupportedLanguages, handleUncaughtException, hasPermission, log, notifyLocaleChange, obtainRootCommand, onLocaleChange, registerDependency, registerDependency, sendMessage, sendMessage, setDefaultExceptionHandler, setDefaultFormatter, setDefaultHelpPerPage, setFormat, setFormat, setFormat, setIssuerLocale, usePerIssuerLocale, usingPerIssuerLocale
+addSupportedLanguage, enableUnstableAPI, formatMessage, generateCommandHelp, generateCommandHelp, generateCommandHelp, generateCommandHelp, getCommandConditions, getCommandReplacements, getCurrentCommandIssuer, getCurrentCommandManager, getCurrentCommandOperationContext, getDefaultExceptionHandler, getDefaultFormatter, getDefaultHelpPerPage, getFormat, getHelpFormatter, getIssuerLocale, getRootCommand, getSupportedLanguages, handleUncaughtException, hasPermission, log, notifyLocaleChange, obtainRootCommand, onLocaleChange, registerDependency, registerDependency, sendMessage, sendMessage, setDefaultExceptionHandler, setDefaultFormatter, setDefaultHelpPerPage, setFormat, setFormat, setFormat, setHelpFormatter, setIssuerLocale, usePerIssuerLocale, usingPerIssuerLocale
public boolean usePerIssuerLocale(boolean usePerIssuerLocale, boolean autoDetectFromClient)
public String getCommandPrefix(co.aikar.commands.CommandIssuer issuer)+
getCommandPrefix in class co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,BukkitCommandIssuer,org.bukkit.ChatColor,BukkitMessageFormatter,BukkitCommandExecutionContext,BukkitConditionContext>conditions, defaultExceptionHandler, defaultFormatter, defaultHelpPerPage, dependencies, formatters, issuersLocale, localeChangedCallbacks, replacements, rootCommands, supportedLanguages, usePerIssuerLocale
+conditions, defaultExceptionHandler, defaultFormatter, defaultHelpPerPage, dependencies, formatters, helpFormatter, issuersLocale, localeChangedCallbacks, replacements, rootCommands, supportedLanguages, usePerIssuerLocale
@@ -238,44 +238,48 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,getCommandIssuer(Object issuer)
StringgetCommandPrefix(co.aikar.commands.CommandIssuer issuer) BungeeLocalesgetLocales() net.md_5.bungee.api.plugin.PlugingetPlugin() booleanhasRegisteredCommands() booleanisCommandIssuer(Class<?> aClass) voidlog(co.aikar.commands.LogLevel level,
String message,
Throwable throwable) voidreadLocale(net.md_5.bungee.api.connection.ProxiedPlayer player) voidregisterCommand(co.aikar.commands.BaseCommand command) voidunregisterCommand(co.aikar.commands.BaseCommand command) voidunregisterCommand(BungeeRootCommand command) voidunregisterCommands() addSupportedLanguage, enableUnstableAPI, formatMessage, generateCommandHelp, generateCommandHelp, generateCommandHelp, generateCommandHelp, getCommandConditions, getCommandReplacements, getCurrentCommandIssuer, getCurrentCommandManager, getCurrentCommandOperationContext, getDefaultExceptionHandler, getDefaultFormatter, getDefaultHelpPerPage, getFormat, getIssuerLocale, getRootCommand, getSupportedLanguages, handleUncaughtException, hasPermission, log, notifyLocaleChange, obtainRootCommand, onLocaleChange, registerDependency, registerDependency, sendMessage, sendMessage, setDefaultExceptionHandler, setDefaultFormatter, setDefaultHelpPerPage, setFormat, setFormat, setFormat, setIssuerLocale, usePerIssuerLocale, usingPerIssuerLocale
+addSupportedLanguage, enableUnstableAPI, formatMessage, generateCommandHelp, generateCommandHelp, generateCommandHelp, generateCommandHelp, getCommandConditions, getCommandReplacements, getCurrentCommandIssuer, getCurrentCommandManager, getCurrentCommandOperationContext, getDefaultExceptionHandler, getDefaultFormatter, getDefaultHelpPerPage, getFormat, getHelpFormatter, getIssuerLocale, getRootCommand, getSupportedLanguages, handleUncaughtException, hasPermission, log, notifyLocaleChange, obtainRootCommand, onLocaleChange, registerDependency, registerDependency, sendMessage, sendMessage, setDefaultExceptionHandler, setDefaultFormatter, setDefaultHelpPerPage, setFormat, setFormat, setFormat, setHelpFormatter, setIssuerLocale, usePerIssuerLocale, usingPerIssuerLocale
public void log(co.aikar.commands.LogLevel level, @@ -607,6 +611,19 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,
public String getCommandPrefix(co.aikar.commands.CommandIssuer issuer)+
getCommandPrefix in class co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,BungeeCommandIssuer,net.md_5.bungee.api.ChatColor,BungeeMessageFormatter,BungeeCommandExecutionContext,BungeeConditionContext>public BaseCommand()+
public BaseCommand()
public BaseCommand(String cmd)+
public BaseCommand(String cmd)
public String getExecCommandLabel()+
public String getExecCommandLabel()
public String getExecSubcommand()+
public String getExecSubcommand()
public String[] getOrigArgs()+
public String[] getOrigArgs()
public void execute(CommandIssuer issuer, +public void execute(CommandIssuer issuer, String commandLabel, String[] args)
public CommandIssuer getCurrentCommandIssuer()+
public CommandIssuer getCurrentCommandIssuer()
public CommandManager getCurrentCommandManager()+
public CommandManager getCurrentCommandManager()
public boolean canExecute(CommandIssuer issuer, +public boolean canExecute(CommandIssuer issuer, RegisteredCommand<?> cmd)
public List<String> tabComplete(CommandIssuer issuer, +public List<String> tabComplete(CommandIssuer issuer, String commandLabel, String[] args)
public List<String> tabComplete(CommandIssuer issuer, +public List<String> tabComplete(CommandIssuer issuer, String commandLabel, String[] args, boolean isAsync) @@ -505,7 +505,7 @@ extendsgetCommandHelp
@Deprecated -public CommandHelp getCommandHelp()+public CommandHelp getCommandHelp()Deprecated. Unstable API
@Deprecated -public void showCommandHelp()+public void showCommandHelp()
public void help(Object issuer, +public void help(Object issuer, String[] args)
public void help(CommandIssuer issuer, +public void help(CommandIssuer issuer, String[] args)
public void doHelp(Object issuer, +public void doHelp(Object issuer, String... args)
public void doHelp(CommandIssuer issuer, +public void doHelp(CommandIssuer issuer, String... args)
public void showSyntax(CommandIssuer issuer, +public void showSyntax(CommandIssuer issuer, RegisteredCommand<?> cmd)
public boolean hasPermission(Object issuer)+
public boolean hasPermission(Object issuer)
public boolean hasPermission(CommandIssuer issuer)+
public boolean hasPermission(CommandIssuer issuer)
public Set<String> getRequiredPermissions()+
public Set<String> getRequiredPermissions()
public boolean requiresPermission(String permission)+
public boolean requiresPermission(String permission)
public String getName()+
public String getName()
public ExceptionHandler getExceptionHandler()+
public ExceptionHandler getExceptionHandler()
public BaseCommand setExceptionHandler(ExceptionHandler exceptionHandler)+
public BaseCommand setExceptionHandler(ExceptionHandler exceptionHandler)
public RegisteredCommand getDefaultRegisteredCommand()+
public RegisteredCommand getDefaultRegisteredCommand()
public String setContextFlags(Class<?> cls, +public String setContextFlags(Class<?> cls, String flags)
public String getContextFlags(Class<?> cls)+
public String getContextFlags(Class<?> cls)
@Deprecated -public <T> void registerSenderAwareContext(Class<T> context, +public <T> void registerSenderAwareContext(Class<T> context, IssuerAwareContextResolver<T,R> supplier)
registerIssuerAwareContext(Class, IssuerAwareContextResolver)
as the core wants to use the platform agnostic term of "Issuer" instead of Senderpublic <T> void registerIssuerAwareContext(Class<T> context, +public <T> void registerIssuerAwareContext(Class<T> context, IssuerAwareContextResolver<T,R> supplier)Registers a context resolver that may conditionally consume input, falling back to using the context of the issuer to potentially fulfill this context. @@ -279,7 +279,7 @@ public <T> voidregisterIssuerOnlyContext
-public <T> void registerIssuerOnlyContext(Class<T> context, +public <T> void registerIssuerOnlyContext(Class<T> context, IssuerOnlyContextResolver<T,R> supplier)Registers a context resolver that will never consume input. It will always satisfy its context based on the issuer of the command, so it will not appear in syntax strings.@@ -291,7 +291,7 @@ public <T> void- - - - -
registerOptionalContext
-public <T> void registerOptionalContext(Class<T> context, +public <T> void registerOptionalContext(Class<T> context, OptionalContextResolver<T,R> supplier)Registers a context that can safely accept a null input from the command issuer to resolve. This resolver should always call@@ -303,7 +303,7 @@ public <T> voidCommandExecutionContext.popFirstArg()- diff --git a/docs/acf-core/co/aikar/commands/CommandHelp.html b/docs/acf-core/co/aikar/commands/CommandHelp.html index e6994c97..c22223d7 100644 --- a/docs/acf-core/co/aikar/commands/CommandHelp.html +++ b/docs/acf-core/co/aikar/commands/CommandHelp.html @@ -18,7 +18,7 @@ catch(err) { } //--> -var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10}; +var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10,"i11":10,"i12":10,"i13":10,"i14":10,"i15":10,"i16":10,"i17":10,"i18":10,"i19":10,"i20":10}; var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]}; var altColor = "altColor"; var rowColor = "rowColor"; @@ -49,7 +49,7 @@ var activeTableTab = "activeTableTab";
registerContext
-public <T> void registerContext(Class<T> context, +public <T> void registerContext(Class<T> context, ContextResolver<T,R> supplier)Registers a context that requires input from the command issuer to resolve. This resolver should always call@@ -315,7 +315,7 @@ public <T> voidCommandExecutionContext.popFirstArg()getResolver
-public ContextResolver<?,R> getResolver(Class<?> type)+public ContextResolver<?,R> getResolver(Class<?> type)@@ -148,50 +148,88 @@ extends Method and Description- - @NotNull String[]+ getFormatReplacements(HelpEntry e)-Override this to control replacements-+ StringgetCommandName()+ ++ String+ getCommandPrefix()- List<HelpEntry>getHelpEntries()+ + ++ CommandIssuer+ getIssuer()- CommandManagergetManager()+ + ++ int+ getPage()+ ++ int+ getPerPage()+ ++ List<String>+ getSearch()+ ++ HelpEntry+ getSelectedEntry()+ ++ int+ getTotalPages()+ ++ int+ getTotalResults()+ ++ boolean+ isExactMatch(String command)+ ++ boolean+ isLastPage()- voidsetPage(int page)+ - voidsetPage(int page, int perPage)+ - voidsetPerPage(int perPage)+ - voidsetSearch(List<String> search)+ + ++ void+ showDetailedHelp(HelpEntry entry, + CommandIssuer issuer)- voidshowHelp()+ - voidshowHelp(CommandIssuer issuer)- -- void- showHelp(CommandIssuer issuer, - co.aikar.locales.MessageKeyProvider format)+ @@ -223,7 +261,7 @@ extends protected voidupdateSearchScore(HelpEntry help)- @@ -242,7 +280,7 @@ extends
CommandHelp
-public CommandHelp(CommandManager manager, +public CommandHelp(CommandManager manager, co.aikar.commands.RootCommand rootCommand, CommandIssuer issuer)- @@ -251,7 +289,16 @@ extends
updateSearchScore
-protected void updateSearchScore(HelpEntry help)+protected void updateSearchScore(HelpEntry help)- + + + + +
getManager
-public CommandManager getManager()+public CommandManager getManager()++
@@ -260,7 +307,7 @@ extends- +
isExactMatch
+public boolean isExactMatch(String command)- @@ -269,33 +316,17 @@ extends
showHelp
-public void showHelp()+public void showHelp()- - +
showHelp
-public void showHelp(CommandIssuer issuer)+public void showHelp(CommandIssuer issuer)- - - -
- -
-showHelp
-public void showHelp(CommandIssuer issuer, - co.aikar.locales.MessageKeyProvider format)--
@@ -304,7 +335,7 @@ public @NotNull- -
getFormatReplacements
-@NotNull -public @NotNull String[] getFormatReplacements(HelpEntry e)-Override this to control replacements--
+- Parameters:
-- -
e-- Returns:
-showDetailedHelp
+public void showDetailedHelp(HelpEntry entry, + CommandIssuer issuer)- @@ -313,7 +344,7 @@ public @NotNull
getHelpEntries
-public List<HelpEntry> getHelpEntries()+public List<HelpEntry> getHelpEntries()- @@ -322,7 +353,7 @@ public @NotNull
setPerPage
-public void setPerPage(int perPage)+public void setPerPage(int perPage)- @@ -331,17 +362,107 @@ public @NotNull
setPage
-public void setPage(int page)+public void setPage(int page)- -
setPage
-public void setPage(int page, +public void setPage(int page, int perPage)+
+ + + +
- +
setSearch
-public void setSearch(List<String> search)+public void setSearch(List<String> search)++
+ + + +- +
+getIssuer
+public CommandIssuer getIssuer()++
+ + + +- +
+getCommandName
+public String getCommandName()++
+ + + +- +
+getCommandPrefix
+public String getCommandPrefix()++
+ + + +- +
+getPage
+public int getPage()++
+ + + + + + + +- +
+getPerPage
+public int getPerPage()++
+ + + +- +
+getSelectedEntry
+public HelpEntry getSelectedEntry()++
+ + + +- +
+getTotalResults
+public int getTotalResults()++
+ + + +- +
+getTotalPages
+public int getTotalPages()++
@@ -372,7 +493,7 @@ public @NotNull- +
isLastPage
+public boolean isLastPage()public static final MessageKeys COULD_NOT_FIND_PLAYER-
- -
-HELP_FORMAT
-public static final MessageKeys HELP_FORMAT-@@ -415,16 +418,61 @@ the order they are declared.
NO_COMMAND_MATCHED_SEARCH
-public static final MessageKeys NO_COMMAND_MATCHED_SEARCH+public static final MessageKeys NO_COMMAND_MATCHED_SEARCH
public static final MessageKeys HELP_PAGE_INFORMATION+
public static final MessageKeys HELP_PAGE_INFORMATION
public static final MessageKeys HELP_NO_RESULTS+
public static final MessageKeys HELP_NO_RESULTS+
public static final MessageKeys HELP_HEADER+
public static final MessageKeys HELP_FORMAT+
public static final MessageKeys HELP_DETAILED_HEADER+
public static final MessageKeys HELP_DETAILED_PARAMETER_FORMAT+
public static final MessageKeys HELP_SEARCH_HEADER
public co.aikar.locales.MessageKey getMessageKey()+
public co.aikar.locales.MessageKey getMessageKey()
getMessageKey in interface co.aikar.locales.MessageKeyProvider| Modifier and Type | +Method and Description | +
|---|---|
String[] |
+CommandHelpFormatter.getEntryFormatReplacements(CommandHelp help,
+ HelpEntry e)
+Override this to control replacements
+ |
+
String[] |
+CommandHelpFormatter.getHeaderFooterFormatReplacements(CommandHelp help)
+Override this to control replacements
+ |
+
@NotNull String[] |
+CommandHelpFormatter.getParameterFormatReplacements(CommandHelp help,
+ String name,
+ String description,
+ HelpEntry page)
+Override this to control replacements
+ |
+
void |
+CommandHelpFormatter.printDetailedHelpFooter(CommandHelp help,
+ CommandIssuer issuer,
+ HelpEntry entry) |
+
void |
+CommandHelpFormatter.printDetailedHelpHeader(CommandHelp help,
+ CommandIssuer issuer,
+ String command,
+ HelpEntry entry) |
+
void |
+CommandHelpFormatter.printDetailedParameter(CommandHelp help,
+ CommandIssuer issuer,
+ HelpEntry entry,
+ CommandParameter param) |
+
void |
+CommandHelpFormatter.printHelpEntry(CommandHelp help,
+ CommandIssuer issuer,
+ HelpEntry entry) |
+
void |
+CommandHelpFormatter.printHelpFooter(CommandHelp help,
+ CommandIssuer issuer) |
+
void |
+CommandHelpFormatter.printHelpHeader(CommandHelp help,
+ CommandIssuer issuer) |
+
void |
+CommandHelpFormatter.printSearchEntry(CommandHelp help,
+ CommandIssuer issuer,
+ HelpEntry page) |
+
void |
+CommandHelpFormatter.printSearchFooter(CommandHelp help,
+ CommandIssuer issuer) |
+
void |
+CommandHelpFormatter.printSearchHeader(CommandHelp help,
+ CommandIssuer issuer) |
+
| Package | +Description | +
|---|---|
| co.aikar.commands | ++ |
| Modifier and Type | +Field and Description | +
|---|---|
protected CommandHelpFormatter |
+CommandManager.helpFormatter |
+
| Modifier and Type | +Method and Description | +
|---|---|
CommandHelpFormatter |
+CommandManager.getHelpFormatter()
+Deprecated.
+
+Unstable API
+ |
+
| Modifier and Type | +Method and Description | +
|---|---|
void |
+CommandManager.setHelpFormatter(CommandHelpFormatter helpFormatter)
+Deprecated.
+
+Unstable API
+ |
+
Copyright © 2018. All rights reserved.
+ + diff --git a/docs/acf-core/co/aikar/commands/class-use/CommandIssuer.html b/docs/acf-core/co/aikar/commands/class-use/CommandIssuer.html index caca7441..e9535e44 100644 --- a/docs/acf-core/co/aikar/commands/class-use/CommandIssuer.html +++ b/docs/acf-core/co/aikar/commands/class-use/CommandIssuer.html @@ -191,6 +191,10 @@CommandIssuergetIssuer() CommandIssuergetIssuer() StringgetCommandPrefix(CommandIssuer issuer) LocalegetIssuerLocale(CommandIssuer issuer) StringgetMessage(CommandIssuer issuer,
co.aikar.locales.MessageKeyProvider key) protected booleanhandleUncaughtException(BaseCommand scope,
RegisteredCommand registeredCommand,
@@ -300,24 +308,76 @@
List<String> args,
Throwable t) booleanhasPermission(CommandIssuer issuer) booleanhasPermission(CommandIssuer sender) booleanhasPermission(CommandIssuer issuer,
String permission) voidhelp(CommandIssuer issuer,
String[] args) voidprintDetailedHelpFooter(CommandHelp help,
+ CommandIssuer issuer,
+ HelpEntry entry) voidprintDetailedHelpHeader(CommandHelp help,
+ CommandIssuer issuer,
+ String command,
+ HelpEntry entry) voidprintDetailedParameter(CommandHelp help,
+ CommandIssuer issuer,
+ HelpEntry entry,
+ CommandParameter param) voidprintHelpEntry(CommandHelp help,
+ CommandIssuer issuer,
+ HelpEntry entry) voidprintHelpFooter(CommandHelp help,
+ CommandIssuer issuer) voidprintHelpHeader(CommandHelp help,
+ CommandIssuer issuer) voidprintSearchEntry(CommandHelp help,
+ CommandIssuer issuer,
+ HelpEntry page) voidprintSearchFooter(CommandHelp help,
+ CommandIssuer issuer) voidprintSearchHeader(CommandHelp help,
+ CommandIssuer issuer) voidsendMessage(CommandIssuer issuer,
@@ -327,12 +387,12 @@
voidshowHelp(CommandIssuer issuer) showDetailedHelp(HelpEntry entry,
+ CommandIssuer issuer) voidshowHelp(CommandIssuer issuer,
- co.aikar.locales.MessageKeyProvider format) showHelp(CommandIssuer issuer) voidCommandHelpFormatter(CommandManager manager) Locales(CommandManager manager) | Modifier and Type | +Method and Description | +
|---|---|
CommandParameter[] |
+HelpEntry.getParameters() |
+
| Modifier and Type | @@ -110,6 +123,13 @@ int i, Map<String,Object> passedArgs)|
|---|---|
void |
+CommandHelpFormatter.printDetailedParameter(CommandHelp help,
+ CommandIssuer issuer,
+ HelpEntry entry,
+ CommandParameter param) |
+
| Modifier and Type | +Method and Description | +
|---|---|
HelpEntry |
+CommandHelp.getSelectedEntry() |
+
| Modifier and Type | @@ -115,12 +128,59 @@|||
|---|---|---|---|
@NotNull String[] |
-CommandHelp.getFormatReplacements(HelpEntry e)
+ | String[] |
+CommandHelpFormatter.getEntryFormatReplacements(CommandHelp help,
+ HelpEntry e)
Override this to control replacements
|
@NotNull String[] |
+CommandHelpFormatter.getParameterFormatReplacements(CommandHelp help,
+ String name,
+ String description,
+ HelpEntry page)
+Override this to control replacements
+ |
+||
void |
+CommandHelpFormatter.printDetailedHelpFooter(CommandHelp help,
+ CommandIssuer issuer,
+ HelpEntry entry) |
+||
void |
+CommandHelpFormatter.printDetailedHelpHeader(CommandHelp help,
+ CommandIssuer issuer,
+ String command,
+ HelpEntry entry) |
+||
void |
+CommandHelpFormatter.printDetailedParameter(CommandHelp help,
+ CommandIssuer issuer,
+ HelpEntry entry,
+ CommandParameter param) |
+||
void |
+CommandHelpFormatter.printHelpEntry(CommandHelp help,
+ CommandIssuer issuer,
+ HelpEntry entry) |
+||
void |
+CommandHelpFormatter.printSearchEntry(CommandHelp help,
+ CommandIssuer issuer,
+ HelpEntry page) |
+||
void |
+CommandHelp.showDetailedHelp(HelpEntry entry,
+ CommandIssuer issuer) |
+||
protected void |
CommandHelp.updateSearchScore(HelpEntry help) |
||
CommandHelpFormatter |
+CommandManager.getHelpFormatter()
+Deprecated.
+
+Unstable API
+ |
+||
void |
CommandManager.setDefaultHelpPerPage(int defaultHelpPerPage)
Deprecated.
@@ -159,6 +167,14 @@
|
||
void |
+CommandManager.setHelpFormatter(CommandHelpFormatter helpFormatter)
+Deprecated.
+
+Unstable API
+ |
+||
void |
BaseCommand.showCommandHelp()
diff --git a/docs/acf-core/co/aikar/commands/package-frame.html b/docs/acf-core/co/aikar/commands/package-frame.html
index 9b07b93f..6cf326f7 100644
--- a/docs/acf-core/co/aikar/commands/package-frame.html
+++ b/docs/acf-core/co/aikar/commands/package-frame.html
@@ -32,6 +32,7 @@
| ||
| CommandManager<IT,I extends CommandIssuer,FT,MF extends MessageFormatter<FT>,CEC extends CommandExecutionContext<CEC,I>,CC extends ConditionContext<I>> | +CommandHelpFormatter | ||
| CommandManager<IT,I extends CommandIssuer,FT,MF extends MessageFormatter<FT>,CEC extends CommandExecutionContext<CEC,I>,CC extends ConditionContext<I>> | ++ | ||
| CommandOperationContext<I extends CommandIssuer> |
Holds information about the currently executing command on this thread
|
||
| CommandParameter<CEC extends CommandExecutionContext<CEC,? extends CommandIssuer>> | |||
| CommandReplacements |
Manages replacement template strings
|
||
| ConditionContext<I extends CommandIssuer> | |||
| ForwardingCommand | |||
| HelpEntry | |||
| Locales | |||
| MessageFormatter<FT> |
Handles formatting Messages and managing colors
|
||
| MessageType | |||
| RegisteredCommand<CEC extends CommandExecutionContext<CEC,? extends CommandIssuer>> | CommandHelp | ||
| CommandIssuer | +CommandHelpFormatter | ||
| CommandManager | +CommandIssuer | ||
| CommandManager | +|||
| CommandOperationContext
Holds information about the currently executing command on this thread
|
|||
| CommandParameter | |||
| CommandReplacements
Manages replacement template strings
|
|||
| ConditionContext | |||
| ExceptionHandler
Functional interface to allow plugins to handle uncaught excetpions
|
|||
| HelpEntry | |||
| InvalidCommandArgument | |||
| IssuerLocaleChangedCallback | |||
| Locales | |||
| MessageFormatter
Handles formatting Messages and managing colors
|
|||
| MessageKeys
Enum Name = MessageKey in lowercase prefixed with acf-core.
|
|||
| MessageType | |||
| RegisteredCommand | |||
| UnstableAPI
Deprecated.
|
diff --git a/docs/acf-core/deprecated-list.html b/docs/acf-core/deprecated-list.html
index 5881f90a..152b081d 100644
--- a/docs/acf-core/deprecated-list.html
+++ b/docs/acf-core/deprecated-list.html
@@ -205,30 +205,40 @@
|||
| co.aikar.commands.CommandManager.getHelpFormatter()
+ Unstable API
+ |
+|||
| co.aikar.commands.CommandExecutionContext.getParam() | |||
| co.aikar.commands.RegisteredCommand.getPermission() | |||
| co.aikar.commands.ACFUtil.random(Class<? extends T>) | |||
| co.aikar.commands.CommandContexts.registerSenderAwareContext(Class<T>, IssuerAwareContextResolver<T, R>)
Please switch to
CommandContexts.registerIssuerAwareContext(Class, IssuerAwareContextResolver)
as the core wants to use the platform agnostic term of "Issuer" instead of Sender |
|||
| co.aikar.commands.CommandIssuer.sendMessageInternal(String)
Do not call this, for internal use. Not considered part of the API and may break.
|
|||
| co.aikar.commands.CommandManager.setDefaultHelpPerPage(int)
Unstable API
|
|||
| co.aikar.commands.CommandManager.setHelpFormatter(CommandHelpFormatter)
+ Unstable API
+ |
+|||
| co.aikar.commands.BaseCommand.showCommandHelp()
Unstable API
diff --git a/docs/acf-core/index-all.html b/docs/acf-core/index-all.html
index ac1f733b..259ce9d5 100644
--- a/docs/acf-core/index-all.html
+++ b/docs/acf-core/index-all.html
@@ -90,7 +90,7 @@
Lets you add custom string replacements that can be applied to annotation values,
@@ -592,6 +602,10 @@
Override this to control replacements
+Override this to control replacements
-A way to get the entire nested stack-trace of an throwable.
Override this to control replacements
+Deprecated.
+
+Unstable API
+Gets the issuer in the platforms native object
@@ -701,12 +723,20 @@
Gets the actual args in string form the user typed
Deprecated.
Override this to control replacements
+Deprecated.
Gets the stack trace from a Throwable as a String.
@@ -788,6 +824,10 @@
in an array of Throwables, one element for each
Throwable.Checks whether this
@@ -1309,11 +1355,29 @@
Throwable class can store a cause.Prints the stack trace for this exception only--root cause not
included--using the provided writer.
Prints the stack trace of this exception to the specified print
@@ -1543,6 +1607,12 @@
Deprecated.
+
+Unstable API
+
+
+
+
diff --git a/docs/acf-core/src-html/co/aikar/commands/CommandManager.html b/docs/acf-core/src-html/co/aikar/commands/CommandManager.html
index 32c77313..ae4786bd 100644
--- a/docs/acf-core/src-html/co/aikar/commands/CommandManager.html
+++ b/docs/acf-core/src-html/co/aikar/commands/CommandManager.html
@@ -80,429 +80,443 @@
072 protected final CommandConditions<I, CEC, CC> conditions = new CommandConditions<>(this);
073 protected ExceptionHandler defaultExceptionHandler = null;
074 protected Table<Class<?>, String, Object> dependencies = HashBasedTable.create();
-075
-076 protected boolean usePerIssuerLocale = false;
-077 protected List<IssuerLocaleChangedCallback<I>> localeChangedCallbacks = Lists.newArrayList();
-078 protected Set<Locale> supportedLanguages = Sets.newHashSet(Locales.ENGLISH, Locales.GERMAN, Locales.SPANISH, Locales.CZECH, Locales.PORTUGUESE);
-079 protected Map<MessageType, MF> formatters = new IdentityHashMap<>();
-080 protected MF defaultFormatter;
-081 protected int defaultHelpPerPage = 10;
-082
-083 protected Map<UUID, Locale> issuersLocale = Maps.newConcurrentMap();
-084
-085 private Set<String> unstableAPIs = Sets.newHashSet();
-086
-087 private Annotations annotations = new Annotations<>(this);
-088
-089 public static CommandOperationContext getCurrentCommandOperationContext() {
-090 return commandOperationContext.get().peek();
-091 }
-092
-093 public static CommandIssuer getCurrentCommandIssuer() {
-094 CommandOperationContext context = commandOperationContext.get().peek();
-095 return context != null ? context.getCommandIssuer() : null;
-096 }
-097
-098 public static CommandManager getCurrentCommandManager() {
-099 CommandOperationContext context = commandOperationContext.get().peek();
-100 return context != null ? context.getCommandManager() : null;
-101 }
-102
-103 public MF setFormat(MessageType type, MF formatter) {
-104 return formatters.put(type, formatter);
-105 }
-106
-107 public MF getFormat(MessageType type) {
-108 return formatters.getOrDefault(type, defaultFormatter);
-109 }
-110
-111 public void setFormat(MessageType type, FT... colors) {
-112 MF format = getFormat(type);
-113 for (int i = 1; i <= colors.length; i++) {
-114 format.setColor(i, colors[i-1]);
-115 }
-116 }
-117
-118 public void setFormat(MessageType type, int i, FT color) {
-119 MF format = getFormat(type);
-120 format.setColor(i, color);
-121 }
-122
-123 public MF getDefaultFormatter() {
-124 return defaultFormatter;
-125 }
-126
-127 public void setDefaultFormatter(MF defaultFormatter) {
-128 this.defaultFormatter = defaultFormatter;
-129 }
-130
-131 public CommandConditions<I, CEC, CC> getCommandConditions() {
-132 return conditions;
-133 }
-134
-135 /**
-136 * Gets the command contexts manager
-137 * @return Command Contexts
-138 */
-139 public abstract CommandContexts<?> getCommandContexts();
-140
-141 /**
-142 * Gets the command completions manager
-143 * @return Command Completions
-144 */
-145 public abstract CommandCompletions<?> getCommandCompletions();
-146
-147 /** @deprecated Unstable API */ @Deprecated @UnstableAPI
-148 public CommandHelp generateCommandHelp(@NotNull String command) {
-149 verifyUnstableAPI("help");
-150 CommandOperationContext context = getCurrentCommandOperationContext();
-151 if (context == null) {
-152 throw new IllegalStateException("This method can only be called as part of a command execution.");
-153 }
-154 return generateCommandHelp(context.getCommandIssuer(), command);
-155 }
-156
-157 /** @deprecated Unstable API */ @Deprecated @UnstableAPI
-158 public CommandHelp generateCommandHelp(CommandIssuer issuer, @NotNull String command) {
-159 verifyUnstableAPI("help");
-160 return generateCommandHelp(issuer, obtainRootCommand(command));
-161 }
-162
-163 /** @deprecated Unstable API */ @Deprecated @UnstableAPI
-164 public CommandHelp generateCommandHelp() {
-165 verifyUnstableAPI("help");
-166 CommandOperationContext context = getCurrentCommandOperationContext();
-167 if (context == null) {
-168 throw new IllegalStateException("This method can only be called as part of a command execution.");
-169 }
-170 String commandLabel = context.getCommandLabel();
-171 return generateCommandHelp(context.getCommandIssuer(), this.obtainRootCommand(commandLabel));
-172 }
-173
-174 /** @deprecated Unstable API */ @Deprecated @UnstableAPI
-175 public CommandHelp generateCommandHelp(CommandIssuer issuer, RootCommand rootCommand) {
-176 verifyUnstableAPI("help");
-177 return new CommandHelp(this, rootCommand, issuer);
-178 }
-179
-180 /** @deprecated Unstable API */ @Deprecated @UnstableAPI
-181 public int getDefaultHelpPerPage() {
-182 verifyUnstableAPI("help");
-183 return defaultHelpPerPage;
-184 }
-185
-186 /** @deprecated Unstable API */ @Deprecated @UnstableAPI
-187 public void setDefaultHelpPerPage(int defaultHelpPerPage) {
-188 verifyUnstableAPI("help");
-189 this.defaultHelpPerPage = defaultHelpPerPage;
-190 }
-191
-192 /**
-193 * Registers a command with ACF
-194 *
-195 * @param command The command to register
-196 * @return boolean
-197 */
-198 public abstract void registerCommand(BaseCommand command);
-199 public abstract boolean hasRegisteredCommands();
-200 public abstract boolean isCommandIssuer(Class<?> type);
+075 protected CommandHelpFormatter helpFormatter = new CommandHelpFormatter(this);
+076
+077 protected boolean usePerIssuerLocale = false;
+078 protected List<IssuerLocaleChangedCallback<I>> localeChangedCallbacks = Lists.newArrayList();
+079 protected Set<Locale> supportedLanguages = Sets.newHashSet(Locales.ENGLISH, Locales.GERMAN, Locales.SPANISH, Locales.CZECH, Locales.PORTUGUESE, Locales.SWEDISH);
+080 protected Map<MessageType, MF> formatters = new IdentityHashMap<>();
+081 protected MF defaultFormatter;
+082 protected int defaultHelpPerPage = 10;
+083
+084 protected Map<UUID, Locale> issuersLocale = Maps.newConcurrentMap();
+085
+086 private Set<String> unstableAPIs = Sets.newHashSet();
+087
+088 private Annotations annotations = new Annotations<>(this);
+089
+090 public static CommandOperationContext getCurrentCommandOperationContext() {
+091 return commandOperationContext.get().peek();
+092 }
+093
+094 public static CommandIssuer getCurrentCommandIssuer() {
+095 CommandOperationContext context = commandOperationContext.get().peek();
+096 return context != null ? context.getCommandIssuer() : null;
+097 }
+098
+099 public static CommandManager getCurrentCommandManager() {
+100 CommandOperationContext context = commandOperationContext.get().peek();
+101 return context != null ? context.getCommandManager() : null;
+102 }
+103
+104 public MF setFormat(MessageType type, MF formatter) {
+105 return formatters.put(type, formatter);
+106 }
+107
+108 public MF getFormat(MessageType type) {
+109 return formatters.getOrDefault(type, defaultFormatter);
+110 }
+111
+112 public void setFormat(MessageType type, FT... colors) {
+113 MF format = getFormat(type);
+114 for (int i = 1; i <= colors.length; i++) {
+115 format.setColor(i, colors[i-1]);
+116 }
+117 }
+118
+119 public void setFormat(MessageType type, int i, FT color) {
+120 MF format = getFormat(type);
+121 format.setColor(i, color);
+122 }
+123
+124 public MF getDefaultFormatter() {
+125 return defaultFormatter;
+126 }
+127
+128 public void setDefaultFormatter(MF defaultFormatter) {
+129 this.defaultFormatter = defaultFormatter;
+130 }
+131
+132 public CommandConditions<I, CEC, CC> getCommandConditions() {
+133 return conditions;
+134 }
+135
+136 /**
+137 * Gets the command contexts manager
+138 * @return Command Contexts
+139 */
+140 public abstract CommandContexts<?> getCommandContexts();
+141
+142 /**
+143 * Gets the command completions manager
+144 * @return Command Completions
+145 */
+146 public abstract CommandCompletions<?> getCommandCompletions();
+147
+148 /** @deprecated Unstable API */ @Deprecated @UnstableAPI
+149 public CommandHelp generateCommandHelp(@NotNull String command) {
+150 verifyUnstableAPI("help");
+151 CommandOperationContext context = getCurrentCommandOperationContext();
+152 if (context == null) {
+153 throw new IllegalStateException("This method can only be called as part of a command execution.");
+154 }
+155 return generateCommandHelp(context.getCommandIssuer(), command);
+156 }
+157
+158 /** @deprecated Unstable API */ @Deprecated @UnstableAPI
+159 public CommandHelp generateCommandHelp(CommandIssuer issuer, @NotNull String command) {
+160 verifyUnstableAPI("help");
+161 return generateCommandHelp(issuer, obtainRootCommand(command));
+162 }
+163
+164 /** @deprecated Unstable API */ @Deprecated @UnstableAPI
+165 public CommandHelp generateCommandHelp() {
+166 verifyUnstableAPI("help");
+167 CommandOperationContext context = getCurrentCommandOperationContext();
+168 if (context == null) {
+169 throw new IllegalStateException("This method can only be called as part of a command execution.");
+170 }
+171 String commandLabel = context.getCommandLabel();
+172 return generateCommandHelp(context.getCommandIssuer(), this.obtainRootCommand(commandLabel));
+173 }
+174
+175 /** @deprecated Unstable API */ @Deprecated @UnstableAPI
+176 public CommandHelp generateCommandHelp(CommandIssuer issuer, RootCommand rootCommand) {
+177 verifyUnstableAPI("help");
+178 return new CommandHelp(this, rootCommand, issuer);
+179 }
+180
+181 /** @deprecated Unstable API */ @Deprecated @UnstableAPI
+182 public int getDefaultHelpPerPage() {
+183 verifyUnstableAPI("help");
+184 return defaultHelpPerPage;
+185 }
+186
+187 /** @deprecated Unstable API */ @Deprecated @UnstableAPI
+188 public void setDefaultHelpPerPage(int defaultHelpPerPage) {
+189 verifyUnstableAPI("help");
+190 this.defaultHelpPerPage = defaultHelpPerPage;
+191 }
+192 /** @deprecated Unstable API */ @Deprecated @UnstableAPI
+193 public void setHelpFormatter(CommandHelpFormatter helpFormatter) {
+194 this.helpFormatter = helpFormatter;
+195 }
+196
+197 /** @deprecated Unstable API */ @Deprecated @UnstableAPI
+198 public CommandHelpFormatter getHelpFormatter() {
+199 return helpFormatter;
+200 }
201
-202 // TODO: Change this to IT if we make a breaking change
-203 public abstract I getCommandIssuer(Object issuer);
-204
-205 public abstract RootCommand createRootCommand(String cmd);
-206
-207 /**
-208 * Returns a Locales Manager to add and modify language tables for your commands.
-209 * @return
-210 */
-211 public abstract Locales getLocales();
-212
-213 public boolean usingPerIssuerLocale() {
-214 return usePerIssuerLocale;
-215 }
+202 /**
+203 * Registers a command with ACF
+204 *
+205 * @param command The command to register
+206 * @return boolean
+207 */
+208 public abstract void registerCommand(BaseCommand command);
+209 public abstract boolean hasRegisteredCommands();
+210 public abstract boolean isCommandIssuer(Class<?> type);
+211
+212 // TODO: Change this to IT if we make a breaking change
+213 public abstract I getCommandIssuer(Object issuer);
+214
+215 public abstract RootCommand createRootCommand(String cmd);
216
-217 public boolean usePerIssuerLocale(boolean setting) {
-218 boolean old = usePerIssuerLocale;
-219 usePerIssuerLocale = setting;
-220 return old;
-221 }
+217 /**
+218 * Returns a Locales Manager to add and modify language tables for your commands.
+219 * @return
+220 */
+221 public abstract Locales getLocales();
222
-223 public ConditionContext createConditionContext(CommandIssuer issuer, String config) {
-224 //noinspection unchecked
-225 return new ConditionContext(issuer, config);
-226 }
-227
-228 public abstract CommandExecutionContext createCommandContext(RegisteredCommand command, CommandParameter parameter, CommandIssuer sender, List<String> args, int i, Map<String, Object> passedArgs);
-229
-230 public abstract CommandCompletionContext createCompletionContext(RegisteredCommand command, CommandIssuer sender, String input, String config, String[] args);
-231
-232 public abstract void log(final LogLevel level, final String message, final Throwable throwable);
-233
-234 public void log(final LogLevel level, final String message) {
-235 log(level, message, null);
+223 public boolean usingPerIssuerLocale() {
+224 return usePerIssuerLocale;
+225 }
+226
+227 public boolean usePerIssuerLocale(boolean setting) {
+228 boolean old = usePerIssuerLocale;
+229 usePerIssuerLocale = setting;
+230 return old;
+231 }
+232
+233 public ConditionContext createConditionContext(CommandIssuer issuer, String config) {
+234 //noinspection unchecked
+235 return new ConditionContext(issuer, config);
236 }
237
-238 /**
-239 * Lets you add custom string replacements that can be applied to annotation values,
-240 * to reduce duplication/repetition of common values such as permission nodes and command prefixes.
-241 *
-242 * Any replacement registered starts with a %
-243 *
-244 * So for ex @CommandPermission("%staff")
-245 * @return Replacements Manager
-246 */
-247 public CommandReplacements getCommandReplacements() {
-248 return replacements;
-249 }
-250
-251 public boolean hasPermission(CommandIssuer issuer, String permission) {
-252 if (permission == null || permission.isEmpty()) {
-253 return true;
-254 }
-255 for (String perm : ACFPatterns.COMMA.split(permission)) {
-256 if (!perm.isEmpty() && !issuer.hasPermission(perm)) {
-257 return false;
-258 }
-259 }
-260 return true;
-261 }
-262
-263 BaseCommand getBaseCommand(String commandLabel, @NotNull String[] args) {
-264 RootCommand rootCommand = obtainRootCommand(commandLabel);
-265 if (rootCommand == null) {
-266 return null;
-267 }
-268 return rootCommand.getBaseCommand(args);
-269 }
-270
-271 public synchronized RootCommand getRootCommand(@NotNull String cmd) {
-272 return rootCommands.get(ACFPatterns.SPACE.split(cmd.toLowerCase(), 2)[0]);
-273 }
-274
-275 public synchronized RootCommand obtainRootCommand(@NotNull String cmd) {
-276 return rootCommands.computeIfAbsent(ACFPatterns.SPACE.split(cmd.toLowerCase(), 2)[0], this::createRootCommand);
-277 }
-278
-279 public RegisteredCommand createRegisteredCommand(BaseCommand command, String cmdName, Method method, String prefSubCommand) {
-280 return new RegisteredCommand(command, cmdName, method, prefSubCommand);
-281 }
-282
-283 /**
-284 * Sets the default {@link ExceptionHandler} that is called when an exception occurs while executing a command, if the command doesn't have it's own exception handler registered.
-285 *
-286 * @param exceptionHandler the handler that should handle uncaught exceptions
-287 */
-288 public void setDefaultExceptionHandler(ExceptionHandler exceptionHandler) {
-289 defaultExceptionHandler = exceptionHandler;
-290 }
-291
-292 /**
-293 * Gets the current default exception handler, might be null.
-294 *
-295 * @return the default exception handler
-296 */
-297 public ExceptionHandler getDefaultExceptionHandler() {
-298 return defaultExceptionHandler;
-299 }
-300
-301 protected boolean handleUncaughtException(BaseCommand scope, RegisteredCommand registeredCommand, CommandIssuer sender, List<String> args, Throwable t) {
-302 if (t instanceof InvocationTargetException && t.getCause() != null) {
-303 t = t.getCause();
-304 }
-305 boolean result = false;
-306 if (scope.getExceptionHandler() != null) {
-307 result = scope.getExceptionHandler().execute(scope, registeredCommand, sender, args, t);
-308 } else if (defaultExceptionHandler != null) {
-309 result = defaultExceptionHandler.execute(scope, registeredCommand, sender, args, t);
-310 }
-311 return result;
-312 }
-313
-314 public void sendMessage(IT issuerArg, MessageType type, MessageKeyProvider key, String... replacements) {
-315 sendMessage(getCommandIssuer(issuerArg), type, key, replacements);
-316 }
-317
-318 public void sendMessage(CommandIssuer issuer, MessageType type, MessageKeyProvider key, String... replacements) {
-319 String message = formatMessage(issuer, type, key, replacements);
-320
-321 for (String msg : ACFPatterns.NEWLINE.split(message)) {
-322 issuer.sendMessageInternal(ACFUtil.rtrim(msg));
-323 }
-324 }
-325
-326 public String formatMessage(CommandIssuer issuer, MessageType type, MessageKeyProvider key, String... replacements) {
-327 String message = getLocales().getMessage(issuer, key.getMessageKey());
-328 if (replacements.length > 0) {
-329 message = ACFUtil.replaceStrings(message, replacements);
-330 }
-331
-332 message = getCommandReplacements().replace(message);
-333
-334 MessageFormatter formatter = formatters.getOrDefault(type, defaultFormatter);
-335 if (formatter != null) {
-336 message = formatter.format(message);
-337 }
-338 return message;
-339 }
-340
-341 public void onLocaleChange(IssuerLocaleChangedCallback<I> onChange) {
-342 localeChangedCallbacks.add(onChange);
-343 }
-344
-345 public void notifyLocaleChange(I issuer, Locale oldLocale, Locale newLocale) {
-346 localeChangedCallbacks.forEach(cb -> {
-347 try {
-348 cb.onIssuerLocaleChange(issuer, oldLocale, newLocale);
-349 } catch (Exception e) {
-350 this.log(LogLevel.ERROR, "Error in notifyLocaleChange", e);
-351 }
-352 });
+238 public abstract CommandExecutionContext createCommandContext(RegisteredCommand command, CommandParameter parameter, CommandIssuer sender, List<String> args, int i, Map<String, Object> passedArgs);
+239
+240 public abstract CommandCompletionContext createCompletionContext(RegisteredCommand command, CommandIssuer sender, String input, String config, String[] args);
+241
+242 public abstract void log(final LogLevel level, final String message, final Throwable throwable);
+243
+244 public void log(final LogLevel level, final String message) {
+245 log(level, message, null);
+246 }
+247
+248 /**
+249 * Lets you add custom string replacements that can be applied to annotation values,
+250 * to reduce duplication/repetition of common values such as permission nodes and command prefixes.
+251 *
+252 * Any replacement registered starts with a %
+253 *
+254 * So for ex @CommandPermission("%staff")
+255 * @return Replacements Manager
+256 */
+257 public CommandReplacements getCommandReplacements() {
+258 return replacements;
+259 }
+260
+261 public boolean hasPermission(CommandIssuer issuer, String permission) {
+262 if (permission == null || permission.isEmpty()) {
+263 return true;
+264 }
+265 for (String perm : ACFPatterns.COMMA.split(permission)) {
+266 if (!perm.isEmpty() && !issuer.hasPermission(perm)) {
+267 return false;
+268 }
+269 }
+270 return true;
+271 }
+272
+273 BaseCommand getBaseCommand(String commandLabel, @NotNull String[] args) {
+274 RootCommand rootCommand = obtainRootCommand(commandLabel);
+275 if (rootCommand == null) {
+276 return null;
+277 }
+278 return rootCommand.getBaseCommand(args);
+279 }
+280
+281 public synchronized RootCommand getRootCommand(@NotNull String cmd) {
+282 return rootCommands.get(ACFPatterns.SPACE.split(cmd.toLowerCase(), 2)[0]);
+283 }
+284
+285 public synchronized RootCommand obtainRootCommand(@NotNull String cmd) {
+286 return rootCommands.computeIfAbsent(ACFPatterns.SPACE.split(cmd.toLowerCase(), 2)[0], this::createRootCommand);
+287 }
+288
+289 public RegisteredCommand createRegisteredCommand(BaseCommand command, String cmdName, Method method, String prefSubCommand) {
+290 return new RegisteredCommand(command, cmdName, method, prefSubCommand);
+291 }
+292
+293 /**
+294 * Sets the default {@link ExceptionHandler} that is called when an exception occurs while executing a command, if the command doesn't have it's own exception handler registered.
+295 *
+296 * @param exceptionHandler the handler that should handle uncaught exceptions
+297 */
+298 public void setDefaultExceptionHandler(ExceptionHandler exceptionHandler) {
+299 defaultExceptionHandler = exceptionHandler;
+300 }
+301
+302 /**
+303 * Gets the current default exception handler, might be null.
+304 *
+305 * @return the default exception handler
+306 */
+307 public ExceptionHandler getDefaultExceptionHandler() {
+308 return defaultExceptionHandler;
+309 }
+310
+311 protected boolean handleUncaughtException(BaseCommand scope, RegisteredCommand registeredCommand, CommandIssuer sender, List<String> args, Throwable t) {
+312 if (t instanceof InvocationTargetException && t.getCause() != null) {
+313 t = t.getCause();
+314 }
+315 boolean result = false;
+316 if (scope.getExceptionHandler() != null) {
+317 result = scope.getExceptionHandler().execute(scope, registeredCommand, sender, args, t);
+318 } else if (defaultExceptionHandler != null) {
+319 result = defaultExceptionHandler.execute(scope, registeredCommand, sender, args, t);
+320 }
+321 return result;
+322 }
+323
+324 public void sendMessage(IT issuerArg, MessageType type, MessageKeyProvider key, String... replacements) {
+325 sendMessage(getCommandIssuer(issuerArg), type, key, replacements);
+326 }
+327
+328 public void sendMessage(CommandIssuer issuer, MessageType type, MessageKeyProvider key, String... replacements) {
+329 String message = formatMessage(issuer, type, key, replacements);
+330
+331 for (String msg : ACFPatterns.NEWLINE.split(message)) {
+332 issuer.sendMessageInternal(ACFUtil.rtrim(msg));
+333 }
+334 }
+335
+336 public String formatMessage(CommandIssuer issuer, MessageType type, MessageKeyProvider key, String... replacements) {
+337 String message = getLocales().getMessage(issuer, key.getMessageKey());
+338 if (replacements.length > 0) {
+339 message = ACFUtil.replaceStrings(message, replacements);
+340 }
+341
+342 message = getCommandReplacements().replace(message);
+343
+344 MessageFormatter formatter = formatters.getOrDefault(type, defaultFormatter);
+345 if (formatter != null) {
+346 message = formatter.format(message);
+347 }
+348 return message;
+349 }
+350
+351 public void onLocaleChange(IssuerLocaleChangedCallback<I> onChange) {
+352 localeChangedCallbacks.add(onChange);
353 }
354
-355 public Locale setIssuerLocale(IT issuer, Locale locale) {
-356 I commandIssuer = getCommandIssuer(issuer);
-357
-358 Locale old = issuersLocale.put(commandIssuer.getUniqueId(), locale);
-359 if (!Objects.equals(old, locale)) {
-360 this.notifyLocaleChange(commandIssuer, old, locale);
-361 }
-362
-363 return old;
-364 }
-365
-366 public Locale getIssuerLocale(CommandIssuer issuer) {
-367 if (usingPerIssuerLocale()) {
-368 Locale locale = issuersLocale.get(issuer.getUniqueId());
-369 if (locale != null) {
-370 return locale;
-371 }
-372 }
-373
-374 return getLocales().getDefaultLocale();
-375 }
-376
-377 CommandOperationContext<I> createCommandOperationContext(BaseCommand command, CommandIssuer issuer, String commandLabel, String[] args, boolean isAsync) {
-378 //noinspection unchecked
-379 return new CommandOperationContext<>(
-380 this,
-381 (I) issuer,
-382 command,
-383 commandLabel,
-384 args,
-385 isAsync
-386 );
-387 }
-388
-389 /**
-390 * Gets a list of all currently supported languages for this manager.
-391 * These locales will be automatically loaded from
-392 * @return
-393 */
-394 public Set<Locale> getSupportedLanguages() {
-395 return supportedLanguages;
-396 }
-397
-398 /**
-399 * Adds a new locale to the list of automatic Locales to load Message Bundles for.
-400 * All bundles loaded under the previous supported languages will now automatically load for this new locale too.
-401 *
-402 * @param locale
+355 public void notifyLocaleChange(I issuer, Locale oldLocale, Locale newLocale) {
+356 localeChangedCallbacks.forEach(cb -> {
+357 try {
+358 cb.onIssuerLocaleChange(issuer, oldLocale, newLocale);
+359 } catch (Exception e) {
+360 this.log(LogLevel.ERROR, "Error in notifyLocaleChange", e);
+361 }
+362 });
+363 }
+364
+365 public Locale setIssuerLocale(IT issuer, Locale locale) {
+366 I commandIssuer = getCommandIssuer(issuer);
+367
+368 Locale old = issuersLocale.put(commandIssuer.getUniqueId(), locale);
+369 if (!Objects.equals(old, locale)) {
+370 this.notifyLocaleChange(commandIssuer, old, locale);
+371 }
+372
+373 return old;
+374 }
+375
+376 public Locale getIssuerLocale(CommandIssuer issuer) {
+377 if (usingPerIssuerLocale()) {
+378 Locale locale = issuersLocale.get(issuer.getUniqueId());
+379 if (locale != null) {
+380 return locale;
+381 }
+382 }
+383
+384 return getLocales().getDefaultLocale();
+385 }
+386
+387 CommandOperationContext<I> createCommandOperationContext(BaseCommand command, CommandIssuer issuer, String commandLabel, String[] args, boolean isAsync) {
+388 //noinspection unchecked
+389 return new CommandOperationContext<>(
+390 this,
+391 (I) issuer,
+392 command,
+393 commandLabel,
+394 args,
+395 isAsync
+396 );
+397 }
+398
+399 /**
+400 * Gets a list of all currently supported languages for this manager.
+401 * These locales will be automatically loaded from
+402 * @return
403 */
-404 public void addSupportedLanguage(Locale locale) {
-405 supportedLanguages.add(locale);
-406 getLocales().loadMissingBundles();
-407 }
-408
-409 /**
-410 * Registers an instance of a class to be registered as an injectable dependency.<br>
-411 * The command manager will attempt to inject all fields in a command class that are annotated with
-412 * {@link co.aikar.commands.annotation.Dependency} with the provided instance.
-413 *
-414 * @param clazz the class the injector should look for when injecting
-415 * @param instance the instance of the class that should be injected
-416 * @throws IllegalStateException when there is already an instance for the provided class registered
-417 */
-418 public <T> void registerDependency(Class<? extends T> clazz, T instance){
-419 registerDependency(clazz, clazz.getName(), instance);
-420 }
-421
-422 /**
-423 * Registers an instance of a class to be registered as an injectable dependency.<br>
-424 * The command manager will attempt to inject all fields in a command class that are annotated with
-425 * {@link co.aikar.commands.annotation.Dependency} with the provided instance.
-426 *
-427 * @param clazz the class the injector should look for when injecting
-428 * @param key the key which needs to be present if that
-429 * @param instance the instance of the class that should be injected
-430 * @throws IllegalStateException when there is already an instance for the provided class registered
-431 */
-432 public <T> void registerDependency(Class<? extends T> clazz, String key, T instance){
-433 if(dependencies.containsRow(clazz) && dependencies.containsColumn(key)){
-434 throw new IllegalStateException("There is already an instance of " + clazz.getName() + " with the key " + key + " registered!");
-435 }
-436
-437 dependencies.put(clazz, key, instance);
-438 }
-439
-440 /**
-441 * Attempts to inject instances of classes registered with {@link CommandManager#registerDependency(Class, Object)}
-442 * into all fields of the class and its superclasses that are marked with {@link Dependency}.
-443 *
-444 * @param baseCommand the instance which fields should be filled
-445 */
-446 void injectDependencies(BaseCommand baseCommand) {
-447 Class clazz = baseCommand.getClass();
-448 do {
-449 for (Field field : clazz.getDeclaredFields()) {
-450 if (annotations.hasAnnotation(field, Dependency.class)) {
-451 String dependency = annotations.getAnnotationValue(field, Dependency.class);
-452 String key = (key = dependency).isEmpty() ? field.getType().getName() : key;
-453 Object object = dependencies.row(field.getType()).get(key);
-454 if (object == null) {
-455 throw new UnresolvedDependencyException("Could not find a registered instance of " +
-456 field.getType().getName() + " with key " + key + " for field " + field.getName() +
-457 " in class " + baseCommand.getClass().getName());
-458 }
-459
-460 try {
-461 boolean accessible = field.isAccessible();
-462 if (!accessible) {
-463 field.setAccessible(true);
-464 }
-465 field.set(baseCommand, object);
-466 field.setAccessible(accessible);
-467 } catch (IllegalAccessException e) {
-468 e.printStackTrace(); //TODO should we print our own exception here to make a more descriptive error?
-469 }
-470 }
-471 }
-472 clazz = clazz.getSuperclass();
-473 } while (!clazz.equals(BaseCommand.class));
-474 }
-475
-476 /**
-477 * @deprecated Use this with caution! If you enable and use Unstable API's, your next compile using ACF
-478 * may require you to update your implementation to those unstable API's
-479 */
-480 @Deprecated
-481 public void enableUnstableAPI(String api) {
-482 unstableAPIs.add(api);
-483 }
-484 void verifyUnstableAPI(String api) {
-485 if (!unstableAPIs.contains(api)) {
-486 throw new IllegalStateException("Using an unstable API that has not been enabled ( " + api + "). See https://acfunstable.emc.gs");
-487 }
-488 }
-489
-490 boolean hasUnstableAPI(String api) {
-491 return unstableAPIs.contains(api);
-492 }
-493
-494 Annotations getAnnotations() {
-495 return annotations;
-496 }
-497}
+404 public Set<Locale> getSupportedLanguages() {
+405 return supportedLanguages;
+406 }
+407
+408 /**
+409 * Adds a new locale to the list of automatic Locales to load Message Bundles for.
+410 * All bundles loaded under the previous supported languages will now automatically load for this new locale too.
+411 *
+412 * @param locale
+413 */
+414 public void addSupportedLanguage(Locale locale) {
+415 supportedLanguages.add(locale);
+416 getLocales().loadMissingBundles();
+417 }
+418
+419 /**
+420 * Registers an instance of a class to be registered as an injectable dependency.<br>
+421 * The command manager will attempt to inject all fields in a command class that are annotated with
+422 * {@link co.aikar.commands.annotation.Dependency} with the provided instance.
+423 *
+424 * @param clazz the class the injector should look for when injecting
+425 * @param instance the instance of the class that should be injected
+426 * @throws IllegalStateException when there is already an instance for the provided class registered
+427 */
+428 public <T> void registerDependency(Class<? extends T> clazz, T instance){
+429 registerDependency(clazz, clazz.getName(), instance);
+430 }
+431
+432 /**
+433 * Registers an instance of a class to be registered as an injectable dependency.<br>
+434 * The command manager will attempt to inject all fields in a command class that are annotated with
+435 * {@link co.aikar.commands.annotation.Dependency} with the provided instance.
+436 *
+437 * @param clazz the class the injector should look for when injecting
+438 * @param key the key which needs to be present if that
+439 * @param instance the instance of the class that should be injected
+440 * @throws IllegalStateException when there is already an instance for the provided class registered
+441 */
+442 public <T> void registerDependency(Class<? extends T> clazz, String key, T instance){
+443 if(dependencies.containsRow(clazz) && dependencies.containsColumn(key)){
+444 throw new IllegalStateException("There is already an instance of " + clazz.getName() + " with the key " + key + " registered!");
+445 }
+446
+447 dependencies.put(clazz, key, instance);
+448 }
+449
+450 /**
+451 * Attempts to inject instances of classes registered with {@link CommandManager#registerDependency(Class, Object)}
+452 * into all fields of the class and its superclasses that are marked with {@link Dependency}.
+453 *
+454 * @param baseCommand the instance which fields should be filled
+455 */
+456 void injectDependencies(BaseCommand baseCommand) {
+457 Class clazz = baseCommand.getClass();
+458 do {
+459 for (Field field : clazz.getDeclaredFields()) {
+460 if (annotations.hasAnnotation(field, Dependency.class)) {
+461 String dependency = annotations.getAnnotationValue(field, Dependency.class);
+462 String key = (key = dependency).isEmpty() ? field.getType().getName() : key;
+463 Object object = dependencies.row(field.getType()).get(key);
+464 if (object == null) {
+465 throw new UnresolvedDependencyException("Could not find a registered instance of " +
+466 field.getType().getName() + " with key " + key + " for field " + field.getName() +
+467 " in class " + baseCommand.getClass().getName());
+468 }
+469
+470 try {
+471 boolean accessible = field.isAccessible();
+472 if (!accessible) {
+473 field.setAccessible(true);
+474 }
+475 field.set(baseCommand, object);
+476 field.setAccessible(accessible);
+477 } catch (IllegalAccessException e) {
+478 e.printStackTrace(); //TODO should we print our own exception here to make a more descriptive error?
+479 }
+480 }
+481 }
+482 clazz = clazz.getSuperclass();
+483 } while (!clazz.equals(BaseCommand.class));
+484 }
+485
+486 /**
+487 * @deprecated Use this with caution! If you enable and use Unstable API's, your next compile using ACF
+488 * may require you to update your implementation to those unstable API's
+489 */
+490 @Deprecated
+491 public void enableUnstableAPI(String api) {
+492 unstableAPIs.add(api);
+493 }
+494 void verifyUnstableAPI(String api) {
+495 if (!unstableAPIs.contains(api)) {
+496 throw new IllegalStateException("Using an unstable API that has not been enabled ( " + api + "). See https://acfunstable.emc.gs");
+497 }
+498 }
+499
+500 boolean hasUnstableAPI(String api) {
+501 return unstableAPIs.contains(api);
+502 }
+503
+504 Annotations getAnnotations() {
+505 return annotations;
+506 }
+507
+508 public String getCommandPrefix(CommandIssuer issuer) {
+509 return "";
+510 }
+511}
diff --git a/docs/acf-core/src-html/co/aikar/commands/HelpEntry.html b/docs/acf-core/src-html/co/aikar/commands/HelpEntry.html
index e3aa7651..87c18b0d 100644
--- a/docs/acf-core/src-html/co/aikar/commands/HelpEntry.html
+++ b/docs/acf-core/src-html/co/aikar/commands/HelpEntry.html
@@ -31,14 +31,14 @@
023
024package co.aikar.commands;
025
-026import co.aikar.commands.annotation.HelpSearchTags;
+026public class HelpEntry {
027
-028public class HelpEntry {
-029
-030 private final RegisteredCommand command;
-031 private int searchScore = 1;
-032
-033 HelpEntry(RegisteredCommand command) {
+028 private final CommandHelp commandHelp;
+029 private final RegisteredCommand command;
+030 private int searchScore = 1;
+031
+032 HelpEntry(CommandHelp commandHelp, RegisteredCommand command) {
+033 this.commandHelp = commandHelp;
034 this.command = command;
035 }
036
@@ -46,35 +46,38 @@
038 return this.command;
039 }
040
-041
-042 public String getCommand(){
-043 return "/" + this.command.command;
-044 }
-045
-046 public String getParameterSyntax(){
-047 return this.command.syntaxText;
-048 }
-049
-050 public String getDescription(){
-051 return this.command.helpText;
-052 }
-053
-054 public void setSearchScore(int searchScore) {
-055 this.searchScore = searchScore;
-056 }
-057
-058 public boolean shouldShow() {
-059 return this.searchScore > 0;
-060 }
-061
-062 public int getSearchScore() {
-063 return searchScore;
-064 }
-065
-066 public String getSearchTags() {
-067 return command.helpSearchTags;
-068 }
-069}
+041 public String getCommand() {
+042 return this.commandHelp.commandPrefix + this.command.command;
+043 }
+044
+045 public String getParameterSyntax(){
+046 return this.command.syntaxText != null ? this.command.syntaxText : "";
+047 }
+048
+049 public String getDescription(){
+050 return this.command.helpText != null ? this.command.helpText : "";
+051 }
+052
+053 public void setSearchScore(int searchScore) {
+054 this.searchScore = searchScore;
+055 }
+056
+057 public boolean shouldShow() {
+058 return this.searchScore > 0;
+059 }
+060
+061 public int getSearchScore() {
+062 return searchScore;
+063 }
+064
+065 public String getSearchTags() {
+066 return command.helpSearchTags;
+067 }
+068
+069 public CommandParameter[] getParameters() {
+070 return command.parameters;
+071 }
+072}
diff --git a/docs/acf-core/src-html/co/aikar/commands/Locales.html b/docs/acf-core/src-html/co/aikar/commands/Locales.html
index 8565b2a2..4518dc7c 100644
--- a/docs/acf-core/src-html/co/aikar/commands/Locales.html
+++ b/docs/acf-core/src-html/co/aikar/commands/Locales.html
@@ -41,171 +41,177 @@
033
034import java.util.ArrayList;
035import java.util.HashMap;
-036import java.util.List;
-037import java.util.Locale;
-038import java.util.Map;
-039import java.util.Set;
-040import java.util.regex.Matcher;
-041
-042@SuppressWarnings("WeakerAccess")
-043public class Locales {
-044 // Locales for reference since Locale doesn't have as many, add our own here for ease of use.
-045 public static final Locale ENGLISH = Locale.ENGLISH;
-046 public static final Locale GERMAN = Locale.GERMAN;
-047 public static final Locale FRENCH = Locale.FRENCH;
-048 public static final Locale JAPANESE = Locale.JAPANESE;
-049 public static final Locale ITALIAN = Locale.ITALIAN;
-050 public static final Locale KOREAN = Locale.KOREAN;
-051 public static final Locale CHINESE = Locale.CHINESE;
-052 public static final Locale SIMPLIFIED_CHINESE = Locale.SIMPLIFIED_CHINESE;
-053 public static final Locale TRADITIONAL_CHINESE = Locale.TRADITIONAL_CHINESE;
-054 public static final Locale SPANISH = new Locale("es");
-055 public static final Locale DUTCH = new Locale("nl");
-056 public static final Locale DANISH = new Locale("da");
-057 public static final Locale CZECH = new Locale("cs");
-058 public static final Locale GREEK = new Locale("el");
-059 public static final Locale LATIN = new Locale("la");
-060 public static final Locale BULGARIAN = new Locale("bg");
-061 public static final Locale AFRIKAANS = new Locale("af");
-062 public static final Locale HINDI = new Locale("hi");
-063 public static final Locale HEBREW = new Locale("he");
-064 public static final Locale POLISH = new Locale("pl");
-065 public static final Locale PORTUGUESE = new Locale("pt");
-066 public static final Locale FINNISH = new Locale("fi");
-067 public static final Locale SWEDISH = new Locale("sv");
-068 public static final Locale RUSSIAN = new Locale("ru");
-069 public static final Locale ROMANIAN = new Locale("ro");
-070 public static final Locale VIETNAMESE = new Locale("vi");
-071 public static final Locale THAI = new Locale("th");
-072 public static final Locale TURKISH = new Locale("tr");
-073 public static final Locale UKRANIAN = new Locale("uk");
-074 public static final Locale ARABIC = new Locale("ar");
-075 public static final Locale WELSH = new Locale("cy");
-076
+036import java.util.LinkedHashMap;
+037import java.util.List;
+038import java.util.Locale;
+039import java.util.Map;
+040import java.util.Set;
+041import java.util.regex.Matcher;
+042
+043@SuppressWarnings("WeakerAccess")
+044public class Locales {
+045 // Locales for reference since Locale doesn't have as many, add our own here for ease of use.
+046 public static final Locale ENGLISH = Locale.ENGLISH;
+047 public static final Locale GERMAN = Locale.GERMAN;
+048 public static final Locale FRENCH = Locale.FRENCH;
+049 public static final Locale JAPANESE = Locale.JAPANESE;
+050 public static final Locale ITALIAN = Locale.ITALIAN;
+051 public static final Locale KOREAN = Locale.KOREAN;
+052 public static final Locale CHINESE = Locale.CHINESE;
+053 public static final Locale SIMPLIFIED_CHINESE = Locale.SIMPLIFIED_CHINESE;
+054 public static final Locale TRADITIONAL_CHINESE = Locale.TRADITIONAL_CHINESE;
+055 public static final Locale SPANISH = new Locale("es");
+056 public static final Locale DUTCH = new Locale("nl");
+057 public static final Locale DANISH = new Locale("da");
+058 public static final Locale CZECH = new Locale("cs");
+059 public static final Locale GREEK = new Locale("el");
+060 public static final Locale LATIN = new Locale("la");
+061 public static final Locale BULGARIAN = new Locale("bg");
+062 public static final Locale AFRIKAANS = new Locale("af");
+063 public static final Locale HINDI = new Locale("hi");
+064 public static final Locale HEBREW = new Locale("he");
+065 public static final Locale POLISH = new Locale("pl");
+066 public static final Locale PORTUGUESE = new Locale("pt");
+067 public static final Locale FINNISH = new Locale("fi");
+068 public static final Locale SWEDISH = new Locale("sv");
+069 public static final Locale RUSSIAN = new Locale("ru");
+070 public static final Locale ROMANIAN = new Locale("ro");
+071 public static final Locale VIETNAMESE = new Locale("vi");
+072 public static final Locale THAI = new Locale("th");
+073 public static final Locale TURKISH = new Locale("tr");
+074 public static final Locale UKRANIAN = new Locale("uk");
+075 public static final Locale ARABIC = new Locale("ar");
+076 public static final Locale WELSH = new Locale("cy");
077
-078 private final CommandManager manager;
-079 private final LocaleManager<CommandIssuer> localeManager;
-080 private final Map<ClassLoader, SetMultimap<String, Locale>> loadedBundles = new HashMap<>();
-081 private final List<ClassLoader> registeredClassLoaders = new ArrayList<>();
-082
-083 public Locales(CommandManager manager) {
-084 this.manager = manager;
-085 this.localeManager = LocaleManager.create(manager::getIssuerLocale);
-086 this.addBundleClassLoader(this.getClass().getClassLoader());
-087 }
-088
-089 public void loadLanguages() {
-090 addMessageBundles("acf-core");
-091 }
-092
-093 public Locale getDefaultLocale() {
-094 return this.localeManager.getDefaultLocale();
-095 }
-096
-097 public Locale setDefaultLocale(Locale locale) {
-098 return this.localeManager.setDefaultLocale(locale);
-099 }
-100
-101 /**
-102 * Looks for all previously loaded bundles, and if any new Supported Languages have been added, load them.
-103 */
-104 public void loadMissingBundles() {
-105 //noinspection unchecked
-106 Set<Locale> supportedLanguages = manager.getSupportedLanguages();
-107 for (Locale locale : supportedLanguages) {
-108 for(SetMultimap<String, Locale> localeData: this.loadedBundles.values()) {
-109 for (String bundleName : Sets.newHashSet(localeData.keys())) {
-110 addMessageBundle(bundleName, locale);
-111 }
-112 }
-113
-114 }
-115 }
-116
-117 public void addMessageBundles(String... bundleNames) {
-118 for (String bundleName : bundleNames) {
-119 //noinspection unchecked
-120 Set<Locale> supportedLanguages = manager.getSupportedLanguages();
-121 for (Locale locale : supportedLanguages) {
-122 addMessageBundle(bundleName, locale);
-123 }
-124 }
-125 }
-126
-127 public boolean addMessageBundle(String bundleName, Locale locale) {
-128 boolean found = false;
-129 for(ClassLoader classLoader: this.registeredClassLoaders) {
-130 if(this.addMessageBundle(classLoader, bundleName, locale)) {
-131 found = true;
-132 }
-133 }
-134
-135 return found;
-136 }
-137
-138 public boolean addMessageBundle(ClassLoader classLoader, String bundleName, Locale locale) {
-139 SetMultimap<String, Locale> classLoadersLocales = this.loadedBundles.getOrDefault(classLoader, HashMultimap.create());
-140 if(!classLoadersLocales.containsEntry(bundleName, locale)) {
-141 if(this.localeManager.addMessageBundle(classLoader, bundleName, locale)) {
-142 classLoadersLocales.put(bundleName, locale);
-143 this.loadedBundles.put(classLoader, classLoadersLocales);
-144 return true;
-145 }
-146 }
-147
-148 return false;
-149 }
-150
-151 public void addMessageStrings(Locale locale, @NotNull Map<String, String> messages) {
-152 Map<MessageKey, String> map = new HashMap<>(messages.size());
-153 messages.forEach((key, value) -> map.put(MessageKey.of(key), value));
-154 addMessages(locale, map);
-155 }
-156
-157 public void addMessages(Locale locale, @NotNull Map<MessageKey, String> messages) {
-158 this.localeManager.addMessages(locale, messages);
-159 }
-160
-161 public String addMessage(Locale locale, MessageKey key, String message) {
-162 return this.localeManager.addMessage(locale, key, message);
-163 }
-164
-165 public String getMessage(CommandIssuer issuer, MessageKeyProvider key) {
-166 final MessageKey msgKey = key.getMessageKey();
-167 String message = this.localeManager.getMessage(issuer, msgKey);
-168 if (message == null) {
-169 manager.log(LogLevel.ERROR, "Missing Language Key: " + msgKey.getKey());
-170 message = "<MISSING_LANGUAGE_KEY:" + msgKey.getKey() + ">";
-171 }
-172 return message;
-173 }
-174
-175 public String replaceI18NStrings(String message) {
-176 if (message == null) {
-177 return null;
-178 }
-179 Matcher matcher = ACFPatterns.I18N_STRING.matcher(message);
-180 if (!matcher.matches()) {
-181 return message;
-182 }
-183
-184 CommandIssuer issuer = CommandManager.getCurrentCommandIssuer();
-185
-186 matcher.reset();
-187 StringBuffer sb = new StringBuffer(message.length());
-188 while (matcher.find()) {
-189 MessageKey key = MessageKey.of(matcher.group("key"));
-190 matcher.appendReplacement(sb, Matcher.quoteReplacement(getMessage(issuer, key)));
-191 }
-192 matcher.appendTail(sb);
-193 return sb.toString();
-194 }
-195
-196 public boolean addBundleClassLoader(ClassLoader classLoader) {
-197 return !this.registeredClassLoaders.contains(classLoader) && this.registeredClassLoaders.add(classLoader);
-198
-199 }
-200}
+078
+079 private final CommandManager manager;
+080 private final LocaleManager<CommandIssuer> localeManager;
+081 private final Map<ClassLoader, SetMultimap<String, Locale>> loadedBundles = new HashMap<>();
+082 private final List<ClassLoader> registeredClassLoaders = new ArrayList<>();
+083
+084 public Locales(CommandManager manager) {
+085 this.manager = manager;
+086 this.localeManager = LocaleManager.create(manager::getIssuerLocale);
+087 this.addBundleClassLoader(this.getClass().getClassLoader());
+088 }
+089
+090 public void loadLanguages() {
+091 addMessageBundles("acf-core");
+092 }
+093
+094 public Locale getDefaultLocale() {
+095 return this.localeManager.getDefaultLocale();
+096 }
+097
+098 public Locale setDefaultLocale(Locale locale) {
+099 return this.localeManager.setDefaultLocale(locale);
+100 }
+101
+102 /**
+103 * Looks for all previously loaded bundles, and if any new Supported Languages have been added, load them.
+104 */
+105 public void loadMissingBundles() {
+106 //noinspection unchecked
+107 Set<Locale> supportedLanguages = manager.getSupportedLanguages();
+108 for (Locale locale : supportedLanguages) {
+109 for(SetMultimap<String, Locale> localeData: this.loadedBundles.values()) {
+110 for (String bundleName : Sets.newHashSet(localeData.keys())) {
+111 addMessageBundle(bundleName, locale);
+112 }
+113 }
+114
+115 }
+116 }
+117
+118 public void addMessageBundles(String... bundleNames) {
+119 for (String bundleName : bundleNames) {
+120 //noinspection unchecked
+121 Set<Locale> supportedLanguages = manager.getSupportedLanguages();
+122 for (Locale locale : supportedLanguages) {
+123 addMessageBundle(bundleName, locale);
+124 }
+125 }
+126 }
+127
+128 public boolean addMessageBundle(String bundleName, Locale locale) {
+129 boolean found = false;
+130 for(ClassLoader classLoader: this.registeredClassLoaders) {
+131 if(this.addMessageBundle(classLoader, bundleName, locale)) {
+132 found = true;
+133 }
+134 }
+135
+136 return found;
+137 }
+138
+139 public boolean addMessageBundle(ClassLoader classLoader, String bundleName, Locale locale) {
+140 SetMultimap<String, Locale> classLoadersLocales = this.loadedBundles.getOrDefault(classLoader, HashMultimap.create());
+141 if(!classLoadersLocales.containsEntry(bundleName, locale)) {
+142 if(this.localeManager.addMessageBundle(classLoader, bundleName, locale)) {
+143 classLoadersLocales.put(bundleName, locale);
+144 this.loadedBundles.put(classLoader, classLoadersLocales);
+145 return true;
+146 }
+147 }
+148
+149 return false;
+150 }
+151
+152 public void addMessageStrings(Locale locale, @NotNull Map<String, String> messages) {
+153 Map<MessageKey, String> map = new HashMap<>(messages.size());
+154 messages.forEach((key, value) -> map.put(MessageKey.of(key), value));
+155 this.localeManager.addMessages(locale, map);
+156 }
+157
+158 public void addMessages(Locale locale, @NotNull Map<? extends MessageKeyProvider, String> messages) {
+159 Map<MessageKey, String> messagesMap = new LinkedHashMap<>();
+160 for (Map.Entry<? extends MessageKeyProvider, String> entry : messages.entrySet()) {
+161 messagesMap.put(entry.getKey().getMessageKey(), entry.getValue());
+162 }
+163
+164 this.localeManager.addMessages(locale, messagesMap);
+165 }
+166
+167 public String addMessage(Locale locale, MessageKeyProvider key, String message) {
+168 return this.localeManager.addMessage(locale, key.getMessageKey(), message);
+169 }
+170
+171 public String getMessage(CommandIssuer issuer, MessageKeyProvider key) {
+172 final MessageKey msgKey = key.getMessageKey();
+173 String message = this.localeManager.getMessage(issuer, msgKey);
+174 if (message == null) {
+175 manager.log(LogLevel.ERROR, "Missing Language Key: " + msgKey.getKey());
+176 message = "<MISSING_LANGUAGE_KEY:" + msgKey.getKey() + ">";
+177 }
+178 return message;
+179 }
+180
+181 public String replaceI18NStrings(String message) {
+182 if (message == null) {
+183 return null;
+184 }
+185 Matcher matcher = ACFPatterns.I18N_STRING.matcher(message);
+186 if (!matcher.matches()) {
+187 return message;
+188 }
+189
+190 CommandIssuer issuer = CommandManager.getCurrentCommandIssuer();
+191
+192 matcher.reset();
+193 StringBuffer sb = new StringBuffer(message.length());
+194 while (matcher.find()) {
+195 MessageKey key = MessageKey.of(matcher.group("key"));
+196 matcher.appendReplacement(sb, Matcher.quoteReplacement(getMessage(issuer, key)));
+197 }
+198 matcher.appendTail(sb);
+199 return sb.toString();
+200 }
+201
+202 public boolean addBundleClassLoader(ClassLoader classLoader) {
+203 return !this.registeredClassLoaders.contains(classLoader) && this.registeredClassLoaders.add(classLoader);
+204
+205 }
+206}
diff --git a/docs/acf-core/src-html/co/aikar/commands/MessageKeys.html b/docs/acf-core/src-html/co/aikar/commands/MessageKeys.html
index cfa3a076..b4c5ff40 100644
--- a/docs/acf-core/src-html/co/aikar/commands/MessageKeys.html
+++ b/docs/acf-core/src-html/co/aikar/commands/MessageKeys.html
@@ -54,17 +54,21 @@
046 PLEASE_SPECIFY_AT_MOST,
047 NOT_ALLOWED_ON_CONSOLE,
048 COULD_NOT_FIND_PLAYER,
-049 HELP_FORMAT,
-050 NO_COMMAND_MATCHED_SEARCH,
-051 HELP_PAGE_INFORMATION,
-052 HELP_NO_RESULTS
-053 ;
-054
-055 private final MessageKey key = MessageKey.of("acf-core." + this.name().toLowerCase());
-056 public MessageKey getMessageKey() {
-057 return key;
-058 }
-059}
+049 NO_COMMAND_MATCHED_SEARCH,
+050 HELP_PAGE_INFORMATION,
+051 HELP_NO_RESULTS,
+052 HELP_HEADER,
+053 HELP_FORMAT,
+054 HELP_DETAILED_HEADER,
+055 HELP_DETAILED_PARAMETER_FORMAT,
+056 HELP_SEARCH_HEADER,
+057 ;
+058
+059 private final MessageKey key = MessageKey.of("acf-core." + this.name().toLowerCase());
+060 public MessageKey getMessageKey() {
+061 return key;
+062 }
+063}
diff --git a/docs/acf-jda/co/aikar/commands/JDACommandManager.html b/docs/acf-jda/co/aikar/commands/JDACommandManager.html
index fefa5db5..34ec246d 100644
--- a/docs/acf-jda/co/aikar/commands/JDACommandManager.html
+++ b/docs/acf-jda/co/aikar/commands/JDACommandManager.html
@@ -18,7 +18,7 @@
catch(err) {
}
//-->
-var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10,"i11":10,"i12":10,"i13":10,"i14":10,"i15":9,"i16":10,"i17":10,"i18":10,"i19":10,"i20":10};
+var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10,"i11":10,"i12":10,"i13":10,"i14":10,"i15":10,"i16":9,"i17":10,"i18":10,"i19":10,"i20":10,"i21":10};
var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
@@ -154,7 +154,7 @@ extends co.aikar.commands.CommandManager<net.dv8tion.jda.core.events.message.
001/* +002 * Copyright (c) 2016-2018 Daniel Ennis (Aikar) - MIT License +003 * +004 * Permission is hereby granted, free of charge, to any person obtaining +005 * a copy of this software and associated documentation files (the +006 * "Software"), to deal in the Software without restriction, including +007 * without limitation the rights to use, copy, modify, merge, publish, +008 * distribute, sublicense, and/or sell copies of the Software, and to +009 * permit persons to whom the Software is furnished to do so, subject to +010 * the following conditions: +011 * +012 * The above copyright notice and this permission notice shall be +013 * included in all copies or substantial portions of the Software. +014 * +015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +016 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +017 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +018 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +019 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +020 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +021 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +022 */ +023 +024package co.aikar.commands; +025 +026import org.jetbrains.annotations.NotNull; +027 +028public class CommandHelpFormatter { +029 +030 private final CommandManager manager; +031 +032 public CommandHelpFormatter(CommandManager manager) { +033 this.manager = manager; +034 } +035 +036 // ######## +037 // # help # +038 // ######## +039 +040 public void printHelpHeader(CommandHelp help, CommandIssuer issuer) { +041 issuer.sendMessage(MessageType.HELP, MessageKeys.HELP_HEADER, getHeaderFooterFormatReplacements(help)); +042 } +043 +044 public void printHelpEntry(CommandHelp help, CommandIssuer issuer, HelpEntry entry) { +045 String formatted = this.manager.formatMessage(issuer, MessageType.HELP, MessageKeys.HELP_FORMAT, getEntryFormatReplacements(help, entry)); +046 for (String msg : ACFPatterns.NEWLINE.split(formatted)) { +047 issuer.sendMessageInternal(ACFUtil.rtrim(msg)); +048 } +049 } +050 +051 public void printHelpFooter(CommandHelp help, CommandIssuer issuer) { +052 if (help.isLastPage()) { +053 return; +054 } +055 issuer.sendMessage(MessageType.HELP, MessageKeys.HELP_PAGE_INFORMATION, getHeaderFooterFormatReplacements(help)); +056 } +057 +058 // ########## +059 // # search # +060 // ########## +061 +062 public void printSearchHeader(CommandHelp help, CommandIssuer issuer) { +063 issuer.sendMessage(MessageType.HELP, MessageKeys.HELP_SEARCH_HEADER, getHeaderFooterFormatReplacements(help)); +064 } +065 +066 public void printSearchEntry(CommandHelp help, CommandIssuer issuer, HelpEntry page) { +067 String formatted = this.manager.formatMessage(issuer, MessageType.HELP, MessageKeys.HELP_FORMAT, getEntryFormatReplacements(help, page)); +068 for (String msg : ACFPatterns.NEWLINE.split(formatted)) { +069 issuer.sendMessageInternal(ACFUtil.rtrim(msg)); +070 } +071 } +072 +073 public void printSearchFooter(CommandHelp help, CommandIssuer issuer) { +074 if (help.isLastPage()) { +075 return; +076 } +077 issuer.sendMessage(MessageType.HELP, MessageKeys.HELP_PAGE_INFORMATION, getHeaderFooterFormatReplacements(help) +078 ); +079 } +080 +081 +082 // ############ +083 // # detailed # +084 // ############ +085 +086 public void printDetailedHelpHeader(CommandHelp help, CommandIssuer issuer, String command, HelpEntry entry) { +087 issuer.sendMessage(MessageType.HELP, MessageKeys.HELP_DETAILED_HEADER, +088 "{command}", entry.getCommand(), +089 "{command}", command +090 ); +091 } +092 +093 public void printDetailedParameter(CommandHelp help, CommandIssuer issuer, HelpEntry entry, CommandParameter param) { +094 String formattedMsg = this.manager.formatMessage(issuer, MessageType.HELP, MessageKeys.HELP_DETAILED_PARAMETER_FORMAT, getParameterFormatReplacements(help, param.getName(), param.getDescription(), entry)); +095 for (String msg : ACFPatterns.NEWLINE.split(formattedMsg)) { +096 issuer.sendMessageInternal(ACFUtil.rtrim(msg)); +097 } +098 } +099 +100 public void printDetailedHelpFooter(CommandHelp help, CommandIssuer issuer, HelpEntry entry) { +101 // default doesn't have a footer +102 } +103 +104 /** +105 * Override this to control replacements +106 * +107 * @param help +108 * @return +109 */ +110 public String[] getHeaderFooterFormatReplacements(CommandHelp help) { +111 return new String[]{ +112 "{search}", help.search != null ? String.join(" ", help.search) : "", +113 "{command}", help.getCommandName(), +114 "{rootcommand}", help.getCommandName(), +115 "{page}", "" + help.getPage(), +116 "{totalpages}", "" + help.getTotalPages(), +117 "{results}", "" + help.getTotalResults() +118 }; +119 } +120 +121 /** +122 * Override this to control replacements +123 * +124 * @param help +125 * @param e +126 * @return +127 */ +128 public String[] getEntryFormatReplacements(CommandHelp help, HelpEntry e) { +129 //{command} {parameters} {separator} {description} +130 return new String[]{ +131 "{command}", e.getCommand(), +132 "{rootcommand}", help.getCommandName(), +133 "{parameters}", e.getParameterSyntax(), +134 "{separator}", e.getDescription().isEmpty() ? "" : "-", +135 "{description}", e.getDescription() +136 }; +137 } +138 +139 /** +140 * Override this to control replacements +141 * +142 * @param help +143 * @param name +144 * @param description +145 * @param page +146 * @return +147 */ +148 @NotNull +149 public String[] getParameterFormatReplacements(CommandHelp help, String name, String description, HelpEntry page) { +150 //{name} {description} +151 return new String[]{ +152 "{name}", name, +153 "{description}", description, +154 "{command}", page.getCommand(), +155 "{rootcommand}", help.getCommandName() +156 }; +157 } +158} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ++ Fields inherited from class co.aikar.commands.CommandManager-conditions, defaultExceptionHandler, defaultFormatter, defaultHelpPerPage, dependencies, formatters, issuersLocale, localeChangedCallbacks, replacements, rootCommands, supportedLanguages, usePerIssuerLocale
+conditions, defaultExceptionHandler, defaultFormatter, defaultHelpPerPage, dependencies, formatters, helpFormatter, issuersLocale, localeChangedCallbacks, replacements, rootCommands, supportedLanguages, usePerIssuerLocale
@@ -225,64 +225,68 @@ extends co.aikar.commands.CommandManager<net.dv8tion.jda.core.events.message.
getCommandIssuer(Object issuer) | |||
String |
+getCommandPrefix(co.aikar.commands.CommandIssuer issuer) |
+||
CommandConfigProvider |
getConfigProvider() |
||
CommandConfig |
getDefaultConfig() |
||
net.dv8tion.jda.core.JDA |
getJDA() |
||
co.aikar.commands.Locales |
getLocales() |
||
Logger |
getLogger() |
||
CommandPermissionResolver |
getPermissionResolver() |
||
boolean |
hasRegisteredCommands() |
||
boolean |
isCommandIssuer(Class<?> type) |
||
void |
log(co.aikar.commands.LogLevel level,
String message,
Throwable throwable) |
||
static JDAOptions |
options() |
||
void |
registerCommand(co.aikar.commands.BaseCommand command) |
||
void |
setConfigProvider(CommandConfigProvider configProvider) |
||
void |
setDefaultConfig(@NotNull CommandConfig defaultConfig) |
||
void |
setLogger(Logger logger) |
||
void |
setPermissionResolver(CommandPermissionResolver permissionResolver) |
getCommandIssuer(Object issuer) |
|
String |
+getCommandPrefix(co.aikar.commands.CommandIssuer issuer) |
+||
SpongeLocales |
getLocales() |
||
org.spongepowered.api.plugin.PluginContainer |
getPlugin() |
||
boolean |
hasRegisteredCommands() |
||
boolean |
isCommandIssuer(Class<?> type) |
||
void |
log(co.aikar.commands.LogLevel level,
String message,
Throwable throwable) |
||
void |
registerCommand(co.aikar.commands.BaseCommand command) |