diff --git a/docs/acf-bukkit/co/aikar/commands/BukkitCommandManager.html b/docs/acf-bukkit/co/aikar/commands/BukkitCommandManager.html index 000fb917..e067dd38 100644 --- a/docs/acf-bukkit/co/aikar/commands/BukkitCommandManager.html +++ b/docs/acf-bukkit/co/aikar/commands/BukkitCommandManager.html @@ -113,7 +113,7 @@ var activeTableTab = "activeTableTab";


  • -
    public class BukkitCommandManager
    +
    public class BukkitCommandManager
     extends co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,BukkitCommandIssuer,org.bukkit.ChatColor,BukkitMessageFormatter,BukkitCommandExecutionContext,BukkitConditionContext>
  • @@ -167,7 +167,7 @@ extends co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,

    Fields inherited from class co.aikar.commands.CommandManager

    -conditions, defaultExceptionHandler, defaultFormatter, defaultHelpPerPage, formatters, localeChangedCallbacks, replacements, rootCommands, supportedLanguages, usePerIssuerLocale +conditions, defaultExceptionHandler, defaultFormatter, defaultHelpPerPage, dependencies, formatters, localeChangedCallbacks, replacements, rootCommands, supportedLanguages, usePerIssuerLocale @@ -311,7 +311,7 @@ extends co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,

    Methods inherited from class co.aikar.commands.CommandManager

    -addSupportedLanguage, enableUnstableAPI, formatMessage, generateCommandHelp, generateCommandHelp, generateCommandHelp, generateCommandHelp, getCommandConditions, getCommandReplacements, getCurrentCommandIssuer, getCurrentCommandManager, getCurrentCommandOperationContext, getDefaultExceptionHandler, getDefaultFormatter, getDefaultHelpPerPage, getFormat, getRootCommand, getSupportedLanguages, handleUncaughtException, hasPermission, log, notifyLocaleChange, obtainRootCommand, onLocaleChange, sendMessage, sendMessage, setDefaultExceptionHandler, setDefaultFormatter, setDefaultHelpPerPage, setFormat, setFormat, setFormat, usePerIssuerLocale, usingPerIssuerLocale +addSupportedLanguage, enableUnstableAPI, formatMessage, generateCommandHelp, generateCommandHelp, generateCommandHelp, generateCommandHelp, getCommandConditions, getCommandReplacements, getCurrentCommandIssuer, getCurrentCommandManager, getCurrentCommandOperationContext, getDefaultExceptionHandler, getDefaultFormatter, getDefaultHelpPerPage, getFormat, getRootCommand, getSupportedLanguages, handleUncaughtException, hasPermission, log, notifyLocaleChange, obtainRootCommand, onLocaleChange, registerDependency, registerDependency, sendMessage, sendMessage, setDefaultExceptionHandler, setDefaultFormatter, setDefaultHelpPerPage, setFormat, setFormat, setFormat, usePerIssuerLocale, usingPerIssuerLocale @@ -349,7 +349,7 @@ extends co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,
  • knownCommands

    -
    protected Map<String,org.bukkit.command.Command> knownCommands
    +
    protected Map<String,org.bukkit.command.Command> knownCommands
  • @@ -358,7 +358,7 @@ extends co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,
  • registeredCommands

    -
    protected Map<String,BukkitRootCommand> registeredCommands
    +
    protected Map<String,BukkitRootCommand> registeredCommands
  • @@ -367,7 +367,7 @@ extends co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,
  • contexts

    -
    protected BukkitCommandContexts contexts
    +
    protected BukkitCommandContexts contexts
  • @@ -376,7 +376,7 @@ extends co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,
  • completions

    -
    protected BukkitCommandCompletions completions
    +
    protected BukkitCommandCompletions completions
  • @@ -385,7 +385,7 @@ extends co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,
  • locales

    -
    protected BukkitLocales locales
    +
    protected BukkitLocales locales
  • @@ -394,7 +394,7 @@ extends co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,
  • issuersLocale

    -
    protected Map<UUID,Locale> issuersLocale
    +
    protected Map<UUID,Locale> issuersLocale
  • @@ -411,7 +411,7 @@ extends co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,
  • BukkitCommandManager

    -
    public BukkitCommandManager(org.bukkit.plugin.Plugin plugin)
    +
    public BukkitCommandManager(org.bukkit.plugin.Plugin plugin)
  • @@ -428,7 +428,7 @@ extends co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,
  • getPlugin

    -
    public org.bukkit.plugin.Plugin getPlugin()
    +
    public org.bukkit.plugin.Plugin getPlugin()
  • @@ -437,7 +437,7 @@ extends co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,
  • isCommandIssuer

    -
    public boolean isCommandIssuer(Class<?> type)
    +
    public boolean isCommandIssuer(Class<?> type)
    Specified by:
    isCommandIssuer in class co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,BukkitCommandIssuer,org.bukkit.ChatColor,BukkitMessageFormatter,BukkitCommandExecutionContext,BukkitConditionContext>
    @@ -450,7 +450,7 @@ extends co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,
  • getCommandContexts

    -
    public co.aikar.commands.CommandContexts<BukkitCommandExecutionContextgetCommandContexts()
    +
    public co.aikar.commands.CommandContexts<BukkitCommandExecutionContextgetCommandContexts()
    Specified by:
    getCommandContexts in class co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,BukkitCommandIssuer,org.bukkit.ChatColor,BukkitMessageFormatter,BukkitCommandExecutionContext,BukkitConditionContext>
    @@ -463,7 +463,7 @@ extends co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,
  • getCommandCompletions

    -
    public co.aikar.commands.CommandCompletions<BukkitCommandCompletionContextgetCommandCompletions()
    +
    public co.aikar.commands.CommandCompletions<BukkitCommandCompletionContextgetCommandCompletions()
    Specified by:
    getCommandCompletions in class co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,BukkitCommandIssuer,org.bukkit.ChatColor,BukkitMessageFormatter,BukkitCommandExecutionContext,BukkitConditionContext>
    @@ -476,7 +476,7 @@ extends co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,
  • getLocales

    -
    public BukkitLocales getLocales()
    +
    public BukkitLocales getLocales()
    Specified by:
    getLocales in class co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,BukkitCommandIssuer,org.bukkit.ChatColor,BukkitMessageFormatter,BukkitCommandExecutionContext,BukkitConditionContext>
    @@ -489,7 +489,7 @@ extends co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,
  • hasRegisteredCommands

    -
    public boolean hasRegisteredCommands()
    +
    public boolean hasRegisteredCommands()
    Specified by:
    hasRegisteredCommands in class co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,BukkitCommandIssuer,org.bukkit.ChatColor,BukkitMessageFormatter,BukkitCommandExecutionContext,BukkitConditionContext>
    @@ -502,7 +502,7 @@ extends co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,
  • registerCommand

    -
    public void registerCommand(co.aikar.commands.BaseCommand command,
    +
    public void registerCommand(co.aikar.commands.BaseCommand command,
                                 boolean force)
  • @@ -512,7 +512,7 @@ extends co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,
  • registerCommand

    -
    public void registerCommand(co.aikar.commands.BaseCommand command)
    +
    public void registerCommand(co.aikar.commands.BaseCommand command)
    Specified by:
    registerCommand in class co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,BukkitCommandIssuer,org.bukkit.ChatColor,BukkitMessageFormatter,BukkitCommandExecutionContext,BukkitConditionContext>
    @@ -525,7 +525,7 @@ extends co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,
  • unregisterCommand

    -
    public void unregisterCommand(co.aikar.commands.BaseCommand command)
    +
    public void unregisterCommand(co.aikar.commands.BaseCommand command)
  • @@ -535,7 +535,7 @@ extends co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,

    unregisterCommand

    @Deprecated
    -public void unregisterCommand(BukkitRootCommand command)
    +public void unregisterCommand(BukkitRootCommand command)
    Deprecated. Use unregisterCommand(BaseCommand) - this will be visibility reduced later.
    Parameters:
    @@ -549,7 +549,7 @@ public void 
  • unregisterCommands

    -
    public void unregisterCommands()
    +
    public void unregisterCommands()
  • @@ -558,7 +558,7 @@ public void 
  • getTimings

    -
    public co.aikar.timings.lib.TimingManager getTimings()
    +
    public co.aikar.timings.lib.TimingManager getTimings()
  • @@ -567,7 +567,7 @@ public void 
  • createRootCommand

    -
    public co.aikar.commands.RootCommand createRootCommand(String cmd)
    +
    public co.aikar.commands.RootCommand createRootCommand(String cmd)
    Specified by:
    createRootCommand in class co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,BukkitCommandIssuer,org.bukkit.ChatColor,BukkitMessageFormatter,BukkitCommandExecutionContext,BukkitConditionContext>
    @@ -580,7 +580,7 @@ public void 
  • getCommandIssuer

    -
    public BukkitCommandIssuer getCommandIssuer(Object issuer)
    +
    public BukkitCommandIssuer getCommandIssuer(Object issuer)
    Specified by:
    getCommandIssuer in class co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,BukkitCommandIssuer,org.bukkit.ChatColor,BukkitMessageFormatter,BukkitCommandExecutionContext,BukkitConditionContext>
    @@ -593,7 +593,7 @@ public void 
  • createCommandContext

    -
    public BukkitCommandExecutionContext createCommandContext(co.aikar.commands.RegisteredCommand command,
    +
    public BukkitCommandExecutionContext createCommandContext(co.aikar.commands.RegisteredCommand command,
                                                               Parameter parameter,
                                                               co.aikar.commands.CommandIssuer sender,
                                                               List<String> args,
    @@ -611,7 +611,7 @@ public void 
     
  • createCompletionContext

    -
    public BukkitCommandCompletionContext createCompletionContext(co.aikar.commands.RegisteredCommand command,
    +
    public BukkitCommandCompletionContext createCompletionContext(co.aikar.commands.RegisteredCommand command,
                                                                   co.aikar.commands.CommandIssuer sender,
                                                                   String input,
                                                                   String config,
    @@ -628,7 +628,7 @@ public void 
     
  • createRegisteredCommand

    -
    public co.aikar.commands.RegisteredCommand createRegisteredCommand(co.aikar.commands.BaseCommand command,
    +
    public co.aikar.commands.RegisteredCommand createRegisteredCommand(co.aikar.commands.BaseCommand command,
                                                                        String cmdName,
                                                                        Method method,
                                                                        String prefSubCommand)
    @@ -644,7 +644,7 @@ public void 
  • createConditionContext

    -
    public BukkitConditionContext createConditionContext(co.aikar.commands.CommandIssuer issuer,
    +
    public BukkitConditionContext createConditionContext(co.aikar.commands.CommandIssuer issuer,
                                                          String config)
    Overrides:
    @@ -658,7 +658,7 @@ public void 
  • log

    -
    public void log(co.aikar.commands.LogLevel level,
    +
    public void log(co.aikar.commands.LogLevel level,
                     String message,
                     Throwable throwable)
    @@ -673,7 +673,7 @@ public void 
  • setPlayerLocale

    -
    public Locale setPlayerLocale(org.bukkit.entity.Player player,
    +
    public Locale setPlayerLocale(org.bukkit.entity.Player player,
                                   Locale locale)
  • @@ -683,7 +683,7 @@ public void 
  • getIssuerLocale

    -
    public Locale getIssuerLocale(co.aikar.commands.CommandIssuer issuer)
    +
    public Locale getIssuerLocale(co.aikar.commands.CommandIssuer issuer)
    Overrides:
    getIssuerLocale in class co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,BukkitCommandIssuer,org.bukkit.ChatColor,BukkitMessageFormatter,BukkitCommandExecutionContext,BukkitConditionContext>
    diff --git a/docs/acf-bukkit/src-html/co/aikar/commands/BukkitCommandCompletions.html b/docs/acf-bukkit/src-html/co/aikar/commands/BukkitCommandCompletions.html index 6a9f18f6..53f4f463 100644 --- a/docs/acf-bukkit/src-html/co/aikar/commands/BukkitCommandCompletions.html +++ b/docs/acf-bukkit/src-html/co/aikar/commands/BukkitCommandCompletions.html @@ -82,7 +82,7 @@ 074 075 Player senderPlayer = sender instanceof Player ? (Player) sender : null; 076 -077 ArrayList<String> matchedPlayers = new ArrayList<String>(); +077 ArrayList<String> matchedPlayers = new ArrayList<>(); 078 for (Player player : Bukkit.getOnlinePlayers()) { 079 String name = player.getName(); 080 if ((senderPlayer == null || senderPlayer.canSee(player)) && StringUtil.startsWithIgnoreCase(name, c.getInput())) { diff --git a/docs/acf-bukkit/src-html/co/aikar/commands/BukkitCommandManager.html b/docs/acf-bukkit/src-html/co/aikar/commands/BukkitCommandManager.html index 610a1594..0c3a61fa 100644 --- a/docs/acf-bukkit/src-html/co/aikar/commands/BukkitCommandManager.html +++ b/docs/acf-bukkit/src-html/co/aikar/commands/BukkitCommandManager.html @@ -43,317 +43,331 @@ 035import org.bukkit.command.CommandSender; 036import org.bukkit.command.SimpleCommandMap; 037import org.bukkit.entity.Player; -038import org.bukkit.plugin.Plugin; -039import org.bukkit.scheduler.BukkitTask; -040import org.jetbrains.annotations.NotNull; -041 -042import java.lang.reflect.Field; -043import java.lang.reflect.Method; -044import java.lang.reflect.Parameter; -045import java.util.HashMap; -046import java.util.List; -047import java.util.Locale; -048import java.util.Map; -049import java.util.Objects; -050import java.util.UUID; -051import java.util.logging.Level; -052import java.util.logging.Logger; -053 -054@SuppressWarnings("WeakerAccess") -055public class BukkitCommandManager extends CommandManager< -056 CommandSender, -057 BukkitCommandIssuer, -058 ChatColor, -059 BukkitMessageFormatter, -060 BukkitCommandExecutionContext, -061 BukkitConditionContext -062 > { -063 -064 @SuppressWarnings("WeakerAccess") -065 protected final Plugin plugin; -066 private final CommandMap commandMap; -067 private final TimingManager timingManager; -068 private final BukkitTask localeTask; -069 private final Logger logger; -070 protected Map<String, Command> knownCommands = new HashMap<>(); -071 protected Map<String, BukkitRootCommand> registeredCommands = new HashMap<>(); -072 protected BukkitCommandContexts contexts; -073 protected BukkitCommandCompletions completions; -074 MCTiming commandTiming; -075 protected BukkitLocales locales; -076 private boolean cantReadLocale = false; -077 protected Map<UUID, Locale> issuersLocale = Maps.newConcurrentMap(); -078 -079 @SuppressWarnings("JavaReflectionMemberAccess") -080 public BukkitCommandManager(Plugin plugin) { -081 this.plugin = plugin; -082 this.logger = Logger.getLogger(this.plugin.getName()); -083 this.timingManager = TimingManager.of(plugin); -084 this.commandTiming = this.timingManager.of("Commands"); -085 this.commandMap = hookCommandMap(); -086 this.formatters.put(MessageType.ERROR, defaultFormatter = new BukkitMessageFormatter(ChatColor.RED, ChatColor.YELLOW, ChatColor.RED)); -087 this.formatters.put(MessageType.SYNTAX, new BukkitMessageFormatter(ChatColor.YELLOW, ChatColor.GREEN, ChatColor.WHITE)); -088 this.formatters.put(MessageType.INFO, new BukkitMessageFormatter(ChatColor.BLUE, ChatColor.DARK_GREEN, ChatColor.GREEN)); -089 this.formatters.put(MessageType.HELP, new BukkitMessageFormatter(ChatColor.AQUA, ChatColor.GREEN, ChatColor.YELLOW)); -090 Bukkit.getPluginManager().registerEvents(new ACFBukkitListener(this, plugin), plugin); -091 getLocales(); // auto load locales -092 this.localeTask = Bukkit.getScheduler().runTaskTimer(plugin, () -> { -093 if (cantReadLocale) { -094 return; -095 } -096 Bukkit.getOnlinePlayers().forEach(this::readPlayerLocale); -097 }, 5, 5); -098 } -099 -100 @NotNull private CommandMap hookCommandMap() { -101 CommandMap commandMap = null; -102 try { -103 Server server = Bukkit.getServer(); -104 Method getCommandMap = server.getClass().getDeclaredMethod("getCommandMap"); -105 getCommandMap.setAccessible(true); -106 commandMap = (CommandMap) getCommandMap.invoke(server); -107 if (!SimpleCommandMap.class.isAssignableFrom(commandMap.getClass())) { -108 this.log(LogLevel.ERROR, "ERROR: CommandMap has been hijacked! Offending command map is located at: " + commandMap.getClass().getName()); -109 this.log(LogLevel.ERROR, "We are going to try to hijack it back and resolve this, but you are now in dangerous territory."); -110 this.log(LogLevel.ERROR, "We can not guarantee things are going to work."); -111 Field cmField = server.getClass().getDeclaredField("commandMap"); -112 commandMap = new ProxyCommandMap(this, commandMap); -113 cmField.set(server, commandMap); -114 this.log(LogLevel.INFO, "Injected Proxy Command Map... good luck..."); -115 } -116 Field knownCommands = SimpleCommandMap.class.getDeclaredField("knownCommands"); -117 knownCommands.setAccessible(true); -118 //noinspection unchecked -119 this.knownCommands = (Map<String, Command>) knownCommands.get(commandMap); -120 } catch (Exception e) { -121 this.log(LogLevel.ERROR, "Failed to get Command Map. ACF will not function."); -122 ACFUtil.sneaky(e); -123 } -124 return commandMap; -125 } -126 -127 public Plugin getPlugin() { -128 return this.plugin; -129 } -130 -131 @Override -132 public boolean isCommandIssuer(Class<?> type) { -133 return CommandSender.class.isAssignableFrom(type); -134 } -135 -136 @Override -137 public synchronized CommandContexts<BukkitCommandExecutionContext> getCommandContexts() { -138 if (this.contexts == null) { -139 this.contexts = new BukkitCommandContexts(this); -140 } -141 return contexts; -142 } -143 -144 @Override -145 public synchronized CommandCompletions<BukkitCommandCompletionContext> getCommandCompletions() { -146 if (this.completions == null) { -147 this.completions = new BukkitCommandCompletions(this); -148 } -149 return completions; -150 } -151 -152 -153 @Override -154 public BukkitLocales getLocales() { -155 if (this.locales == null) { -156 this.locales = new BukkitLocales(this); -157 this.locales.loadLanguages(); -158 } -159 return locales; -160 } -161 -162 -163 @Override -164 public boolean hasRegisteredCommands() { -165 return !registeredCommands.isEmpty(); -166 } -167 -168 public void registerCommand(BaseCommand command, boolean force) { -169 final String plugin = this.plugin.getName().toLowerCase(); -170 command.onRegister(this); -171 for (Map.Entry<String, RootCommand> entry : command.registeredCommands.entrySet()) { -172 String commandName = entry.getKey().toLowerCase(); -173 BukkitRootCommand bukkitCommand = (BukkitRootCommand) entry.getValue(); -174 if (!bukkitCommand.isRegistered) { -175 if (force && knownCommands.containsKey(commandName)) { -176 Command oldCommand = commandMap.getCommand(commandName); -177 knownCommands.remove(commandName); -178 for (Map.Entry<String, Command> ce : knownCommands.entrySet()) { -179 String key = ce.getKey(); -180 Command value = ce.getValue(); -181 if (key.contains(":") && oldCommand.equals(value)) { -182 String[] split = ACFPatterns.COLON.split(key, 2); -183 if (split.length > 1) { -184 oldCommand.unregister(commandMap); -185 oldCommand.setLabel(split[0] + ":" + command.getName()); -186 oldCommand.register(commandMap); -187 } -188 } -189 } -190 } -191 commandMap.register(commandName, plugin, bukkitCommand); -192 } -193 bukkitCommand.isRegistered = true; -194 registeredCommands.put(commandName, bukkitCommand); -195 } -196 } -197 -198 @Override -199 public void registerCommand(BaseCommand command) { -200 registerCommand(command, false); -201 } -202 -203 public void unregisterCommand(BaseCommand command) { -204 for (RootCommand rootcommand : command.registeredCommands.values()) { -205 BukkitRootCommand bukkitCommand = (BukkitRootCommand) rootcommand; -206 bukkitCommand.getSubCommands().values().removeAll(command.subCommands.values()); -207 if (bukkitCommand.isRegistered && bukkitCommand.getSubCommands().isEmpty()) { -208 unregisterCommand(bukkitCommand); -209 bukkitCommand.isRegistered = false; -210 } -211 } -212 } -213 -214 /** -215 * @deprecated Use unregisterCommand(BaseCommand) - this will be visibility reduced later. -216 * @param command -217 */ -218 @Deprecated -219 public void unregisterCommand(BukkitRootCommand command) { -220 final String plugin = this.plugin.getName().toLowerCase(); -221 command.unregister(commandMap); -222 String key = command.getName(); -223 Command registered = knownCommands.get(key); -224 if (command.equals(registered)) { -225 knownCommands.remove(key); -226 } -227 knownCommands.remove(plugin + ":" + key); -228 } -229 -230 public void unregisterCommands() { -231 for (Map.Entry<String, BukkitRootCommand> entry : registeredCommands.entrySet()) { -232 unregisterCommand(entry.getValue()); -233 } -234 this.registeredCommands.clear(); -235 } -236 -237 -238 private Field getEntityField(Player player) throws NoSuchFieldException { -239 Class cls = player.getClass(); -240 while (cls != Object.class) { -241 if (cls.getName().endsWith("CraftEntity")) { -242 Field field = cls.getDeclaredField("entity"); -243 field.setAccessible(true); -244 return field; -245 } -246 cls = cls.getSuperclass(); +038import org.bukkit.inventory.ItemFactory; +039import org.bukkit.plugin.Plugin; +040import org.bukkit.plugin.PluginManager; +041import org.bukkit.plugin.java.JavaPlugin; +042import org.bukkit.scheduler.BukkitScheduler; +043import org.bukkit.scheduler.BukkitTask; +044import org.bukkit.scoreboard.ScoreboardManager; +045import org.jetbrains.annotations.NotNull; +046 +047import java.lang.reflect.Field; +048import java.lang.reflect.Method; +049import java.lang.reflect.Parameter; +050import java.util.HashMap; +051import java.util.List; +052import java.util.Locale; +053import java.util.Map; +054import java.util.Objects; +055import java.util.UUID; +056import java.util.logging.Level; +057import java.util.logging.Logger; +058 +059@SuppressWarnings("WeakerAccess") +060public class BukkitCommandManager extends CommandManager< +061 CommandSender, +062 BukkitCommandIssuer, +063 ChatColor, +064 BukkitMessageFormatter, +065 BukkitCommandExecutionContext, +066 BukkitConditionContext +067 > { +068 +069 @SuppressWarnings("WeakerAccess") +070 protected final Plugin plugin; +071 private final CommandMap commandMap; +072 private final TimingManager timingManager; +073 private final BukkitTask localeTask; +074 private final Logger logger; +075 protected Map<String, Command> knownCommands = new HashMap<>(); +076 protected Map<String, BukkitRootCommand> registeredCommands = new HashMap<>(); +077 protected BukkitCommandContexts contexts; +078 protected BukkitCommandCompletions completions; +079 MCTiming commandTiming; +080 protected BukkitLocales locales; +081 private boolean cantReadLocale = false; +082 protected Map<UUID, Locale> issuersLocale = Maps.newConcurrentMap(); +083 +084 @SuppressWarnings("JavaReflectionMemberAccess") +085 public BukkitCommandManager(Plugin plugin) { +086 this.plugin = plugin; +087 this.logger = Logger.getLogger(this.plugin.getName()); +088 this.timingManager = TimingManager.of(plugin); +089 this.commandTiming = this.timingManager.of("Commands"); +090 this.commandMap = hookCommandMap(); +091 this.formatters.put(MessageType.ERROR, defaultFormatter = new BukkitMessageFormatter(ChatColor.RED, ChatColor.YELLOW, ChatColor.RED)); +092 this.formatters.put(MessageType.SYNTAX, new BukkitMessageFormatter(ChatColor.YELLOW, ChatColor.GREEN, ChatColor.WHITE)); +093 this.formatters.put(MessageType.INFO, new BukkitMessageFormatter(ChatColor.BLUE, ChatColor.DARK_GREEN, ChatColor.GREEN)); +094 this.formatters.put(MessageType.HELP, new BukkitMessageFormatter(ChatColor.AQUA, ChatColor.GREEN, ChatColor.YELLOW)); +095 Bukkit.getPluginManager().registerEvents(new ACFBukkitListener(this, plugin), plugin); +096 getLocales(); // auto load locales +097 this.localeTask = Bukkit.getScheduler().runTaskTimer(plugin, () -> { +098 if (cantReadLocale) { +099 return; +100 } +101 Bukkit.getOnlinePlayers().forEach(this::readPlayerLocale); +102 }, 5, 5); +103 +104 registerDependency(plugin.getClass(), plugin); +105 registerDependency(Plugin.class, plugin); +106 registerDependency(JavaPlugin.class, plugin); +107 registerDependency(PluginManager.class, Bukkit.getPluginManager()); +108 registerDependency(Server.class, Bukkit.getServer()); +109 registerDependency(BukkitScheduler.class, Bukkit.getScheduler()); +110 registerDependency(ScoreboardManager.class, Bukkit.getScoreboardManager()); +111 registerDependency(ItemFactory.class, Bukkit.getItemFactory()); +112 } +113 +114 @NotNull private CommandMap hookCommandMap() { +115 CommandMap commandMap = null; +116 try { +117 Server server = Bukkit.getServer(); +118 Method getCommandMap = server.getClass().getDeclaredMethod("getCommandMap"); +119 getCommandMap.setAccessible(true); +120 commandMap = (CommandMap) getCommandMap.invoke(server); +121 if (!SimpleCommandMap.class.isAssignableFrom(commandMap.getClass())) { +122 this.log(LogLevel.ERROR, "ERROR: CommandMap has been hijacked! Offending command map is located at: " + commandMap.getClass().getName()); +123 this.log(LogLevel.ERROR, "We are going to try to hijack it back and resolve this, but you are now in dangerous territory."); +124 this.log(LogLevel.ERROR, "We can not guarantee things are going to work."); +125 Field cmField = server.getClass().getDeclaredField("commandMap"); +126 commandMap = new ProxyCommandMap(this, commandMap); +127 cmField.set(server, commandMap); +128 this.log(LogLevel.INFO, "Injected Proxy Command Map... good luck..."); +129 } +130 Field knownCommands = SimpleCommandMap.class.getDeclaredField("knownCommands"); +131 knownCommands.setAccessible(true); +132 //noinspection unchecked +133 this.knownCommands = (Map<String, Command>) knownCommands.get(commandMap); +134 } catch (Exception e) { +135 this.log(LogLevel.ERROR, "Failed to get Command Map. ACF will not function."); +136 ACFUtil.sneaky(e); +137 } +138 return commandMap; +139 } +140 +141 public Plugin getPlugin() { +142 return this.plugin; +143 } +144 +145 @Override +146 public boolean isCommandIssuer(Class<?> type) { +147 return CommandSender.class.isAssignableFrom(type); +148 } +149 +150 @Override +151 public synchronized CommandContexts<BukkitCommandExecutionContext> getCommandContexts() { +152 if (this.contexts == null) { +153 this.contexts = new BukkitCommandContexts(this); +154 } +155 return contexts; +156 } +157 +158 @Override +159 public synchronized CommandCompletions<BukkitCommandCompletionContext> getCommandCompletions() { +160 if (this.completions == null) { +161 this.completions = new BukkitCommandCompletions(this); +162 } +163 return completions; +164 } +165 +166 +167 @Override +168 public BukkitLocales getLocales() { +169 if (this.locales == null) { +170 this.locales = new BukkitLocales(this); +171 this.locales.loadLanguages(); +172 } +173 return locales; +174 } +175 +176 +177 @Override +178 public boolean hasRegisteredCommands() { +179 return !registeredCommands.isEmpty(); +180 } +181 +182 public void registerCommand(BaseCommand command, boolean force) { +183 final String plugin = this.plugin.getName().toLowerCase(); +184 command.onRegister(this); +185 for (Map.Entry<String, RootCommand> entry : command.registeredCommands.entrySet()) { +186 String commandName = entry.getKey().toLowerCase(); +187 BukkitRootCommand bukkitCommand = (BukkitRootCommand) entry.getValue(); +188 if (!bukkitCommand.isRegistered) { +189 if (force && knownCommands.containsKey(commandName)) { +190 Command oldCommand = commandMap.getCommand(commandName); +191 knownCommands.remove(commandName); +192 for (Map.Entry<String, Command> ce : knownCommands.entrySet()) { +193 String key = ce.getKey(); +194 Command value = ce.getValue(); +195 if (key.contains(":") && oldCommand.equals(value)) { +196 String[] split = ACFPatterns.COLON.split(key, 2); +197 if (split.length > 1) { +198 oldCommand.unregister(commandMap); +199 oldCommand.setLabel(split[0] + ":" + command.getName()); +200 oldCommand.register(commandMap); +201 } +202 } +203 } +204 } +205 commandMap.register(commandName, plugin, bukkitCommand); +206 } +207 bukkitCommand.isRegistered = true; +208 registeredCommands.put(commandName, bukkitCommand); +209 } +210 } +211 +212 @Override +213 public void registerCommand(BaseCommand command) { +214 registerCommand(command, false); +215 } +216 +217 public void unregisterCommand(BaseCommand command) { +218 for (RootCommand rootcommand : command.registeredCommands.values()) { +219 BukkitRootCommand bukkitCommand = (BukkitRootCommand) rootcommand; +220 bukkitCommand.getSubCommands().values().removeAll(command.subCommands.values()); +221 if (bukkitCommand.isRegistered && bukkitCommand.getSubCommands().isEmpty()) { +222 unregisterCommand(bukkitCommand); +223 bukkitCommand.isRegistered = false; +224 } +225 } +226 } +227 +228 /** +229 * @deprecated Use unregisterCommand(BaseCommand) - this will be visibility reduced later. +230 * @param command +231 */ +232 @Deprecated +233 public void unregisterCommand(BukkitRootCommand command) { +234 final String plugin = this.plugin.getName().toLowerCase(); +235 command.unregister(commandMap); +236 String key = command.getName(); +237 Command registered = knownCommands.get(key); +238 if (command.equals(registered)) { +239 knownCommands.remove(key); +240 } +241 knownCommands.remove(plugin + ":" + key); +242 } +243 +244 public void unregisterCommands() { +245 for (Map.Entry<String, BukkitRootCommand> entry : registeredCommands.entrySet()) { +246 unregisterCommand(entry.getValue()); 247 } -248 return null; +248 this.registeredCommands.clear(); 249 } 250 -251 void readPlayerLocale(Player player) { -252 if (!player.isOnline() || cantReadLocale) { -253 return; -254 } -255 try { -256 Field entityField = getEntityField(player); -257 if (entityField == null) { -258 return; +251 +252 private Field getEntityField(Player player) throws NoSuchFieldException { +253 Class cls = player.getClass(); +254 while (cls != Object.class) { +255 if (cls.getName().endsWith("CraftEntity")) { +256 Field field = cls.getDeclaredField("entity"); +257 field.setAccessible(true); +258 return field; 259 } -260 Object nmsPlayer = entityField.get(player); -261 if (nmsPlayer != null) { -262 Field localeField = nmsPlayer.getClass().getField("locale"); -263 Object localeString = localeField.get(nmsPlayer); -264 if (localeString != null && localeString instanceof String) { -265 String[] split = ACFPatterns.UNDERSCORE.split((String) localeString); -266 Locale locale = split.length > 1 ? new Locale(split[0], split[1]) : new Locale(split[0]); -267 Locale prev = issuersLocale.put(player.getUniqueId(), locale); -268 if (!Objects.equals(locale, prev)) { -269 this.notifyLocaleChange(getCommandIssuer(player), prev, locale); -270 } -271 } -272 } -273 } catch (Exception e) { -274 cantReadLocale = true; -275 this.localeTask.cancel(); -276 this.log(LogLevel.INFO, "Can't read players locale, you will be unable to automatically detect players language. Only Bukkit 1.7+ is supported for this.", e); -277 } -278 } -279 -280 public TimingManager getTimings() { -281 return timingManager; -282 } -283 -284 @Override -285 public RootCommand createRootCommand(String cmd) { -286 return new BukkitRootCommand(this, cmd); -287 } -288 -289 @Override -290 public BukkitCommandIssuer getCommandIssuer(Object issuer) { -291 if (!(issuer instanceof CommandSender)) { -292 throw new IllegalArgumentException(issuer.getClass().getName() + " is not a Command Issuer."); -293 } -294 return new BukkitCommandIssuer(this, (CommandSender) issuer); -295 } -296 -297 @Override -298 public BukkitCommandExecutionContext createCommandContext(RegisteredCommand command, Parameter parameter, CommandIssuer sender, List<String> args, int i, Map<String, Object> passedArgs) { -299 return new BukkitCommandExecutionContext(command, parameter, (BukkitCommandIssuer) sender, args, i, passedArgs); -300 } -301 -302 @Override -303 public BukkitCommandCompletionContext createCompletionContext(RegisteredCommand command, CommandIssuer sender, String input, String config, String[] args) { -304 return new BukkitCommandCompletionContext(command, (BukkitCommandIssuer) sender, input, config, args); -305 } -306 -307 @Override -308 public RegisteredCommand createRegisteredCommand(BaseCommand command, String cmdName, Method method, String prefSubCommand) { -309 return new BukkitRegisteredCommand(command, cmdName, method, prefSubCommand); -310 } -311 -312 @Override -313 public BukkitConditionContext createConditionContext(CommandIssuer issuer, String config) { -314 return new BukkitConditionContext((BukkitCommandIssuer) issuer, config); -315 } -316 -317 -318 @Override -319 public void log(LogLevel level, String message, Throwable throwable) { -320 Level logLevel = level == LogLevel.INFO ? Level.INFO : Level.SEVERE; -321 logger.log(logLevel, LogLevel.LOG_PREFIX + message); -322 if (throwable != null) { -323 for (String line : ACFPatterns.NEWLINE.split(ApacheCommonsExceptionUtil.getFullStackTrace(throwable))) { -324 logger.log(logLevel, LogLevel.LOG_PREFIX + line); -325 } -326 } -327 } -328 -329 public Locale setPlayerLocale(Player player, Locale locale) { -330 Locale old = this.issuersLocale.put(player.getUniqueId(), locale); -331 if (!Objects.equals(old, locale)) { -332 this.notifyLocaleChange(getCommandIssuer(player), old, locale); -333 } -334 return old; -335 } -336 -337 @Override -338 public Locale getIssuerLocale(CommandIssuer issuer) { -339 if (usingPerIssuerLocale() && issuer.getIssuer() instanceof Player) { -340 UUID uniqueId = ((Player) issuer.getIssuer()).getUniqueId(); -341 Locale locale = issuersLocale.get(uniqueId); -342 if (locale != null) { -343 return locale; -344 } -345 } -346 return super.getIssuerLocale(issuer); -347 } -348} +260 cls = cls.getSuperclass(); +261 } +262 return null; +263 } +264 +265 void readPlayerLocale(Player player) { +266 if (!player.isOnline() || cantReadLocale) { +267 return; +268 } +269 try { +270 Field entityField = getEntityField(player); +271 if (entityField == null) { +272 return; +273 } +274 Object nmsPlayer = entityField.get(player); +275 if (nmsPlayer != null) { +276 Field localeField = nmsPlayer.getClass().getField("locale"); +277 Object localeString = localeField.get(nmsPlayer); +278 if (localeString instanceof String) { +279 String[] split = ACFPatterns.UNDERSCORE.split((String) localeString); +280 Locale locale = split.length > 1 ? new Locale(split[0], split[1]) : new Locale(split[0]); +281 Locale prev = issuersLocale.put(player.getUniqueId(), locale); +282 if (!Objects.equals(locale, prev)) { +283 this.notifyLocaleChange(getCommandIssuer(player), prev, locale); +284 } +285 } +286 } +287 } catch (Exception e) { +288 cantReadLocale = true; +289 this.localeTask.cancel(); +290 this.log(LogLevel.INFO, "Can't read players locale, you will be unable to automatically detect players language. Only Bukkit 1.7+ is supported for this.", e); +291 } +292 } +293 +294 public TimingManager getTimings() { +295 return timingManager; +296 } +297 +298 @Override +299 public RootCommand createRootCommand(String cmd) { +300 return new BukkitRootCommand(this, cmd); +301 } +302 +303 @Override +304 public BukkitCommandIssuer getCommandIssuer(Object issuer) { +305 if (!(issuer instanceof CommandSender)) { +306 throw new IllegalArgumentException(issuer.getClass().getName() + " is not a Command Issuer."); +307 } +308 return new BukkitCommandIssuer(this, (CommandSender) issuer); +309 } +310 +311 @Override +312 public BukkitCommandExecutionContext createCommandContext(RegisteredCommand command, Parameter parameter, CommandIssuer sender, List<String> args, int i, Map<String, Object> passedArgs) { +313 return new BukkitCommandExecutionContext(command, parameter, (BukkitCommandIssuer) sender, args, i, passedArgs); +314 } +315 +316 @Override +317 public BukkitCommandCompletionContext createCompletionContext(RegisteredCommand command, CommandIssuer sender, String input, String config, String[] args) { +318 return new BukkitCommandCompletionContext(command, (BukkitCommandIssuer) sender, input, config, args); +319 } +320 +321 @Override +322 public RegisteredCommand createRegisteredCommand(BaseCommand command, String cmdName, Method method, String prefSubCommand) { +323 return new BukkitRegisteredCommand(command, cmdName, method, prefSubCommand); +324 } +325 +326 @Override +327 public BukkitConditionContext createConditionContext(CommandIssuer issuer, String config) { +328 return new BukkitConditionContext((BukkitCommandIssuer) issuer, config); +329 } +330 +331 +332 @Override +333 public void log(LogLevel level, String message, Throwable throwable) { +334 Level logLevel = level == LogLevel.INFO ? Level.INFO : Level.SEVERE; +335 logger.log(logLevel, LogLevel.LOG_PREFIX + message); +336 if (throwable != null) { +337 for (String line : ACFPatterns.NEWLINE.split(ApacheCommonsExceptionUtil.getFullStackTrace(throwable))) { +338 logger.log(logLevel, LogLevel.LOG_PREFIX + line); +339 } +340 } +341 } +342 +343 public Locale setPlayerLocale(Player player, Locale locale) { +344 Locale old = this.issuersLocale.put(player.getUniqueId(), locale); +345 if (!Objects.equals(old, locale)) { +346 this.notifyLocaleChange(getCommandIssuer(player), old, locale); +347 } +348 return old; +349 } +350 +351 @Override +352 public Locale getIssuerLocale(CommandIssuer issuer) { +353 if (usingPerIssuerLocale() && issuer.getIssuer() instanceof Player) { +354 UUID uniqueId = ((Player) issuer.getIssuer()).getUniqueId(); +355 Locale locale = issuersLocale.get(uniqueId); +356 if (locale != null) { +357 return locale; +358 } +359 } +360 return super.getIssuerLocale(issuer); +361 } +362} diff --git a/docs/acf-bungee/co/aikar/commands/BungeeCommandManager.html b/docs/acf-bungee/co/aikar/commands/BungeeCommandManager.html index 632ec953..a054aa59 100644 --- a/docs/acf-bungee/co/aikar/commands/BungeeCommandManager.html +++ b/docs/acf-bungee/co/aikar/commands/BungeeCommandManager.html @@ -159,7 +159,7 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,

    Fields inherited from class co.aikar.commands.CommandManager

    -conditions, defaultExceptionHandler, defaultFormatter, defaultHelpPerPage, formatters, localeChangedCallbacks, replacements, rootCommands, supportedLanguages, usePerIssuerLocale
  • +conditions, defaultExceptionHandler, defaultFormatter, defaultHelpPerPage, dependencies, formatters, localeChangedCallbacks, replacements, rootCommands, supportedLanguages, usePerIssuerLocale
  • @@ -281,7 +281,7 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,

    Methods inherited from class co.aikar.commands.CommandManager

    -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, sendMessage, sendMessage, setDefaultExceptionHandler, setDefaultFormatter, setDefaultHelpPerPage, setFormat, setFormat, setFormat, usePerIssuerLocale, usingPerIssuerLocale
  • +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, usePerIssuerLocale, usingPerIssuerLocale
  • @@ -389,7 +389,7 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,
  • getCommandContexts

    -
    public co.aikar.commands.CommandContexts<BungeeCommandExecutionContextgetCommandContexts()
    +
    public co.aikar.commands.CommandContexts<BungeeCommandExecutionContextgetCommandContexts()
    Specified by:
    getCommandContexts in class co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,BungeeCommandIssuer,net.md_5.bungee.api.ChatColor,BungeeMessageFormatter,BungeeCommandExecutionContext,BungeeConditionContext>
    @@ -402,7 +402,7 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,
  • getCommandCompletions

    -
    public co.aikar.commands.CommandCompletions<BungeeCommandCompletionContextgetCommandCompletions()
    +
    public co.aikar.commands.CommandCompletions<BungeeCommandCompletionContextgetCommandCompletions()
    Specified by:
    getCommandCompletions in class co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,BungeeCommandIssuer,net.md_5.bungee.api.ChatColor,BungeeMessageFormatter,BungeeCommandExecutionContext,BungeeConditionContext>
    @@ -415,7 +415,7 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,
  • getLocales

    -
    public BungeeLocales getLocales()
    +
    public BungeeLocales getLocales()
    Specified by:
    getLocales in class co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,BungeeCommandIssuer,net.md_5.bungee.api.ChatColor,BungeeMessageFormatter,BungeeCommandExecutionContext,BungeeConditionContext>
    @@ -428,7 +428,7 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,
  • registerCommand

    -
    public void registerCommand(co.aikar.commands.BaseCommand command)
    +
    public void registerCommand(co.aikar.commands.BaseCommand command)
    Specified by:
    registerCommand in class co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,BungeeCommandIssuer,net.md_5.bungee.api.ChatColor,BungeeMessageFormatter,BungeeCommandExecutionContext,BungeeConditionContext>
    @@ -441,7 +441,7 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,
  • unregisterCommand

    -
    public void unregisterCommand(co.aikar.commands.BaseCommand command)
    +
    public void unregisterCommand(co.aikar.commands.BaseCommand command)
  • @@ -450,7 +450,7 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,
  • unregisterCommand

    -
    public void unregisterCommand(BungeeRootCommand command)
    +
    public void unregisterCommand(BungeeRootCommand command)
  • @@ -459,7 +459,7 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,
  • unregisterCommands

    -
    public void unregisterCommands()
    +
    public void unregisterCommands()
  • @@ -468,7 +468,7 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,
  • hasRegisteredCommands

    -
    public boolean hasRegisteredCommands()
    +
    public boolean hasRegisteredCommands()
    Specified by:
    hasRegisteredCommands in class co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,BungeeCommandIssuer,net.md_5.bungee.api.ChatColor,BungeeMessageFormatter,BungeeCommandExecutionContext,BungeeConditionContext>
    @@ -481,7 +481,7 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,
  • isCommandIssuer

    -
    public boolean isCommandIssuer(Class<?> aClass)
    +
    public boolean isCommandIssuer(Class<?> aClass)
    Specified by:
    isCommandIssuer in class co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,BungeeCommandIssuer,net.md_5.bungee.api.ChatColor,BungeeMessageFormatter,BungeeCommandExecutionContext,BungeeConditionContext>
    @@ -494,7 +494,7 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,
  • getCommandIssuer

    -
    public BungeeCommandIssuer getCommandIssuer(Object issuer)
    +
    public BungeeCommandIssuer getCommandIssuer(Object issuer)
    Specified by:
    getCommandIssuer in class co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,BungeeCommandIssuer,net.md_5.bungee.api.ChatColor,BungeeMessageFormatter,BungeeCommandExecutionContext,BungeeConditionContext>
    @@ -507,7 +507,7 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,
  • createRootCommand

    -
    public co.aikar.commands.RootCommand createRootCommand(String cmd)
    +
    public co.aikar.commands.RootCommand createRootCommand(String cmd)
    Specified by:
    createRootCommand in class co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,BungeeCommandIssuer,net.md_5.bungee.api.ChatColor,BungeeMessageFormatter,BungeeCommandExecutionContext,BungeeConditionContext>
    @@ -520,7 +520,7 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,
  • createCommandContext

    -
    public BungeeCommandExecutionContext createCommandContext(co.aikar.commands.RegisteredCommand command,
    +
    public BungeeCommandExecutionContext createCommandContext(co.aikar.commands.RegisteredCommand command,
                                                               Parameter parameter,
                                                               co.aikar.commands.CommandIssuer sender,
                                                               List<String> args,
    @@ -538,7 +538,7 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,
     
  • createCompletionContext

    -
    public co.aikar.commands.CommandCompletionContext createCompletionContext(co.aikar.commands.RegisteredCommand command,
    +
    public co.aikar.commands.CommandCompletionContext createCompletionContext(co.aikar.commands.RegisteredCommand command,
                                                                               co.aikar.commands.CommandIssuer sender,
                                                                               String input,
                                                                               String config,
    @@ -555,7 +555,7 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,
     
  • createRegisteredCommand

    -
    public co.aikar.commands.RegisteredCommand createRegisteredCommand(co.aikar.commands.BaseCommand command,
    +
    public co.aikar.commands.RegisteredCommand createRegisteredCommand(co.aikar.commands.BaseCommand command,
                                                                        String cmdName,
                                                                        Method method,
                                                                        String prefSubCommand)
    @@ -571,7 +571,7 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,
  • createConditionContext

    -
    public BungeeConditionContext createConditionContext(co.aikar.commands.CommandIssuer issuer,
    +
    public BungeeConditionContext createConditionContext(co.aikar.commands.CommandIssuer issuer,
                                                          String config)
    Overrides:
    @@ -585,7 +585,7 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,
  • log

    -
    public void log(co.aikar.commands.LogLevel level,
    +
    public void log(co.aikar.commands.LogLevel level,
                     String message,
                     Throwable throwable)
    diff --git a/docs/acf-bungee/src-html/co/aikar/commands/ACFBungeeUtil.html b/docs/acf-bungee/src-html/co/aikar/commands/ACFBungeeUtil.html index 79b7ec4b..3503876e 100644 --- a/docs/acf-bungee/src-html/co/aikar/commands/ACFBungeeUtil.html +++ b/docs/acf-bungee/src-html/co/aikar/commands/ACFBungeeUtil.html @@ -87,7 +87,7 @@ 079 public static final char COLOR_CHAR = '\u00A7'; 080 081 public static String getLastColors(String input) { -082 String result = ""; +082 StringBuilder result = new StringBuilder(); 083 int length = input.length(); 084 085 // Search backwards from the end as it is faster @@ -98,7 +98,7 @@ 090 ChatColor color = ChatColor.getByChar(c); 091 092 if (color != null) { -093 result = color.toString() + result; +093 result.insert(0, color.toString()); 094 095 // Once we find a color or reset we can stop searching 096 if (isChatColorAColor(color) || color.equals(ChatColor.RESET)) { @@ -107,7 +107,7 @@ 099 } 100 } 101 } -102 return result; +102 return result.toString(); 103 } 104 105 public static boolean isChatColorAColor(ChatColor chatColor) { diff --git a/docs/acf-bungee/src-html/co/aikar/commands/BungeeCommandManager.html b/docs/acf-bungee/src-html/co/aikar/commands/BungeeCommandManager.html index 5754950a..2566df06 100644 --- a/docs/acf-bungee/src-html/co/aikar/commands/BungeeCommandManager.html +++ b/docs/acf-bungee/src-html/co/aikar/commands/BungeeCommandManager.html @@ -66,130 +66,134 @@ 058 this.formatters.put(MessageType.INFO, new BungeeMessageFormatter(ChatColor.BLUE, ChatColor.DARK_GREEN, ChatColor.GREEN)); 059 this.formatters.put(MessageType.HELP, new BungeeMessageFormatter(ChatColor.AQUA, ChatColor.GREEN, ChatColor.YELLOW)); 060 getLocales(); // auto load locales -061 } -062 -063 public Plugin getPlugin() { -064 return this.plugin; +061 +062 // TODO more default dependencies for bungee +063 registerDependency(plugin.getClass(), plugin); +064 registerDependency(Plugin.class, plugin); 065 } 066 -067 @Override -068 public synchronized CommandContexts<BungeeCommandExecutionContext> getCommandContexts() { -069 if (this.contexts == null) { -070 this.contexts = new BungeeCommandContexts(this); -071 } -072 return contexts; -073 } -074 -075 @Override -076 public synchronized CommandCompletions<BungeeCommandCompletionContext> getCommandCompletions() { -077 if (this.completions == null) { -078 this.completions = new BungeeCommandCompletions(this); -079 } -080 return completions; -081 } -082 -083 @Override -084 public BungeeLocales getLocales() { -085 if (this.locales == null) { -086 this.locales = new BungeeLocales(this); -087 this.locales.loadLanguages(); -088 } -089 return locales; -090 } -091 -092 -093 @Override -094 public void registerCommand(BaseCommand command) { -095 command.onRegister(this); -096 for (Map.Entry<String, RootCommand> entry : command.registeredCommands.entrySet()) { -097 String commandName = entry.getKey().toLowerCase(); -098 BungeeRootCommand bungeeCommand = (BungeeRootCommand) entry.getValue(); -099 if (!bungeeCommand.isRegistered) { -100 this.plugin.getProxy().getPluginManager().registerCommand(this.plugin, bungeeCommand); -101 } -102 bungeeCommand.isRegistered = true; -103 registeredCommands.put(commandName, bungeeCommand); -104 } -105 } -106 -107 public void unregisterCommand(BaseCommand command) { -108 for (Map.Entry<String, RootCommand> entry : command.registeredCommands.entrySet()) { -109 String commandName = entry.getKey().toLowerCase(); -110 BungeeRootCommand bungeeCommand = (BungeeRootCommand) entry.getValue(); -111 bungeeCommand.getSubCommands().values().removeAll(command.subCommands.values()); -112 if (bungeeCommand.getSubCommands().isEmpty() && bungeeCommand.isRegistered) { -113 unregisterCommand(bungeeCommand); -114 bungeeCommand.isRegistered = false; -115 registeredCommands.remove(commandName); -116 } -117 } -118 } -119 -120 public void unregisterCommand(BungeeRootCommand command) { -121 this.plugin.getProxy().getPluginManager().unregisterCommand(command); +067 public Plugin getPlugin() { +068 return this.plugin; +069 } +070 +071 @Override +072 public synchronized CommandContexts<BungeeCommandExecutionContext> getCommandContexts() { +073 if (this.contexts == null) { +074 this.contexts = new BungeeCommandContexts(this); +075 } +076 return contexts; +077 } +078 +079 @Override +080 public synchronized CommandCompletions<BungeeCommandCompletionContext> getCommandCompletions() { +081 if (this.completions == null) { +082 this.completions = new BungeeCommandCompletions(this); +083 } +084 return completions; +085 } +086 +087 @Override +088 public BungeeLocales getLocales() { +089 if (this.locales == null) { +090 this.locales = new BungeeLocales(this); +091 this.locales.loadLanguages(); +092 } +093 return locales; +094 } +095 +096 +097 @Override +098 public void registerCommand(BaseCommand command) { +099 command.onRegister(this); +100 for (Map.Entry<String, RootCommand> entry : command.registeredCommands.entrySet()) { +101 String commandName = entry.getKey().toLowerCase(); +102 BungeeRootCommand bungeeCommand = (BungeeRootCommand) entry.getValue(); +103 if (!bungeeCommand.isRegistered) { +104 this.plugin.getProxy().getPluginManager().registerCommand(this.plugin, bungeeCommand); +105 } +106 bungeeCommand.isRegistered = true; +107 registeredCommands.put(commandName, bungeeCommand); +108 } +109 } +110 +111 public void unregisterCommand(BaseCommand command) { +112 for (Map.Entry<String, RootCommand> entry : command.registeredCommands.entrySet()) { +113 String commandName = entry.getKey().toLowerCase(); +114 BungeeRootCommand bungeeCommand = (BungeeRootCommand) entry.getValue(); +115 bungeeCommand.getSubCommands().values().removeAll(command.subCommands.values()); +116 if (bungeeCommand.getSubCommands().isEmpty() && bungeeCommand.isRegistered) { +117 unregisterCommand(bungeeCommand); +118 bungeeCommand.isRegistered = false; +119 registeredCommands.remove(commandName); +120 } +121 } 122 } 123 -124 public void unregisterCommands() { -125 for (Map.Entry<String, BungeeRootCommand> entry : registeredCommands.entrySet()) { -126 unregisterCommand(entry.getValue()); -127 } -128 } -129 -130 @Override -131 public boolean hasRegisteredCommands() { -132 return !registeredCommands.isEmpty(); -133 } -134 -135 @Override -136 public boolean isCommandIssuer(Class<?> aClass) { -137 return CommandSender.class.isAssignableFrom(aClass); -138 } -139 -140 @Override -141 public BungeeCommandIssuer getCommandIssuer(Object issuer) { -142 if (!(issuer instanceof CommandSender)) { -143 throw new IllegalArgumentException(issuer.getClass().getName() + " is not a Command Issuer."); -144 } -145 return new BungeeCommandIssuer(this, (CommandSender) issuer); -146 } -147 -148 @Override -149 public RootCommand createRootCommand(String cmd) { -150 return new BungeeRootCommand(this, cmd); -151 } -152 -153 @Override -154 public BungeeCommandExecutionContext createCommandContext(RegisteredCommand command, Parameter parameter, CommandIssuer sender, List<String> args, int i, Map<String, Object> passedArgs) { -155 return new BungeeCommandExecutionContext(command, parameter, (BungeeCommandIssuer) sender, args, i, passedArgs); -156 } -157 -158 @Override -159 public CommandCompletionContext createCompletionContext(RegisteredCommand command, CommandIssuer sender, String input, String config, String[] args) { -160 return new BungeeCommandCompletionContext(command, (BungeeCommandIssuer) sender, input, config, args); -161 } -162 -163 @Override -164 public RegisteredCommand createRegisteredCommand(BaseCommand command, String cmdName, Method method, String prefSubCommand) { -165 return new RegisteredCommand(command, cmdName, method, prefSubCommand); -166 } -167 -168 @Override -169 public BungeeConditionContext createConditionContext(CommandIssuer issuer, String config) { -170 return new BungeeConditionContext((BungeeCommandIssuer) issuer, config); -171 } -172 -173 @Override -174 public void log(LogLevel level, String message, Throwable throwable) { -175 Logger logger = this.plugin.getLogger(); -176 Level logLevel = level == LogLevel.INFO ? Level.INFO : Level.SEVERE; -177 logger.log(logLevel, LogLevel.LOG_PREFIX + message); -178 if (throwable != null) { -179 for (String line : ACFPatterns.NEWLINE.split(ApacheCommonsExceptionUtil.getFullStackTrace(throwable))) { -180 logger.log(logLevel, LogLevel.LOG_PREFIX + line); -181 } -182 } -183 } -184} +124 public void unregisterCommand(BungeeRootCommand command) { +125 this.plugin.getProxy().getPluginManager().unregisterCommand(command); +126 } +127 +128 public void unregisterCommands() { +129 for (Map.Entry<String, BungeeRootCommand> entry : registeredCommands.entrySet()) { +130 unregisterCommand(entry.getValue()); +131 } +132 } +133 +134 @Override +135 public boolean hasRegisteredCommands() { +136 return !registeredCommands.isEmpty(); +137 } +138 +139 @Override +140 public boolean isCommandIssuer(Class<?> aClass) { +141 return CommandSender.class.isAssignableFrom(aClass); +142 } +143 +144 @Override +145 public BungeeCommandIssuer getCommandIssuer(Object issuer) { +146 if (!(issuer instanceof CommandSender)) { +147 throw new IllegalArgumentException(issuer.getClass().getName() + " is not a Command Issuer."); +148 } +149 return new BungeeCommandIssuer(this, (CommandSender) issuer); +150 } +151 +152 @Override +153 public RootCommand createRootCommand(String cmd) { +154 return new BungeeRootCommand(this, cmd); +155 } +156 +157 @Override +158 public BungeeCommandExecutionContext createCommandContext(RegisteredCommand command, Parameter parameter, CommandIssuer sender, List<String> args, int i, Map<String, Object> passedArgs) { +159 return new BungeeCommandExecutionContext(command, parameter, (BungeeCommandIssuer) sender, args, i, passedArgs); +160 } +161 +162 @Override +163 public CommandCompletionContext createCompletionContext(RegisteredCommand command, CommandIssuer sender, String input, String config, String[] args) { +164 return new BungeeCommandCompletionContext(command, (BungeeCommandIssuer) sender, input, config, args); +165 } +166 +167 @Override +168 public RegisteredCommand createRegisteredCommand(BaseCommand command, String cmdName, Method method, String prefSubCommand) { +169 return new RegisteredCommand(command, cmdName, method, prefSubCommand); +170 } +171 +172 @Override +173 public BungeeConditionContext createConditionContext(CommandIssuer issuer, String config) { +174 return new BungeeConditionContext((BungeeCommandIssuer) issuer, config); +175 } +176 +177 @Override +178 public void log(LogLevel level, String message, Throwable throwable) { +179 Logger logger = this.plugin.getLogger(); +180 Level logLevel = level == LogLevel.INFO ? Level.INFO : Level.SEVERE; +181 logger.log(logLevel, LogLevel.LOG_PREFIX + message); +182 if (throwable != null) { +183 for (String line : ACFPatterns.NEWLINE.split(ApacheCommonsExceptionUtil.getFullStackTrace(throwable))) { +184 logger.log(logLevel, LogLevel.LOG_PREFIX + line); +185 } +186 } +187 } +188} diff --git a/docs/acf-core/allclasses-frame.html b/docs/acf-core/allclasses-frame.html index 3e7a3779..6c7a8e35 100644 --- a/docs/acf-core/allclasses-frame.html +++ b/docs/acf-core/allclasses-frame.html @@ -18,6 +18,7 @@
  • ApacheCommonsLangUtil
  • BaseCommand
  • CatchAll
  • +
  • CatchUnknown
  • CommandAlias
  • CommandCompletion
  • CommandCompletionContext
  • @@ -41,6 +42,7 @@
  • Conditions
  • ContextResolver
  • Default
  • +
  • Dependency
  • Description
  • ExceptionHandler
  • Flags
  • @@ -68,6 +70,7 @@
  • Subcommand
  • Syntax
  • UnknownHandler
  • +
  • UnresolvedDependencyException
  • UnstableAPI
  • Values
  • diff --git a/docs/acf-core/allclasses-noframe.html b/docs/acf-core/allclasses-noframe.html index 01964e46..0801c73e 100644 --- a/docs/acf-core/allclasses-noframe.html +++ b/docs/acf-core/allclasses-noframe.html @@ -18,6 +18,7 @@
  • ApacheCommonsLangUtil
  • BaseCommand
  • CatchAll
  • +
  • CatchUnknown
  • CommandAlias
  • CommandCompletion
  • CommandCompletionContext
  • @@ -41,6 +42,7 @@
  • Conditions
  • ContextResolver
  • Default
  • +
  • Dependency
  • Description
  • ExceptionHandler
  • Flags
  • @@ -68,6 +70,7 @@
  • Subcommand
  • Syntax
  • UnknownHandler
  • +
  • UnresolvedDependencyException
  • UnstableAPI
  • Values
  • diff --git a/docs/acf-core/co/aikar/commands/BaseCommand.html b/docs/acf-core/co/aikar/commands/BaseCommand.html index 26b175b9..be1e8fb4 100644 --- a/docs/acf-core/co/aikar/commands/BaseCommand.html +++ b/docs/acf-core/co/aikar/commands/BaseCommand.html @@ -112,7 +112,7 @@ var activeTableTab = "activeTableTab";


    -
    public abstract class BaseCommand
    +
    public abstract class BaseCommand
     extends Object
  • @@ -134,7 +134,7 @@ extends static String -CATCHALL  +CATCHUNKNOWN  static String @@ -329,16 +329,16 @@ extends + @@ -348,7 +348,7 @@ extends
  • DEFAULT

    -
    public static final String DEFAULT
    +
    public static final String DEFAULT
    See Also:
    Constant Field Values
    @@ -369,7 +369,7 @@ extends
  • BaseCommand

    -
    public BaseCommand()
    +
    public BaseCommand()
  • @@ -378,7 +378,7 @@ extends
  • BaseCommand

    -
    public BaseCommand(String cmd)
    +
    public BaseCommand(String cmd)
  • @@ -395,7 +395,7 @@ extends
  • getExecCommandLabel

    -
    public String getExecCommandLabel()
    +
    public String getExecCommandLabel()
    Gets the root command name that the user actually typed
    Returns:
    @@ -409,7 +409,7 @@ extends
  • getExecSubcommand

    -
    public String getExecSubcommand()
    +
    public String getExecSubcommand()
    Gets the actual sub command name the user typed
    Returns:
    @@ -423,7 +423,7 @@ extends
  • getOrigArgs

    -
    public String[] getOrigArgs()
    +
    public String[] getOrigArgs()
    Gets the actual args in string form the user typed
    Returns:
    diff --git a/docs/acf-core/co/aikar/commands/CommandManager.html b/docs/acf-core/co/aikar/commands/CommandManager.html index 1c3c6ba7..b5d8d9d1 100644 --- a/docs/acf-core/co/aikar/commands/CommandManager.html +++ b/docs/acf-core/co/aikar/commands/CommandManager.html @@ -18,7 +18,7 @@ catch(err) { } //--> -var methods = {"i0":10,"i1":6,"i2":6,"i3":10,"i4":10,"i5":6,"i6":42,"i7":10,"i8":42,"i9":42,"i10":42,"i11":42,"i12":6,"i13":10,"i14":6,"i15":6,"i16":10,"i17":9,"i18":9,"i19":9,"i20":10,"i21":10,"i22":42,"i23":10,"i24":10,"i25":6,"i26":10,"i27":10,"i28":10,"i29":10,"i30":6,"i31":6,"i32":10,"i33":6,"i34":10,"i35":10,"i36":10,"i37":6,"i38":10,"i39":10,"i40":10,"i41":10,"i42":42,"i43":10,"i44":10,"i45":10,"i46":10,"i47":10}; +var methods = {"i0":10,"i1":6,"i2":6,"i3":10,"i4":10,"i5":6,"i6":42,"i7":10,"i8":42,"i9":42,"i10":42,"i11":42,"i12":6,"i13":10,"i14":6,"i15":6,"i16":10,"i17":9,"i18":9,"i19":9,"i20":10,"i21":10,"i22":42,"i23":10,"i24":10,"i25":6,"i26":10,"i27":10,"i28":10,"i29":10,"i30":6,"i31":6,"i32":10,"i33":6,"i34":10,"i35":10,"i36":10,"i37":6,"i38":10,"i39":10,"i40":10,"i41":10,"i42":10,"i43":10,"i44":42,"i45":10,"i46":10,"i47":10,"i48":10,"i49":10}; var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],2:["t2","Instance Methods"],4:["t3","Abstract Methods"],8:["t4","Concrete Methods"],32:["t6","Deprecated Methods"]}; var altColor = "altColor"; var rowColor = "rowColor"; @@ -108,7 +108,7 @@ var activeTableTab = "activeTableTab";


  • -
    public abstract class CommandManager<IT,I extends CommandIssuer,FT,MF extends MessageFormatter<FT>,CEC extends CommandExecutionContext<CEC,I>,CC extends ConditionContext<I>>
    +
    public abstract class CommandManager<IT,I extends CommandIssuer,FT,MF extends MessageFormatter<FT>,CEC extends CommandExecutionContext<CEC,I>,CC extends ConditionContext<I>>
     extends Object
  • @@ -145,26 +145,30 @@ extends defaultHelpPerPage  +protected com.google.common.collect.Table<Class<?>,String,Object> +dependencies  + + protected Map<MessageType,MF> formatters  - + protected List<IssuerLocaleChangedCallback<I>> localeChangedCallbacks  - + protected CommandReplacements replacements  - + protected Map<String,co.aikar.commands.RootCommand> rootCommands  - + protected Set<Locale> supportedLanguages  - + protected boolean usePerIssuerLocale  @@ -423,30 +427,49 @@ extends +<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.  @@ -454,27 +477,27 @@ extends + void setFormat(MessageType type, FT... colors)  - + void setFormat(MessageType type, int i, FT color)  - + MF setFormat(MessageType type, MF formatter)  - + boolean usePerIssuerLocale(boolean setting)  - + boolean usingPerIssuerLocale()  @@ -506,7 +529,7 @@ extends
  • rootCommands

    -
    protected Map<String,co.aikar.commands.RootCommand> rootCommands
    +
    protected Map<String,co.aikar.commands.RootCommand> rootCommands
  • @@ -515,7 +538,7 @@ extends
  • replacements

    -
    protected final CommandReplacements replacements
    +
    protected final CommandReplacements replacements
  • @@ -524,7 +547,7 @@ extends
  • conditions

    -
    protected final CommandConditions<I extends CommandIssuer,CEC extends CommandExecutionContext<CEC,I>,CC extends ConditionContext<I>> conditions
    +
    protected final CommandConditions<I extends CommandIssuer,CEC extends CommandExecutionContext<CEC,I>,CC extends ConditionContext<I>> conditions
  • @@ -533,7 +556,16 @@ extends
  • defaultExceptionHandler

    -
    protected ExceptionHandler defaultExceptionHandler
    +
    protected ExceptionHandler defaultExceptionHandler
    +
  • + + + + + @@ -542,7 +574,7 @@ extends
  • usePerIssuerLocale

    -
    protected boolean usePerIssuerLocale
    +
    protected boolean usePerIssuerLocale
  • @@ -551,7 +583,7 @@ extends
  • localeChangedCallbacks

    -
    protected List<IssuerLocaleChangedCallback<I extends CommandIssuer>> localeChangedCallbacks
    +
    protected List<IssuerLocaleChangedCallback<I extends CommandIssuer>> localeChangedCallbacks
  • @@ -560,7 +592,7 @@ extends
  • supportedLanguages

    -
    protected Set<Locale> supportedLanguages
    +
    protected Set<Locale> supportedLanguages
  • @@ -569,7 +601,7 @@ extends
  • formatters

    -
    protected Map<MessageType,MF extends MessageFormatter<FT>> formatters
    +
    protected Map<MessageType,MF extends MessageFormatter<FT>> formatters
  • @@ -578,7 +610,7 @@ extends
  • defaultFormatter

    -
    protected MF extends MessageFormatter<FT> defaultFormatter
    +
    protected MF extends MessageFormatter<FT> defaultFormatter
  • @@ -587,7 +619,7 @@ extends
  • defaultHelpPerPage

    -
    protected int defaultHelpPerPage
    +
    protected int defaultHelpPerPage
  • @@ -604,7 +636,7 @@ extends
  • CommandManager

    -
    public CommandManager()
    +
    public CommandManager()
  • @@ -621,7 +653,7 @@ extends
  • getCurrentCommandOperationContext

    -
    public static CommandOperationContext getCurrentCommandOperationContext()
    +
    public static CommandOperationContext getCurrentCommandOperationContext()
  • @@ -630,7 +662,7 @@ extends
  • getCurrentCommandIssuer

    -
    public static CommandIssuer getCurrentCommandIssuer()
    +
    public static CommandIssuer getCurrentCommandIssuer()
  • @@ -639,7 +671,7 @@ extends
  • getCurrentCommandManager

    -
    public static CommandManager getCurrentCommandManager()
    +
    public static CommandManager getCurrentCommandManager()
  • @@ -650,7 +682,7 @@ extends
  • setFormat

    -
    public MF setFormat(MessageType type,
    +
    public MF setFormat(MessageType type,
                         MF formatter)
  • @@ -660,7 +692,7 @@ extends
  • getFormat

    -
    public MF getFormat(MessageType type)
    +
    public MF getFormat(MessageType type)
  • @@ -671,7 +703,7 @@ extends
  • setFormat

    -
    public void setFormat(MessageType type,
    +
    public void setFormat(MessageType type,
                           FT... colors)
  • @@ -683,7 +715,7 @@ extends
  • setFormat

    -
    public void setFormat(MessageType type,
    +
    public void setFormat(MessageType type,
                           int i,
                           FT color)
  • @@ -694,7 +726,7 @@ extends
  • getDefaultFormatter

    -
    public MF getDefaultFormatter()
    +
    public MF getDefaultFormatter()
  • @@ -705,7 +737,7 @@ extends
  • setDefaultFormatter

    -
    public void setDefaultFormatter(MF defaultFormatter)
    +
    public void setDefaultFormatter(MF defaultFormatter)
  • @@ -714,7 +746,7 @@ extends
  • getCommandConditions

    -
    public CommandConditions<I,CEC,CCgetCommandConditions()
    +
    public CommandConditions<I,CEC,CCgetCommandConditions()
  • @@ -723,7 +755,7 @@ extends
  • getCommandContexts

    -
    public abstract CommandContexts<?> getCommandContexts()
    +
    public abstract CommandContexts<?> getCommandContexts()
    Gets the command contexts manager
    Returns:
    @@ -737,7 +769,7 @@ extends
  • getCommandCompletions

    -
    public abstract CommandCompletions<?> getCommandCompletions()
    +
    public abstract CommandCompletions<?> getCommandCompletions()
    Gets the command completions manager
    Returns:
    @@ -752,7 +784,7 @@ extends

    generateCommandHelp

    @Deprecated
    -public CommandHelp generateCommandHelp(@NotNull
    +public CommandHelp generateCommandHelp(@NotNull
                                                        @NotNull String command)
    Deprecated. Unstable API
  • @@ -764,7 +796,7 @@ public 

    generateCommandHelp

    @Deprecated
    -public CommandHelp generateCommandHelp(CommandIssuer issuer,
    +public CommandHelp generateCommandHelp(CommandIssuer issuer,
                                                        @NotNull
                                                        @NotNull String command)
    Deprecated. Unstable API
    @@ -777,7 +809,7 @@ public 

    generateCommandHelp

    @Deprecated
    -public CommandHelp generateCommandHelp()
    +public CommandHelp generateCommandHelp()
  • Deprecated. Unstable API
  • @@ -788,7 +820,7 @@ public 

    generateCommandHelp

    @Deprecated
    -public CommandHelp generateCommandHelp(CommandIssuer issuer,
    +public CommandHelp generateCommandHelp(CommandIssuer issuer,
                                                        co.aikar.commands.RootCommand rootCommand)
    Deprecated. Unstable API
  • @@ -800,7 +832,7 @@ public 

    getDefaultHelpPerPage

    @Deprecated
    -public int getDefaultHelpPerPage()
    +public int getDefaultHelpPerPage()
    Deprecated. Unstable API
  • @@ -811,7 +843,7 @@ public int 

    setDefaultHelpPerPage

    @Deprecated
    -public void setDefaultHelpPerPage(int defaultHelpPerPage)
    +public void setDefaultHelpPerPage(int defaultHelpPerPage)
    Deprecated. Unstable API
  • @@ -821,7 +853,7 @@ public void 
  • registerCommand

    -
    public abstract void registerCommand(BaseCommand command)
    +
    public abstract void registerCommand(BaseCommand command)
    Registers a command with ACF
    Parameters:
    @@ -835,7 +867,7 @@ public void 
  • hasRegisteredCommands

    -
    public abstract boolean hasRegisteredCommands()
    +
    public abstract boolean hasRegisteredCommands()
  • @@ -844,7 +876,7 @@ public void 
  • isCommandIssuer

    -
    public abstract boolean isCommandIssuer(Class<?> type)
    +
    public abstract boolean isCommandIssuer(Class<?> type)
  • @@ -853,7 +885,7 @@ public void 
  • getCommandIssuer

    -
    public abstract I getCommandIssuer(Object issuer)
    +
    public abstract I getCommandIssuer(Object issuer)
  • @@ -862,7 +894,7 @@ public void 
  • createRootCommand

    -
    public abstract co.aikar.commands.RootCommand createRootCommand(String cmd)
    +
    public abstract co.aikar.commands.RootCommand createRootCommand(String cmd)
  • @@ -871,7 +903,7 @@ public void 
  • getLocales

    -
    public abstract Locales getLocales()
    +
    public abstract Locales getLocales()
    Returns a Locales Manager to add and modify language tables for your commands.
    Returns:
    @@ -884,7 +916,7 @@ public void 
  • usingPerIssuerLocale

    -
    public boolean usingPerIssuerLocale()
    +
    public boolean usingPerIssuerLocale()
  • @@ -893,7 +925,7 @@ public void 
  • usePerIssuerLocale

    -
    public boolean usePerIssuerLocale(boolean setting)
    +
    public boolean usePerIssuerLocale(boolean setting)
  • @@ -902,7 +934,7 @@ public void 
  • createConditionContext

    -
    public ConditionContext createConditionContext(CommandIssuer issuer,
    +
    public ConditionContext createConditionContext(CommandIssuer issuer,
                                                    String config)
  • @@ -912,7 +944,7 @@ public void 
  • createCommandContext

    -
    public abstract CommandExecutionContext createCommandContext(RegisteredCommand command,
    +
    public abstract CommandExecutionContext createCommandContext(RegisteredCommand command,
                                                                  Parameter parameter,
                                                                  CommandIssuer sender,
                                                                  List<String> args,
    @@ -926,7 +958,7 @@ public void 
     
  • createCompletionContext

    -
    public abstract CommandCompletionContext createCompletionContext(RegisteredCommand command,
    +
    public abstract CommandCompletionContext createCompletionContext(RegisteredCommand command,
                                                                      CommandIssuer sender,
                                                                      String input,
                                                                      String config,
    @@ -939,7 +971,7 @@ public void 
     
  • log

    -
    public abstract void log(co.aikar.commands.LogLevel level,
    +
    public abstract void log(co.aikar.commands.LogLevel level,
                              String message,
                              Throwable throwable)
  • @@ -950,7 +982,7 @@ public void 
  • log

    -
    public void log(co.aikar.commands.LogLevel level,
    +
    public void log(co.aikar.commands.LogLevel level,
                     String message)
  • @@ -960,7 +992,7 @@ public void 
  • getCommandReplacements

    -
    public CommandReplacements getCommandReplacements()
    +
    public CommandReplacements getCommandReplacements()
    Lets you add custom string replacements that can be applied to annotation values, to reduce duplication/repetition of common values such as permission nodes and command prefixes. @@ -979,7 +1011,7 @@ public void 
  • hasPermission

    -
    public boolean hasPermission(CommandIssuer issuer,
    +
    public boolean hasPermission(CommandIssuer issuer,
                                  String permission)
  • @@ -989,7 +1021,7 @@ public void 
  • getRootCommand

    -
    public co.aikar.commands.RootCommand getRootCommand(@NotNull
    +
    public co.aikar.commands.RootCommand getRootCommand(@NotNull
                                                         @NotNull String cmd)
  • @@ -999,7 +1031,7 @@ public void 
  • obtainRootCommand

    -
    public co.aikar.commands.RootCommand obtainRootCommand(@NotNull
    +
    public co.aikar.commands.RootCommand obtainRootCommand(@NotNull
                                                            @NotNull String cmd)
  • @@ -1009,7 +1041,7 @@ public void 
  • createRegisteredCommand

    -
    public RegisteredCommand createRegisteredCommand(BaseCommand command,
    +
    public RegisteredCommand createRegisteredCommand(BaseCommand command,
                                                      String cmdName,
                                                      Method method,
                                                      String prefSubCommand)
    @@ -1021,7 +1053,7 @@ public void 
  • setDefaultExceptionHandler

    -
    public void setDefaultExceptionHandler(ExceptionHandler exceptionHandler)
    +
    public void setDefaultExceptionHandler(ExceptionHandler exceptionHandler)
    Sets the default ExceptionHandler that is called when an exception occurs while executing a command, if the command doesn't have it's own exception handler registered.
    Parameters:
    @@ -1035,7 +1067,7 @@ public void 
  • getDefaultExceptionHandler

    -
    public ExceptionHandler getDefaultExceptionHandler()
    +
    public ExceptionHandler getDefaultExceptionHandler()
    Gets the current default exception handler, might be null.
    Returns:
    @@ -1049,7 +1081,7 @@ public void 
  • handleUncaughtException

    -
    protected boolean handleUncaughtException(BaseCommand scope,
    +
    protected boolean handleUncaughtException(BaseCommand scope,
                                               RegisteredCommand registeredCommand,
                                               CommandIssuer sender,
                                               List<String> args,
    @@ -1064,7 +1096,7 @@ public void 
     
  • sendMessage

    -
    public void sendMessage(IT issuerArg,
    +
    public void sendMessage(IT issuerArg,
                             MessageType type,
                             co.aikar.locales.MessageKeyProvider key,
                             String... replacements)
    @@ -1076,7 +1108,7 @@ public void 
  • sendMessage

    -
    public void sendMessage(CommandIssuer issuer,
    +
    public void sendMessage(CommandIssuer issuer,
                             MessageType type,
                             co.aikar.locales.MessageKeyProvider key,
                             String... replacements)
    @@ -1088,7 +1120,7 @@ public void 
  • formatMessage

    -
    public String formatMessage(CommandIssuer issuer,
    +
    public String formatMessage(CommandIssuer issuer,
                                 MessageType type,
                                 co.aikar.locales.MessageKeyProvider key,
                                 String... replacements)
    @@ -1100,7 +1132,7 @@ public void 
  • onLocaleChange

    -
    public void onLocaleChange(IssuerLocaleChangedCallback<I> onChange)
    +
    public void onLocaleChange(IssuerLocaleChangedCallback<I> onChange)
  • @@ -1111,7 +1143,7 @@ public void 
  • notifyLocaleChange

    -
    public void notifyLocaleChange(I issuer,
    +
    public void notifyLocaleChange(I issuer,
                                    Locale oldLocale,
                                    Locale newLocale)
  • @@ -1122,7 +1154,7 @@ public void 
  • getIssuerLocale

    -
    public Locale getIssuerLocale(CommandIssuer issuer)
    +
    public Locale getIssuerLocale(CommandIssuer issuer)
  • @@ -1131,7 +1163,7 @@ public void 
  • getSupportedLanguages

    -
    public Set<LocalegetSupportedLanguages()
    +
    public Set<LocalegetSupportedLanguages()
    Gets a list of all currently supported languages for this manager. These locales will be automatically loaded from
    @@ -1145,7 +1177,7 @@ public void 
  • addSupportedLanguage

    -
    public void addSupportedLanguage(Locale locale)
    +
    public void addSupportedLanguage(Locale locale)
    Adds a new locale to the list of automatic Locales to load Message Bundles for. All bundles loaded under the previous supported languages will now automatically load for this new locale too.
    @@ -1154,6 +1186,52 @@ public void  + + + + +
      +
    • +

      registerDependency

      +
      public <T> void registerDependency(Class<? extends T> clazz,
      +                                   T instance)
      +
      Registers an instance of a class to be registered as an injectable dependency.
      + The command manager will attempt to inject all fields in a command class that are annotated with + Dependency with the provided instance.
      +
      +
      Parameters:
      +
      clazz - the class the injector should look for when injecting
      +
      instance - the instance of the class that should be injected
      +
      Throws:
      +
      IllegalStateException - when there is already an instance for the provided class registered
      +
      +
    • +
    + + + + + +
      +
    • +

      registerDependency

      +
      public <T> void registerDependency(Class<? extends T> clazz,
      +                                   String key,
      +                                   T instance)
      +
      Registers an instance of a class to be registered as an injectable dependency.
      + The command manager will attempt to inject all fields in a command class that are annotated with + Dependency with the provided instance.
      +
      +
      Parameters:
      +
      clazz - the class the injector should look for when injecting
      +
      key - the key which needs to be present if that
      +
      instance - the instance of the class that should be injected
      +
      Throws:
      +
      IllegalStateException - when there is already an instance for the provided class registered
      +
      +
    • +
    @@ -1161,7 +1239,7 @@ public void 

    enableUnstableAPI

    @Deprecated
    -public void enableUnstableAPI(String api)
    +public void enableUnstableAPI(String api)
  • Deprecated. Use this with caution! If you enable and use Unstable API's, your next compile using ACF may require you to update your implementation to those unstable API's
  • diff --git a/docs/acf-core/co/aikar/commands/ForwardingCommand.html b/docs/acf-core/co/aikar/commands/ForwardingCommand.html index 2868530b..5257d5f1 100644 --- a/docs/acf-core/co/aikar/commands/ForwardingCommand.html +++ b/docs/acf-core/co/aikar/commands/ForwardingCommand.html @@ -132,7 +132,7 @@ extends BaseCommand -CATCHALL, DEFAULT
  • +CATCHUNKNOWN, DEFAULT
  • diff --git a/docs/acf-core/co/aikar/commands/ShowCommandHelp.html b/docs/acf-core/co/aikar/commands/ShowCommandHelp.html index 8b187893..281cb78c 100644 --- a/docs/acf-core/co/aikar/commands/ShowCommandHelp.html +++ b/docs/acf-core/co/aikar/commands/ShowCommandHelp.html @@ -43,7 +43,7 @@ +
    UnresolvedDependencyException - Exception in co.aikar.commands
    +
    +
    Thrown when a command mananger couldn't find a registered instance for a field that is marked with + Dependency
    +
    UnstableAPI - Annotation Type in co.aikar.commands
    Deprecated.
    diff --git a/docs/acf-core/overview-tree.html b/docs/acf-core/overview-tree.html index 6f767b60..66843017 100644 --- a/docs/acf-core/overview-tree.html +++ b/docs/acf-core/overview-tree.html @@ -120,6 +120,7 @@
  • java.lang.RuntimeException
  • @@ -157,25 +158,27 @@

    Annotation Type Hierarchy

    Enum Hierarchy

      diff --git a/docs/acf-core/serialized-form.html b/docs/acf-core/serialized-form.html index 262943d3..7081977e 100644 --- a/docs/acf-core/serialized-form.html +++ b/docs/acf-core/serialized-form.html @@ -135,6 +135,11 @@
  • +
  • + + +

    Class co.aikar.commands.UnresolvedDependencyException extends RuntimeException implements Serializable

    +
  • diff --git a/docs/acf-core/src-html/co/aikar/commands/BaseCommand.html b/docs/acf-core/src-html/co/aikar/commands/BaseCommand.html index 14b4dfa8..0e63a6c7 100644 --- a/docs/acf-core/src-html/co/aikar/commands/BaseCommand.html +++ b/docs/acf-core/src-html/co/aikar/commands/BaseCommand.html @@ -32,167 +32,167 @@ 024package co.aikar.commands; 025 026import co.aikar.commands.annotation.CatchAll; -027import co.aikar.commands.annotation.CommandAlias; -028import co.aikar.commands.annotation.CommandPermission; -029import co.aikar.commands.annotation.Default; -030import co.aikar.commands.annotation.HelpCommand; -031import co.aikar.commands.annotation.PreCommand; -032import co.aikar.commands.annotation.Subcommand; -033import co.aikar.commands.annotation.UnknownHandler; -034import co.aikar.commands.apachecommonslang.ApacheCommonsLangUtil; -035import com.google.common.collect.HashMultimap; -036import com.google.common.collect.ImmutableList; -037import com.google.common.collect.ImmutableSet; -038import com.google.common.collect.Iterables; -039import com.google.common.collect.Lists; -040import com.google.common.collect.Maps; -041import com.google.common.collect.SetMultimap; -042import com.google.common.collect.Sets; -043 -044import java.lang.reflect.Constructor; -045import java.lang.reflect.InvocationTargetException; -046import java.lang.reflect.Method; -047import java.lang.reflect.Parameter; -048import java.util.ArrayList; -049import java.util.Arrays; -050import java.util.Collections; -051import java.util.HashMap; -052import java.util.HashSet; -053import java.util.List; -054import java.util.Map; -055import java.util.Objects; -056import java.util.Optional; -057import java.util.Set; -058import java.util.Stack; -059import java.util.stream.Collectors; -060import java.util.stream.Stream; -061 -062@SuppressWarnings("unused") -063public abstract class BaseCommand { -064 -065 public static final String CATCHALL = "__catchall"; -066 public static final String DEFAULT = "__default"; -067 final SetMultimap<String, RegisteredCommand> subCommands = HashMultimap.create(); -068 final Map<Class<?>, String> contextFlags = Maps.newHashMap(); -069 private Method preCommandHandler; -070 -071 @SuppressWarnings("WeakerAccess") -072 private String execLabel; -073 @SuppressWarnings("WeakerAccess") -074 private String execSubcommand; -075 @SuppressWarnings("WeakerAccess") -076 private String[] origArgs; -077 CommandManager<?, ?, ?, ?, ?, ?> manager = null; -078 BaseCommand parentCommand; -079 Map<String, RootCommand> registeredCommands = new HashMap<>(); -080 String description; -081 String commandName; -082 String usageMessage; -083 String permission; -084 -085 private ExceptionHandler exceptionHandler = null; -086 CommandOperationContext lastCommandOperationContext; -087 private String parentSubcommand; -088 -089 public BaseCommand() {} -090 public BaseCommand(String cmd) { -091 this.commandName = cmd; -092 } -093 -094 /** -095 * Gets the root command name that the user actually typed -096 * @return Name -097 */ -098 public String getExecCommandLabel() { -099 return execLabel; -100 } -101 -102 /** -103 * Gets the actual sub command name the user typed -104 * @return Name -105 */ -106 public String getExecSubcommand() { -107 return execSubcommand; -108 } -109 -110 /** -111 * Gets the actual args in string form the user typed -112 * @return Args -113 */ -114 public String[] getOrigArgs() { -115 return origArgs; -116 } -117 -118 void setParentCommand(BaseCommand command) { -119 this.parentCommand = command; -120 } -121 void onRegister(CommandManager manager) { -122 onRegister(manager, this.commandName); -123 } -124 void onRegister(CommandManager manager, String cmd) { -125 this.manager = manager; -126 final Class<? extends BaseCommand> self = this.getClass(); -127 CommandAlias rootCmdAliasAnno = self.getAnnotation(CommandAlias.class); -128 String rootCmdAlias = rootCmdAliasAnno != null ? manager.getCommandReplacements().replace(rootCmdAliasAnno.value()).toLowerCase() : null; -129 if (cmd == null && rootCmdAlias != null) { -130 cmd = ACFPatterns.PIPE.split(rootCmdAlias)[0]; -131 } -132 this.commandName = cmd != null ? cmd : self.getSimpleName().toLowerCase(); -133 -134 this.description = this.commandName + " commands"; -135 this.usageMessage = "/" + this.commandName; -136 this.parentSubcommand = getParentSubcommand(this.getClass()); -137 -138 final CommandPermission perm = self.getAnnotation(CommandPermission.class); -139 if (perm != null) { -140 this.permission = manager.getCommandReplacements().replace(perm.value()); -141 } -142 -143 boolean foundDefault = false; -144 boolean foundCatchAll = false; -145 boolean isParentEmpty = parentSubcommand.isEmpty(); -146 for (Method method : self.getMethods()) { -147 method.setAccessible(true); -148 String sublist = null; -149 String sub = getSubcommandValue(method); -150 final Default def = method.getAnnotation(Default.class); -151 final HelpCommand helpCommand = method.getAnnotation(HelpCommand.class); -152 final CommandAlias commandAliases = method.getAnnotation(CommandAlias.class); -153 -154 if (!isParentEmpty && def != null) { -155 sub = parentSubcommand; -156 } -157 if (isParentEmpty && (def != null || (!foundDefault && helpCommand != null))) { -158 if (!foundDefault) { -159 if (def != null) { -160 this.subCommands.get(DEFAULT).clear(); -161 foundDefault = true; -162 } -163 registerSubcommand(method, DEFAULT); -164 } else { -165 ACFUtil.sneaky(new IllegalStateException("Multiple @Default/@HelpCommand commands, duplicate on " + method.getDeclaringClass().getName() + "#" + method.getName())); -166 } -167 } -168 -169 if (sub != null) { -170 sublist = sub; -171 } else if (commandAliases != null) { -172 sublist = commandAliases.value(); -173 } else if (helpCommand != null) { -174 sublist = helpCommand.value(); -175 } -176 -177 UnknownHandler unknown = method.getAnnotation(UnknownHandler.class); -178 CatchAll catchAll = method.getAnnotation(CatchAll.class); +027import co.aikar.commands.annotation.CatchUnknown; +028import co.aikar.commands.annotation.CommandAlias; +029import co.aikar.commands.annotation.CommandPermission; +030import co.aikar.commands.annotation.Default; +031import co.aikar.commands.annotation.HelpCommand; +032import co.aikar.commands.annotation.PreCommand; +033import co.aikar.commands.annotation.Subcommand; +034import co.aikar.commands.annotation.UnknownHandler; +035import co.aikar.commands.apachecommonslang.ApacheCommonsLangUtil; +036import com.google.common.collect.HashMultimap; +037import com.google.common.collect.ImmutableList; +038import com.google.common.collect.ImmutableSet; +039import com.google.common.collect.Iterables; +040import com.google.common.collect.Lists; +041import com.google.common.collect.Maps; +042import com.google.common.collect.SetMultimap; +043import com.google.common.collect.Sets; +044 +045import java.lang.reflect.Constructor; +046import java.lang.reflect.InvocationTargetException; +047import java.lang.reflect.Method; +048import java.lang.reflect.Parameter; +049import java.util.ArrayList; +050import java.util.Arrays; +051import java.util.Collections; +052import java.util.HashMap; +053import java.util.HashSet; +054import java.util.List; +055import java.util.Map; +056import java.util.Objects; +057import java.util.Optional; +058import java.util.Set; +059import java.util.Stack; +060import java.util.stream.Collectors; +061import java.util.stream.Stream; +062 +063@SuppressWarnings("unused") +064public abstract class BaseCommand { +065 +066 public static final String CATCHUNKNOWN = "__catchunknown"; +067 public static final String DEFAULT = "__default"; +068 final SetMultimap<String, RegisteredCommand> subCommands = HashMultimap.create(); +069 final Map<Class<?>, String> contextFlags = Maps.newHashMap(); +070 private Method preCommandHandler; +071 +072 @SuppressWarnings("WeakerAccess") +073 private String execLabel; +074 @SuppressWarnings("WeakerAccess") +075 private String execSubcommand; +076 @SuppressWarnings("WeakerAccess") +077 private String[] origArgs; +078 CommandManager<?, ?, ?, ?, ?, ?> manager = null; +079 BaseCommand parentCommand; +080 Map<String, RootCommand> registeredCommands = new HashMap<>(); +081 String description; +082 String commandName; +083 String usageMessage; +084 String permission; +085 +086 private ExceptionHandler exceptionHandler = null; +087 CommandOperationContext lastCommandOperationContext; +088 private String parentSubcommand; +089 +090 public BaseCommand() {} +091 public BaseCommand(String cmd) { +092 this.commandName = cmd; +093 } +094 +095 /** +096 * Gets the root command name that the user actually typed +097 * @return Name +098 */ +099 public String getExecCommandLabel() { +100 return execLabel; +101 } +102 +103 /** +104 * Gets the actual sub command name the user typed +105 * @return Name +106 */ +107 public String getExecSubcommand() { +108 return execSubcommand; +109 } +110 +111 /** +112 * Gets the actual args in string form the user typed +113 * @return Args +114 */ +115 public String[] getOrigArgs() { +116 return origArgs; +117 } +118 +119 void setParentCommand(BaseCommand command) { +120 this.parentCommand = command; +121 } +122 void onRegister(CommandManager manager) { +123 onRegister(manager, this.commandName); +124 } +125 void onRegister(CommandManager manager, String cmd) { +126 manager.injectDependencies(this); +127 this.manager = manager; +128 final Class<? extends BaseCommand> self = this.getClass(); +129 CommandAlias rootCmdAliasAnno = self.getAnnotation(CommandAlias.class); +130 String rootCmdAlias = rootCmdAliasAnno != null ? manager.getCommandReplacements().replace(rootCmdAliasAnno.value()).toLowerCase() : null; +131 if (cmd == null && rootCmdAlias != null) { +132 cmd = ACFPatterns.PIPE.split(rootCmdAlias)[0]; +133 } +134 this.commandName = cmd != null ? cmd : self.getSimpleName().toLowerCase(); +135 +136 this.description = this.commandName + " commands"; +137 this.usageMessage = "/" + this.commandName; +138 this.parentSubcommand = getParentSubcommand(this.getClass()); +139 +140 final CommandPermission perm = self.getAnnotation(CommandPermission.class); +141 if (perm != null) { +142 this.permission = manager.getCommandReplacements().replace(perm.value()); +143 } +144 +145 boolean foundDefault = false; +146 boolean foundCatchUnknown = false; +147 boolean isParentEmpty = parentSubcommand.isEmpty(); +148 for (Method method : self.getMethods()) { +149 method.setAccessible(true); +150 String sublist = null; +151 String sub = getSubcommandValue(method); +152 final Default def = method.getAnnotation(Default.class); +153 final HelpCommand helpCommand = method.getAnnotation(HelpCommand.class); +154 final CommandAlias commandAliases = method.getAnnotation(CommandAlias.class); +155 +156 if (!isParentEmpty && def != null) { +157 sub = parentSubcommand; +158 } +159 if (isParentEmpty && (def != null || (!foundDefault && helpCommand != null))) { +160 if (!foundDefault) { +161 if (def != null) { +162 this.subCommands.get(DEFAULT).clear(); +163 foundDefault = true; +164 } +165 registerSubcommand(method, DEFAULT); +166 } else { +167 ACFUtil.sneaky(new IllegalStateException("Multiple @Default/@HelpCommand commands, duplicate on " + method.getDeclaringClass().getName() + "#" + method.getName())); +168 } +169 } +170 +171 if (sub != null) { +172 sublist = sub; +173 } else if (commandAliases != null) { +174 sublist = commandAliases.value(); +175 } else if (helpCommand != null) { +176 sublist = helpCommand.value(); +177 } +178 179 PreCommand preCommand = method.getAnnotation(PreCommand.class); -180 boolean hasCatchAll = catchAll != null || unknown != null; -181 if (hasCatchAll || (!foundCatchAll && helpCommand != null)) { -182 if (!foundCatchAll) { -183 if (hasCatchAll) { -184 this.subCommands.get(CATCHALL).clear(); -185 foundCatchAll = true; +180 boolean hasCatchUnknown = method.isAnnotationPresent(CatchUnknown.class) || method.isAnnotationPresent(CatchAll.class) || method.isAnnotationPresent(UnknownHandler.class); +181 if (hasCatchUnknown || (!foundCatchUnknown && helpCommand != null)) { +182 if (!foundCatchUnknown) { +183 if (hasCatchUnknown) { +184 this.subCommands.get(CATCHUNKNOWN).clear(); +185 foundCatchUnknown = true; 186 } -187 registerSubcommand(method, CATCHALL); +187 registerSubcommand(method, CATCHUNKNOWN); 188 } else { 189 ACFUtil.sneaky(new IllegalStateException("Multiple @UnknownHandler/@HelpCommand commands, duplicate on " + method.getDeclaringClass().getName() + "#" + method.getName())); 190 } @@ -366,8 +366,8 @@ 358 359 if (subCommands.get(DEFAULT) != null && args.length == 0) { 360 executeSubcommand(commandContext, DEFAULT, issuer, args); -361 } else if (subCommands.get(CATCHALL) != null) { -362 if (!executeSubcommand(commandContext, CATCHALL, issuer, args)) { +361 } else if (subCommands.get(CATCHUNKNOWN) != null) { +362 if (!executeSubcommand(commandContext, CATCHUNKNOWN, issuer, args)) { 363 help(issuer, args); 364 } 365 } else if (subCommands.get(DEFAULT) != null) { @@ -486,8 +486,8 @@ 478 479 if (search != null) { 480 cmds.addAll(completeCommand(issuer, search.cmd, Arrays.copyOfRange(args, search.argIndex, args.length), commandLabel, isAsync)); -481 } else if (subCommands.get(CATCHALL).size() == 1) { -482 cmds.addAll(completeCommand(issuer, Iterables.getOnlyElement(subCommands.get(CATCHALL)), args, commandLabel, isAsync)); +481 } else if (subCommands.get(CATCHUNKNOWN).size() == 1) { +482 cmds.addAll(completeCommand(issuer, Iterables.getOnlyElement(subCommands.get(CATCHUNKNOWN)), args, commandLabel, isAsync)); 483 } else if (subCommands.get(DEFAULT).size() == 1) { 484 cmds.addAll(completeCommand(issuer, Iterables.getOnlyElement(subCommands.get(DEFAULT)), args, commandLabel, isAsync)); 485 } @@ -503,7 +503,7 @@ 495 String argString = ApacheCommonsLangUtil.join(args, " ").toLowerCase(); 496 for (Map.Entry<String, RegisteredCommand> entry : subCommands.entries()) { 497 final String key = entry.getKey(); -498 if (key.startsWith(argString) && !CATCHALL.equals(key) && !DEFAULT.equals(key)) { +498 if (key.startsWith(argString) && !CATCHUNKNOWN.equals(key) && !DEFAULT.equals(key)) { 499 final RegisteredCommand value = entry.getValue(); 500 if (!value.hasPermission(issuer)) { 501 continue; diff --git a/docs/acf-core/src-html/co/aikar/commands/CommandHelp.html b/docs/acf-core/src-html/co/aikar/commands/CommandHelp.html index f532c0ed..90279a20 100644 --- a/docs/acf-core/src-html/co/aikar/commands/CommandHelp.html +++ b/docs/acf-core/src-html/co/aikar/commands/CommandHelp.html @@ -61,7 +61,7 @@ 053 Set<RegisteredCommand> seen = new HashSet<>(); 054 subCommands.entries().forEach(e -> { 055 String key = e.getKey(); -056 if (key.equals(BaseCommand.DEFAULT) || key.equals(BaseCommand.CATCHALL)){ +056 if (key.equals(BaseCommand.DEFAULT) || key.equals(BaseCommand.CATCHUNKNOWN)){ 057 return; 058 } 059 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 d344ad14..8edd5cf3 100644 --- a/docs/acf-core/src-html/co/aikar/commands/CommandManager.html +++ b/docs/acf-core/src-html/co/aikar/commands/CommandManager.html @@ -31,378 +31,448 @@ 023 024package co.aikar.commands; 025 -026import co.aikar.commands.annotation.Conditions; +026import co.aikar.commands.annotation.Dependency; 027import co.aikar.locales.MessageKeyProvider; -028import com.google.common.collect.Lists; -029import com.google.common.collect.Sets; -030import org.jetbrains.annotations.NotNull; -031 -032import java.lang.reflect.InvocationTargetException; -033import java.lang.reflect.Method; -034import java.lang.reflect.Parameter; -035import java.util.HashMap; -036import java.util.IdentityHashMap; -037import java.util.List; -038import java.util.Locale; -039import java.util.Map; -040import java.util.Set; -041import java.util.Stack; -042 -043@SuppressWarnings("WeakerAccess") -044public abstract class CommandManager < -045 IT, -046 I extends CommandIssuer, -047 FT, -048 MF extends MessageFormatter<FT>, -049 CEC extends CommandExecutionContext<CEC, I>, -050 CC extends ConditionContext<I> -051 > { -052 -053 /** -054 * This is a stack incase a command calls a command -055 */ -056 static ThreadLocal<Stack<CommandOperationContext>> commandOperationContext = ThreadLocal.withInitial(() -> { -057 return new Stack<CommandOperationContext>() { -058 @Override -059 public synchronized CommandOperationContext peek() { -060 return super.size() == 0 ? null : super.peek(); -061 } -062 }; -063 }); -064 protected Map<String, RootCommand> rootCommands = new HashMap<>(); -065 protected final CommandReplacements replacements = new CommandReplacements(this); -066 protected final CommandConditions<I, CEC, CC> conditions = new CommandConditions<>(this); -067 protected ExceptionHandler defaultExceptionHandler = null; -068 -069 protected boolean usePerIssuerLocale = false; -070 protected List<IssuerLocaleChangedCallback<I>> localeChangedCallbacks = Lists.newArrayList(); -071 protected Set<Locale> supportedLanguages = Sets.newHashSet(Locales.ENGLISH, Locales.GERMAN, Locales.SPANISH, Locales.CZECH); -072 protected Map<MessageType, MF> formatters = new IdentityHashMap<>(); -073 protected MF defaultFormatter; -074 protected int defaultHelpPerPage = 10; -075 -076 private Set<String> unstableAPIs = Sets.newHashSet(); -077 -078 public static CommandOperationContext getCurrentCommandOperationContext() { -079 return commandOperationContext.get().peek(); -080 } -081 -082 public static CommandIssuer getCurrentCommandIssuer() { -083 CommandOperationContext context = commandOperationContext.get().peek(); -084 return context != null ? context.getCommandIssuer() : null; -085 } -086 -087 public static CommandManager getCurrentCommandManager() { -088 CommandOperationContext context = commandOperationContext.get().peek(); -089 return context != null ? context.getCommandManager() : null; -090 } -091 -092 public MF setFormat(MessageType type, MF formatter) { -093 return formatters.put(type, formatter); -094 } -095 -096 public MF getFormat(MessageType type) { -097 return formatters.getOrDefault(type, defaultFormatter); -098 } -099 -100 public void setFormat(MessageType type, FT... colors) { -101 MF format = getFormat(type); -102 for (int i = 1; i <= colors.length; i++) { -103 format.setColor(i, colors[i-1]); -104 } -105 } -106 -107 public void setFormat(MessageType type, int i, FT color) { -108 MF format = getFormat(type); -109 format.setColor(i, color); -110 } -111 -112 public MF getDefaultFormatter() { -113 return defaultFormatter; -114 } -115 -116 public void setDefaultFormatter(MF defaultFormatter) { -117 this.defaultFormatter = defaultFormatter; -118 } -119 -120 public CommandConditions<I, CEC, CC> getCommandConditions() { -121 return conditions; -122 } -123 -124 /** -125 * Gets the command contexts manager -126 * @return Command Contexts -127 */ -128 public abstract CommandContexts<?> getCommandContexts(); -129 -130 /** -131 * Gets the command completions manager -132 * @return Command Completions -133 */ -134 public abstract CommandCompletions<?> getCommandCompletions(); -135 -136 /** @deprecated Unstable API */ @Deprecated @UnstableAPI -137 public CommandHelp generateCommandHelp(@NotNull String command) { -138 verifyUnstableAPI("help"); -139 CommandOperationContext context = getCurrentCommandOperationContext(); -140 if (context == null) { -141 throw new IllegalStateException("This method can only be called as part of a command execution."); -142 } -143 return generateCommandHelp(context.getCommandIssuer(), command); -144 } -145 -146 /** @deprecated Unstable API */ @Deprecated @UnstableAPI -147 public CommandHelp generateCommandHelp(CommandIssuer issuer, @NotNull String command) { -148 verifyUnstableAPI("help"); -149 return generateCommandHelp(issuer, obtainRootCommand(command)); -150 } -151 -152 /** @deprecated Unstable API */ @Deprecated @UnstableAPI -153 public CommandHelp generateCommandHelp() { -154 verifyUnstableAPI("help"); -155 CommandOperationContext context = getCurrentCommandOperationContext(); -156 if (context == null) { -157 throw new IllegalStateException("This method can only be called as part of a command execution."); -158 } -159 String commandLabel = context.getCommandLabel(); -160 return generateCommandHelp(context.getCommandIssuer(), this.obtainRootCommand(commandLabel)); -161 } -162 -163 /** @deprecated Unstable API */ @Deprecated @UnstableAPI -164 public CommandHelp generateCommandHelp(CommandIssuer issuer, RootCommand rootCommand) { -165 verifyUnstableAPI("help"); -166 return new CommandHelp(this, rootCommand, issuer); -167 } -168 -169 /** @deprecated Unstable API */ @Deprecated @UnstableAPI -170 public int getDefaultHelpPerPage() { -171 verifyUnstableAPI("help"); -172 return defaultHelpPerPage; -173 } -174 -175 /** @deprecated Unstable API */ @Deprecated @UnstableAPI -176 public void setDefaultHelpPerPage(int defaultHelpPerPage) { -177 verifyUnstableAPI("help"); -178 this.defaultHelpPerPage = defaultHelpPerPage; -179 } -180 -181 /** -182 * Registers a command with ACF -183 * -184 * @param command The command to register -185 * @return boolean -186 */ -187 public abstract void registerCommand(BaseCommand command); -188 public abstract boolean hasRegisteredCommands(); -189 public abstract boolean isCommandIssuer(Class<?> type); -190 -191 // TODO: Change this to I if we make a breaking change -192 public abstract I getCommandIssuer(Object issuer); +028import com.google.common.collect.HashBasedTable; +029import com.google.common.collect.Lists; +030import com.google.common.collect.Sets; +031import com.google.common.collect.Table; +032import org.jetbrains.annotations.NotNull; +033 +034import java.lang.reflect.Field; +035import java.lang.reflect.InvocationTargetException; +036import java.lang.reflect.Method; +037import java.lang.reflect.Parameter; +038import java.util.Arrays; +039import java.util.HashMap; +040import java.util.IdentityHashMap; +041import java.util.List; +042import java.util.Locale; +043import java.util.Map; +044import java.util.Set; +045import java.util.Stack; +046 +047@SuppressWarnings("WeakerAccess") +048public abstract class CommandManager < +049 IT, +050 I extends CommandIssuer, +051 FT, +052 MF extends MessageFormatter<FT>, +053 CEC extends CommandExecutionContext<CEC, I>, +054 CC extends ConditionContext<I> +055 > { +056 +057 /** +058 * This is a stack incase a command calls a command +059 */ +060 static ThreadLocal<Stack<CommandOperationContext>> commandOperationContext = ThreadLocal.withInitial(() -> new Stack<CommandOperationContext>() { +061 @Override +062 public synchronized CommandOperationContext peek() { +063 return super.size() == 0 ? null : super.peek(); +064 } +065 }); +066 protected Map<String, RootCommand> rootCommands = new HashMap<>(); +067 protected final CommandReplacements replacements = new CommandReplacements(this); +068 protected final CommandConditions<I, CEC, CC> conditions = new CommandConditions<>(this); +069 protected ExceptionHandler defaultExceptionHandler = null; +070 protected Table<Class<?>, String, Object> dependencies = HashBasedTable.create(); +071 +072 protected boolean usePerIssuerLocale = false; +073 protected List<IssuerLocaleChangedCallback<I>> localeChangedCallbacks = Lists.newArrayList(); +074 protected Set<Locale> supportedLanguages = Sets.newHashSet(Locales.ENGLISH, Locales.GERMAN, Locales.SPANISH, Locales.CZECH); +075 protected Map<MessageType, MF> formatters = new IdentityHashMap<>(); +076 protected MF defaultFormatter; +077 protected int defaultHelpPerPage = 10; +078 +079 private Set<String> unstableAPIs = Sets.newHashSet(); +080 +081 public static CommandOperationContext getCurrentCommandOperationContext() { +082 return commandOperationContext.get().peek(); +083 } +084 +085 public static CommandIssuer getCurrentCommandIssuer() { +086 CommandOperationContext context = commandOperationContext.get().peek(); +087 return context != null ? context.getCommandIssuer() : null; +088 } +089 +090 public static CommandManager getCurrentCommandManager() { +091 CommandOperationContext context = commandOperationContext.get().peek(); +092 return context != null ? context.getCommandManager() : null; +093 } +094 +095 public MF setFormat(MessageType type, MF formatter) { +096 return formatters.put(type, formatter); +097 } +098 +099 public MF getFormat(MessageType type) { +100 return formatters.getOrDefault(type, defaultFormatter); +101 } +102 +103 public void setFormat(MessageType type, FT... colors) { +104 MF format = getFormat(type); +105 for (int i = 1; i <= colors.length; i++) { +106 format.setColor(i, colors[i-1]); +107 } +108 } +109 +110 public void setFormat(MessageType type, int i, FT color) { +111 MF format = getFormat(type); +112 format.setColor(i, color); +113 } +114 +115 public MF getDefaultFormatter() { +116 return defaultFormatter; +117 } +118 +119 public void setDefaultFormatter(MF defaultFormatter) { +120 this.defaultFormatter = defaultFormatter; +121 } +122 +123 public CommandConditions<I, CEC, CC> getCommandConditions() { +124 return conditions; +125 } +126 +127 /** +128 * Gets the command contexts manager +129 * @return Command Contexts +130 */ +131 public abstract CommandContexts<?> getCommandContexts(); +132 +133 /** +134 * Gets the command completions manager +135 * @return Command Completions +136 */ +137 public abstract CommandCompletions<?> getCommandCompletions(); +138 +139 /** @deprecated Unstable API */ @Deprecated @UnstableAPI +140 public CommandHelp generateCommandHelp(@NotNull String command) { +141 verifyUnstableAPI("help"); +142 CommandOperationContext context = getCurrentCommandOperationContext(); +143 if (context == null) { +144 throw new IllegalStateException("This method can only be called as part of a command execution."); +145 } +146 return generateCommandHelp(context.getCommandIssuer(), command); +147 } +148 +149 /** @deprecated Unstable API */ @Deprecated @UnstableAPI +150 public CommandHelp generateCommandHelp(CommandIssuer issuer, @NotNull String command) { +151 verifyUnstableAPI("help"); +152 return generateCommandHelp(issuer, obtainRootCommand(command)); +153 } +154 +155 /** @deprecated Unstable API */ @Deprecated @UnstableAPI +156 public CommandHelp generateCommandHelp() { +157 verifyUnstableAPI("help"); +158 CommandOperationContext context = getCurrentCommandOperationContext(); +159 if (context == null) { +160 throw new IllegalStateException("This method can only be called as part of a command execution."); +161 } +162 String commandLabel = context.getCommandLabel(); +163 return generateCommandHelp(context.getCommandIssuer(), this.obtainRootCommand(commandLabel)); +164 } +165 +166 /** @deprecated Unstable API */ @Deprecated @UnstableAPI +167 public CommandHelp generateCommandHelp(CommandIssuer issuer, RootCommand rootCommand) { +168 verifyUnstableAPI("help"); +169 return new CommandHelp(this, rootCommand, issuer); +170 } +171 +172 /** @deprecated Unstable API */ @Deprecated @UnstableAPI +173 public int getDefaultHelpPerPage() { +174 verifyUnstableAPI("help"); +175 return defaultHelpPerPage; +176 } +177 +178 /** @deprecated Unstable API */ @Deprecated @UnstableAPI +179 public void setDefaultHelpPerPage(int defaultHelpPerPage) { +180 verifyUnstableAPI("help"); +181 this.defaultHelpPerPage = defaultHelpPerPage; +182 } +183 +184 /** +185 * Registers a command with ACF +186 * +187 * @param command The command to register +188 * @return boolean +189 */ +190 public abstract void registerCommand(BaseCommand command); +191 public abstract boolean hasRegisteredCommands(); +192 public abstract boolean isCommandIssuer(Class<?> type); 193 -194 public abstract RootCommand createRootCommand(String cmd); -195 -196 /** -197 * Returns a Locales Manager to add and modify language tables for your commands. -198 * @return -199 */ -200 public abstract Locales getLocales(); -201 -202 public boolean usingPerIssuerLocale() { -203 return usePerIssuerLocale; -204 } -205 -206 public boolean usePerIssuerLocale(boolean setting) { -207 boolean old = usePerIssuerLocale; -208 usePerIssuerLocale = setting; -209 return old; -210 } -211 -212 public ConditionContext createConditionContext(CommandIssuer issuer, String config) { -213 //noinspection unchecked -214 return new ConditionContext(issuer, config); -215 } -216 -217 public abstract CommandExecutionContext createCommandContext(RegisteredCommand command, Parameter parameter, CommandIssuer sender, List<String> args, int i, Map<String, Object> passedArgs); -218 -219 public abstract CommandCompletionContext createCompletionContext(RegisteredCommand command, CommandIssuer sender, String input, String config, String[] args); -220 -221 public abstract void log(final LogLevel level, final String message, final Throwable throwable); -222 -223 public void log(final LogLevel level, final String message) { -224 log(level, message, null); -225 } -226 -227 /** -228 * Lets you add custom string replacements that can be applied to annotation values, -229 * to reduce duplication/repetition of common values such as permission nodes and command prefixes. -230 * -231 * Any replacement registered starts with a % -232 * -233 * So for ex @CommandPermission("%staff") -234 * @return Replacements Manager -235 */ -236 public CommandReplacements getCommandReplacements() { -237 return replacements; -238 } -239 -240 public boolean hasPermission(CommandIssuer issuer, String permission) { -241 if (permission == null || permission.isEmpty()) { -242 return true; -243 } -244 for (String perm : ACFPatterns.COMMA.split(permission)) { -245 if (!perm.isEmpty() && !issuer.hasPermission(perm)) { -246 return false; -247 } -248 } -249 return true; -250 } -251 -252 BaseCommand getBaseCommand(String commandLabel, @NotNull String[] args) { -253 RootCommand rootCommand = obtainRootCommand(commandLabel); -254 if (rootCommand == null) { -255 return null; -256 } -257 return rootCommand.getBaseCommand(args); -258 } -259 -260 public synchronized RootCommand getRootCommand(@NotNull String cmd) { -261 return rootCommands.get(ACFPatterns.SPACE.split(cmd.toLowerCase(), 2)[0]); -262 } -263 -264 public synchronized RootCommand obtainRootCommand(@NotNull String cmd) { -265 return rootCommands.computeIfAbsent(ACFPatterns.SPACE.split(cmd.toLowerCase(), 2)[0], this::createRootCommand); -266 } -267 -268 public RegisteredCommand createRegisteredCommand(BaseCommand command, String cmdName, Method method, String prefSubCommand) { -269 return new RegisteredCommand(command, cmdName, method, prefSubCommand); -270 } -271 -272 /** -273 * 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. -274 * -275 * @param exceptionHandler the handler that should handle uncaught exceptions -276 */ -277 public void setDefaultExceptionHandler(ExceptionHandler exceptionHandler) { -278 defaultExceptionHandler = exceptionHandler; -279 } -280 -281 /** -282 * Gets the current default exception handler, might be null. -283 * -284 * @return the default exception handler -285 */ -286 public ExceptionHandler getDefaultExceptionHandler() { -287 return defaultExceptionHandler; -288 } -289 -290 protected boolean handleUncaughtException(BaseCommand scope, RegisteredCommand registeredCommand, CommandIssuer sender, List<String> args, Throwable t) { -291 if (t instanceof InvocationTargetException && t.getCause() != null) { -292 t = t.getCause(); -293 } -294 boolean result = false; -295 if (scope.getExceptionHandler() != null) { -296 result = scope.getExceptionHandler().execute(scope, registeredCommand, sender, args, t); -297 } else if (defaultExceptionHandler != null) { -298 result = defaultExceptionHandler.execute(scope, registeredCommand, sender, args, t); -299 } -300 return result; -301 } -302 -303 public void sendMessage(IT issuerArg, MessageType type, MessageKeyProvider key, String... replacements) { -304 sendMessage(getCommandIssuer(issuerArg), type, key, replacements); -305 } -306 -307 public void sendMessage(CommandIssuer issuer, MessageType type, MessageKeyProvider key, String... replacements) { -308 String message = formatMessage(issuer, type, key, replacements); +194 // TODO: Change this to I if we make a breaking change +195 public abstract I getCommandIssuer(Object issuer); +196 +197 public abstract RootCommand createRootCommand(String cmd); +198 +199 /** +200 * Returns a Locales Manager to add and modify language tables for your commands. +201 * @return +202 */ +203 public abstract Locales getLocales(); +204 +205 public boolean usingPerIssuerLocale() { +206 return usePerIssuerLocale; +207 } +208 +209 public boolean usePerIssuerLocale(boolean setting) { +210 boolean old = usePerIssuerLocale; +211 usePerIssuerLocale = setting; +212 return old; +213 } +214 +215 public ConditionContext createConditionContext(CommandIssuer issuer, String config) { +216 //noinspection unchecked +217 return new ConditionContext(issuer, config); +218 } +219 +220 public abstract CommandExecutionContext createCommandContext(RegisteredCommand command, Parameter parameter, CommandIssuer sender, List<String> args, int i, Map<String, Object> passedArgs); +221 +222 public abstract CommandCompletionContext createCompletionContext(RegisteredCommand command, CommandIssuer sender, String input, String config, String[] args); +223 +224 public abstract void log(final LogLevel level, final String message, final Throwable throwable); +225 +226 public void log(final LogLevel level, final String message) { +227 log(level, message, null); +228 } +229 +230 /** +231 * Lets you add custom string replacements that can be applied to annotation values, +232 * to reduce duplication/repetition of common values such as permission nodes and command prefixes. +233 * +234 * Any replacement registered starts with a % +235 * +236 * So for ex @CommandPermission("%staff") +237 * @return Replacements Manager +238 */ +239 public CommandReplacements getCommandReplacements() { +240 return replacements; +241 } +242 +243 public boolean hasPermission(CommandIssuer issuer, String permission) { +244 if (permission == null || permission.isEmpty()) { +245 return true; +246 } +247 for (String perm : ACFPatterns.COMMA.split(permission)) { +248 if (!perm.isEmpty() && !issuer.hasPermission(perm)) { +249 return false; +250 } +251 } +252 return true; +253 } +254 +255 BaseCommand getBaseCommand(String commandLabel, @NotNull String[] args) { +256 RootCommand rootCommand = obtainRootCommand(commandLabel); +257 if (rootCommand == null) { +258 return null; +259 } +260 return rootCommand.getBaseCommand(args); +261 } +262 +263 public synchronized RootCommand getRootCommand(@NotNull String cmd) { +264 return rootCommands.get(ACFPatterns.SPACE.split(cmd.toLowerCase(), 2)[0]); +265 } +266 +267 public synchronized RootCommand obtainRootCommand(@NotNull String cmd) { +268 return rootCommands.computeIfAbsent(ACFPatterns.SPACE.split(cmd.toLowerCase(), 2)[0], this::createRootCommand); +269 } +270 +271 public RegisteredCommand createRegisteredCommand(BaseCommand command, String cmdName, Method method, String prefSubCommand) { +272 return new RegisteredCommand(command, cmdName, method, prefSubCommand); +273 } +274 +275 /** +276 * 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. +277 * +278 * @param exceptionHandler the handler that should handle uncaught exceptions +279 */ +280 public void setDefaultExceptionHandler(ExceptionHandler exceptionHandler) { +281 defaultExceptionHandler = exceptionHandler; +282 } +283 +284 /** +285 * Gets the current default exception handler, might be null. +286 * +287 * @return the default exception handler +288 */ +289 public ExceptionHandler getDefaultExceptionHandler() { +290 return defaultExceptionHandler; +291 } +292 +293 protected boolean handleUncaughtException(BaseCommand scope, RegisteredCommand registeredCommand, CommandIssuer sender, List<String> args, Throwable t) { +294 if (t instanceof InvocationTargetException && t.getCause() != null) { +295 t = t.getCause(); +296 } +297 boolean result = false; +298 if (scope.getExceptionHandler() != null) { +299 result = scope.getExceptionHandler().execute(scope, registeredCommand, sender, args, t); +300 } else if (defaultExceptionHandler != null) { +301 result = defaultExceptionHandler.execute(scope, registeredCommand, sender, args, t); +302 } +303 return result; +304 } +305 +306 public void sendMessage(IT issuerArg, MessageType type, MessageKeyProvider key, String... replacements) { +307 sendMessage(getCommandIssuer(issuerArg), type, key, replacements); +308 } 309 -310 for (String msg : ACFPatterns.NEWLINE.split(message)) { -311 issuer.sendMessageInternal(ACFUtil.rtrim(msg)); -312 } -313 } -314 -315 public String formatMessage(CommandIssuer issuer, MessageType type, MessageKeyProvider key, String... replacements) { -316 String message = getLocales().getMessage(issuer, key.getMessageKey()); -317 if (replacements.length > 0) { -318 message = ACFUtil.replaceStrings(message, replacements); -319 } -320 -321 message = getCommandReplacements().replace(message); -322 -323 MessageFormatter formatter = formatters.getOrDefault(type, defaultFormatter); -324 if (formatter != null) { -325 message = formatter.format(message); -326 } -327 return message; -328 } -329 -330 public void onLocaleChange(IssuerLocaleChangedCallback<I> onChange) { -331 localeChangedCallbacks.add(onChange); -332 } -333 -334 public void notifyLocaleChange(I issuer, Locale oldLocale, Locale newLocale) { -335 localeChangedCallbacks.forEach(cb -> { -336 try { -337 cb.onIssuerLocaleChange(issuer, oldLocale, newLocale); -338 } catch (Exception e) { -339 this.log(LogLevel.ERROR, "Error in notifyLocaleChange", e); -340 } -341 }); -342 } -343 -344 public Locale getIssuerLocale(CommandIssuer issuer) { -345 return getLocales().getDefaultLocale(); -346 } -347 -348 CommandOperationContext<I> createCommandOperationContext(BaseCommand command, CommandIssuer issuer, String commandLabel, String[] args, boolean isAsync) { -349 //noinspection unchecked -350 return new CommandOperationContext<>( -351 this, -352 (I) issuer, -353 command, -354 commandLabel, -355 args, -356 isAsync -357 ); -358 } -359 -360 /** -361 * Gets a list of all currently supported languages for this manager. -362 * These locales will be automatically loaded from -363 * @return -364 */ -365 public Set<Locale> getSupportedLanguages() { -366 return supportedLanguages; -367 } -368 -369 /** -370 * Adds a new locale to the list of automatic Locales to load Message Bundles for. -371 * All bundles loaded under the previous supported languages will now automatically load for this new locale too. -372 * -373 * @param locale -374 */ -375 public void addSupportedLanguage(Locale locale) { -376 supportedLanguages.add(locale); -377 getLocales().loadMissingBundles(); -378 } -379 -380 /** -381 * @deprecated Use this with caution! If you enable and use Unstable API's, your next compile using ACF -382 * may require you to update your implementation to those unstable API's -383 */ -384 @Deprecated -385 public void enableUnstableAPI(String api) { -386 unstableAPIs.add(api); -387 } -388 void verifyUnstableAPI(String api) { -389 if (!unstableAPIs.contains(api)) { -390 throw new IllegalStateException("Using an unstable API that has not been enabled ( " + api + "). See https://acfunstable.emc.gs"); -391 } -392 } -393 -394 boolean hasUnstableAPI(String api) { -395 return unstableAPIs.contains(api); -396 } -397} +310 public void sendMessage(CommandIssuer issuer, MessageType type, MessageKeyProvider key, String... replacements) { +311 String message = formatMessage(issuer, type, key, replacements); +312 +313 for (String msg : ACFPatterns.NEWLINE.split(message)) { +314 issuer.sendMessageInternal(ACFUtil.rtrim(msg)); +315 } +316 } +317 +318 public String formatMessage(CommandIssuer issuer, MessageType type, MessageKeyProvider key, String... replacements) { +319 String message = getLocales().getMessage(issuer, key.getMessageKey()); +320 if (replacements.length > 0) { +321 message = ACFUtil.replaceStrings(message, replacements); +322 } +323 +324 message = getCommandReplacements().replace(message); +325 +326 MessageFormatter formatter = formatters.getOrDefault(type, defaultFormatter); +327 if (formatter != null) { +328 message = formatter.format(message); +329 } +330 return message; +331 } +332 +333 public void onLocaleChange(IssuerLocaleChangedCallback<I> onChange) { +334 localeChangedCallbacks.add(onChange); +335 } +336 +337 public void notifyLocaleChange(I issuer, Locale oldLocale, Locale newLocale) { +338 localeChangedCallbacks.forEach(cb -> { +339 try { +340 cb.onIssuerLocaleChange(issuer, oldLocale, newLocale); +341 } catch (Exception e) { +342 this.log(LogLevel.ERROR, "Error in notifyLocaleChange", e); +343 } +344 }); +345 } +346 +347 public Locale getIssuerLocale(CommandIssuer issuer) { +348 return getLocales().getDefaultLocale(); +349 } +350 +351 CommandOperationContext<I> createCommandOperationContext(BaseCommand command, CommandIssuer issuer, String commandLabel, String[] args, boolean isAsync) { +352 //noinspection unchecked +353 return new CommandOperationContext<>( +354 this, +355 (I) issuer, +356 command, +357 commandLabel, +358 args, +359 isAsync +360 ); +361 } +362 +363 /** +364 * Gets a list of all currently supported languages for this manager. +365 * These locales will be automatically loaded from +366 * @return +367 */ +368 public Set<Locale> getSupportedLanguages() { +369 return supportedLanguages; +370 } +371 +372 /** +373 * Adds a new locale to the list of automatic Locales to load Message Bundles for. +374 * All bundles loaded under the previous supported languages will now automatically load for this new locale too. +375 * +376 * @param locale +377 */ +378 public void addSupportedLanguage(Locale locale) { +379 supportedLanguages.add(locale); +380 getLocales().loadMissingBundles(); +381 } +382 +383 /** +384 * Registers an instance of a class to be registered as an injectable dependency.<br> +385 * The command manager will attempt to inject all fields in a command class that are annotated with +386 * {@link co.aikar.commands.annotation.Dependency} with the provided instance. +387 * +388 * @param clazz the class the injector should look for when injecting +389 * @param instance the instance of the class that should be injected +390 * @throws IllegalStateException when there is already an instance for the provided class registered +391 */ +392 public <T> void registerDependency(Class<? extends T> clazz, T instance){ +393 registerDependency(clazz, clazz.getName(), instance); +394 } +395 +396 /** +397 * Registers an instance of a class to be registered as an injectable dependency.<br> +398 * The command manager will attempt to inject all fields in a command class that are annotated with +399 * {@link co.aikar.commands.annotation.Dependency} with the provided instance. +400 * +401 * @param clazz the class the injector should look for when injecting +402 * @param key the key which needs to be present if that +403 * @param instance the instance of the class that should be injected +404 * @throws IllegalStateException when there is already an instance for the provided class registered +405 */ +406 public <T> void registerDependency(Class<? extends T> clazz, String key, T instance){ +407 if(dependencies.containsRow(clazz) && dependencies.containsColumn(key)){ +408 throw new IllegalStateException("There is already an instance of " + clazz.getName() + " with the key " + key + " registered!"); +409 } +410 +411 dependencies.put(clazz, key, instance); +412 } +413 +414 /** +415 * Attempts to inject instances of classes registered with {@link CommandManager#registerDependency(Class, Object)} +416 * into all fields of the class and its superclasses that are marked with {@link Dependency}. +417 * +418 * @param baseCommand the instance which fields should be filled +419 */ +420 void injectDependencies(BaseCommand baseCommand) { +421 Class clazz = baseCommand.getClass(); +422 do { +423 for (Field field : clazz.getDeclaredFields()) { +424 if (field.isAnnotationPresent(Dependency.class)) { +425 Dependency dependency = field.getAnnotation(Dependency.class); +426 String key = (key = dependency.value()).equals("") ? field.getType().getName() : key; +427 Object object = dependencies.row(field.getType()).get(key); +428 if (object == null) { +429 throw new UnresolvedDependencyException("Could not find a registered instance of " + +430 field.getType().getName() + " with key " + key + " for field " + field.getName() + +431 " in class " + baseCommand.getClass().getName()); +432 } +433 +434 try { +435 boolean accessible = field.isAccessible(); +436 if (!accessible) { +437 field.setAccessible(true); +438 } +439 field.set(baseCommand, object); +440 field.setAccessible(accessible); +441 } catch (IllegalAccessException e) { +442 e.printStackTrace(); //TODO should we print our own exception here to make a more descriptive error? +443 } +444 } +445 } +446 clazz = clazz.getSuperclass(); +447 } while (!clazz.equals(BaseCommand.class)); +448 } +449 +450 /** +451 * @deprecated Use this with caution! If you enable and use Unstable API's, your next compile using ACF +452 * may require you to update your implementation to those unstable API's +453 */ +454 @Deprecated +455 public void enableUnstableAPI(String api) { +456 unstableAPIs.add(api); +457 } +458 void verifyUnstableAPI(String api) { +459 if (!unstableAPIs.contains(api)) { +460 throw new IllegalStateException("Using an unstable API that has not been enabled ( " + api + "). See https://acfunstable.emc.gs"); +461 } +462 } +463 +464 boolean hasUnstableAPI(String api) { +465 return unstableAPIs.contains(api); +466 } +467} diff --git a/docs/acf-core/src-html/co/aikar/commands/InvalidCommandArgument.html b/docs/acf-core/src-html/co/aikar/commands/InvalidCommandArgument.html index 9ad7e215..818a6198 100644 --- a/docs/acf-core/src-html/co/aikar/commands/InvalidCommandArgument.html +++ b/docs/acf-core/src-html/co/aikar/commands/InvalidCommandArgument.html @@ -40,7 +40,7 @@ 032 final String[] replacements; 033 034 public InvalidCommandArgument() { -035 this((String) null, true); +035 this(null, true); 036 } 037 public InvalidCommandArgument(boolean showSyntax) { 038 this(null, showSyntax); diff --git a/docs/acf-core/src-html/co/aikar/commands/RegisteredCommand.html b/docs/acf-core/src-html/co/aikar/commands/RegisteredCommand.html index 74efdc1b..e04ce3cc 100644 --- a/docs/acf-core/src-html/co/aikar/commands/RegisteredCommand.html +++ b/docs/acf-core/src-html/co/aikar/commands/RegisteredCommand.html @@ -80,7 +80,7 @@ 072 RegisteredCommand(BaseCommand scope, String command, Method method, String prefSubCommand) { 073 this.scope = scope; 074 this.manager = this.scope.manager; -075 if (BaseCommand.CATCHALL.equals(prefSubCommand) || BaseCommand.DEFAULT.equals(prefSubCommand)) { +075 if (BaseCommand.CATCHUNKNOWN.equals(prefSubCommand) || BaseCommand.DEFAULT.equals(prefSubCommand)) { 076 prefSubCommand = ""; 077 } 078 this.command = command + (method.getAnnotation(CommandAlias.class) == null && !prefSubCommand.isEmpty() ? prefSubCommand : ""); diff --git a/docs/acf-core/src-html/co/aikar/commands/UnresolvedDependencyException.html b/docs/acf-core/src-html/co/aikar/commands/UnresolvedDependencyException.html new file mode 100644 index 00000000..35bfb198 --- /dev/null +++ b/docs/acf-core/src-html/co/aikar/commands/UnresolvedDependencyException.html @@ -0,0 +1,106 @@ + + + +Source code + + + +
    +
    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
    +026/**
    +027 * Thrown when a command mananger couldn't find a registered instance for a field that is marked with
    +028 * {@link co.aikar.commands.annotation.Dependency}
    +029 */
    +030public class UnresolvedDependencyException extends RuntimeException {
    +031    UnresolvedDependencyException(String message) {
    +032        super(message);
    +033    }
    +034}
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + diff --git a/docs/acf-core/src-html/co/aikar/commands/annotation/CatchAll.html b/docs/acf-core/src-html/co/aikar/commands/annotation/CatchAll.html index eb8721b4..c1b34b54 100644 --- a/docs/acf-core/src-html/co/aikar/commands/annotation/CatchAll.html +++ b/docs/acf-core/src-html/co/aikar/commands/annotation/CatchAll.html @@ -34,8 +34,12 @@ 026import java.lang.annotation.Retention; 027import java.lang.annotation.RetentionPolicy; 028 -029@Retention(RetentionPolicy.RUNTIME) -030public @interface CatchAll {} +029/** +030 * @deprecated Use {@link CatchUnknown instead, which is more accurately named} +031 */ +032@Deprecated +033@Retention(RetentionPolicy.RUNTIME) +034public @interface CatchAll {} diff --git a/docs/acf-core/src-html/co/aikar/commands/annotation/CatchUnknown.html b/docs/acf-core/src-html/co/aikar/commands/annotation/CatchUnknown.html new file mode 100644 index 00000000..fee94b2e --- /dev/null +++ b/docs/acf-core/src-html/co/aikar/commands/annotation/CatchUnknown.html @@ -0,0 +1,103 @@ + + + +Source code + + + +
    +
    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.annotation;
    +025
    +026import java.lang.annotation.Retention;
    +027import java.lang.annotation.RetentionPolicy;
    +028
    +029@Retention(RetentionPolicy.RUNTIME)
    +030public @interface CatchUnknown {
    +031}
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + diff --git a/docs/acf-core/src-html/co/aikar/commands/annotation/Dependency.html b/docs/acf-core/src-html/co/aikar/commands/annotation/Dependency.html new file mode 100644 index 00000000..0d06a5a5 --- /dev/null +++ b/docs/acf-core/src-html/co/aikar/commands/annotation/Dependency.html @@ -0,0 +1,108 @@ + + + +Source code + + + +
    +
    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.annotation;
    +025
    +026import java.lang.annotation.Retention;
    +027import java.lang.annotation.RetentionPolicy;
    +028
    +029@Retention(RetentionPolicy.RUNTIME)
    +030public @interface Dependency {
    +031    /**
    +032     * The key that should be used to lookup the instances, defaults to \"\"
    +033     * @return the key
    +034     */
    +035    String value() default "";
    +036}
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + diff --git a/docs/acf-jda/allclasses-frame.html b/docs/acf-jda/allclasses-frame.html new file mode 100644 index 00000000..65498003 --- /dev/null +++ b/docs/acf-jda/allclasses-frame.html @@ -0,0 +1,33 @@ + + + + + + +All Classes (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + +

    All Classes

    + + + diff --git a/docs/acf-jda/allclasses-noframe.html b/docs/acf-jda/allclasses-noframe.html new file mode 100644 index 00000000..dd70283d --- /dev/null +++ b/docs/acf-jda/allclasses-noframe.html @@ -0,0 +1,33 @@ + + + + + + +All Classes (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + +

    All Classes

    + + + diff --git a/docs/acf-jda/co/aikar/commands/CommandConfig.html b/docs/acf-jda/co/aikar/commands/CommandConfig.html new file mode 100644 index 00000000..d065af09 --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/CommandConfig.html @@ -0,0 +1,245 @@ + + + + + + +CommandConfig (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + + +
    +
    co.aikar.commands
    +

    Interface CommandConfig

    +
    +
    +
    + +
    +
    + +
    +
    + +
    +
    + + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/CommandConfigProvider.html b/docs/acf-jda/co/aikar/commands/CommandConfigProvider.html new file mode 100644 index 00000000..d068239e --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/CommandConfigProvider.html @@ -0,0 +1,226 @@ + + + + + + +CommandConfigProvider (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + + +
    +
    co.aikar.commands
    +

    Interface CommandConfigProvider

    +
    +
    +
    + +
    +
    + +
    +
    +
      +
    • + + +
    • +
    +
    +
    + + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/CommandPermissionResolver.html b/docs/acf-jda/co/aikar/commands/CommandPermissionResolver.html new file mode 100644 index 00000000..733f3763 --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/CommandPermissionResolver.html @@ -0,0 +1,220 @@ + + + + + + +CommandPermissionResolver (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + + +
    +
    co.aikar.commands
    +

    Interface CommandPermissionResolver

    +
    +
    +
    + +
    +
    + +
    +
    + +
    +
    + + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/JDACommandCompletions.html b/docs/acf-jda/co/aikar/commands/JDACommandCompletions.html new file mode 100644 index 00000000..2c4e4c9c --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/JDACommandCompletions.html @@ -0,0 +1,313 @@ + + + + + + +JDACommandCompletions (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + + +
    +
    co.aikar.commands
    +

    Class JDACommandCompletions

    +
    +
    +
      +
    • java.lang.Object
    • +
    • +
        +
      • co.aikar.commands.CommandCompletions<co.aikar.commands.CommandCompletionContext<?>>
      • +
      • +
          +
        • co.aikar.commands.JDACommandCompletions
        • +
        +
      • +
      +
    • +
    +
    +
      +
    • +
      +
      +
      public class JDACommandCompletions
      +extends co.aikar.commands.CommandCompletions<co.aikar.commands.CommandCompletionContext<?>>
      +
    • +
    +
    +
    +
      +
    • + +
        +
      • + + +

        Nested Class Summary

        +
          +
        • + + +

          Nested classes/interfaces inherited from class co.aikar.commands.CommandCompletions

          +co.aikar.commands.CommandCompletions.AsyncCommandCompletionHandler<C extends co.aikar.commands.CommandCompletionContext>, co.aikar.commands.CommandCompletions.CommandCompletionHandler<C extends co.aikar.commands.CommandCompletionContext>, co.aikar.commands.CommandCompletions.SyncCompletionRequired
        • +
        +
      • +
      + +
        +
      • + + +

        Constructor Summary

        + + + + + + + + +
        Constructors 
        Constructor and Description
        JDACommandCompletions(co.aikar.commands.CommandManager manager) 
        +
      • +
      + + +
    • +
    +
    +
    +
      +
    • + + + +
        +
      • + + +

        Method Detail

        + + + +
          +
        • +

          registerCompletion

          +
          public co.aikar.commands.CommandCompletions.CommandCompletionHandler registerCompletion(String id,
          +                                                                                        co.aikar.commands.CommandCompletions.CommandCompletionHandler<co.aikar.commands.CommandCompletionContext<?>> handler)
          +
          +
          Overrides:
          +
          registerCompletion in class co.aikar.commands.CommandCompletions<co.aikar.commands.CommandCompletionContext<?>>
          +
          +
        • +
        + + + +
          +
        • +

          registerAsyncCompletion

          +
          public co.aikar.commands.CommandCompletions.CommandCompletionHandler registerAsyncCompletion(String id,
          +                                                                                             co.aikar.commands.CommandCompletions.AsyncCommandCompletionHandler<co.aikar.commands.CommandCompletionContext<?>> handler)
          +
          +
          Overrides:
          +
          registerAsyncCompletion in class co.aikar.commands.CommandCompletions<co.aikar.commands.CommandCompletionContext<?>>
          +
          +
        • +
        +
      • +
      +
    • +
    +
    +
    + + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/JDACommandConfig.html b/docs/acf-jda/co/aikar/commands/JDACommandConfig.html new file mode 100644 index 00000000..d060a525 --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/JDACommandConfig.html @@ -0,0 +1,322 @@ + + + + + + +JDACommandConfig (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + + +
    +
    co.aikar.commands
    +

    Class JDACommandConfig

    +
    +
    + +
    + +
    +
    + +
    +
    + +
    +
    + + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/JDACommandContexts.html b/docs/acf-jda/co/aikar/commands/JDACommandContexts.html new file mode 100644 index 00000000..6999ac88 --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/JDACommandContexts.html @@ -0,0 +1,261 @@ + + + + + + +JDACommandContexts (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + + +
    +
    co.aikar.commands
    +

    Class JDACommandContexts

    +
    +
    + +
    + +
    +
    + +
    +
    + +
    +
    + + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/JDACommandEvent.html b/docs/acf-jda/co/aikar/commands/JDACommandEvent.html new file mode 100644 index 00000000..2cc4e833 --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/JDACommandEvent.html @@ -0,0 +1,393 @@ + + + + + + +JDACommandEvent (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + + +
    +
    co.aikar.commands
    +

    Class JDACommandEvent

    +
    +
    + +
    +
      +
    • +
      +
      All Implemented Interfaces:
      +
      co.aikar.commands.CommandIssuer
      +
      +
      +
      +
      public class JDACommandEvent
      +extends Object
      +implements co.aikar.commands.CommandIssuer
      +
    • +
    +
    +
    + +
    +
    +
      +
    • + + + +
        +
      • + + +

        Method Detail

        + + + +
          +
        • +

          getEvent

          +
          public net.dv8tion.jda.core.events.message.MessageReceivedEvent getEvent()
          +
        • +
        + + + +
          +
        • +

          getIssuer

          +
          public net.dv8tion.jda.core.events.message.MessageReceivedEvent getIssuer()
          +
          +
          Specified by:
          +
          getIssuer in interface co.aikar.commands.CommandIssuer
          +
          +
        • +
        + + + +
          +
        • +

          getManager

          +
          public co.aikar.commands.CommandManager getManager()
          +
          +
          Specified by:
          +
          getManager in interface co.aikar.commands.CommandIssuer
          +
          +
        • +
        + + + +
          +
        • +

          isPlayer

          +
          public boolean isPlayer()
          +
          +
          Specified by:
          +
          isPlayer in interface co.aikar.commands.CommandIssuer
          +
          +
        • +
        + + + +
          +
        • +

          hasPermission

          +
          public boolean hasPermission(String permission)
          +
          +
          Specified by:
          +
          hasPermission in interface co.aikar.commands.CommandIssuer
          +
          +
        • +
        + + + +
          +
        • +

          sendMessageInternal

          +
          public void sendMessageInternal(String message)
          +
          +
          Specified by:
          +
          sendMessageInternal in interface co.aikar.commands.CommandIssuer
          +
          +
        • +
        + + + +
          +
        • +

          sendMessage

          +
          public void sendMessage(net.dv8tion.jda.core.entities.Message message)
          +
        • +
        + + + +
          +
        • +

          sendMessage

          +
          public void sendMessage(net.dv8tion.jda.core.entities.MessageEmbed message)
          +
        • +
        +
      • +
      +
    • +
    +
    +
    + + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/JDACommandExecutionContext.html b/docs/acf-jda/co/aikar/commands/JDACommandExecutionContext.html new file mode 100644 index 00000000..2804a57f --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/JDACommandExecutionContext.html @@ -0,0 +1,221 @@ + + + + + + +JDACommandExecutionContext (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + + +
    +
    co.aikar.commands
    +

    Class JDACommandExecutionContext

    +
    +
    + +
    + +
    +
    +
      +
    • + +
        +
      • + + +

        Field Summary

        +
          +
        • + + +

          Fields inherited from class co.aikar.commands.CommandExecutionContext

          +issuer
        • +
        +
      • +
      + +
        +
      • + + +

        Method Summary

        +
          +
        • + + +

          Methods inherited from class co.aikar.commands.CommandExecutionContext

          +canOverridePlayerContext, getAnnotation, getArgs, getCmd, getFirstArg, getFlags, getFlagValue, getFlagValue, getIndex, getIssuer, getLastArg, getNumParams, getParam, getPassedArgs, getResolvedArg, getResolvedArg, getResolvedArg, hasAnnotation, hasFlag, isLastArg, isOptional, joinArgs, joinArgs, popFirstArg, popLastArg
        • +
        + +
      • +
      +
    • +
    +
    +
    + + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/JDACommandManager.html b/docs/acf-jda/co/aikar/commands/JDACommandManager.html new file mode 100644 index 00000000..5d70b140 --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/JDACommandManager.html @@ -0,0 +1,707 @@ + + + + + + +JDACommandManager (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + + +
    +
    co.aikar.commands
    +

    Class JDACommandManager

    +
    +
    + +
    + +
    +
    + +
    +
    + +
    +
    + + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/JDACommandManagerBuilder.html b/docs/acf-jda/co/aikar/commands/JDACommandManagerBuilder.html new file mode 100644 index 00000000..5bc8deb3 --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/JDACommandManagerBuilder.html @@ -0,0 +1,310 @@ + + + + + + +JDACommandManagerBuilder (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + + +
    +
    co.aikar.commands
    +

    Class JDACommandManagerBuilder

    +
    +
    + +
    + +
    +
    + +
    +
    + +
    +
    + + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/JDAConditionContext.html b/docs/acf-jda/co/aikar/commands/JDAConditionContext.html new file mode 100644 index 00000000..2b317098 --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/JDAConditionContext.html @@ -0,0 +1,206 @@ + + + + + + +JDAConditionContext (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + + +
    +
    co.aikar.commands
    +

    Class JDAConditionContext

    +
    +
    + +
    + +
    +
    + +
    +
    + + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/JDAListener.html b/docs/acf-jda/co/aikar/commands/JDAListener.html new file mode 100644 index 00000000..0a601d1e --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/JDAListener.html @@ -0,0 +1,271 @@ + + + + + + +JDAListener (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + + +
    +
    co.aikar.commands
    +

    Class JDAListener

    +
    +
    +
      +
    • java.lang.Object
    • +
    • +
        +
      • net.dv8tion.jda.core.hooks.ListenerAdapter
      • +
      • +
          +
        • co.aikar.commands.JDAListener
        • +
        +
      • +
      +
    • +
    +
    +
      +
    • +
      +
      All Implemented Interfaces:
      +
      net.dv8tion.jda.core.hooks.EventListener
      +
      +
      +
      +
      public class JDAListener
      +extends net.dv8tion.jda.core.hooks.ListenerAdapter
      +
    • +
    +
    +
    +
      +
    • + +
        +
      • + + +

        Method Summary

        + + + + + + + + + + + + + + +
        All Methods Instance Methods Concrete Methods 
        Modifier and TypeMethod and Description
        voidonMessageReceived(net.dv8tion.jda.core.events.message.MessageReceivedEvent event) 
        voidonReady(net.dv8tion.jda.core.events.ReadyEvent event) 
        +
          +
        • + + +

          Methods inherited from class net.dv8tion.jda.core.hooks.ListenerAdapter

          +onCallCreate, onCallDelete, onCallUpdateRegion, onCallUpdateRingingUsers, onCallVoiceJoin, onCallVoiceLeave, onCallVoiceSelfDeafen, onCallVoiceSelfMute, onCategoryCreate, onCategoryDelete, onCategoryUpdateName, onCategoryUpdatePermissions, onCategoryUpdatePosition, onDisconnect, onEmoteAdded, onEmoteRemoved, onEmoteUpdateName, onEmoteUpdateRoles, onEvent, onException, onFriendAdded, onFriendRemoved, onFriendRequestCanceled, onFriendRequestIgnored, onFriendRequestReceived, onFriendRequestSent, onGenericCall, onGenericCallUpdate, onGenericCallVoice, onGenericCategory, onGenericCategoryUpdate, onGenericEmote, onGenericEmoteUpdate, onGenericEvent, onGenericGroup, onGenericGroupMessage, onGenericGroupMessageReaction, onGenericGroupUpdate, onGenericGuild, onGenericGuildMember, onGenericGuildMessage, onGenericGuildMessageReaction, onGenericGuildUpdate, onGenericGuildVoice, onGenericMessage, onGenericMessageReaction, onGenericPrivateMessage, onGenericPrivateMessageReaction, onGenericRelationship, onGenericRelationshipAdd, onGenericRelationshipRemove, onGenericRole, onGenericRoleUpdate, onGenericSelfUpdate, onGenericTextChannel, onGenericTextChannelUpdate, onGenericUser, onGenericUserPresence, onGenericVoiceChannel, onGenericVoiceChannelUpdate, onGroupJoin, onGroupLeave, onGroupMessageDelete, onGroupMessageEmbed, onGroupMessageReactionAdd, onGroupMessageReactionRemove, onGroupMessageReactionRemoveAll, onGroupMessageReceived, onGroupMessageUpdate, onGroupUpdateIcon, onGroupUpdateName, onGroupUpdateOwner, onGroupUserJoin, onGroupUserLeave, onGuildAvailable, onGuildBan, onGuildJoin, onGuildLeave, onGuildMemberJoin, onGuildMemberLeave, onGuildMemberNickChange, onGuildMemberRoleAdd, onGuildMemberRoleRemove, onGuildMessageDelete, onGuildMessageEmbed, onGuildMessageReactionAdd, onGuildMessageReactionRemove, onGuildMessageReactionRemoveAll, onGuildMessageReceived, onGuildMessageUpdate, onGuildUnavailable, onGuildUnban, onGuildUpdateAfkChannel, onGuildUpdateAfkTimeout, onGuildUpdateExplicitContentLevel, onGuildUpdateFeatures, onGuildUpdateIcon, onGuildUpdateMFALevel, onGuildUpdateName, onGuildUpdateNotificationLevel, onGuildUpdateOwner, onGuildUpdateRegion, onGuildUpdateSplash, onGuildUpdateSystemChannel, onGuildUpdateVerificationLevel, onGuildVoiceDeafen, onGuildVoiceGuildDeafen, onGuildVoiceGuildMute, onGuildVoiceJoin, onGuildVoiceLeave, onGuildVoiceMove, onGuildVoiceMute, onGuildVoiceSelfDeafen, onGuildVoiceSelfMute, onGuildVoiceSuppress, onGuildVoiceUpdate, onHttpRequest, onMessageBulkDelete, onMessageDelete, onMessageEmbed, onMessageReactionAdd, onMessageReactionRemove, onMessageReactionRemoveAll, onMessageUpdate, onPrivateChannelCreate, onPrivateChannelDelete, onPrivateMessageDelete, onPrivateMessageEmbed, onPrivateMessageReactionAdd, onPrivateMessageReactionRemove, onPrivateMessageReceived, onPrivateMessageUpdate, onReconnect, onResume, onRoleCreate, onRoleDelete, onRoleUpdateColor, onRoleUpdateHoisted, onRoleUpdateMentionable, onRoleUpdateName, onRoleUpdatePermissions, onRoleUpdatePosition, onSelfUpdateAvatar, onSelfUpdateEmail, onSelfUpdateMFA, onSelfUpdateName, onSelfUpdateVerified, onShutdown, onStatusChange, onTextChannelCreate, onTextChannelDelete, onTextChannelUpdateName, onTextChannelUpdateNSFW, onTextChannelUpdateParent, onTextChannelUpdatePermissions, onTextChannelUpdatePosition, onTextChannelUpdateTopic, onUnavailableGuildJoined, onUserAvatarUpdate, onUserBlocked, onUserGameUpdate, onUserNameUpdate, onUserOnlineStatusUpdate, onUserTyping, onUserUnblocked, onVoiceChannelCreate, onVoiceChannelDelete, onVoiceChannelUpdateBitrate, onVoiceChannelUpdateName, onVoiceChannelUpdateParent, onVoiceChannelUpdatePermissions, onVoiceChannelUpdatePosition, onVoiceChannelUpdateUserLimit
        • +
        + +
      • +
      +
    • +
    +
    +
    +
      +
    • + +
        +
      • + + +

        Method Detail

        + + + +
          +
        • +

          onMessageReceived

          +
          public void onMessageReceived(net.dv8tion.jda.core.events.message.MessageReceivedEvent event)
          +
          +
          Overrides:
          +
          onMessageReceived in class net.dv8tion.jda.core.hooks.ListenerAdapter
          +
          +
        • +
        + + + +
          +
        • +

          onReady

          +
          public void onReady(net.dv8tion.jda.core.events.ReadyEvent event)
          +
          +
          Overrides:
          +
          onReady in class net.dv8tion.jda.core.hooks.ListenerAdapter
          +
          +
        • +
        +
      • +
      +
    • +
    +
    +
    + + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/JDALocales.html b/docs/acf-jda/co/aikar/commands/JDALocales.html new file mode 100644 index 00000000..d765b350 --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/JDALocales.html @@ -0,0 +1,261 @@ + + + + + + +JDALocales (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + + +
    +
    co.aikar.commands
    +

    Class JDALocales

    +
    +
    +
      +
    • java.lang.Object
    • +
    • +
        +
      • co.aikar.commands.Locales
      • +
      • +
          +
        • co.aikar.commands.JDALocales
        • +
        +
      • +
      +
    • +
    +
    +
      +
    • +
      +
      +
      public class JDALocales
      +extends co.aikar.commands.Locales
      +
    • +
    +
    +
    +
      +
    • + +
        +
      • + + +

        Field Summary

        +
          +
        • + + +

          Fields inherited from class co.aikar.commands.Locales

          +AFRIKAANS, ARABIC, BULGARIAN, CHINESE, CZECH, DANISH, DUTCH, ENGLISH, FINNISH, FRENCH, GERMAN, GREEK, HEBREW, HINDI, ITALIAN, JAPANESE, KOREAN, LATIN, POLISH, PORTUGUESE, ROMANIAN, RUSSIAN, SIMPLIFIED_CHINESE, SPANISH, SWEDISH, THAI, TRADITIONAL_CHINESE, TURKISH, UKRANIAN, VIETNAMESE, WELSH
        • +
        +
      • +
      + +
        +
      • + + +

        Constructor Summary

        + + + + + + + + +
        Constructors 
        Constructor and Description
        JDALocales(co.aikar.commands.CommandManager manager) 
        +
      • +
      + + +
    • +
    +
    +
    +
      +
    • + +
        +
      • + + +

        Constructor Detail

        + + + +
          +
        • +

          JDALocales

          +
          public JDALocales(co.aikar.commands.CommandManager manager)
          +
        • +
        +
      • +
      +
    • +
    +
    +
    + + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/JDAMessageFormatter.html b/docs/acf-jda/co/aikar/commands/JDAMessageFormatter.html new file mode 100644 index 00000000..a079f30c --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/JDAMessageFormatter.html @@ -0,0 +1,246 @@ + + + + + + +JDAMessageFormatter (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + + +
    +
    co.aikar.commands
    +

    Class JDAMessageFormatter

    +
    +
    +
      +
    • java.lang.Object
    • +
    • +
        +
      • co.aikar.commands.MessageFormatter<String>
      • +
      • +
          +
        • co.aikar.commands.JDAMessageFormatter
        • +
        +
      • +
      +
    • +
    +
    + +
    +
    + +
    +
    + +
    +
    + + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/JDARootCommand.html b/docs/acf-jda/co/aikar/commands/JDARootCommand.html new file mode 100644 index 00000000..913def1f --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/JDARootCommand.html @@ -0,0 +1,395 @@ + + + + + + +JDARootCommand (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + + +
    +
    co.aikar.commands
    +

    Class JDARootCommand

    +
    +
    + +
    + +
    +
    + +
    +
    + +
    +
    + + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/class-use/CommandConfig.html b/docs/acf-jda/co/aikar/commands/class-use/CommandConfig.html new file mode 100644 index 00000000..8a41c36e --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/class-use/CommandConfig.html @@ -0,0 +1,198 @@ + + + + + + +Uses of Interface co.aikar.commands.CommandConfig (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + +
    +

    Uses of Interface
    co.aikar.commands.CommandConfig

    +
    +
    + +
    + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/class-use/CommandConfigProvider.html b/docs/acf-jda/co/aikar/commands/class-use/CommandConfigProvider.html new file mode 100644 index 00000000..7ec6e391 --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/class-use/CommandConfigProvider.html @@ -0,0 +1,203 @@ + + + + + + +Uses of Interface co.aikar.commands.CommandConfigProvider (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + +
    +

    Uses of Interface
    co.aikar.commands.CommandConfigProvider

    +
    +
    + +
    + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/class-use/CommandPermissionResolver.html b/docs/acf-jda/co/aikar/commands/class-use/CommandPermissionResolver.html new file mode 100644 index 00000000..56346172 --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/class-use/CommandPermissionResolver.html @@ -0,0 +1,177 @@ + + + + + + +Uses of Interface co.aikar.commands.CommandPermissionResolver (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + +
    +

    Uses of Interface
    co.aikar.commands.CommandPermissionResolver

    +
    +
    + +
    + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/class-use/JDACommandCompletions.html b/docs/acf-jda/co/aikar/commands/class-use/JDACommandCompletions.html new file mode 100644 index 00000000..550169ae --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/class-use/JDACommandCompletions.html @@ -0,0 +1,146 @@ + + + + + + +Uses of Class co.aikar.commands.JDACommandCompletions (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + +
    +

    Uses of Class
    co.aikar.commands.JDACommandCompletions

    +
    +
    + +
    + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/class-use/JDACommandConfig.html b/docs/acf-jda/co/aikar/commands/class-use/JDACommandConfig.html new file mode 100644 index 00000000..584e5045 --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/class-use/JDACommandConfig.html @@ -0,0 +1,121 @@ + + + + + + +Uses of Class co.aikar.commands.JDACommandConfig (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + +
    +

    Uses of Class
    co.aikar.commands.JDACommandConfig

    +
    +
    No usage of co.aikar.commands.JDACommandConfig
    + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/class-use/JDACommandContexts.html b/docs/acf-jda/co/aikar/commands/class-use/JDACommandContexts.html new file mode 100644 index 00000000..8243500f --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/class-use/JDACommandContexts.html @@ -0,0 +1,146 @@ + + + + + + +Uses of Class co.aikar.commands.JDACommandContexts (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + +
    +

    Uses of Class
    co.aikar.commands.JDACommandContexts

    +
    +
    + +
    + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/class-use/JDACommandEvent.html b/docs/acf-jda/co/aikar/commands/class-use/JDACommandEvent.html new file mode 100644 index 00000000..0af04432 --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/class-use/JDACommandEvent.html @@ -0,0 +1,160 @@ + + + + + + +Uses of Class co.aikar.commands.JDACommandEvent (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + +
    +

    Uses of Class
    co.aikar.commands.JDACommandEvent

    +
    +
    + +
    + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/class-use/JDACommandExecutionContext.html b/docs/acf-jda/co/aikar/commands/class-use/JDACommandExecutionContext.html new file mode 100644 index 00000000..af93224e --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/class-use/JDACommandExecutionContext.html @@ -0,0 +1,121 @@ + + + + + + +Uses of Class co.aikar.commands.JDACommandExecutionContext (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + +
    +

    Uses of Class
    co.aikar.commands.JDACommandExecutionContext

    +
    +
    No usage of co.aikar.commands.JDACommandExecutionContext
    + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/class-use/JDACommandManager.html b/docs/acf-jda/co/aikar/commands/class-use/JDACommandManager.html new file mode 100644 index 00000000..05596233 --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/class-use/JDACommandManager.html @@ -0,0 +1,161 @@ + + + + + + +Uses of Class co.aikar.commands.JDACommandManager (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + +
    +

    Uses of Class
    co.aikar.commands.JDACommandManager

    +
    +
    + +
    + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/class-use/JDACommandManagerBuilder.html b/docs/acf-jda/co/aikar/commands/class-use/JDACommandManagerBuilder.html new file mode 100644 index 00000000..581f958b --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/class-use/JDACommandManagerBuilder.html @@ -0,0 +1,158 @@ + + + + + + +Uses of Class co.aikar.commands.JDACommandManagerBuilder (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + +
    +

    Uses of Class
    co.aikar.commands.JDACommandManagerBuilder

    +
    +
    + +
    + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/class-use/JDAConditionContext.html b/docs/acf-jda/co/aikar/commands/class-use/JDAConditionContext.html new file mode 100644 index 00000000..ab20da79 --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/class-use/JDAConditionContext.html @@ -0,0 +1,121 @@ + + + + + + +Uses of Class co.aikar.commands.JDAConditionContext (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + +
    +

    Uses of Class
    co.aikar.commands.JDAConditionContext

    +
    +
    No usage of co.aikar.commands.JDAConditionContext
    + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/class-use/JDAListener.html b/docs/acf-jda/co/aikar/commands/class-use/JDAListener.html new file mode 100644 index 00000000..8ed57374 --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/class-use/JDAListener.html @@ -0,0 +1,121 @@ + + + + + + +Uses of Class co.aikar.commands.JDAListener (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + +
    +

    Uses of Class
    co.aikar.commands.JDAListener

    +
    +
    No usage of co.aikar.commands.JDAListener
    + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/class-use/JDALocales.html b/docs/acf-jda/co/aikar/commands/class-use/JDALocales.html new file mode 100644 index 00000000..81c9d5e0 --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/class-use/JDALocales.html @@ -0,0 +1,146 @@ + + + + + + +Uses of Class co.aikar.commands.JDALocales (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + +
    +

    Uses of Class
    co.aikar.commands.JDALocales

    +
    +
    + +
    + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/class-use/JDAMessageFormatter.html b/docs/acf-jda/co/aikar/commands/class-use/JDAMessageFormatter.html new file mode 100644 index 00000000..618c5867 --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/class-use/JDAMessageFormatter.html @@ -0,0 +1,121 @@ + + + + + + +Uses of Class co.aikar.commands.JDAMessageFormatter (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + +
    +

    Uses of Class
    co.aikar.commands.JDAMessageFormatter

    +
    +
    No usage of co.aikar.commands.JDAMessageFormatter
    + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/class-use/JDARootCommand.html b/docs/acf-jda/co/aikar/commands/class-use/JDARootCommand.html new file mode 100644 index 00000000..019b887f --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/class-use/JDARootCommand.html @@ -0,0 +1,146 @@ + + + + + + +Uses of Class co.aikar.commands.JDARootCommand (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + +
    +

    Uses of Class
    co.aikar.commands.JDARootCommand

    +
    +
    + +
    + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/package-frame.html b/docs/acf-jda/co/aikar/commands/package-frame.html new file mode 100644 index 00000000..bb29aa8d --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/package-frame.html @@ -0,0 +1,37 @@ + + + + + + +co.aikar.commands (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + +

    co.aikar.commands

    + + + diff --git a/docs/acf-jda/co/aikar/commands/package-summary.html b/docs/acf-jda/co/aikar/commands/package-summary.html new file mode 100644 index 00000000..c5c8cc25 --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/package-summary.html @@ -0,0 +1,206 @@ + + + + + + +co.aikar.commands (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + +
    +

    Package co.aikar.commands

    +
    +
    + +
    + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/package-tree.html b/docs/acf-jda/co/aikar/commands/package-tree.html new file mode 100644 index 00000000..2ab45a63 --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/package-tree.html @@ -0,0 +1,182 @@ + + + + + + +co.aikar.commands Class Hierarchy (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + +
    + + + + + + + +
    + + +
    +

    Hierarchy For Package co.aikar.commands

    +
    +
    +

    Class Hierarchy

    + +

    Interface Hierarchy

    + +
    + +
    + + + + + + + +
    + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/co/aikar/commands/package-use.html b/docs/acf-jda/co/aikar/commands/package-use.html new file mode 100644 index 00000000..1e26a167 --- /dev/null +++ b/docs/acf-jda/co/aikar/commands/package-use.html @@ -0,0 +1,166 @@ + + + + + + +Uses of Package co.aikar.commands (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + +
    +

    Uses of Package
    co.aikar.commands

    +
    +
    + +
    + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/constant-values.html b/docs/acf-jda/constant-values.html new file mode 100644 index 00000000..1667322f --- /dev/null +++ b/docs/acf-jda/constant-values.html @@ -0,0 +1,121 @@ + + + + + + +Constant Field Values (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + + + + +
    +

    Constant Field Values

    +

    Contents

    +
    + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/deprecated-list.html b/docs/acf-jda/deprecated-list.html new file mode 100644 index 00000000..4a515f8f --- /dev/null +++ b/docs/acf-jda/deprecated-list.html @@ -0,0 +1,121 @@ + + + + + + +Deprecated List (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + +
    + + + + + + + +
    + + +
    +

    Deprecated API

    +

    Contents

    +
    + +
    + + + + + + + +
    + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/index-all.html b/docs/acf-jda/index-all.html new file mode 100644 index 00000000..7ae5fa1a --- /dev/null +++ b/docs/acf-jda/index-all.html @@ -0,0 +1,350 @@ + + + + + + +Index (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + +
    + + + + + + + +
    + + +
    A B C D G H I J L O P R S  + + +

    A

    +
    +
    addChild(BaseCommand) - Method in class co.aikar.commands.JDARootCommand
    +
     
    +
    + + + +

    B

    +
    +
    builder(JDA) - Static method in class co.aikar.commands.JDACommandManager
    +
     
    +
    + + + +

    C

    +
    +
    co.aikar.commands - package co.aikar.commands
    +
     
    +
    CommandConfig - Interface in co.aikar.commands
    +
     
    +
    CommandConfigProvider - Interface in co.aikar.commands
    +
     
    +
    CommandPermissionResolver - Interface in co.aikar.commands
    +
     
    +
    commandPrefixes - Variable in class co.aikar.commands.JDACommandConfig
    +
     
    +
    commands - Variable in class co.aikar.commands.JDACommandManager
    +
     
    +
    completions - Variable in class co.aikar.commands.JDACommandManager
    +
     
    +
    configProvider(CommandConfigProvider) - Method in class co.aikar.commands.JDACommandManagerBuilder
    +
     
    +
    contexts - Variable in class co.aikar.commands.JDACommandManager
    +
     
    +
    create() - Method in class co.aikar.commands.JDACommandManagerBuilder
    +
     
    +
    createCommandContext(RegisteredCommand, Parameter, CommandIssuer, List<String>, int, Map<String, Object>) - Method in class co.aikar.commands.JDACommandManager
    +
     
    +
    createCompletionContext(RegisteredCommand, CommandIssuer, String, String, String[]) - Method in class co.aikar.commands.JDACommandManager
    +
     
    +
    createRootCommand(String) - Method in class co.aikar.commands.JDACommandManager
    +
     
    +
    + + + +

    D

    +
    +
    defaultConfig(CommandConfig) - Method in class co.aikar.commands.JDACommandManagerBuilder
    +
     
    +
    + + + +

    G

    +
    +
    getChildren() - Method in class co.aikar.commands.JDARootCommand
    +
     
    +
    getCommandCompletions() - Method in class co.aikar.commands.JDACommandManager
    +
     
    +
    getCommandContexts() - Method in class co.aikar.commands.JDACommandManager
    +
     
    +
    getCommandIssuer(Object) - Method in class co.aikar.commands.JDACommandManager
    +
     
    +
    getCommandName() - Method in class co.aikar.commands.JDARootCommand
    +
     
    +
    getCommandPrefixes() - Method in interface co.aikar.commands.CommandConfig
    +
     
    +
    getCommandPrefixes() - Method in class co.aikar.commands.JDACommandConfig
    +
     
    +
    getConfigProvider() - Method in class co.aikar.commands.JDACommandManager
    +
     
    +
    getDefaultConfig() - Method in class co.aikar.commands.JDACommandManager
    +
     
    +
    getEvent() - Method in class co.aikar.commands.JDACommandEvent
    +
     
    +
    getIssuer() - Method in class co.aikar.commands.JDACommandEvent
    +
     
    +
    getJDA() - Method in class co.aikar.commands.JDACommandManager
    +
     
    +
    getLocales() - Method in class co.aikar.commands.JDACommandManager
    +
     
    +
    getLogger() - Method in class co.aikar.commands.JDACommandManager
    +
     
    +
    getManager() - Method in class co.aikar.commands.JDACommandEvent
    +
     
    +
    getManager() - Method in class co.aikar.commands.JDARootCommand
    +
     
    +
    getPermissionResolver() - Method in class co.aikar.commands.JDACommandManager
    +
     
    +
    getSubCommands() - Method in class co.aikar.commands.JDARootCommand
    +
     
    +
    + + + +

    H

    +
    +
    hasPermission(JDACommandEvent, String) - Method in interface co.aikar.commands.CommandPermissionResolver
    +
     
    +
    hasPermission(String) - Method in class co.aikar.commands.JDACommandEvent
    +
     
    +
    hasRegisteredCommands() - Method in class co.aikar.commands.JDACommandManager
    +
     
    +
    + + + +

    I

    +
    +
    isCommandIssuer(Class<?>) - Method in class co.aikar.commands.JDACommandManager
    +
     
    +
    isPlayer() - Method in class co.aikar.commands.JDACommandEvent
    +
     
    +
    + + + +

    J

    +
    +
    JDACommandCompletions - Class in co.aikar.commands
    +
     
    +
    JDACommandCompletions(CommandManager) - Constructor for class co.aikar.commands.JDACommandCompletions
    +
     
    +
    JDACommandConfig - Class in co.aikar.commands
    +
     
    +
    JDACommandConfig() - Constructor for class co.aikar.commands.JDACommandConfig
    +
     
    +
    JDACommandContexts - Class in co.aikar.commands
    +
     
    +
    JDACommandContexts(JDACommandManager) - Constructor for class co.aikar.commands.JDACommandContexts
    +
     
    +
    JDACommandEvent - Class in co.aikar.commands
    +
     
    +
    JDACommandEvent(JDACommandManager, MessageReceivedEvent) - Constructor for class co.aikar.commands.JDACommandEvent
    +
     
    +
    JDACommandExecutionContext - Class in co.aikar.commands
    +
     
    +
    JDACommandManager - Class in co.aikar.commands
    +
     
    +
    JDACommandManager(JDA) - Constructor for class co.aikar.commands.JDACommandManager
    +
     
    +
    JDACommandManager(JDA, CommandConfig, CommandConfigProvider, CommandPermissionResolver) - Constructor for class co.aikar.commands.JDACommandManager
    +
     
    +
    JDACommandManagerBuilder - Class in co.aikar.commands
    +
     
    +
    JDACommandManagerBuilder(JDA) - Constructor for class co.aikar.commands.JDACommandManagerBuilder
    +
     
    +
    JDAConditionContext - Class in co.aikar.commands
    +
     
    +
    JDAListener - Class in co.aikar.commands
    +
     
    +
    JDALocales - Class in co.aikar.commands
    +
     
    +
    JDALocales(CommandManager) - Constructor for class co.aikar.commands.JDALocales
    +
     
    +
    JDAMessageFormatter - Class in co.aikar.commands
    +
     
    +
    JDAMessageFormatter() - Constructor for class co.aikar.commands.JDAMessageFormatter
    +
     
    +
    JDARootCommand - Class in co.aikar.commands
    +
     
    +
    + + + +

    L

    +
    +
    locales - Variable in class co.aikar.commands.JDACommandManager
    +
     
    +
    log(LogLevel, String, Throwable) - Method in class co.aikar.commands.JDACommandManager
    +
     
    +
    + + + +

    O

    +
    +
    onMessageReceived(MessageReceivedEvent) - Method in class co.aikar.commands.JDAListener
    +
     
    +
    onReady(ReadyEvent) - Method in class co.aikar.commands.JDAListener
    +
     
    +
    + + + +

    P

    +
    +
    permissionResolver(CommandPermissionResolver) - Method in class co.aikar.commands.JDACommandManagerBuilder
    +
     
    +
    provide(MessageReceivedEvent) - Method in interface co.aikar.commands.CommandConfig
    +
     
    +
    provide(MessageReceivedEvent) - Method in interface co.aikar.commands.CommandConfigProvider
    +
     
    +
    + + + +

    R

    +
    +
    registerAsyncCompletion(String, CommandCompletions.AsyncCommandCompletionHandler<CommandCompletionContext<?>>) - Method in class co.aikar.commands.JDACommandCompletions
    +
     
    +
    registerCommand(BaseCommand) - Method in class co.aikar.commands.JDACommandManager
    +
     
    +
    registerCompletion(String, CommandCompletions.CommandCompletionHandler<CommandCompletionContext<?>>) - Method in class co.aikar.commands.JDACommandCompletions
    +
     
    +
    + + + +

    S

    +
    +
    sendMessage(Message) - Method in class co.aikar.commands.JDACommandEvent
    +
     
    +
    sendMessage(MessageEmbed) - Method in class co.aikar.commands.JDACommandEvent
    +
     
    +
    sendMessageInternal(String) - Method in class co.aikar.commands.JDACommandEvent
    +
     
    +
    setConfigProvider(CommandConfigProvider) - Method in class co.aikar.commands.JDACommandManager
    +
     
    +
    setDefaultConfig(CommandConfig) - Method in class co.aikar.commands.JDACommandManager
    +
     
    +
    setLogger(Logger) - Method in class co.aikar.commands.JDACommandManager
    +
     
    +
    setPermissionResolver(CommandPermissionResolver) - Method in class co.aikar.commands.JDACommandManager
    +
     
    +
    +A B C D G H I J L O P R S 
    + +
    + + + + + + + +
    + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/index.html b/docs/acf-jda/index.html new file mode 100644 index 00000000..82a5aa1c --- /dev/null +++ b/docs/acf-jda/index.html @@ -0,0 +1,73 @@ + + + + + + +ACF (JDA) 0.5.0-SNAPSHOT API + + + + + + +<noscript> +<div>JavaScript is disabled on your browser.</div> +</noscript> +<h2>Frame Alert</h2> +<p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="co/aikar/commands/package-summary.html">Non-frame version</a>.</p> + + + diff --git a/docs/acf-jda/overview-tree.html b/docs/acf-jda/overview-tree.html new file mode 100644 index 00000000..8e26936a --- /dev/null +++ b/docs/acf-jda/overview-tree.html @@ -0,0 +1,186 @@ + + + + + + +Class Hierarchy (ACF (JDA) 0.5.0-SNAPSHOT API) + + + + + + + +
    + + + + + + + +
    + + +
    +

    Hierarchy For All Packages

    +Package Hierarchies: + +
    +
    +

    Class Hierarchy

    + +

    Interface Hierarchy

    + +
    + +
    + + + + + + + +
    + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-jda/package-list b/docs/acf-jda/package-list new file mode 100644 index 00000000..0886d25c --- /dev/null +++ b/docs/acf-jda/package-list @@ -0,0 +1 @@ +co.aikar.commands diff --git a/docs/acf-jda/script.js b/docs/acf-jda/script.js new file mode 100644 index 00000000..b3463569 --- /dev/null +++ b/docs/acf-jda/script.js @@ -0,0 +1,30 @@ +function show(type) +{ + count = 0; + for (var key in methods) { + var row = document.getElementById(key); + if ((methods[key] & type) != 0) { + row.style.display = ''; + row.className = (count++ % 2) ? rowColor : altColor; + } + else + row.style.display = 'none'; + } + updateTabs(type); +} + +function updateTabs(type) +{ + for (var value in tabs) { + var sNode = document.getElementById(tabs[value][0]); + var spanNode = sNode.firstChild; + if (value == type) { + sNode.className = activeTableTab; + spanNode.innerHTML = tabs[value][1]; + } + else { + sNode.className = tableTab; + spanNode.innerHTML = "" + tabs[value][1] + ""; + } + } +} diff --git a/docs/acf-jda/src-html/co/aikar/commands/CommandConfig.html b/docs/acf-jda/src-html/co/aikar/commands/CommandConfig.html new file mode 100644 index 00000000..15d37de9 --- /dev/null +++ b/docs/acf-jda/src-html/co/aikar/commands/CommandConfig.html @@ -0,0 +1,87 @@ + + + +Source code + + + +
    +
    001package co.aikar.commands;
    +002
    +003import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
    +004import org.jetbrains.annotations.NotNull;
    +005
    +006import java.util.List;
    +007
    +008public interface CommandConfig extends CommandConfigProvider {
    +009    @NotNull List<String> getCommandPrefixes();
    +010
    +011    @Override
    +012    default CommandConfig provide(MessageReceivedEvent event) {
    +013        return this;
    +014    }
    +015}
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + diff --git a/docs/acf-jda/src-html/co/aikar/commands/CommandConfigProvider.html b/docs/acf-jda/src-html/co/aikar/commands/CommandConfigProvider.html new file mode 100644 index 00000000..7efbde2d --- /dev/null +++ b/docs/acf-jda/src-html/co/aikar/commands/CommandConfigProvider.html @@ -0,0 +1,79 @@ + + + +Source code + + + +
    +
    001package co.aikar.commands;
    +002
    +003import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
    +004
    +005public interface CommandConfigProvider {
    +006    CommandConfig provide(MessageReceivedEvent event);
    +007}
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + diff --git a/docs/acf-jda/src-html/co/aikar/commands/CommandPermissionResolver.html b/docs/acf-jda/src-html/co/aikar/commands/CommandPermissionResolver.html new file mode 100644 index 00000000..0453f991 --- /dev/null +++ b/docs/acf-jda/src-html/co/aikar/commands/CommandPermissionResolver.html @@ -0,0 +1,78 @@ + + + +Source code + + + +
    +
    001package co.aikar.commands;
    +002
    +003
    +004public interface CommandPermissionResolver {
    +005    boolean hasPermission(JDACommandEvent event, String permission);
    +006}
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + diff --git a/docs/acf-jda/src-html/co/aikar/commands/JDACommandCompletions.html b/docs/acf-jda/src-html/co/aikar/commands/JDACommandCompletions.html new file mode 100644 index 00000000..b7706797 --- /dev/null +++ b/docs/acf-jda/src-html/co/aikar/commands/JDACommandCompletions.html @@ -0,0 +1,113 @@ + + + +Source code + + + +
    +
    001package co.aikar.commands;
    +002
    +003import com.google.common.collect.ImmutableList;
    +004import org.jetbrains.annotations.NotNull;
    +005
    +006import java.util.List;
    +007
    +008public class JDACommandCompletions extends CommandCompletions<CommandCompletionContext<?>> {
    +009    private boolean initialized;
    +010    public JDACommandCompletions(CommandManager manager) {
    +011        super(manager);
    +012        this.initialized = true;
    +013    }
    +014
    +015    @Override
    +016    public CommandCompletionHandler registerCompletion(String id, CommandCompletionHandler<CommandCompletionContext<?>> handler) {
    +017        if (initialized) {
    +018            throw new UnsupportedOperationException("JDA Doesn't support Command Completions");
    +019        }
    +020        return null;
    +021    }
    +022
    +023    @Override
    +024    public CommandCompletionHandler registerAsyncCompletion(String id, AsyncCommandCompletionHandler<CommandCompletionContext<?>> handler) {
    +025        if (initialized) {
    +026            throw new UnsupportedOperationException("JDA Doesn't support Command Completions");
    +027        }
    +028        return null;
    +029    }
    +030
    +031    @NotNull
    +032    @Override
    +033    List<String> of(RegisteredCommand command, CommandIssuer sender, String[] completionInfo, String[] args, boolean isAsync) {
    +034        return ImmutableList.of();
    +035    }
    +036
    +037    @Override
    +038    List<String> getCompletionValues(RegisteredCommand command, CommandIssuer sender, String completion, String[] args, boolean isAsync) {
    +039        return ImmutableList.of();
    +040    }
    +041}
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + diff --git a/docs/acf-jda/src-html/co/aikar/commands/JDACommandConfig.html b/docs/acf-jda/src-html/co/aikar/commands/JDACommandConfig.html new file mode 100644 index 00000000..4263645e --- /dev/null +++ b/docs/acf-jda/src-html/co/aikar/commands/JDACommandConfig.html @@ -0,0 +1,91 @@ + + + +Source code + + + +
    +
    001package co.aikar.commands;
    +002
    +003import org.jetbrains.annotations.NotNull;
    +004
    +005import java.util.List;
    +006import java.util.concurrent.CopyOnWriteArrayList;
    +007
    +008public class JDACommandConfig implements CommandConfig {
    +009    protected @NotNull List<String> commandPrefixes = new CopyOnWriteArrayList<>(new String[] {"!"});
    +010
    +011    public JDACommandConfig() {
    +012
    +013    }
    +014
    +015    @NotNull
    +016    public List<String> getCommandPrefixes() {
    +017        return commandPrefixes;
    +018    }
    +019}
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + diff --git a/docs/acf-jda/src-html/co/aikar/commands/JDACommandContexts.html b/docs/acf-jda/src-html/co/aikar/commands/JDACommandContexts.html new file mode 100644 index 00000000..3e3e1a8e --- /dev/null +++ b/docs/acf-jda/src-html/co/aikar/commands/JDACommandContexts.html @@ -0,0 +1,137 @@ + + + +Source code + + + +
    +
    001package co.aikar.commands;
    +002
    +003import co.aikar.commands.annotation.Optional;
    +004import net.dv8tion.jda.core.JDA;
    +005import net.dv8tion.jda.core.entities.ChannelType;
    +006import net.dv8tion.jda.core.entities.Guild;
    +007import net.dv8tion.jda.core.entities.Message;
    +008import net.dv8tion.jda.core.entities.MessageChannel;
    +009import net.dv8tion.jda.core.entities.User;
    +010import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
    +011
    +012import java.util.List;
    +013
    +014public class JDACommandContexts extends CommandContexts<JDACommandExecutionContext> {
    +015    private final JDACommandManager manager;
    +016    private final JDA jda;
    +017
    +018    public JDACommandContexts(JDACommandManager manager) {
    +019        super(manager);
    +020        this.manager = manager;
    +021        this.jda = this.manager.getJDA();
    +022        this.registerIssuerOnlyContext(JDACommandEvent.class, CommandExecutionContext::getIssuer);
    +023        this.registerIssuerOnlyContext(MessageReceivedEvent.class, c -> c.getIssuer().getIssuer());
    +024        this.registerIssuerOnlyContext(Message.class, c -> {
    +025            MessageReceivedEvent event = c.getIssuer().getIssuer();
    +026            return event.getMessage();
    +027        });
    +028        this.registerIssuerOnlyContext(Guild.class, c -> {
    +029            MessageReceivedEvent event = c.getIssuer().getIssuer();
    +030            if (event.isFromType(ChannelType.PRIVATE) && c.getAnnotation(Optional.class) == null) {
    +031                throw new InvalidCommandArgument("This command can only be executed in a Guild.", false); // TODO: Message Keys
    +032            } else {
    +033                return event.getGuild();
    +034            }
    +035        });
    +036        this.registerIssuerOnlyContext(MessageChannel.class, c -> {
    +037            MessageReceivedEvent event = c.getIssuer().getIssuer();
    +038            return event.getChannel();
    +039        });
    +040        this.registerIssuerOnlyContext(ChannelType.class, c -> {
    +041            MessageReceivedEvent event = c.getIssuer().getIssuer();
    +042            return event.getChannelType();
    +043        });
    +044
    +045
    +046        this.registerIssuerOnlyContext(JDA.class, c -> jda);
    +047        this.registerContext(User.class, c -> {
    +048            String arg = c.popFirstArg();
    +049            User user = null;
    +050            if (arg.startsWith("@")) {
    +051                user = jda.getUserById(arg.substring(1));
    +052            } else {
    +053                List<User> users = jda.getUsersByName(arg, true);
    +054                if (!users.isEmpty()) {
    +055                    user = users.get(0);
    +056                }
    +057            }
    +058            if (user == null) {
    +059                throw new InvalidCommandArgument("Could not find a user with that name or ID"); // TODO: Message keys
    +060            }
    +061            return user;
    +062        });
    +063    }
    +064
    +065}
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + diff --git a/docs/acf-jda/src-html/co/aikar/commands/JDACommandEvent.html b/docs/acf-jda/src-html/co/aikar/commands/JDACommandEvent.html new file mode 100644 index 00000000..1b508426 --- /dev/null +++ b/docs/acf-jda/src-html/co/aikar/commands/JDACommandEvent.html @@ -0,0 +1,126 @@ + + + +Source code + + + +
    +
    001package co.aikar.commands;
    +002
    +003import net.dv8tion.jda.core.entities.Message;
    +004import net.dv8tion.jda.core.entities.MessageEmbed;
    +005import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
    +006
    +007public class JDACommandEvent implements CommandIssuer {
    +008
    +009    private MessageReceivedEvent event;
    +010    private JDACommandManager manager;
    +011
    +012    public JDACommandEvent(JDACommandManager manager, MessageReceivedEvent event) {
    +013
    +014        this.manager = manager;
    +015        this.event = event;
    +016    }
    +017
    +018    public MessageReceivedEvent getEvent() {
    +019        return event;
    +020    }
    +021
    +022    @Override
    +023    public MessageReceivedEvent getIssuer() {
    +024        return event;
    +025    }
    +026
    +027    @Override
    +028    public CommandManager getManager() {
    +029        return this.manager;
    +030    }
    +031
    +032    @Override
    +033    public boolean isPlayer() {
    +034        return false;
    +035    }
    +036
    +037    @Override
    +038    public boolean hasPermission(String permission) {
    +039        CommandPermissionResolver permissionResolver = this.manager.getPermissionResolver();
    +040        return permissionResolver == null || permissionResolver.hasPermission(this, permission);
    +041    }
    +042
    +043    @Override
    +044    public void sendMessageInternal(String message) {
    +045        this.event.getChannel().sendMessage(message).queue();
    +046    }
    +047
    +048    public void sendMessage(Message message) {
    +049        this.event.getChannel().sendMessage(message).queue();
    +050    }
    +051    public void sendMessage(MessageEmbed message) {
    +052        this.event.getChannel().sendMessage(message).queue();
    +053    }
    +054}
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + diff --git a/docs/acf-jda/src-html/co/aikar/commands/JDACommandExecutionContext.html b/docs/acf-jda/src-html/co/aikar/commands/JDACommandExecutionContext.html new file mode 100644 index 00000000..fb5050f4 --- /dev/null +++ b/docs/acf-jda/src-html/co/aikar/commands/JDACommandExecutionContext.html @@ -0,0 +1,83 @@ + + + +Source code + + + +
    +
    001package co.aikar.commands;
    +002
    +003import java.lang.reflect.Parameter;
    +004import java.util.List;
    +005import java.util.Map;
    +006
    +007public class JDACommandExecutionContext extends CommandExecutionContext<JDACommandExecutionContext,JDACommandEvent> {
    +008    JDACommandExecutionContext(RegisteredCommand cmd, Parameter param, JDACommandEvent sender, List<String> args, int index, Map<String, Object> passedArgs) {
    +009        super(cmd, param, sender, args, index, passedArgs);
    +010    }
    +011}
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + diff --git a/docs/acf-jda/src-html/co/aikar/commands/JDACommandManager.html b/docs/acf-jda/src-html/co/aikar/commands/JDACommandManager.html new file mode 100644 index 00000000..bed191e9 --- /dev/null +++ b/docs/acf-jda/src-html/co/aikar/commands/JDACommandManager.html @@ -0,0 +1,328 @@ + + + +Source code + + + +
    +
    001package co.aikar.commands;
    +002
    +003import co.aikar.commands.apachecommonslang.ApacheCommonsExceptionUtil;
    +004import com.google.common.collect.Maps;
    +005import net.dv8tion.jda.core.AccountType;
    +006import net.dv8tion.jda.core.JDA;
    +007import net.dv8tion.jda.core.entities.ChannelType;
    +008import net.dv8tion.jda.core.entities.Message;
    +009import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
    +010import org.jetbrains.annotations.NotNull;
    +011
    +012import java.lang.reflect.Parameter;
    +013import java.util.Arrays;
    +014import java.util.List;
    +015import java.util.Map;
    +016import java.util.logging.Level;
    +017import java.util.logging.Logger;
    +018
    +019public class JDACommandManager extends CommandManager<
    +020        MessageReceivedEvent,
    +021        JDACommandEvent,
    +022        String,
    +023        MessageFormatter<String>,
    +024        JDACommandExecutionContext,
    +025        JDAConditionContext
    +026        > {
    +027
    +028    private final JDA jda;
    +029
    +030    private Logger logger;
    +031    private CommandConfig defaultConfig;
    +032    private CommandConfigProvider configProvider;
    +033    private CommandPermissionResolver permissionResolver;
    +034    protected JDACommandCompletions completions;
    +035    protected JDACommandContexts contexts;
    +036    protected JDALocales locales;
    +037    private long botOwner = 0L;
    +038
    +039    protected Map<String, JDARootCommand> commands = Maps.newHashMap();
    +040
    +041    public JDACommandManager(JDA jda) {
    +042        this(jda, null, null, null);
    +043    }
    +044
    +045    public JDACommandManager(JDA jda, CommandConfig defaultConfig, CommandConfigProvider configProvider, CommandPermissionResolver permissionResolver) {
    +046        this.jda = jda;
    +047        this.permissionResolver = permissionResolver;
    +048        jda.addEventListener(new JDAListener(this));
    +049        this.defaultConfig = defaultConfig == null ? new JDACommandConfig() : defaultConfig;
    +050        this.configProvider = configProvider;
    +051        this.completions = new JDACommandCompletions(this);
    +052        this.logger = Logger.getLogger(this.getClass().getSimpleName());
    +053
    +054        getCommandConditions().addCondition("owneronly", context -> {
    +055            if (context.getIssuer().getEvent().getAuthor().getIdLong() != getBotOwnerId()) {
    +056                throw new ConditionFailedException("Only the bot owner can use this command."); // TODO: MessageKey
    +057            }
    +058        });
    +059
    +060        getCommandConditions().addCondition("guildonly", context -> {
    +061            if (context.getIssuer().getEvent().getChannelType() != ChannelType.TEXT) {
    +062                throw new ConditionFailedException("This command must be used in guild chat."); // TODO: MessageKey
    +063            }
    +064        });
    +065
    +066        getCommandConditions().addCondition("privateonly", context -> {
    +067            if (context.getIssuer().getEvent().getChannelType() != ChannelType.PRIVATE) {
    +068                throw new ConditionFailedException("This command must be used in private chat."); // TODO: MessageKey
    +069            }
    +070        });
    +071
    +072        getCommandConditions().addCondition("grouponly", context -> {
    +073            if (context.getIssuer().getEvent().getChannelType() != ChannelType.GROUP) {
    +074                throw new ConditionFailedException("This command must be used in group chat."); // TODO: MessageKey
    +075            }
    +076        });
    +077    }
    +078
    +079    void initializeBotOwner() {
    +080        if (botOwner == 0L) {
    +081            if (jda.getAccountType() == AccountType.BOT) {
    +082                botOwner = jda.asBot().getApplicationInfo().complete().getOwner().getIdLong();
    +083            } else {
    +084                botOwner = jda.getSelfUser().getIdLong();
    +085            }
    +086        }
    +087    }
    +088
    +089    private long getBotOwnerId() {
    +090        // Just in case initialization on ReadyEvent fails.
    +091        initializeBotOwner();
    +092        return botOwner;
    +093    }
    +094
    +095
    +096    public static JDACommandManagerBuilder builder(JDA jda) {
    +097        return new JDACommandManagerBuilder(jda);
    +098    }
    +099
    +100    public JDA getJDA() {
    +101        return jda;
    +102    }
    +103
    +104    public Logger getLogger() {
    +105        return logger;
    +106    }
    +107
    +108    public void setLogger(Logger logger) {
    +109        this.logger = logger;
    +110    }
    +111
    +112    public CommandConfig getDefaultConfig() {
    +113        return defaultConfig;
    +114    }
    +115
    +116    public void setDefaultConfig(@NotNull CommandConfig defaultConfig) {
    +117        this.defaultConfig = defaultConfig;
    +118    }
    +119
    +120    public CommandConfigProvider getConfigProvider() {
    +121        return configProvider;
    +122    }
    +123
    +124    public void setConfigProvider(CommandConfigProvider configProvider) {
    +125        this.configProvider = configProvider;
    +126    }
    +127
    +128    public CommandPermissionResolver getPermissionResolver() {
    +129        return permissionResolver;
    +130    }
    +131
    +132    public void setPermissionResolver(CommandPermissionResolver permissionResolver) {
    +133        this.permissionResolver = permissionResolver;
    +134    }
    +135
    +136    @Override
    +137    public CommandContexts<?> getCommandContexts() {
    +138        if (this.contexts == null) {
    +139            this.contexts = new JDACommandContexts(this);
    +140        }
    +141        return this.contexts;
    +142    }
    +143
    +144    @Override
    +145    public CommandCompletions<?> getCommandCompletions() {
    +146        return this.completions;
    +147    }
    +148
    +149    @Override
    +150    public void registerCommand(BaseCommand command) {
    +151        command.onRegister(this);
    +152        for (Map.Entry<String, RootCommand> entry : command.registeredCommands.entrySet()) {
    +153            String commandName = entry.getKey().toLowerCase();
    +154            JDARootCommand cmd = (JDARootCommand) entry.getValue();
    +155            if (!cmd.isRegistered) {
    +156                cmd.isRegistered = true;
    +157                commands.put(commandName, cmd);
    +158            }
    +159        }
    +160    }
    +161
    +162    @Override
    +163    public boolean hasRegisteredCommands() {
    +164        return !this.commands.isEmpty();
    +165    }
    +166
    +167    @Override
    +168    public boolean isCommandIssuer(Class<?> type) {
    +169        return JDACommandEvent.class.isAssignableFrom(type);
    +170    }
    +171
    +172    @Override
    +173    public JDACommandEvent getCommandIssuer(Object issuer) {
    +174        if (!(issuer instanceof MessageReceivedEvent)) {
    +175            throw new IllegalArgumentException(issuer.getClass().getName() + " is not a Message Received Event.");
    +176        }
    +177        return new JDACommandEvent(this, (MessageReceivedEvent) issuer);
    +178    }
    +179
    +180    @Override
    +181    public RootCommand createRootCommand(String cmd) {
    +182        return new JDARootCommand(this, cmd);
    +183    }
    +184
    +185    @Override
    +186    public Locales getLocales() {
    +187        if (this.locales == null) {
    +188            this.locales = new JDALocales(this);
    +189            this.locales.loadLanguages();
    +190        }
    +191        return this.locales;
    +192    }
    +193
    +194    @Override
    +195    public CommandExecutionContext createCommandContext(RegisteredCommand command, Parameter parameter, CommandIssuer sender, List<String> args, int i, Map<String, Object> passedArgs) {
    +196        return new JDACommandExecutionContext(command, parameter, (JDACommandEvent) sender, args, i, passedArgs);
    +197    }
    +198
    +199    @Override
    +200    public CommandCompletionContext createCompletionContext(RegisteredCommand command, CommandIssuer sender, String input, String config, String[] args) {
    +201        // Not really going to be used;
    +202        //noinspection unchecked
    +203        return new CommandCompletionContext(command, sender, input, config, args);
    +204    }
    +205
    +206    @Override
    +207    public void log(LogLevel level, String message, Throwable throwable) {
    +208        Level logLevel = level == LogLevel.INFO ? Level.INFO : Level.SEVERE;
    +209        logger.log(logLevel, LogLevel.LOG_PREFIX + message);
    +210        if (throwable != null) {
    +211            for (String line : ACFPatterns.NEWLINE.split(ApacheCommonsExceptionUtil.getFullStackTrace(throwable))) {
    +212                logger.log(logLevel, LogLevel.LOG_PREFIX + line);
    +213            }
    +214        }
    +215    }
    +216
    +217    void dispatchEvent(MessageReceivedEvent event) {
    +218        Message message = event.getMessage();
    +219        String msg = message.getContentDisplay();
    +220
    +221        CommandConfig config = this.defaultConfig;
    +222        if (this.configProvider != null) {
    +223            CommandConfig provided = this.configProvider.provide(event);
    +224            if (provided != null) {
    +225                config = provided;
    +226            }
    +227        }
    +228
    +229        String prefixFound = null;
    +230        for (String prefix : config.getCommandPrefixes()) {
    +231            if (msg.startsWith(prefix)) {
    +232                prefixFound = prefix;
    +233                break;
    +234            }
    +235        }
    +236        if (prefixFound == null) {
    +237            return;
    +238        }
    +239
    +240        String[] args = ACFPatterns.SPACE.split(msg.substring(prefixFound.length()), -1);
    +241        if (args.length == 0) {
    +242            return;
    +243        }
    +244        String cmd = args[0].toLowerCase();
    +245        JDARootCommand rootCommand = this.commands.get(cmd);
    +246        if (rootCommand == null) {
    +247            return;
    +248        }
    +249        if (args.length > 1) {
    +250            args = Arrays.copyOfRange(args, 1, args.length);
    +251        } else {
    +252            args = new String[0];
    +253        }
    +254        rootCommand.execute(this.getCommandIssuer(event), cmd, args);
    +255    }
    +256}
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + diff --git a/docs/acf-jda/src-html/co/aikar/commands/JDACommandManagerBuilder.html b/docs/acf-jda/src-html/co/aikar/commands/JDACommandManagerBuilder.html new file mode 100644 index 00000000..e0e37d84 --- /dev/null +++ b/docs/acf-jda/src-html/co/aikar/commands/JDACommandManagerBuilder.html @@ -0,0 +1,106 @@ + + + +Source code + + + +
    +
    001package co.aikar.commands;
    +002
    +003import net.dv8tion.jda.core.JDA;
    +004import org.jetbrains.annotations.NotNull;
    +005
    +006public class JDACommandManagerBuilder {
    +007    private JDA jda;
    +008    private CommandConfig defaultConfig = null;
    +009    private CommandConfigProvider configProvider = null;
    +010    private CommandPermissionResolver permissionResolver = null;
    +011
    +012    public JDACommandManagerBuilder(JDA jda) {
    +013        this.jda = jda;
    +014    }
    +015
    +016    public JDACommandManagerBuilder defaultConfig(@NotNull CommandConfig defaultConfig) {
    +017        this.defaultConfig = defaultConfig;
    +018        return this;
    +019    }
    +020
    +021    public JDACommandManagerBuilder configProvider(@NotNull CommandConfigProvider configProvider) {
    +022        this.configProvider = configProvider;
    +023        return this;
    +024    }
    +025
    +026    public JDACommandManagerBuilder permissionResolver(@NotNull CommandPermissionResolver permissionResolver) {
    +027        this.permissionResolver = permissionResolver;
    +028        return this;
    +029    }
    +030
    +031    public JDACommandManager create() {
    +032        return new JDACommandManager(jda, defaultConfig, configProvider, permissionResolver);
    +033    }
    +034}
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + diff --git a/docs/acf-jda/src-html/co/aikar/commands/JDAConditionContext.html b/docs/acf-jda/src-html/co/aikar/commands/JDAConditionContext.html new file mode 100644 index 00000000..cb4680b9 --- /dev/null +++ b/docs/acf-jda/src-html/co/aikar/commands/JDAConditionContext.html @@ -0,0 +1,79 @@ + + + +Source code + + + +
    +
    001package co.aikar.commands;
    +002
    +003public class JDAConditionContext extends ConditionContext<JDACommandEvent> {
    +004    JDAConditionContext(JDACommandEvent issuer, String config) {
    +005        super(issuer, config);
    +006    }
    +007}
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + diff --git a/docs/acf-jda/src-html/co/aikar/commands/JDAListener.html b/docs/acf-jda/src-html/co/aikar/commands/JDAListener.html new file mode 100644 index 00000000..b189129a --- /dev/null +++ b/docs/acf-jda/src-html/co/aikar/commands/JDAListener.html @@ -0,0 +1,100 @@ + + + +Source code + + + +
    +
    001package co.aikar.commands;
    +002
    +003import net.dv8tion.jda.core.entities.ChannelType;
    +004import net.dv8tion.jda.core.events.ReadyEvent;
    +005import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
    +006import net.dv8tion.jda.core.hooks.ListenerAdapter;
    +007
    +008public class JDAListener extends ListenerAdapter {
    +009
    +010    private final JDACommandManager manager;
    +011
    +012    JDAListener(JDACommandManager manager) {
    +013
    +014        this.manager = manager;
    +015    }
    +016
    +017    @Override
    +018    public void onMessageReceived(MessageReceivedEvent event) {
    +019        if (event.isFromType(ChannelType.TEXT) || event.isFromType(ChannelType.PRIVATE)) {
    +020            this.manager.dispatchEvent(event);
    +021        }
    +022    }
    +023
    +024    @Override
    +025    public void onReady(ReadyEvent event) {
    +026        manager.initializeBotOwner();
    +027    }
    +028}
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + diff --git a/docs/acf-jda/src-html/co/aikar/commands/JDALocales.html b/docs/acf-jda/src-html/co/aikar/commands/JDALocales.html new file mode 100644 index 00000000..1b6fbd51 --- /dev/null +++ b/docs/acf-jda/src-html/co/aikar/commands/JDALocales.html @@ -0,0 +1,79 @@ + + + +Source code + + + +
    +
    001package co.aikar.commands;
    +002
    +003public class JDALocales extends Locales {
    +004    public JDALocales(CommandManager manager) {
    +005        super(manager);
    +006    }
    +007}
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + diff --git a/docs/acf-jda/src-html/co/aikar/commands/JDAMessageFormatter.html b/docs/acf-jda/src-html/co/aikar/commands/JDAMessageFormatter.html new file mode 100644 index 00000000..85e5a99e --- /dev/null +++ b/docs/acf-jda/src-html/co/aikar/commands/JDAMessageFormatter.html @@ -0,0 +1,80 @@ + + + +Source code + + + +
    +
    001package co.aikar.commands;
    +002
    +003public class JDAMessageFormatter extends MessageFormatter<String> {
    +004    @Override
    +005    String format(String color, String message) {
    +006        return message;
    +007    }
    +008}
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + diff --git a/docs/acf-jda/src-html/co/aikar/commands/JDARootCommand.html b/docs/acf-jda/src-html/co/aikar/commands/JDARootCommand.html new file mode 100644 index 00000000..805b2145 --- /dev/null +++ b/docs/acf-jda/src-html/co/aikar/commands/JDARootCommand.html @@ -0,0 +1,123 @@ + + + +Source code + + + +
    +
    001package co.aikar.commands;
    +002
    +003import com.google.common.collect.HashMultimap;
    +004import com.google.common.collect.SetMultimap;
    +005
    +006import java.util.ArrayList;
    +007import java.util.List;
    +008
    +009public class JDARootCommand implements RootCommand {
    +010
    +011    private JDACommandManager manager;
    +012    private final String name;
    +013    private BaseCommand defCommand;
    +014    private SetMultimap<String, RegisteredCommand> subCommands = HashMultimap.create();
    +015    private List<BaseCommand> children = new ArrayList<>();
    +016    boolean isRegistered = false;
    +017
    +018    JDARootCommand(JDACommandManager manager, String name) {
    +019        this.manager = manager;
    +020        this.name = name;
    +021    }
    +022
    +023    @Override
    +024
    +025    public void addChild(BaseCommand command) {
    +026        if (this.defCommand == null || !command.subCommands.get(BaseCommand.DEFAULT).isEmpty()) {
    +027            this.defCommand = command;
    +028        }
    +029        addChildShared(this.children, this.subCommands, command);
    +030    }
    +031
    +032    @Override
    +033    public CommandManager getManager() {
    +034        return this.manager;
    +035    }
    +036
    +037    @Override
    +038    public SetMultimap<String, RegisteredCommand> getSubCommands() {
    +039        return this.subCommands;
    +040    }
    +041
    +042    @Override
    +043    public List<BaseCommand> getChildren() {
    +044        return this.children;
    +045    }
    +046
    +047    @Override
    +048    public String getCommandName() {
    +049        return this.name;
    +050    }
    +051}
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + diff --git a/docs/acf-jda/stylesheet.css b/docs/acf-jda/stylesheet.css new file mode 100644 index 00000000..98055b22 --- /dev/null +++ b/docs/acf-jda/stylesheet.css @@ -0,0 +1,574 @@ +/* Javadoc style sheet */ +/* +Overall document style +*/ + +@import url('resources/fonts/dejavu.css'); + +body { + background-color:#ffffff; + color:#353833; + font-family:'DejaVu Sans', Arial, Helvetica, sans-serif; + font-size:14px; + margin:0; +} +a:link, a:visited { + text-decoration:none; + color:#4A6782; +} +a:hover, a:focus { + text-decoration:none; + color:#bb7a2a; +} +a:active { + text-decoration:none; + color:#4A6782; +} +a[name] { + color:#353833; +} +a[name]:hover { + text-decoration:none; + color:#353833; +} +pre { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; +} +h1 { + font-size:20px; +} +h2 { + font-size:18px; +} +h3 { + font-size:16px; + font-style:italic; +} +h4 { + font-size:13px; +} +h5 { + font-size:12px; +} +h6 { + font-size:11px; +} +ul { + list-style-type:disc; +} +code, tt { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; + margin-top:8px; + line-height:1.4em; +} +dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; +} +table tr td dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + vertical-align:top; + padding-top:4px; +} +sup { + font-size:8px; +} +/* +Document title and Copyright styles +*/ +.clear { + clear:both; + height:0px; + overflow:hidden; +} +.aboutLanguage { + float:right; + padding:0px 21px; + font-size:11px; + z-index:200; + margin-top:-9px; +} +.legalCopy { + margin-left:.5em; +} +.bar a, .bar a:link, .bar a:visited, .bar a:active { + color:#FFFFFF; + text-decoration:none; +} +.bar a:hover, .bar a:focus { + color:#bb7a2a; +} +.tab { + background-color:#0066FF; + color:#ffffff; + padding:8px; + width:5em; + font-weight:bold; +} +/* +Navigation bar styles +*/ +.bar { + background-color:#4D7A97; + color:#FFFFFF; + padding:.8em .5em .4em .8em; + height:auto;/*height:1.8em;*/ + font-size:11px; + margin:0; +} +.topNav { + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.bottomNav { + margin-top:10px; + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.subNav { + background-color:#dee3e9; + float:left; + width:100%; + overflow:hidden; + font-size:12px; +} +.subNav div { + clear:left; + float:left; + padding:0 0 5px 6px; + text-transform:uppercase; +} +ul.navList, ul.subNavList { + float:left; + margin:0 25px 0 0; + padding:0; +} +ul.navList li{ + list-style:none; + float:left; + padding: 5px 6px; + text-transform:uppercase; +} +ul.subNavList li{ + list-style:none; + float:left; +} +.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { + color:#FFFFFF; + text-decoration:none; + text-transform:uppercase; +} +.topNav a:hover, .bottomNav a:hover { + text-decoration:none; + color:#bb7a2a; + text-transform:uppercase; +} +.navBarCell1Rev { + background-color:#F8981D; + color:#253441; + margin: auto 5px; +} +.skipNav { + position:absolute; + top:auto; + left:-9999px; + overflow:hidden; +} +/* +Page header and footer styles +*/ +.header, .footer { + clear:both; + margin:0 20px; + padding:5px 0 0 0; +} +.indexHeader { + margin:10px; + position:relative; +} +.indexHeader span{ + margin-right:15px; +} +.indexHeader h1 { + font-size:13px; +} +.title { + color:#2c4557; + margin:10px 0; +} +.subTitle { + margin:5px 0 0 0; +} +.header ul { + margin:0 0 15px 0; + padding:0; +} +.footer ul { + margin:20px 0 5px 0; +} +.header ul li, .footer ul li { + list-style:none; + font-size:13px; +} +/* +Heading styles +*/ +div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList ul.blockList li.blockList h3 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList li.blockList h3 { + padding:0; + margin:15px 0; +} +ul.blockList li.blockList h2 { + padding:0px 0 20px 0; +} +/* +Page layout container styles +*/ +.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { + clear:both; + padding:10px 20px; + position:relative; +} +.indexContainer { + margin:10px; + position:relative; + font-size:12px; +} +.indexContainer h2 { + font-size:13px; + padding:0 0 3px 0; +} +.indexContainer ul { + margin:0; + padding:0; +} +.indexContainer ul li { + list-style:none; + padding-top:2px; +} +.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { + font-size:12px; + font-weight:bold; + margin:10px 0 0 0; + color:#4E4E4E; +} +.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { + margin:5px 0 10px 0px; + font-size:14px; + font-family:'DejaVu Sans Mono',monospace; +} +.serializedFormContainer dl.nameValue dt { + margin-left:1px; + font-size:1.1em; + display:inline; + font-weight:bold; +} +.serializedFormContainer dl.nameValue dd { + margin:0 0 0 1px; + font-size:1.1em; + display:inline; +} +/* +List styles +*/ +ul.horizontal li { + display:inline; + font-size:0.9em; +} +ul.inheritance { + margin:0; + padding:0; +} +ul.inheritance li { + display:inline; + list-style:none; +} +ul.inheritance li ul.inheritance { + margin-left:15px; + padding-left:15px; + padding-top:1px; +} +ul.blockList, ul.blockListLast { + margin:10px 0 10px 0; + padding:0; +} +ul.blockList li.blockList, ul.blockListLast li.blockList { + list-style:none; + margin-bottom:15px; + line-height:1.4; +} +ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { + padding:0px 20px 5px 10px; + border:1px solid #ededed; + background-color:#f8f8f8; +} +ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { + padding:0 0 5px 8px; + background-color:#ffffff; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { + margin-left:0; + padding-left:0; + padding-bottom:15px; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { + list-style:none; + border-bottom:none; + padding-bottom:0; +} +table tr td dl, table tr td dl dt, table tr td dl dd { + margin-top:0; + margin-bottom:1px; +} +/* +Table styles +*/ +.overviewSummary, .memberSummary, .typeSummary, .useSummary, .constantsSummary, .deprecatedSummary { + width:100%; + border-left:1px solid #EEE; + border-right:1px solid #EEE; + border-bottom:1px solid #EEE; +} +.overviewSummary, .memberSummary { + padding:0px; +} +.overviewSummary caption, .memberSummary caption, .typeSummary caption, +.useSummary caption, .constantsSummary caption, .deprecatedSummary caption { + position:relative; + text-align:left; + background-repeat:no-repeat; + color:#253441; + font-weight:bold; + clear:none; + overflow:hidden; + padding:0px; + padding-top:10px; + padding-left:1px; + margin:0px; + white-space:pre; +} +.overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link, +.useSummary caption a:link, .constantsSummary caption a:link, .deprecatedSummary caption a:link, +.overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover, +.useSummary caption a:hover, .constantsSummary caption a:hover, .deprecatedSummary caption a:hover, +.overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active, +.useSummary caption a:active, .constantsSummary caption a:active, .deprecatedSummary caption a:active, +.overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited, +.useSummary caption a:visited, .constantsSummary caption a:visited, .deprecatedSummary caption a:visited { + color:#FFFFFF; +} +.overviewSummary caption span, .memberSummary caption span, .typeSummary caption span, +.useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + padding-bottom:7px; + display:inline-block; + float:left; + background-color:#F8981D; + border: none; + height:16px; +} +.memberSummary caption span.activeTableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#F8981D; + height:16px; +} +.memberSummary caption span.tableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#4D7A97; + height:16px; +} +.memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab { + padding-top:0px; + padding-left:0px; + padding-right:0px; + background-image:none; + float:none; + display:inline; +} +.overviewSummary .tabEnd, .memberSummary .tabEnd, .typeSummary .tabEnd, +.useSummary .tabEnd, .constantsSummary .tabEnd, .deprecatedSummary .tabEnd { + display:none; + width:5px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .activeTableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .tableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + background-color:#4D7A97; + float:left; + +} +.overviewSummary td, .memberSummary td, .typeSummary td, +.useSummary td, .constantsSummary td, .deprecatedSummary td { + text-align:left; + padding:0px 0px 12px 10px; +} +th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th, +td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{ + vertical-align:top; + padding-right:0px; + padding-top:8px; + padding-bottom:3px; +} +th.colFirst, th.colLast, th.colOne, .constantsSummary th { + background:#dee3e9; + text-align:left; + padding:8px 3px 3px 7px; +} +td.colFirst, th.colFirst { + white-space:nowrap; + font-size:13px; +} +td.colLast, th.colLast { + font-size:13px; +} +td.colOne, th.colOne { + font-size:13px; +} +.overviewSummary td.colFirst, .overviewSummary th.colFirst, +.useSummary td.colFirst, .useSummary th.colFirst, +.overviewSummary td.colOne, .overviewSummary th.colOne, +.memberSummary td.colFirst, .memberSummary th.colFirst, +.memberSummary td.colOne, .memberSummary th.colOne, +.typeSummary td.colFirst{ + width:25%; + vertical-align:top; +} +td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { + font-weight:bold; +} +.tableSubHeadingColor { + background-color:#EEEEFF; +} +.altColor { + background-color:#FFFFFF; +} +.rowColor { + background-color:#EEEEEF; +} +/* +Content styles +*/ +.description pre { + margin-top:0; +} +.deprecatedContent { + margin:0; + padding:10px 0; +} +.docSummary { + padding:0; +} + +ul.blockList ul.blockList ul.blockList li.blockList h3 { + font-style:normal; +} + +div.block { + font-size:14px; + font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; +} + +td.colLast div { + padding-top:0px; +} + + +td.colLast a { + padding-bottom:3px; +} +/* +Formatting effect styles +*/ +.sourceLineNo { + color:green; + padding:0 30px 0 0; +} +h1.hidden { + visibility:hidden; + overflow:hidden; + font-size:10px; +} +.block { + display:block; + margin:3px 10px 2px 0px; + color:#474747; +} +.deprecatedLabel, .descfrmTypeLabel, .memberNameLabel, .memberNameLink, +.overrideSpecifyLabel, .packageHierarchyLabel, .paramLabel, .returnLabel, +.seeLabel, .simpleTagLabel, .throwsLabel, .typeNameLabel, .typeNameLink { + font-weight:bold; +} +.deprecationComment, .emphasizedPhrase, .interfaceName { + font-style:italic; +} + +div.block div.block span.deprecationComment, div.block div.block span.emphasizedPhrase, +div.block div.block span.interfaceName { + font-style:normal; +} + +div.contentContainer ul.blockList li.blockList h2{ + padding-bottom:0px; +} diff --git a/docs/acf-paper/co/aikar/commands/PaperCommandManager.html b/docs/acf-paper/co/aikar/commands/PaperCommandManager.html index 4fc83d17..2c55c4f5 100644 --- a/docs/acf-paper/co/aikar/commands/PaperCommandManager.html +++ b/docs/acf-paper/co/aikar/commands/PaperCommandManager.html @@ -143,7 +143,7 @@ extends co.aikar.commands.BukkitCommandManager

    Fields inherited from class co.aikar.commands.CommandManager

    -conditions, defaultExceptionHandler, defaultFormatter, defaultHelpPerPage, formatters, localeChangedCallbacks, replacements, rootCommands, supportedLanguages, usePerIssuerLocale
  • +conditions, defaultExceptionHandler, defaultFormatter, defaultHelpPerPage, dependencies, formatters, localeChangedCallbacks, replacements, rootCommands, supportedLanguages, usePerIssuerLocale
  • @@ -197,7 +197,7 @@ extends co.aikar.commands.BukkitCommandManager
  • Methods inherited from class co.aikar.commands.CommandManager

    -addSupportedLanguage, enableUnstableAPI, formatMessage, generateCommandHelp, generateCommandHelp, generateCommandHelp, generateCommandHelp, getCommandConditions, getCommandReplacements, getCurrentCommandIssuer, getCurrentCommandManager, getCurrentCommandOperationContext, getDefaultExceptionHandler, getDefaultFormatter, getDefaultHelpPerPage, getFormat, getRootCommand, getSupportedLanguages, handleUncaughtException, hasPermission, log, notifyLocaleChange, obtainRootCommand, onLocaleChange, sendMessage, sendMessage, setDefaultExceptionHandler, setDefaultFormatter, setDefaultHelpPerPage, setFormat, setFormat, setFormat, usePerIssuerLocale, usingPerIssuerLocale
  • +addSupportedLanguage, enableUnstableAPI, formatMessage, generateCommandHelp, generateCommandHelp, generateCommandHelp, generateCommandHelp, getCommandConditions, getCommandReplacements, getCurrentCommandIssuer, getCurrentCommandManager, getCurrentCommandOperationContext, getDefaultExceptionHandler, getDefaultFormatter, getDefaultHelpPerPage, getFormat, getRootCommand, getSupportedLanguages, handleUncaughtException, hasPermission, log, notifyLocaleChange, obtainRootCommand, onLocaleChange, registerDependency, registerDependency, sendMessage, sendMessage, setDefaultExceptionHandler, setDefaultFormatter, setDefaultHelpPerPage, setFormat, setFormat, setFormat, usePerIssuerLocale, usingPerIssuerLocale
  • @@ -273,7 +273,7 @@ extends co.aikar.commands.CommandManager<org.spongepowered.api.command.Comman

    Methods inherited from class co.aikar.commands.CommandManager

    -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, sendMessage, sendMessage, setDefaultExceptionHandler, setDefaultFormatter, setDefaultHelpPerPage, setFormat, setFormat, setFormat, usePerIssuerLocale, usingPerIssuerLocale
  • +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, usePerIssuerLocale, usingPerIssuerLocale
    • @@ -372,7 +372,7 @@ extends co.aikar.commands.CommandManager<org.spongepowered.api.command.Comman @@ -381,7 +381,7 @@ extends co.aikar.commands.CommandManager<org.spongepowered.api.command.Comman
      • isCommandIssuer

        -
        public boolean isCommandIssuer(Class<?> type)
        +
        public boolean isCommandIssuer(Class<?> type)
        Specified by:
        isCommandIssuer in class co.aikar.commands.CommandManager<org.spongepowered.api.command.CommandSource,SpongeCommandIssuer,org.spongepowered.api.text.format.TextColor,SpongeMessageFormatter,SpongeCommandExecutionContext,SpongeConditionContext>
        @@ -394,7 +394,7 @@ extends co.aikar.commands.CommandManager<org.spongepowered.api.command.Comman
        • getCommandContexts

          -
          public co.aikar.commands.CommandContexts<SpongeCommandExecutionContextgetCommandContexts()
          +
          public co.aikar.commands.CommandContexts<SpongeCommandExecutionContextgetCommandContexts()
          Specified by:
          getCommandContexts in class co.aikar.commands.CommandManager<org.spongepowered.api.command.CommandSource,SpongeCommandIssuer,org.spongepowered.api.text.format.TextColor,SpongeMessageFormatter,SpongeCommandExecutionContext,SpongeConditionContext>
          @@ -407,7 +407,7 @@ extends co.aikar.commands.CommandManager<org.spongepowered.api.command.Comman
          • getCommandCompletions

            -
            public co.aikar.commands.CommandCompletions<SpongeCommandCompletionContextgetCommandCompletions()
            +
            public co.aikar.commands.CommandCompletions<SpongeCommandCompletionContextgetCommandCompletions()
            Specified by:
            getCommandCompletions in class co.aikar.commands.CommandManager<org.spongepowered.api.command.CommandSource,SpongeCommandIssuer,org.spongepowered.api.text.format.TextColor,SpongeMessageFormatter,SpongeCommandExecutionContext,SpongeConditionContext>
            @@ -420,7 +420,7 @@ extends co.aikar.commands.CommandManager<org.spongepowered.api.command.Comman
            • getLocales

              -
              public SpongeLocales getLocales()
              +
              public SpongeLocales getLocales()
              Specified by:
              getLocales in class co.aikar.commands.CommandManager<org.spongepowered.api.command.CommandSource,SpongeCommandIssuer,org.spongepowered.api.text.format.TextColor,SpongeMessageFormatter,SpongeCommandExecutionContext,SpongeConditionContext>
              @@ -433,7 +433,7 @@ extends co.aikar.commands.CommandManager<org.spongepowered.api.command.Comman
              • hasRegisteredCommands

                -
                public boolean hasRegisteredCommands()
                +
                public boolean hasRegisteredCommands()
                Specified by:
                hasRegisteredCommands in class co.aikar.commands.CommandManager<org.spongepowered.api.command.CommandSource,SpongeCommandIssuer,org.spongepowered.api.text.format.TextColor,SpongeMessageFormatter,SpongeCommandExecutionContext,SpongeConditionContext>
                @@ -446,7 +446,7 @@ extends co.aikar.commands.CommandManager<org.spongepowered.api.command.Comman
                • registerCommand

                  -
                  public void registerCommand(co.aikar.commands.BaseCommand command)
                  +
                  public void registerCommand(co.aikar.commands.BaseCommand command)
                  Specified by:
                  registerCommand in class co.aikar.commands.CommandManager<org.spongepowered.api.command.CommandSource,SpongeCommandIssuer,org.spongepowered.api.text.format.TextColor,SpongeMessageFormatter,SpongeCommandExecutionContext,SpongeConditionContext>
                  @@ -459,7 +459,7 @@ extends co.aikar.commands.CommandManager<org.spongepowered.api.command.Comman @@ -468,7 +468,7 @@ extends co.aikar.commands.CommandManager<org.spongepowered.api.command.Comman
                  • createRootCommand

                    -
                    public co.aikar.commands.RootCommand createRootCommand(String cmd)
                    +
                    public co.aikar.commands.RootCommand createRootCommand(String cmd)
                    Specified by:
                    createRootCommand in class co.aikar.commands.CommandManager<org.spongepowered.api.command.CommandSource,SpongeCommandIssuer,org.spongepowered.api.text.format.TextColor,SpongeMessageFormatter,SpongeCommandExecutionContext,SpongeConditionContext>
                    @@ -481,7 +481,7 @@ extends co.aikar.commands.CommandManager<org.spongepowered.api.command.Comman
                    • getCommandIssuer

                      -
                      public SpongeCommandIssuer getCommandIssuer(Object issuer)
                      +
                      public SpongeCommandIssuer getCommandIssuer(Object issuer)
                      Specified by:
                      getCommandIssuer in class co.aikar.commands.CommandManager<org.spongepowered.api.command.CommandSource,SpongeCommandIssuer,org.spongepowered.api.text.format.TextColor,SpongeMessageFormatter,SpongeCommandExecutionContext,SpongeConditionContext>
                      @@ -494,7 +494,7 @@ extends co.aikar.commands.CommandManager<org.spongepowered.api.command.Comman
                      • createCommandContext

                        -
                        public SpongeCommandExecutionContext createCommandContext(co.aikar.commands.RegisteredCommand command,
                        +
                        public SpongeCommandExecutionContext createCommandContext(co.aikar.commands.RegisteredCommand command,
                                                                                   Parameter parameter,
                                                                                   co.aikar.commands.CommandIssuer sender,
                                                                                   List<String> args,
                        @@ -512,7 +512,7 @@ extends co.aikar.commands.CommandManager<org.spongepowered.api.command.Comman
                         
                        • createCompletionContext

                          -
                          public co.aikar.commands.CommandCompletionContext createCompletionContext(co.aikar.commands.RegisteredCommand command,
                          +
                          public co.aikar.commands.CommandCompletionContext createCompletionContext(co.aikar.commands.RegisteredCommand command,
                                                                                                     co.aikar.commands.CommandIssuer sender,
                                                                                                     String input,
                                                                                                     String config,
                          @@ -529,7 +529,7 @@ extends co.aikar.commands.CommandManager<org.spongepowered.api.command.Comman
                           
                          • createRegisteredCommand

                            -
                            public co.aikar.commands.RegisteredCommand createRegisteredCommand(co.aikar.commands.BaseCommand command,
                            +
                            public co.aikar.commands.RegisteredCommand createRegisteredCommand(co.aikar.commands.BaseCommand command,
                                                                                                String cmdName,
                                                                                                Method method,
                                                                                                String prefSubCommand)
                            @@ -545,7 +545,7 @@ extends co.aikar.commands.CommandManager<org.spongepowered.api.command.Comman
                            • log

                              -
                              public void log(co.aikar.commands.LogLevel level,
                              +
                              public void log(co.aikar.commands.LogLevel level,
                                               String message,
                                               Throwable throwable)
                              @@ -560,7 +560,7 @@ extends co.aikar.commands.CommandManager<org.spongepowered.api.command.Comman
                              • createConditionContext

                                -
                                public SpongeConditionContext createConditionContext(co.aikar.commands.CommandIssuer issuer,
                                +
                                public SpongeConditionContext createConditionContext(co.aikar.commands.CommandIssuer issuer,
                                                                                      String config)
                                Overrides:
                                diff --git a/docs/acf-sponge/src-html/co/aikar/commands/ACFSpongeUtil.html b/docs/acf-sponge/src-html/co/aikar/commands/ACFSpongeUtil.html index c25a8aa9..300a183c 100644 --- a/docs/acf-sponge/src-html/co/aikar/commands/ACFSpongeUtil.html +++ b/docs/acf-sponge/src-html/co/aikar/commands/ACFSpongeUtil.html @@ -82,7 +82,7 @@ 074 } 075 076 public static List<Player> matchPlayer(String partialName) { -077 List<Player> matchedPlayers = new ArrayList<Player>(); +077 List<Player> matchedPlayers = new ArrayList<>(); 078 079 for (Player iterPlayer : Sponge.getServer().getOnlinePlayers()) { 080 String iterPlayerName = iterPlayer.getName(); diff --git a/docs/acf-sponge/src-html/co/aikar/commands/SpongeCommandContexts.html b/docs/acf-sponge/src-html/co/aikar/commands/SpongeCommandContexts.html index 315336c0..1688aff0 100644 --- a/docs/acf-sponge/src-html/co/aikar/commands/SpongeCommandContexts.html +++ b/docs/acf-sponge/src-html/co/aikar/commands/SpongeCommandContexts.html @@ -66,98 +66,96 @@ 058 colours = colours.filter(colour -> finalFilter.equals(ACFUtil.simplifyString(colour.getName()))); 059 } 060 Stream<TextColor> finalColours = colours; -061 TextColor match = Sponge.getRegistry().getType(TextColor.class, ACFUtil.simplifyString(first)).orElseThrow(() -> { +061 return Sponge.getRegistry().getType(TextColor.class, ACFUtil.simplifyString(first)).orElseThrow(() -> { 062 String valid = finalColours 063 .map(colour -> "<c2>" + ACFUtil.simplifyString(colour.getName()) + "</c2>") 064 .collect(Collectors.joining("<c1>,</c1> ")); 065 return new InvalidCommandArgument(MessageKeys.PLEASE_SPECIFY_ONE_OF, "{valid}", valid); 066 }); -067 return match; -068 }); -069 registerContext(TextStyle.Base.class, c -> { -070 String first = c.popFirstArg(); -071 Stream<TextStyle.Base> styles = Sponge.getRegistry().getAllOf(TextStyle.Base.class).stream(); -072 String filter = c.getFlagValue("filter", (String)null); -073 if(filter != null) { -074 filter = ACFUtil.simplifyString(filter); -075 String finalFilter = filter; -076 styles = styles.filter(style -> finalFilter.equals(ACFUtil.simplifyString(style.getName()))); -077 } -078 Stream<TextStyle.Base> finalStyles = styles; -079 TextStyle.Base match = Sponge.getRegistry().getType(TextStyle.Base.class, ACFUtil.simplifyString(first)).orElseThrow(() -> { -080 String valid = finalStyles -081 .map(style -> "<c2>" + ACFUtil.simplifyString(style.getName()) + "</c2>") -082 .collect(Collectors.joining("<c1>,</c1> ")); -083 return new InvalidCommandArgument(MessageKeys.PLEASE_SPECIFY_ONE_OF, "{valid}", valid); -084 }); -085 return match; -086 }); -087 -088 registerIssuerAwareContext(CommandSource.class, SpongeCommandExecutionContext::getSource); -089 registerIssuerAwareContext(Player.class, (c) -> { -090 Player player = c.getSource() instanceof Player ? (Player) c.getSource() : null; -091 if (player == null && !c.hasAnnotation(Optional.class)) { -092 throw new InvalidCommandArgument(MessageKeys.NOT_ALLOWED_ON_CONSOLE, false); -093 } -094 /*PlayerInventory inventory = player != null ? player.getInventory() : null; -095 if (inventory != null && c.hasFlag("itemheld") && !ACFBukkitUtil.isValidItem(inventory.getItem(inventory.getHeldItemSlot()))) { -096 throw new InvalidCommandArgument(MinecraftMessageKeys.YOU_MUST_BE_HOLDING_ITEM, false); -097 }*/ -098 return player; -099 }); -100 registerContext(OnlinePlayer[].class, (c) -> { -101 SpongeCommandIssuer issuer = c.getIssuer(); -102 final String search = c.popFirstArg(); -103 boolean allowMissing = c.hasFlag("allowmissing"); -104 Set<OnlinePlayer> players = new HashSet<>(); -105 Pattern split = ACFPatterns.COMMA; -106 String splitter = c.getFlagValue("splitter", (String) null); -107 if (splitter != null) { -108 split = Pattern.compile(Pattern.quote(splitter)); -109 } -110 for (String lookup : split.split(search)) { -111 OnlinePlayer player = getOnlinePlayer(issuer, lookup, allowMissing); -112 if (player != null) { -113 players.add(player); -114 } -115 } -116 if (players.isEmpty() && !c.hasFlag("allowempty")) { -117 issuer.sendError(MinecraftMessageKeys.NO_PLAYER_FOUND_SERVER, -118 "{search}", search); -119 -120 throw new InvalidCommandArgument(false); -121 } -122 return players.toArray(new OnlinePlayer[players.size()]); -123 }); -124 registerIssuerAwareContext(World.class, (c) -> { -125 String firstArg = c.getFirstArg(); -126 java.util.Optional<World> world = firstArg != null ? Sponge.getServer().getWorld(firstArg) : java.util.Optional.empty(); -127 if (world.isPresent()) { -128 c.popFirstArg(); -129 } -130 if (!world.isPresent() && c.getSource() instanceof Player) { -131 world = java.util.Optional.of(((Player) c.getSource()).getWorld()); -132 } -133 if (!world.isPresent()) { -134 throw new InvalidCommandArgument(MinecraftMessageKeys.INVALID_WORLD); -135 } -136 return world.get(); -137 }); -138 } -139 -140 @Nullable -141 OnlinePlayer getOnlinePlayer(SpongeCommandIssuer issuer, String lookup, boolean allowMissing) throws InvalidCommandArgument { -142 Player player = ACFSpongeUtil.findPlayerSmart(issuer, lookup); -143 //noinspection Duplicates -144 if (player == null) { -145 if (allowMissing) { -146 return null; -147 } -148 throw new InvalidCommandArgument(false); -149 } -150 return new OnlinePlayer(player); -151 } -152} +067 }); +068 registerContext(TextStyle.Base.class, c -> { +069 String first = c.popFirstArg(); +070 Stream<TextStyle.Base> styles = Sponge.getRegistry().getAllOf(TextStyle.Base.class).stream(); +071 String filter = c.getFlagValue("filter", (String)null); +072 if(filter != null) { +073 filter = ACFUtil.simplifyString(filter); +074 String finalFilter = filter; +075 styles = styles.filter(style -> finalFilter.equals(ACFUtil.simplifyString(style.getName()))); +076 } +077 Stream<TextStyle.Base> finalStyles = styles; +078 return Sponge.getRegistry().getType(TextStyle.Base.class, ACFUtil.simplifyString(first)).orElseThrow(() -> { +079 String valid = finalStyles +080 .map(style -> "<c2>" + ACFUtil.simplifyString(style.getName()) + "</c2>") +081 .collect(Collectors.joining("<c1>,</c1> ")); +082 return new InvalidCommandArgument(MessageKeys.PLEASE_SPECIFY_ONE_OF, "{valid}", valid); +083 }); +084 }); +085 +086 registerIssuerAwareContext(CommandSource.class, SpongeCommandExecutionContext::getSource); +087 registerIssuerAwareContext(Player.class, (c) -> { +088 Player player = c.getSource() instanceof Player ? (Player) c.getSource() : null; +089 if (player == null && !c.hasAnnotation(Optional.class)) { +090 throw new InvalidCommandArgument(MessageKeys.NOT_ALLOWED_ON_CONSOLE, false); +091 } +092 /*PlayerInventory inventory = player != null ? player.getInventory() : null; +093 if (inventory != null && c.hasFlag("itemheld") && !ACFBukkitUtil.isValidItem(inventory.getItem(inventory.getHeldItemSlot()))) { +094 throw new InvalidCommandArgument(MinecraftMessageKeys.YOU_MUST_BE_HOLDING_ITEM, false); +095 }*/ +096 return player; +097 }); +098 registerContext(OnlinePlayer[].class, (c) -> { +099 SpongeCommandIssuer issuer = c.getIssuer(); +100 final String search = c.popFirstArg(); +101 boolean allowMissing = c.hasFlag("allowmissing"); +102 Set<OnlinePlayer> players = new HashSet<>(); +103 Pattern split = ACFPatterns.COMMA; +104 String splitter = c.getFlagValue("splitter", (String) null); +105 if (splitter != null) { +106 split = Pattern.compile(Pattern.quote(splitter)); +107 } +108 for (String lookup : split.split(search)) { +109 OnlinePlayer player = getOnlinePlayer(issuer, lookup, allowMissing); +110 if (player != null) { +111 players.add(player); +112 } +113 } +114 if (players.isEmpty() && !c.hasFlag("allowempty")) { +115 issuer.sendError(MinecraftMessageKeys.NO_PLAYER_FOUND_SERVER, +116 "{search}", search); +117 +118 throw new InvalidCommandArgument(false); +119 } +120 return players.toArray(new OnlinePlayer[players.size()]); +121 }); +122 registerIssuerAwareContext(World.class, (c) -> { +123 String firstArg = c.getFirstArg(); +124 java.util.Optional<World> world = firstArg != null ? Sponge.getServer().getWorld(firstArg) : java.util.Optional.empty(); +125 if (world.isPresent()) { +126 c.popFirstArg(); +127 } +128 if (!world.isPresent() && c.getSource() instanceof Player) { +129 world = java.util.Optional.of(((Player) c.getSource()).getWorld()); +130 } +131 if (!world.isPresent()) { +132 throw new InvalidCommandArgument(MinecraftMessageKeys.INVALID_WORLD); +133 } +134 return world.get(); +135 }); +136 } +137 +138 @Nullable +139 OnlinePlayer getOnlinePlayer(SpongeCommandIssuer issuer, String lookup, boolean allowMissing) throws InvalidCommandArgument { +140 Player player = ACFSpongeUtil.findPlayerSmart(issuer, lookup); +141 //noinspection Duplicates +142 if (player == null) { +143 if (allowMissing) { +144 return null; +145 } +146 throw new InvalidCommandArgument(false); +147 } +148 return new OnlinePlayer(player); +149 } +150} diff --git a/docs/acf-sponge/src-html/co/aikar/commands/SpongeCommandManager.html b/docs/acf-sponge/src-html/co/aikar/commands/SpongeCommandManager.html index b05a547e..2d13465a 100644 --- a/docs/acf-sponge/src-html/co/aikar/commands/SpongeCommandManager.html +++ b/docs/acf-sponge/src-html/co/aikar/commands/SpongeCommandManager.html @@ -75,134 +75,137 @@ 067 this.formatters.put(MessageType.INFO, new SpongeMessageFormatter(TextColors.BLUE, TextColors.DARK_GREEN, TextColors.GREEN)); 068 this.formatters.put(MessageType.HELP, new SpongeMessageFormatter(TextColors.AQUA, TextColors.GREEN, TextColors.YELLOW)); 069 getLocales(); // auto load locales -070 } -071 -072 public PluginContainer getPlugin() { -073 return plugin; -074 } -075 -076 @Override -077 public boolean isCommandIssuer(Class<?> type) { -078 return CommandSource.class.isAssignableFrom(type); -079 } -080 -081 @Override -082 public synchronized CommandContexts<SpongeCommandExecutionContext> getCommandContexts() { -083 if (this.contexts == null) { -084 this.contexts = new SpongeCommandContexts(this); -085 } -086 return contexts; -087 } -088 -089 @Override -090 public synchronized CommandCompletions<SpongeCommandCompletionContext> getCommandCompletions() { -091 if (this.completions == null) { -092 this.completions = new SpongeCommandCompletions(this); -093 } -094 return completions; -095 } -096 -097 @Override -098 public SpongeLocales getLocales() { -099 if (this.locales == null) { -100 this.locales = new SpongeLocales(this); -101 this.locales.loadLanguages(); -102 } -103 return locales; -104 } -105 -106 @Override -107 public boolean hasRegisteredCommands() { -108 return !registeredCommands.isEmpty(); -109 } -110 -111 @Override -112 public void registerCommand(BaseCommand command) { -113 command.onRegister(this); -114 -115 for (Map.Entry<String, RootCommand> entry : command.registeredCommands.entrySet()) { -116 String commandName = entry.getKey().toLowerCase(); -117 SpongeRootCommand spongeCommand = (SpongeRootCommand) entry.getValue(); -118 if (!spongeCommand.isRegistered) { -119 Sponge.getCommandManager().register(this.plugin, spongeCommand, commandName); -120 } -121 spongeCommand.isRegistered = true; -122 registeredCommands.put(commandName, spongeCommand); -123 } -124 } -125 -126 public Timing createTiming(final String name) { -127 return Timings.of(this.plugin, name, this.commandTiming); -128 } -129 -130 @Override -131 public RootCommand createRootCommand(String cmd) { -132 return new SpongeRootCommand(this, cmd); -133 } -134 -135 @Override -136 public SpongeCommandIssuer getCommandIssuer(Object issuer) { -137 if (!(issuer instanceof CommandSource)) { -138 throw new IllegalArgumentException(issuer.getClass().getName() + " is not a Command Issuer."); -139 } -140 return new SpongeCommandIssuer(this, (CommandSource) issuer); -141 } -142 -143 @Override -144 public SpongeCommandExecutionContext createCommandContext(RegisteredCommand command, Parameter parameter, CommandIssuer sender, List<String> args, int i, Map<String, Object> passedArgs) { -145 return new SpongeCommandExecutionContext(command, parameter, (SpongeCommandIssuer) sender, args, i, passedArgs); -146 } -147 -148 @Override -149 public CommandCompletionContext createCompletionContext(RegisteredCommand command, CommandIssuer sender, String input, String config, String[] args) { -150 return new SpongeCommandCompletionContext(command, (SpongeCommandIssuer) sender, input, config, args); -151 } -152 -153 @Override -154 public RegisteredCommand createRegisteredCommand(BaseCommand command, String cmdName, Method method, String prefSubCommand) { -155 return new SpongeRegisteredCommand(command, cmdName, method, prefSubCommand); -156 } -157 -158 @Override -159 public void log(final LogLevel level, final String message, final Throwable throwable) { -160 Logger logger = this.plugin.getLogger(); -161 switch(level) { -162 case INFO: -163 logger.info(LogLevel.LOG_PREFIX + message); -164 if (throwable != null) { -165 for (String line : ACFPatterns.NEWLINE.split(ApacheCommonsExceptionUtil.getFullStackTrace(throwable))) { -166 logger.info(LogLevel.LOG_PREFIX + line); -167 } -168 } -169 return; -170 case ERROR: -171 logger.error(LogLevel.LOG_PREFIX + message); -172 if (throwable != null) { -173 for (String line : ACFPatterns.NEWLINE.split(ApacheCommonsExceptionUtil.getFullStackTrace(throwable))) { -174 logger.error(LogLevel.LOG_PREFIX + line); -175 } -176 } -177 } -178 } -179 -180 @Override -181 CommandOperationContext createCommandOperationContext(BaseCommand command, CommandIssuer issuer, String commandLabel, String[] args, boolean isAsync) { -182 return new SpongeCommandOperationContext( -183 this, -184 issuer, -185 command, -186 commandLabel, -187 args, -188 isAsync -189 ); -190 } -191 -192 @Override -193 public SpongeConditionContext createConditionContext(CommandIssuer issuer, String config) { -194 return new SpongeConditionContext((SpongeCommandIssuer) issuer, config); -195 } -196 -197} +070 +071 //TODO more default dependencies for sponge +072 registerDependency(plugin.getClass(), plugin); +073 } +074 +075 public PluginContainer getPlugin() { +076 return plugin; +077 } +078 +079 @Override +080 public boolean isCommandIssuer(Class<?> type) { +081 return CommandSource.class.isAssignableFrom(type); +082 } +083 +084 @Override +085 public synchronized CommandContexts<SpongeCommandExecutionContext> getCommandContexts() { +086 if (this.contexts == null) { +087 this.contexts = new SpongeCommandContexts(this); +088 } +089 return contexts; +090 } +091 +092 @Override +093 public synchronized CommandCompletions<SpongeCommandCompletionContext> getCommandCompletions() { +094 if (this.completions == null) { +095 this.completions = new SpongeCommandCompletions(this); +096 } +097 return completions; +098 } +099 +100 @Override +101 public SpongeLocales getLocales() { +102 if (this.locales == null) { +103 this.locales = new SpongeLocales(this); +104 this.locales.loadLanguages(); +105 } +106 return locales; +107 } +108 +109 @Override +110 public boolean hasRegisteredCommands() { +111 return !registeredCommands.isEmpty(); +112 } +113 +114 @Override +115 public void registerCommand(BaseCommand command) { +116 command.onRegister(this); +117 +118 for (Map.Entry<String, RootCommand> entry : command.registeredCommands.entrySet()) { +119 String commandName = entry.getKey().toLowerCase(); +120 SpongeRootCommand spongeCommand = (SpongeRootCommand) entry.getValue(); +121 if (!spongeCommand.isRegistered) { +122 Sponge.getCommandManager().register(this.plugin, spongeCommand, commandName); +123 } +124 spongeCommand.isRegistered = true; +125 registeredCommands.put(commandName, spongeCommand); +126 } +127 } +128 +129 public Timing createTiming(final String name) { +130 return Timings.of(this.plugin, name, this.commandTiming); +131 } +132 +133 @Override +134 public RootCommand createRootCommand(String cmd) { +135 return new SpongeRootCommand(this, cmd); +136 } +137 +138 @Override +139 public SpongeCommandIssuer getCommandIssuer(Object issuer) { +140 if (!(issuer instanceof CommandSource)) { +141 throw new IllegalArgumentException(issuer.getClass().getName() + " is not a Command Issuer."); +142 } +143 return new SpongeCommandIssuer(this, (CommandSource) issuer); +144 } +145 +146 @Override +147 public SpongeCommandExecutionContext createCommandContext(RegisteredCommand command, Parameter parameter, CommandIssuer sender, List<String> args, int i, Map<String, Object> passedArgs) { +148 return new SpongeCommandExecutionContext(command, parameter, (SpongeCommandIssuer) sender, args, i, passedArgs); +149 } +150 +151 @Override +152 public CommandCompletionContext createCompletionContext(RegisteredCommand command, CommandIssuer sender, String input, String config, String[] args) { +153 return new SpongeCommandCompletionContext(command, (SpongeCommandIssuer) sender, input, config, args); +154 } +155 +156 @Override +157 public RegisteredCommand createRegisteredCommand(BaseCommand command, String cmdName, Method method, String prefSubCommand) { +158 return new SpongeRegisteredCommand(command, cmdName, method, prefSubCommand); +159 } +160 +161 @Override +162 public void log(final LogLevel level, final String message, final Throwable throwable) { +163 Logger logger = this.plugin.getLogger(); +164 switch(level) { +165 case INFO: +166 logger.info(LogLevel.LOG_PREFIX + message); +167 if (throwable != null) { +168 for (String line : ACFPatterns.NEWLINE.split(ApacheCommonsExceptionUtil.getFullStackTrace(throwable))) { +169 logger.info(LogLevel.LOG_PREFIX + line); +170 } +171 } +172 return; +173 case ERROR: +174 logger.error(LogLevel.LOG_PREFIX + message); +175 if (throwable != null) { +176 for (String line : ACFPatterns.NEWLINE.split(ApacheCommonsExceptionUtil.getFullStackTrace(throwable))) { +177 logger.error(LogLevel.LOG_PREFIX + line); +178 } +179 } +180 } +181 } +182 +183 @Override +184 CommandOperationContext createCommandOperationContext(BaseCommand command, CommandIssuer issuer, String commandLabel, String[] args, boolean isAsync) { +185 return new SpongeCommandOperationContext( +186 this, +187 issuer, +188 command, +189 commandLabel, +190 args, +191 isAsync +192 ); +193 } +194 +195 @Override +196 public SpongeConditionContext createConditionContext(CommandIssuer issuer, String config) { +197 return new SpongeConditionContext((SpongeCommandIssuer) issuer, config); +198 } +199 +200}