From aab4937f48cd2231aa79919061750dc3d257e7c0 Mon Sep 17 00:00:00 2001 From: Aikar Date: Wed, 28 Feb 2018 22:13:54 -0500 Subject: [PATCH] (DEPLOYED ACF) Updated JavaDocs --- .../aikar/commands/BukkitCommandIssuer.html | 44 +- .../aikar/commands/BukkitCommandManager.html | 146 ++- docs/acf-bukkit/index-all.html | 6 +- .../aikar/commands/BukkitCommandIssuer.html | 115 +-- .../aikar/commands/BukkitCommandManager.html | 661 +++++++------- docs/acf-bungee/allclasses-frame.html | 1 + docs/acf-bungee/allclasses-noframe.html | 1 + .../co/aikar/commands/ACFBungeeListener.html | 290 ++++++ .../co/aikar/commands/ACFBungeeUtil.html | 4 +- .../aikar/commands/BungeeCommandIssuer.html | 44 +- .../aikar/commands/BungeeCommandManager.html | 73 +- .../commands/class-use/ACFBungeeListener.html | 123 +++ .../class-use/BungeeCommandManager.html | 4 + .../co/aikar/commands/package-frame.html | 1 + .../co/aikar/commands/package-summary.html | 26 +- .../co/aikar/commands/package-tree.html | 1 + docs/acf-bungee/index-all.html | 12 + docs/acf-bungee/overview-tree.html | 1 + .../co/aikar/commands/ACFBungeeListener.html | 109 +++ .../aikar/commands/BungeeCommandIssuer.html | 125 +-- .../aikar/commands/BungeeCommandManager.html | 313 ++++--- docs/acf-core/allclasses-frame.html | 2 + docs/acf-core/allclasses-noframe.html | 2 + docs/acf-core/co/aikar/commands/ACFUtil.html | 109 ++- .../aikar/commands/AnnotationProcessor.html | 360 ++++++++ .../co/aikar/commands/BaseCommand.html | 50 +- .../co/aikar/commands/CommandContexts.html | 18 +- .../co/aikar/commands/CommandIssuer.html | 72 +- .../co/aikar/commands/CommandManager.html | 170 ++-- .../class-use/AnnotationProcessor.html | 165 ++++ .../aikar/commands/class-use/BaseCommand.html | 7 + .../class-use/CommandExecutionContext.html | 47 + .../class-use/CommandOperationContext.html | 45 + .../commands/class-use/RegisteredCommand.html | 16 + .../commands/contexts/package-summary.html | 4 +- .../aikar/commands/contexts/package-tree.html | 4 +- .../co/aikar/commands/package-frame.html | 1 + .../co/aikar/commands/package-summary.html | 16 +- .../co/aikar/commands/package-tree.html | 1 + .../co/aikar/commands/package-use.html | 29 + .../processors/ConditionsProcessor.html | 316 +++++++ .../class-use/ConditionsProcessor.html | 123 +++ .../commands/processors/package-frame.html | 20 + .../commands/processors/package-summary.html | 141 +++ .../commands/processors/package-tree.html | 136 +++ .../commands/processors/package-use.html | 123 +++ docs/acf-core/deprecated-list.html | 22 + docs/acf-core/index-all.html | 62 ++ docs/acf-core/overview-frame.html | 1 + docs/acf-core/overview-summary.html | 4 + docs/acf-core/overview-tree.html | 5 +- docs/acf-core/package-list | 1 + .../src-html/co/aikar/commands/ACFUtil.html | 322 ++++--- .../aikar/commands/AnnotationProcessor.html | 134 +++ .../co/aikar/commands/BaseCommand.html | 746 +++++++-------- .../co/aikar/commands/CommandContexts.html | 529 +++++------ .../co/aikar/commands/CommandIssuer.html | 136 +-- .../co/aikar/commands/CommandManager.html | 859 +++++++++--------- .../processors/ConditionsProcessor.html | 115 +++ .../co/aikar/commands/JDACommandEvent.html | 52 +- .../co/aikar/commands/JDACommandManager.html | 4 +- docs/acf-jda/index-all.html | 2 + .../co/aikar/commands/JDACommandEvent.html | 103 ++- .../aikar/commands/PaperCommandManager.html | 8 +- docs/acf-sponge/allclasses-frame.html | 1 + docs/acf-sponge/allclasses-noframe.html | 1 + .../co/aikar/commands/ACFSpongeListener.html | 287 ++++++ .../co/aikar/commands/ACFSpongeUtil.html | 4 +- .../aikar/commands/SpongeCommandIssuer.html | 44 +- .../aikar/commands/SpongeCommandManager.html | 34 +- .../commands/class-use/ACFSpongeListener.html | 123 +++ .../class-use/SpongeCommandManager.html | 7 +- .../co/aikar/commands/package-frame.html | 1 + .../co/aikar/commands/package-summary.html | 28 +- .../co/aikar/commands/package-tree.html | 1 + docs/acf-sponge/index-all.html | 10 + docs/acf-sponge/overview-tree.html | 1 + .../co/aikar/commands/ACFSpongeListener.html | 100 ++ .../aikar/commands/SpongeCommandIssuer.html | 114 ++- .../aikar/commands/SpongeCommandManager.html | 261 +++--- 80 files changed, 5710 insertions(+), 2489 deletions(-) create mode 100644 docs/acf-bungee/co/aikar/commands/ACFBungeeListener.html create mode 100644 docs/acf-bungee/co/aikar/commands/class-use/ACFBungeeListener.html create mode 100644 docs/acf-bungee/src-html/co/aikar/commands/ACFBungeeListener.html create mode 100644 docs/acf-core/co/aikar/commands/AnnotationProcessor.html create mode 100644 docs/acf-core/co/aikar/commands/class-use/AnnotationProcessor.html create mode 100644 docs/acf-core/co/aikar/commands/processors/ConditionsProcessor.html create mode 100644 docs/acf-core/co/aikar/commands/processors/class-use/ConditionsProcessor.html create mode 100644 docs/acf-core/co/aikar/commands/processors/package-frame.html create mode 100644 docs/acf-core/co/aikar/commands/processors/package-summary.html create mode 100644 docs/acf-core/co/aikar/commands/processors/package-tree.html create mode 100644 docs/acf-core/co/aikar/commands/processors/package-use.html create mode 100644 docs/acf-core/src-html/co/aikar/commands/AnnotationProcessor.html create mode 100644 docs/acf-core/src-html/co/aikar/commands/processors/ConditionsProcessor.html create mode 100644 docs/acf-sponge/co/aikar/commands/ACFSpongeListener.html create mode 100644 docs/acf-sponge/co/aikar/commands/class-use/ACFSpongeListener.html create mode 100644 docs/acf-sponge/src-html/co/aikar/commands/ACFSpongeListener.html diff --git a/docs/acf-bukkit/co/aikar/commands/BukkitCommandIssuer.html b/docs/acf-bukkit/co/aikar/commands/BukkitCommandIssuer.html index 374161c9..1426c79e 100644 --- a/docs/acf-bukkit/co/aikar/commands/BukkitCommandIssuer.html +++ b/docs/acf-bukkit/co/aikar/commands/BukkitCommandIssuer.html @@ -18,7 +18,7 @@ catch(err) { } //--> -var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10}; +var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10}; var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]}; var altColor = "altColor"; var rowColor = "rowColor"; @@ -112,7 +112,7 @@ var activeTableTab = "activeTableTab";

-
public class BukkitCommandIssuer
+
public class BukkitCommandIssuer
 extends Object
 implements co.aikar.commands.CommandIssuer
@@ -150,18 +150,22 @@ implements co.aikar.commands.CommandIssuer
getPlayer()  +@NotNull UUID +getUniqueId()  + + int hashCode()  - + boolean hasPermission(String name)  - + boolean isPlayer()  - + void sendMessageInternal(String message)  @@ -200,7 +204,7 @@ implements co.aikar.commands.CommandIssuer @@ -385,7 +377,7 @@ extends co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,
  • completions

    -
    protected BukkitCommandCompletions completions
    +
    protected BukkitCommandCompletions completions
  • @@ -394,25 +386,16 @@ extends co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,
  • locales

    -
    protected BukkitLocales locales
    +
    protected BukkitLocales locales
  • - - - - @@ -429,7 +412,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)
  • @@ -446,7 +429,7 @@ extends co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,
  • getPlugin

    -
    public org.bukkit.plugin.Plugin getPlugin()
    +
    public org.bukkit.plugin.Plugin getPlugin()
  • @@ -455,7 +438,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>
    @@ -468,7 +451,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>
    @@ -481,7 +464,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>
    @@ -494,7 +477,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>
    @@ -507,7 +490,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>
    @@ -520,7 +503,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)
  • @@ -530,7 +513,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>
    @@ -543,7 +526,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)
  • @@ -553,7 +536,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:
    @@ -567,7 +550,17 @@ public void 
  • unregisterCommands

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

    -
    public co.aikar.timings.lib.TimingManager getTimings()
    +
    public co.aikar.timings.lib.TimingManager getTimings()
  • @@ -585,7 +578,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>
    @@ -598,7 +591,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>
    @@ -611,7 +604,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,
    @@ -629,7 +622,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,
    @@ -646,7 +639,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)
    @@ -662,7 +655,7 @@ public void 
  • createConditionContext

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

    -
    public void log(co.aikar.commands.LogLevel level,
    +
    public void log(co.aikar.commands.LogLevel level,
                     String message,
                     Throwable throwable)
    @@ -685,36 +678,13 @@ public void  - - - - - - -
    • usePerIssuerLocale

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

    All Classes

      +
    • ACFBungeeListener
    • ACFBungeeUtil
    • BungeeCommandCompletionContext
    • BungeeCommandCompletions
    • diff --git a/docs/acf-bungee/allclasses-noframe.html b/docs/acf-bungee/allclasses-noframe.html index f080e03f..dafb2984 100644 --- a/docs/acf-bungee/allclasses-noframe.html +++ b/docs/acf-bungee/allclasses-noframe.html @@ -12,6 +12,7 @@

      All Classes

        +
      • ACFBungeeListener
      • ACFBungeeUtil
      • BungeeCommandCompletionContext
      • BungeeCommandCompletions
      • diff --git a/docs/acf-bungee/co/aikar/commands/ACFBungeeListener.html b/docs/acf-bungee/co/aikar/commands/ACFBungeeListener.html new file mode 100644 index 00000000..ea82fdd2 --- /dev/null +++ b/docs/acf-bungee/co/aikar/commands/ACFBungeeListener.html @@ -0,0 +1,290 @@ + + + + + + +ACFBungeeListener (ACF (Bungee) 0.5.0-SNAPSHOT API) + + + + + + + + + + + +
        +
        co.aikar.commands
        +

        Class ACFBungeeListener

        +
        +
        + +
        +
          +
        • +
          +
          All Implemented Interfaces:
          +
          net.md_5.bungee.api.plugin.Listener
          +
          +
          +
          +
          public class ACFBungeeListener
          +extends Object
          +implements net.md_5.bungee.api.plugin.Listener
          +
        • +
        +
        +
        + +
        +
        +
          +
        • + + + +
            +
          • + + +

            Method Detail

            + + + +
              +
            • +

              onPlayerJoin

              +
              public void onPlayerJoin(net.md_5.bungee.api.event.PostLoginEvent loginEvent)
              +
            • +
            + + + +
              +
            • +

              onDisconnect

              +
              public void onDisconnect(net.md_5.bungee.api.event.PlayerDisconnectEvent disconnectEvent)
              +
            • +
            +
          • +
          +
        • +
        +
        +
        + + + + + +

        Copyright © 2018. All rights reserved.

        + + diff --git a/docs/acf-bungee/co/aikar/commands/ACFBungeeUtil.html b/docs/acf-bungee/co/aikar/commands/ACFBungeeUtil.html index 182abda0..3fbb5e53 100644 --- a/docs/acf-bungee/co/aikar/commands/ACFBungeeUtil.html +++ b/docs/acf-bungee/co/aikar/commands/ACFBungeeUtil.html @@ -48,7 +48,7 @@ var activeTableTab = "activeTableTab";


  • -
    public class BungeeCommandIssuer
    +
    public class BungeeCommandIssuer
     extends Object
     implements co.aikar.commands.CommandIssuer
  • @@ -150,18 +150,22 @@ implements co.aikar.commands.CommandIssuer
    getPlayer()  +@NotNull UUID +getUniqueId()  + + int hashCode()  - + boolean hasPermission(String name)  - + boolean isPlayer()  - + void sendMessageInternal(String message)  @@ -200,7 +204,7 @@ implements co.aikar.commands.CommandIssuer
    • getIssuer

      -
      public net.md_5.bungee.api.CommandSender getIssuer()
      +
      public net.md_5.bungee.api.CommandSender getIssuer()
      Specified by:
      getIssuer in interface co.aikar.commands.CommandIssuer
      @@ -213,7 +217,7 @@ implements co.aikar.commands.CommandIssuer
    • getPlayer

      -
      public net.md_5.bungee.api.connection.ProxiedPlayer getPlayer()
      +
      public net.md_5.bungee.api.connection.ProxiedPlayer getPlayer()
    @@ -222,7 +226,7 @@ implements co.aikar.commands.CommandIssuer
    • isPlayer

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

      getUniqueId

      +
      @NotNull
      +public @NotNull UUID getUniqueId()
      +
      +
      Specified by:
      +
      getUniqueId in interface co.aikar.commands.CommandIssuer
      +
      +
    • +
    • sendMessageInternal

      -
      public void sendMessageInternal(String message)
      +
      public void sendMessageInternal(String message)
      Specified by:
      sendMessageInternal in interface co.aikar.commands.CommandIssuer
      @@ -261,7 +279,7 @@ implements co.aikar.commands.CommandIssuer
      • hasPermission

        -
        public boolean hasPermission(String name)
        +
        public boolean hasPermission(String name)
        Specified by:
        hasPermission in interface co.aikar.commands.CommandIssuer
        @@ -274,7 +292,7 @@ implements co.aikar.commands.CommandIssuer
        • equals

          -
          public boolean equals(Object o)
          +
          public boolean equals(Object o)
          Overrides:
          equals in class Object
          @@ -287,7 +305,7 @@ implements co.aikar.commands.CommandIssuer
          • hashCode

            -
            public int hashCode()
            +
            public int hashCode()
            Overrides:
            hashCode in class Object
            diff --git a/docs/acf-bungee/co/aikar/commands/BungeeCommandManager.html b/docs/acf-bungee/co/aikar/commands/BungeeCommandManager.html index a054aa59..6efbe4cb 100644 --- a/docs/acf-bungee/co/aikar/commands/BungeeCommandManager.html +++ b/docs/acf-bungee/co/aikar/commands/BungeeCommandManager.html @@ -18,7 +18,7 @@ catch(err) { } //--> -var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10,"i11":10,"i12":10,"i13":10,"i14":10,"i15":10,"i16":10}; +var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10,"i11":10,"i12":10,"i13":10,"i14":10,"i15":10,"i16":10,"i17":10}; var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]}; var altColor = "altColor"; var rowColor = "rowColor"; @@ -113,7 +113,7 @@ var activeTableTab = "activeTableTab";


          • -
            public class BungeeCommandManager
            +
            public class BungeeCommandManager
             extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,BungeeCommandIssuer,net.md_5.bungee.api.ChatColor,BungeeMessageFormatter,BungeeCommandExecutionContext,BungeeConditionContext>
          @@ -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, dependencies, formatters, localeChangedCallbacks, replacements, rootCommands, supportedLanguages, usePerIssuerLocale
        • +conditions, defaultExceptionHandler, defaultFormatter, defaultHelpPerPage, dependencies, formatters, issuersLocale, localeChangedCallbacks, replacements, rootCommands, supportedLanguages, usePerIssuerLocale
      @@ -261,18 +261,22 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender, void -registerCommand(co.aikar.commands.BaseCommand command)  +readLocale(net.md_5.bungee.api.connection.ProxiedPlayer player)  void -unregisterCommand(co.aikar.commands.BaseCommand command)  +registerCommand(co.aikar.commands.BaseCommand command)  void -unregisterCommand(BungeeRootCommand command)  +unregisterCommand(co.aikar.commands.BaseCommand command)  void +unregisterCommand(BungeeRootCommand command)  + + +void unregisterCommands()  @@ -281,7 +285,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, registerDependency, registerDependency, 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, setIssuerLocale, usePerIssuerLocale, usingPerIssuerLocale
    @@ -319,7 +323,7 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,
  • registeredCommands

    -
    protected Map<String,BungeeRootCommand> registeredCommands
    +
    protected Map<String,BungeeRootCommand> registeredCommands
  • @@ -328,7 +332,7 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,
  • contexts

    -
    protected BungeeCommandContexts contexts
    +
    protected BungeeCommandContexts contexts
  • @@ -337,7 +341,7 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,
  • completions

    -
    protected BungeeCommandCompletions completions
    +
    protected BungeeCommandCompletions completions
  • @@ -346,7 +350,7 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,
  • locales

    -
    protected BungeeLocales locales
    +
    protected BungeeLocales locales
  • @@ -363,7 +367,7 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,
  • BungeeCommandManager

    -
    public BungeeCommandManager(net.md_5.bungee.api.plugin.Plugin plugin)
    +
    public BungeeCommandManager(net.md_5.bungee.api.plugin.Plugin plugin)
  • @@ -380,7 +384,7 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,
  • getPlugin

    -
    public net.md_5.bungee.api.plugin.Plugin getPlugin()
    +
    public net.md_5.bungee.api.plugin.Plugin getPlugin()
  • @@ -389,7 +393,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 +406,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,20 +419,29 @@ 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>
  • + + + +
      +
    • +

      readLocale

      +
      public void readLocale(net.md_5.bungee.api.connection.ProxiedPlayer player)
      +
    • +
    @@ -450,7 +463,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 +472,7 @@ extends co.aikar.commands.CommandManager<net.md_5.bungee.api.CommandSender,
  • unregisterCommands

    -
    public void unregisterCommands()
    +
    public void unregisterCommands()
  • @@ -468,7 +481,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 +494,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 +507,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 +520,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 +533,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 +551,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 +568,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 +584,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 +598,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/co/aikar/commands/class-use/ACFBungeeListener.html b/docs/acf-bungee/co/aikar/commands/class-use/ACFBungeeListener.html new file mode 100644 index 00000000..9c4e4bc6 --- /dev/null +++ b/docs/acf-bungee/co/aikar/commands/class-use/ACFBungeeListener.html @@ -0,0 +1,123 @@ + + + + + + +Uses of Class co.aikar.commands.ACFBungeeListener (ACF (Bungee) 0.5.0-SNAPSHOT API) + + + + + + + + + + +
    +

    Uses of Class
    co.aikar.commands.ACFBungeeListener

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

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-bungee/co/aikar/commands/class-use/BungeeCommandManager.html b/docs/acf-bungee/co/aikar/commands/class-use/BungeeCommandManager.html index c564f63a..fcaf0d4a 100644 --- a/docs/acf-bungee/co/aikar/commands/class-use/BungeeCommandManager.html +++ b/docs/acf-bungee/co/aikar/commands/class-use/BungeeCommandManager.html @@ -101,6 +101,10 @@ +ACFBungeeListener(BungeeCommandManager manager, + net.md_5.bungee.api.plugin.Plugin plugin)  + + BungeeLocales(BungeeCommandManager manager)  diff --git a/docs/acf-bungee/co/aikar/commands/package-frame.html b/docs/acf-bungee/co/aikar/commands/package-frame.html index 46ca97cd..bebc8f18 100644 --- a/docs/acf-bungee/co/aikar/commands/package-frame.html +++ b/docs/acf-bungee/co/aikar/commands/package-frame.html @@ -13,6 +13,7 @@

    Classes

      +
    • ACFBungeeListener
    • ACFBungeeUtil
    • BungeeCommandCompletionContext
    • BungeeCommandCompletions
    • diff --git a/docs/acf-bungee/co/aikar/commands/package-summary.html b/docs/acf-bungee/co/aikar/commands/package-summary.html index eecfcf9c..adde73ef 100644 --- a/docs/acf-bungee/co/aikar/commands/package-summary.html +++ b/docs/acf-bungee/co/aikar/commands/package-summary.html @@ -82,50 +82,54 @@ +ACFBungeeListener +  + + ACFBungeeUtil   - + BungeeCommandCompletionContext   - + BungeeCommandCompletions   - + BungeeCommandContexts   - + BungeeCommandExecutionContext   - + BungeeCommandIssuer   - + BungeeCommandManager   - + BungeeConditionContext   - + BungeeLocales   - + BungeeMessageFormatter   - + BungeeRegisteredCommand   - + BungeeRootCommand   diff --git a/docs/acf-bungee/co/aikar/commands/package-tree.html b/docs/acf-bungee/co/aikar/commands/package-tree.html index 402ae684..1722fc68 100644 --- a/docs/acf-bungee/co/aikar/commands/package-tree.html +++ b/docs/acf-bungee/co/aikar/commands/package-tree.html @@ -80,6 +80,7 @@
      • java.lang.Object
          +
        • co.aikar.commands.ACFBungeeListener (implements net.md_5.bungee.api.plugin.Listener)
        • co.aikar.commands.ACFBungeeUtil
        • co.aikar.commands.BungeeCommandIssuer (implements co.aikar.commands.CommandIssuer)
        • net.md_5.bungee.api.plugin.Command diff --git a/docs/acf-bungee/index-all.html b/docs/acf-bungee/index-all.html index a1d0456a..ded8a430 100644 --- a/docs/acf-bungee/index-all.html +++ b/docs/acf-bungee/index-all.html @@ -73,6 +73,10 @@

          A

          +
          ACFBungeeListener - Class in co.aikar.commands
          +
           
          +
          ACFBungeeListener(BungeeCommandManager, Plugin) - Constructor for class co.aikar.commands.ACFBungeeListener
          +
           
          ACFBungeeUtil - Class in co.aikar.commands
           
          ACFBungeeUtil() - Constructor for class co.aikar.commands.ACFBungeeUtil
          @@ -217,6 +221,8 @@
           
          getSubCommands() - Method in class co.aikar.commands.BungeeRootCommand
           
          +
          getUniqueId() - Method in class co.aikar.commands.BungeeCommandIssuer
          +
           
          @@ -271,10 +277,14 @@

          O

          +
          onDisconnect(PlayerDisconnectEvent) - Method in class co.aikar.commands.ACFBungeeListener
          +
           
          OnlineProxiedPlayer - Class in co.aikar.commands.contexts
           
          OnlineProxiedPlayer(ProxiedPlayer) - Constructor for class co.aikar.commands.contexts.OnlineProxiedPlayer
           
          +
          onPlayerJoin(PostLoginEvent) - Method in class co.aikar.commands.ACFBungeeListener
          +
           
          onTabComplete(CommandSender, String[]) - Method in class co.aikar.commands.BungeeRootCommand
           
          @@ -297,6 +307,8 @@

          R

          +
          readLocale(ProxiedPlayer) - Method in class co.aikar.commands.BungeeCommandManager
          +
           
          registerCommand(BaseCommand) - Method in class co.aikar.commands.BungeeCommandManager
           
          registeredCommands - Variable in class co.aikar.commands.BungeeCommandManager
          diff --git a/docs/acf-bungee/overview-tree.html b/docs/acf-bungee/overview-tree.html index c5b77895..713f4c27 100644 --- a/docs/acf-bungee/overview-tree.html +++ b/docs/acf-bungee/overview-tree.html @@ -81,6 +81,7 @@
          • java.lang.Object
              +
            • co.aikar.commands.ACFBungeeListener (implements net.md_5.bungee.api.plugin.Listener)
            • co.aikar.commands.ACFBungeeUtil
            • co.aikar.commands.BungeeCommandIssuer (implements co.aikar.commands.CommandIssuer)
            • net.md_5.bungee.api.plugin.Command diff --git a/docs/acf-bungee/src-html/co/aikar/commands/ACFBungeeListener.html b/docs/acf-bungee/src-html/co/aikar/commands/ACFBungeeListener.html new file mode 100644 index 00000000..abfb4276 --- /dev/null +++ b/docs/acf-bungee/src-html/co/aikar/commands/ACFBungeeListener.html @@ -0,0 +1,109 @@ + + + +Source code + + + +
              +
              001package co.aikar.commands;
              +002
              +003import net.md_5.bungee.api.connection.ProxiedPlayer;
              +004import net.md_5.bungee.api.event.PlayerDisconnectEvent;
              +005import net.md_5.bungee.api.event.PostLoginEvent;
              +006import net.md_5.bungee.api.plugin.Listener;
              +007import net.md_5.bungee.api.plugin.Plugin;
              +008import net.md_5.bungee.event.EventHandler;
              +009
              +010import java.util.concurrent.TimeUnit;
              +011
              +012public class ACFBungeeListener implements Listener {
              +013
              +014    private final BungeeCommandManager manager;
              +015    private final Plugin plugin;
              +016
              +017    public ACFBungeeListener(BungeeCommandManager manager, Plugin plugin) {
              +018        this.manager = manager;
              +019        this.plugin = plugin;
              +020    }
              +021
              +022    @EventHandler
              +023    public void onPlayerJoin(PostLoginEvent loginEvent) {
              +024        ProxiedPlayer player = loginEvent.getPlayer();
              +025
              +026        //the client settings are sent after a successful login
              +027        Runnable task = () -> manager.readLocale(player);
              +028        plugin.getProxy().getScheduler().schedule(plugin, task, 1, TimeUnit.SECONDS);
              +029    }
              +030
              +031    @EventHandler
              +032    public void onDisconnect(PlayerDisconnectEvent disconnectEvent) {
              +033        //cleanup
              +034        ProxiedPlayer player = disconnectEvent.getPlayer();
              +035        manager.issuersLocale.remove(player.getUniqueId());
              +036    }
              +037}
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              + + diff --git a/docs/acf-bungee/src-html/co/aikar/commands/BungeeCommandIssuer.html b/docs/acf-bungee/src-html/co/aikar/commands/BungeeCommandIssuer.html index 1d1d8d86..968bed8a 100644 --- a/docs/acf-bungee/src-html/co/aikar/commands/BungeeCommandIssuer.html +++ b/docs/acf-bungee/src-html/co/aikar/commands/BungeeCommandIssuer.html @@ -33,62 +33,75 @@ 025 026import net.md_5.bungee.api.CommandSender; 027import net.md_5.bungee.api.connection.ProxiedPlayer; -028 -029import java.util.Objects; -030 -031public class BungeeCommandIssuer implements CommandIssuer { -032 private final BungeeCommandManager manager; -033 private final CommandSender sender; -034 -035 BungeeCommandIssuer(BungeeCommandManager manager, CommandSender sender) { -036 this.manager = manager; -037 this.sender = sender; -038 } -039 -040 -041 @Override -042 public CommandSender getIssuer() { -043 return sender; -044 } -045 -046 public ProxiedPlayer getPlayer() { -047 return isPlayer() ? (ProxiedPlayer) sender : null; -048 } -049 -050 @Override -051 public CommandManager getManager() { -052 return manager; -053 } -054 -055 @Override -056 public boolean isPlayer() { -057 return sender instanceof ProxiedPlayer; -058 } -059 -060 @Override -061 public void sendMessageInternal(String message) { -062 sender.sendMessage(ACFBungeeUtil.color(message)); -063 } -064 -065 @Override -066 public boolean hasPermission(String name) { -067 return sender.hasPermission(name); -068 } -069 -070 -071 @Override -072 public boolean equals(Object o) { -073 if (this == o) return true; -074 if (o == null || getClass() != o.getClass()) return false; -075 BungeeCommandIssuer that = (BungeeCommandIssuer) o; -076 return Objects.equals(sender, that.sender); -077 } -078 -079 @Override -080 public int hashCode() { -081 return Objects.hash(sender); -082 } -083} +028import org.jetbrains.annotations.NotNull; +029 +030import java.nio.charset.StandardCharsets; +031import java.util.Objects; +032import java.util.UUID; +033 +034public class BungeeCommandIssuer implements CommandIssuer { +035 private final BungeeCommandManager manager; +036 private final CommandSender sender; +037 +038 BungeeCommandIssuer(BungeeCommandManager manager, CommandSender sender) { +039 this.manager = manager; +040 this.sender = sender; +041 } +042 +043 +044 @Override +045 public CommandSender getIssuer() { +046 return sender; +047 } +048 +049 public ProxiedPlayer getPlayer() { +050 return isPlayer() ? (ProxiedPlayer) sender : null; +051 } +052 +053 @Override +054 public CommandManager getManager() { +055 return manager; +056 } +057 +058 @Override +059 public boolean isPlayer() { +060 return sender instanceof ProxiedPlayer; +061 } +062 +063 @Override +064 public @NotNull UUID getUniqueId() { +065 if (isPlayer()) { +066 return ((ProxiedPlayer) sender).getUniqueId(); +067 } +068 +069 //generate a unique id based of the name (like for the console command sender) +070 return UUID.nameUUIDFromBytes(sender.getName().getBytes(StandardCharsets.UTF_8)); +071 } +072 +073 @Override +074 public void sendMessageInternal(String message) { +075 sender.sendMessage(ACFBungeeUtil.color(message)); +076 } +077 +078 @Override +079 public boolean hasPermission(String name) { +080 return sender.hasPermission(name); +081 } +082 +083 +084 @Override +085 public boolean equals(Object o) { +086 if (this == o) return true; +087 if (o == null || getClass() != o.getClass()) return false; +088 BungeeCommandIssuer that = (BungeeCommandIssuer) o; +089 return Objects.equals(sender, that.sender); +090 } +091 +092 @Override +093 public int hashCode() { +094 return Objects.hash(sender); +095 } +096} 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 2566df06..185bc19a 100644 --- a/docs/acf-bungee/src-html/co/aikar/commands/BungeeCommandManager.html +++ b/docs/acf-bungee/src-html/co/aikar/commands/BungeeCommandManager.html @@ -34,166 +34,189 @@ 026import co.aikar.commands.apachecommonslang.ApacheCommonsExceptionUtil; 027import net.md_5.bungee.api.ChatColor; 028import net.md_5.bungee.api.CommandSender; -029import net.md_5.bungee.api.plugin.Plugin; -030 -031import java.lang.reflect.Method; -032import java.lang.reflect.Parameter; -033import java.util.HashMap; -034import java.util.List; -035import java.util.Map; -036import java.util.logging.Level; -037import java.util.logging.Logger; -038 -039public class BungeeCommandManager extends CommandManager< -040 CommandSender, -041 BungeeCommandIssuer, -042 ChatColor, -043 BungeeMessageFormatter, -044 BungeeCommandExecutionContext, -045 BungeeConditionContext -046 > { -047 -048 protected final Plugin plugin; -049 protected Map<String, BungeeRootCommand> registeredCommands = new HashMap<>(); -050 protected BungeeCommandContexts contexts; -051 protected BungeeCommandCompletions completions; -052 protected BungeeLocales locales; -053 -054 public BungeeCommandManager(Plugin plugin) { -055 this.plugin = plugin; -056 this.formatters.put(MessageType.ERROR, defaultFormatter = new BungeeMessageFormatter(ChatColor.RED, ChatColor.YELLOW, ChatColor.RED)); -057 this.formatters.put(MessageType.SYNTAX, new BungeeMessageFormatter(ChatColor.YELLOW, ChatColor.GREEN, ChatColor.WHITE)); -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 // TODO more default dependencies for bungee -063 registerDependency(plugin.getClass(), plugin); -064 registerDependency(Plugin.class, plugin); -065 } +029import net.md_5.bungee.api.ProxyServer; +030import net.md_5.bungee.api.connection.ProxiedPlayer; +031import net.md_5.bungee.api.plugin.Plugin; +032 +033import java.lang.reflect.Method; +034import java.lang.reflect.Parameter; +035import java.util.HashMap; +036import java.util.List; +037import java.util.Locale; +038import java.util.Map; +039import java.util.concurrent.TimeUnit; +040import java.util.logging.Level; +041import java.util.logging.Logger; +042 +043public class BungeeCommandManager extends CommandManager< +044 CommandSender, +045 BungeeCommandIssuer, +046 ChatColor, +047 BungeeMessageFormatter, +048 BungeeCommandExecutionContext, +049 BungeeConditionContext +050 > { +051 +052 protected final Plugin plugin; +053 protected Map<String, BungeeRootCommand> registeredCommands = new HashMap<>(); +054 protected BungeeCommandContexts contexts; +055 protected BungeeCommandCompletions completions; +056 protected BungeeLocales locales; +057 +058 public BungeeCommandManager(Plugin plugin) { +059 this.plugin = plugin; +060 this.formatters.put(MessageType.ERROR, defaultFormatter = new BungeeMessageFormatter(ChatColor.RED, ChatColor.YELLOW, ChatColor.RED)); +061 this.formatters.put(MessageType.SYNTAX, new BungeeMessageFormatter(ChatColor.YELLOW, ChatColor.GREEN, ChatColor.WHITE)); +062 this.formatters.put(MessageType.INFO, new BungeeMessageFormatter(ChatColor.BLUE, ChatColor.DARK_GREEN, ChatColor.GREEN)); +063 this.formatters.put(MessageType.HELP, new BungeeMessageFormatter(ChatColor.AQUA, ChatColor.GREEN, ChatColor.YELLOW)); +064 +065 getLocales(); // auto load locales 066 -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; +067 plugin.getProxy().getPluginManager().registerListener(plugin, new ACFBungeeListener(this, plugin)); +068 +069 //BungeeCord has no event for listening for client setting changes +070 plugin.getProxy().getScheduler().schedule(plugin, () -> { +071 ProxyServer.getInstance().getPlayers().forEach(this::readLocale); +072 }, 5, 5, TimeUnit.SECONDS); +073 +074 // TODO more default dependencies for bungee +075 registerDependency(plugin.getClass(), plugin); +076 registerDependency(Plugin.class, plugin); 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 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()); +079 public Plugin getPlugin() { +080 return this.plugin; +081 } +082 +083 @Override +084 public synchronized CommandContexts<BungeeCommandExecutionContext> getCommandContexts() { +085 if (this.contexts == null) { +086 this.contexts = new BungeeCommandContexts(this); +087 } +088 return contexts; +089 } +090 +091 @Override +092 public synchronized CommandCompletions<BungeeCommandCompletionContext> getCommandCompletions() { +093 if (this.completions == null) { +094 this.completions = new BungeeCommandCompletions(this); +095 } +096 return completions; +097 } +098 +099 @Override +100 public BungeeLocales getLocales() { +101 if (this.locales == null) { +102 this.locales = new BungeeLocales(this); +103 this.locales.loadLanguages(); +104 } +105 return locales; +106 } +107 +108 public void readLocale(ProxiedPlayer player) { +109 if (!player.isConnected()) { +110 return; +111 } +112 +113 //This can be null if we didn't received a settings packet +114 Locale locale = player.getLocale(); +115 if (locale != null) { +116 setIssuerLocale(player, player.getLocale()); +117 } +118 } +119 +120 @Override +121 public void registerCommand(BaseCommand command) { +122 command.onRegister(this); +123 for (Map.Entry<String, RootCommand> entry : command.registeredCommands.entrySet()) { +124 String commandName = entry.getKey().toLowerCase(); +125 BungeeRootCommand bungeeCommand = (BungeeRootCommand) entry.getValue(); +126 if (!bungeeCommand.isRegistered) { +127 this.plugin.getProxy().getPluginManager().registerCommand(this.plugin, bungeeCommand); +128 } +129 bungeeCommand.isRegistered = true; +130 registeredCommands.put(commandName, bungeeCommand); 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); +134 public void unregisterCommand(BaseCommand command) { +135 for (Map.Entry<String, RootCommand> entry : command.registeredCommands.entrySet()) { +136 String commandName = entry.getKey().toLowerCase(); +137 BungeeRootCommand bungeeCommand = (BungeeRootCommand) entry.getValue(); +138 bungeeCommand.getSubCommands().values().removeAll(command.subCommands.values()); +139 if (bungeeCommand.getSubCommands().isEmpty() && bungeeCommand.isRegistered) { +140 unregisterCommand(bungeeCommand); +141 bungeeCommand.isRegistered = false; +142 registeredCommands.remove(commandName); +143 } +144 } +145 } +146 +147 public void unregisterCommand(BungeeRootCommand command) { +148 this.plugin.getProxy().getPluginManager().unregisterCommand(command); +149 } +150 +151 public void unregisterCommands() { +152 for (Map.Entry<String, BungeeRootCommand> entry : registeredCommands.entrySet()) { +153 unregisterCommand(entry.getValue()); +154 } 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); +158 public boolean hasRegisteredCommands() { +159 return !registeredCommands.isEmpty(); 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); +163 public boolean isCommandIssuer(Class<?> aClass) { +164 return CommandSender.class.isAssignableFrom(aClass); 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} +168 public BungeeCommandIssuer getCommandIssuer(Object issuer) { +169 if (!(issuer instanceof CommandSender)) { +170 throw new IllegalArgumentException(issuer.getClass().getName() + " is not a Command Issuer."); +171 } +172 return new BungeeCommandIssuer(this, (CommandSender) issuer); +173 } +174 +175 @Override +176 public RootCommand createRootCommand(String cmd) { +177 return new BungeeRootCommand(this, cmd); +178 } +179 +180 @Override +181 public BungeeCommandExecutionContext createCommandContext(RegisteredCommand command, Parameter parameter, CommandIssuer sender, List<String> args, int i, Map<String, Object> passedArgs) { +182 return new BungeeCommandExecutionContext(command, parameter, (BungeeCommandIssuer) sender, args, i, passedArgs); +183 } +184 +185 @Override +186 public CommandCompletionContext createCompletionContext(RegisteredCommand command, CommandIssuer sender, String input, String config, String[] args) { +187 return new BungeeCommandCompletionContext(command, (BungeeCommandIssuer) sender, input, config, args); +188 } +189 +190 @Override +191 public RegisteredCommand createRegisteredCommand(BaseCommand command, String cmdName, Method method, String prefSubCommand) { +192 return new RegisteredCommand(command, cmdName, method, prefSubCommand); +193 } +194 +195 @Override +196 public BungeeConditionContext createConditionContext(CommandIssuer issuer, String config) { +197 return new BungeeConditionContext((BungeeCommandIssuer) issuer, config); +198 } +199 +200 @Override +201 public void log(LogLevel level, String message, Throwable throwable) { +202 Logger logger = this.plugin.getLogger(); +203 Level logLevel = level == LogLevel.INFO ? Level.INFO : Level.SEVERE; +204 logger.log(logLevel, LogLevel.LOG_PREFIX + message); +205 if (throwable != null) { +206 for (String line : ACFPatterns.NEWLINE.split(ApacheCommonsExceptionUtil.getFullStackTrace(throwable))) { +207 logger.log(logLevel, LogLevel.LOG_PREFIX + line); +208 } +209 } +210 } +211} diff --git a/docs/acf-core/allclasses-frame.html b/docs/acf-core/allclasses-frame.html index 6c7a8e35..8d5d498e 100644 --- a/docs/acf-core/allclasses-frame.html +++ b/docs/acf-core/allclasses-frame.html @@ -13,6 +13,7 @@
              - + static String replacePattern(String string, String pattern, @@ -421,7 +426,7 @@ extends Regex version of replace(String, String, String)
    - + static String replacePatternMatch(String string, Pattern pattern, @@ -429,7 +434,7 @@ extends Pure Regex Pattern matching and replacement, no escaping - + static String replacePatternMatch(String string, String pattern, @@ -437,44 +442,44 @@ extends Pure Regex Pattern matching and replacement, no escaping - + static String replacePatterns(String string, String... replacements)  - + static String replaceStrings(String string, String... replacements)  - + static double round(double x, int scale)  - + static int roundUp(int num, int multiple)  - + static String rtrim(String s)  - + static <E extends Enum<E>>
    E
    simpleMatch(Class<? extends Enum<?>> list, String item)  - + static String simplifyString(String str)  - + static void sneaky(Throwable t)  - + static String ucfirst(String str)  @@ -1102,13 +1107,23 @@ public static <E extends + + + @@ -1118,7 +1133,7 @@ public static <E extends
  • intersection

    -
    public static <T> Collection<T> intersection(Collection<T> list1,
    +
    public static <T> Collection<T> intersection(Collection<T> list1,
                                                  Collection<T> list2)
  • @@ -1128,7 +1143,7 @@ public static <E extends
  • rand

    -
    public static int rand(int min,
    +
    public static int rand(int min,
                            int max)
  • @@ -1138,7 +1153,7 @@ public static <E extends
  • rand

    -
    public static int rand(int min1,
    +
    public static int rand(int min1,
                            int max1,
                            int min2,
                            int max2)
    @@ -1160,7 +1175,7 @@ public static <E extends
  • rand

    -
    public static double rand(double min,
    +
    public static double rand(double min,
                               double max)
  • @@ -1170,7 +1185,7 @@ public static <E extends
  • isNumber

    -
    public static boolean isNumber(String str)
    +
    public static boolean isNumber(String str)
  • @@ -1179,7 +1194,7 @@ public static <E extends
  • intToRoman

    -
    public static String intToRoman(int integer)
    +
    public static String intToRoman(int integer)
  • @@ -1188,7 +1203,7 @@ public static <E extends
  • isInteger

    -
    public static boolean isInteger(String string)
    +
    public static boolean isInteger(String string)
  • @@ -1197,7 +1212,7 @@ public static <E extends
  • isFloat

    -
    public static boolean isFloat(String string)
    +
    public static boolean isFloat(String string)
  • @@ -1206,7 +1221,7 @@ public static <E extends
  • isDouble

    -
    public static boolean isDouble(String string)
    +
    public static boolean isDouble(String string)
  • @@ -1215,7 +1230,7 @@ public static <E extends
  • isBetween

    -
    public static boolean isBetween(float num,
    +
    public static boolean isBetween(float num,
                                     double min,
                                     double max)
  • @@ -1226,7 +1241,7 @@ public static <E extends
  • precision

    -
    public static double precision(double x,
    +
    public static double precision(double x,
                                    int p)
  • @@ -1236,7 +1251,7 @@ public static <E extends
  • sneaky

    -
    public static void sneaky(Throwable t)
    +
    public static void sneaky(Throwable t)
  • @@ -1267,7 +1282,7 @@ public static <E extends @@ -466,7 +466,7 @@ extends
  • canExecute

    -
    public boolean canExecute(CommandIssuer issuer,
    +
    public boolean canExecute(CommandIssuer issuer,
                               RegisteredCommand<?> cmd)
  • @@ -476,7 +476,7 @@ extends
  • tabComplete

    -
    public List<StringtabComplete(CommandIssuer issuer,
    +
    public List<StringtabComplete(CommandIssuer issuer,
                                     String commandLabel,
                                     String[] args)
  • @@ -487,7 +487,7 @@ extends
  • tabComplete

    -
    public List<StringtabComplete(CommandIssuer issuer,
    +
    public List<StringtabComplete(CommandIssuer issuer,
                                     String commandLabel,
                                     String[] args,
                                     boolean isAsync)
    @@ -505,7 +505,7 @@ extends 
     

    getCommandHelp

    @Deprecated
    -public CommandHelp getCommandHelp()
    +public CommandHelp getCommandHelp()
    Deprecated. Unstable API
  • @@ -516,7 +516,7 @@ public 

    showCommandHelp

    @Deprecated
    -public void showCommandHelp()
    +public void showCommandHelp()
    Deprecated. Unstable API
  • @@ -526,7 +526,7 @@ public void 
  • help

    -
    public void help(Object issuer,
    +
    public void help(Object issuer,
                      String[] args)
  • @@ -536,7 +536,7 @@ public void 
  • help

    -
    public void help(CommandIssuer issuer,
    +
    public void help(CommandIssuer issuer,
                      String[] args)
  • @@ -546,7 +546,7 @@ public void 
  • doHelp

    -
    public void doHelp(Object issuer,
    +
    public void doHelp(Object issuer,
                        String... args)
  • @@ -556,7 +556,7 @@ public void 
  • doHelp

    -
    public void doHelp(CommandIssuer issuer,
    +
    public void doHelp(CommandIssuer issuer,
                        String... args)
  • @@ -566,7 +566,7 @@ public void 
  • showSyntax

    -
    public void showSyntax(CommandIssuer issuer,
    +
    public void showSyntax(CommandIssuer issuer,
                            RegisteredCommand<?> cmd)
  • @@ -576,7 +576,7 @@ public void 
  • hasPermission

    -
    public boolean hasPermission(Object issuer)
    +
    public boolean hasPermission(Object issuer)
  • @@ -585,7 +585,7 @@ public void 
  • hasPermission

    -
    public boolean hasPermission(CommandIssuer issuer)
    +
    public boolean hasPermission(CommandIssuer issuer)
  • @@ -594,7 +594,7 @@ public void 
  • getRequiredPermissions

    -
    public Set<StringgetRequiredPermissions()
    +
    public Set<StringgetRequiredPermissions()
  • @@ -603,7 +603,7 @@ public void 
  • requiresPermission

    -
    public boolean requiresPermission(String permission)
    +
    public boolean requiresPermission(String permission)
  • @@ -612,7 +612,7 @@ public void 
  • getName

    -
    public String getName()
    +
    public String getName()
  • @@ -621,7 +621,7 @@ public void 
  • getExceptionHandler

    -
    public ExceptionHandler getExceptionHandler()
    +
    public ExceptionHandler getExceptionHandler()
  • @@ -630,7 +630,7 @@ public void 
  • setExceptionHandler

    -
    public BaseCommand setExceptionHandler(ExceptionHandler exceptionHandler)
    +
    public BaseCommand setExceptionHandler(ExceptionHandler exceptionHandler)
  • @@ -639,7 +639,7 @@ public void 
  • getDefaultRegisteredCommand

    -
    public RegisteredCommand getDefaultRegisteredCommand()
    +
    public RegisteredCommand getDefaultRegisteredCommand()
  • @@ -648,7 +648,7 @@ public void 
  • setContextFlags

    -
    public String setContextFlags(Class<?> cls,
    +
    public String setContextFlags(Class<?> cls,
                                   String flags)
  • @@ -658,7 +658,7 @@ public void 
  • getContextFlags

    -
    public String getContextFlags(Class<?> cls)
    +
    public String getContextFlags(Class<?> cls)
  • @@ -688,7 +688,7 @@ public void  @@ -222,7 +222,7 @@ extends
  • contextMap

    -
    protected final Map<Class<?>,ContextResolver<?,R extends CommandExecutionContext<?,? extends CommandIssuer>>> contextMap
    +
    protected final Map<Class<?>,ContextResolver<?,R extends CommandExecutionContext<?,? extends CommandIssuer>>> contextMap
  • @@ -231,7 +231,7 @@ extends
  • manager

    -
    protected final CommandManager manager
    +
    protected final CommandManager manager
  • @@ -249,7 +249,7 @@ extends

    registerSenderAwareContext

    @Deprecated
    -public <T> void registerSenderAwareContext(Class<T> context,
    +public <T> void registerSenderAwareContext(Class<T> context,
                                                            IssuerAwareContextResolver<T,R> supplier)
    Deprecated. Please switch to registerIssuerAwareContext(Class, IssuerAwareContextResolver) as the core wants to use the platform agnostic term of "Issuer" instead of Sender
    @@ -265,7 +265,7 @@ public <T> void 
  • registerIssuerAwareContext

    -
    public <T> void registerIssuerAwareContext(Class<T> context,
    +
    public <T> void registerIssuerAwareContext(Class<T> context,
                                                IssuerAwareContextResolver<T,R> supplier)
    Registers a context resolver that may conditionally consume input, falling back to using the context of the issuer to potentially fulfill this context. @@ -279,7 +279,7 @@ public <T> void 
  • registerIssuerOnlyContext

    -
    public <T> void registerIssuerOnlyContext(Class<T> context,
    +
    public <T> void registerIssuerOnlyContext(Class<T> context,
                                               IssuerOnlyContextResolver<T,R> supplier)
    Registers a context resolver that will never consume input. It will always satisfy its context based on the issuer of the command, so it will not appear in syntax strings.
    @@ -291,7 +291,7 @@ public <T> void 
  • registerOptionalContext

    -
    public <T> void registerOptionalContext(Class<T> context,
    +
    public <T> void registerOptionalContext(Class<T> context,
                                             OptionalContextResolver<T,R> supplier)
    Registers a context that can safely accept a null input from the command issuer to resolve. This resolver should always call CommandExecutionContext.popFirstArg()
    @@ -303,7 +303,7 @@ public <T> void 
  • registerContext

    -
    public <T> void registerContext(Class<T> context,
    +
    public <T> void registerContext(Class<T> context,
                                     ContextResolver<T,R> supplier)
    Registers a context that requires input from the command issuer to resolve. This resolver should always call CommandExecutionContext.popFirstArg()
    @@ -315,7 +315,7 @@ public <T> void 
  • getResolver

    -
    public ContextResolver<?,RgetResolver(Class<?> type)
    +
    public ContextResolver<?,RgetResolver(Class<?> type)
  • diff --git a/docs/acf-core/co/aikar/commands/CommandIssuer.html b/docs/acf-core/co/aikar/commands/CommandIssuer.html index 412cbfb9..88e83a16 100644 --- a/docs/acf-core/co/aikar/commands/CommandIssuer.html +++ b/docs/acf-core/co/aikar/commands/CommandIssuer.html @@ -18,7 +18,7 @@ catch(err) { } //--> -var methods = {"i0":6,"i1":6,"i2":6,"i3":6,"i4":18,"i5":18,"i6":18,"i7":18,"i8":18,"i9":18,"i10":18,"i11":38,"i12":18,"i13":18}; +var methods = {"i0":6,"i1":6,"i2":6,"i3":6,"i4":6,"i5":18,"i6":18,"i7":18,"i8":18,"i9":18,"i10":18,"i11":18,"i12":38,"i13":18,"i14":18}; var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],4:["t3","Abstract Methods"],16:["t5","Default Methods"],32:["t6","Deprecated Methods"]}; var altColor = "altColor"; var rowColor = "rowColor"; @@ -100,7 +100,7 @@ var activeTableTab = "activeTableTab";


  • -
    public interface CommandIssuer
    +
    public interface CommandIssuer
  • @@ -130,56 +130,60 @@ var activeTableTab = "activeTableTab"; getManager()  +@NotNull UUID +getUniqueId()  + + boolean hasPermission(String permission)
    Has permission node
    - + boolean isPlayer()
    Is this issue a player, or server/console sender
    - + default void sendError(co.aikar.locales.MessageKeyProvider key, String... replacements)  - + default void sendError(co.aikar.locales.MessageKey key, String... replacements)  - + default void sendInfo(co.aikar.locales.MessageKeyProvider key, String... replacements)  - + default void sendInfo(co.aikar.locales.MessageKey key, String... replacements)  - + default void sendMessage(MessageType type, co.aikar.locales.MessageKeyProvider key, String... replacements)  - + default void sendMessage(MessageType type, co.aikar.locales.MessageKey key, String... replacements)  - + default void sendMessage(String message)
    Send the Command Issuer a message
    - + void sendMessageInternal(String message)
    Deprecated.  @@ -187,12 +191,12 @@ var activeTableTab = "activeTableTab";
    - + default void sendSyntax(co.aikar.locales.MessageKeyProvider key, String... replacements)  - + default void sendSyntax(co.aikar.locales.MessageKey key, String... replacements)  @@ -218,7 +222,7 @@ var activeTableTab = "activeTableTab";
    • getIssuer

      -
      <T> T getIssuer()
      +
      <T> T getIssuer()
      Gets the issuer in the platforms native object
      Type Parameters:
      @@ -233,7 +237,7 @@ var activeTableTab = "activeTableTab"; @@ -242,7 +246,7 @@ var activeTableTab = "activeTableTab";
      • isPlayer

        -
        boolean isPlayer()
        +
        boolean isPlayer()
        Is this issue a player, or server/console sender
        Returns:
        @@ -255,7 +259,7 @@ var activeTableTab = "activeTableTab";
        • sendMessage

          -
          default void sendMessage(String message)
          +
          default void sendMessage(String message)
          Send the Command Issuer a message
          Parameters:
          @@ -263,13 +267,27 @@ var activeTableTab = "activeTableTab";
        + + + +
          +
        • +

          getUniqueId

          +
          @NotNull
          +@NotNull UUID getUniqueId()
          +
          +
          Returns:
          +
          the unique id of that issuer
          +
          +
        • +
        • hasPermission

          -
          boolean hasPermission(String permission)
          +
          boolean hasPermission(String permission)
          Has permission node
          Parameters:
          @@ -284,7 +302,7 @@ var activeTableTab = "activeTableTab";
          • sendError

            -
            default void sendError(co.aikar.locales.MessageKeyProvider key,
            +
            default void sendError(co.aikar.locales.MessageKeyProvider key,
                                    String... replacements)
          @@ -294,7 +312,7 @@ var activeTableTab = "activeTableTab";
          • sendSyntax

            -
            default void sendSyntax(co.aikar.locales.MessageKeyProvider key,
            +
            default void sendSyntax(co.aikar.locales.MessageKeyProvider key,
                                     String... replacements)
          @@ -304,7 +322,7 @@ var activeTableTab = "activeTableTab";
          • sendInfo

            -
            default void sendInfo(co.aikar.locales.MessageKeyProvider key,
            +
            default void sendInfo(co.aikar.locales.MessageKeyProvider key,
                                   String... replacements)
          @@ -314,7 +332,7 @@ var activeTableTab = "activeTableTab";
          • sendError

            -
            default void sendError(co.aikar.locales.MessageKey key,
            +
            default void sendError(co.aikar.locales.MessageKey key,
                                    String... replacements)
          @@ -324,7 +342,7 @@ var activeTableTab = "activeTableTab";
          • sendSyntax

            -
            default void sendSyntax(co.aikar.locales.MessageKey key,
            +
            default void sendSyntax(co.aikar.locales.MessageKey key,
                                     String... replacements)
          @@ -334,7 +352,7 @@ var activeTableTab = "activeTableTab";
          • sendInfo

            -
            default void sendInfo(co.aikar.locales.MessageKey key,
            +
            default void sendInfo(co.aikar.locales.MessageKey key,
                                   String... replacements)
          @@ -344,7 +362,7 @@ var activeTableTab = "activeTableTab";
    Deprecated. Do not call this, for internal use. Not considered part of the API and may break.
    Parameters:
    diff --git a/docs/acf-core/co/aikar/commands/CommandManager.html b/docs/acf-core/co/aikar/commands/CommandManager.html index b5d8d9d1..ae3f1362 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":10,"i43":10,"i44":42,"i45":10,"i46":10,"i47":10,"i48":10,"i49":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,"i50":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
  • @@ -153,22 +153,26 @@ extends formatters  +protected Map<UUID,Locale> +issuersLocale  + + protected List<IssuerLocaleChangedCallback<I>> localeChangedCallbacks  - + protected CommandReplacements replacements  - + protected Map<String,co.aikar.commands.RootCommand> rootCommands  - + protected Set<Locale> supportedLanguages  - + protected boolean usePerIssuerLocale  @@ -494,10 +498,15 @@ extends MF formatter)
      +Locale +setIssuerLocale(IT issuer, + Locale locale)  + + boolean usePerIssuerLocale(boolean setting)  - + boolean usingPerIssuerLocale()  @@ -529,7 +538,7 @@ extends
  • rootCommands

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

    -
    protected final CommandReplacements replacements
    +
    protected final CommandReplacements replacements
  • @@ -547,7 +556,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
  • @@ -556,7 +565,7 @@ extends
  • defaultExceptionHandler

    -
    protected ExceptionHandler defaultExceptionHandler
    +
    protected ExceptionHandler defaultExceptionHandler
  • @@ -565,7 +574,7 @@ extends
  • dependencies

    -
    protected com.google.common.collect.Table<Class<?>,String,Object> dependencies
    +
    protected com.google.common.collect.Table<Class<?>,String,Object> dependencies
  • @@ -574,7 +583,7 @@ extends
  • usePerIssuerLocale

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

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

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

    -
    protected Map<MessageType,MF extends MessageFormatter<FT>> formatters
    +
    protected Map<MessageType,MF extends MessageFormatter<FT>> formatters
  • @@ -610,16 +619,25 @@ extends
  • defaultFormatter

    -
    protected MF extends MessageFormatter<FT> defaultFormatter
    +
    protected MF extends MessageFormatter<FT> defaultFormatter
  • -
  • @@ -653,7 +671,7 @@ extends
  • getCurrentCommandOperationContext

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

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

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

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

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

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

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

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

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

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

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

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

    generateCommandHelp

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

    generateCommandHelp

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

    generateCommandHelp

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

    generateCommandHelp

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

    getDefaultHelpPerPage

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

    setDefaultHelpPerPage

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

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

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

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

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

    -
    public abstract co.aikar.commands.RootCommand createRootCommand(String cmd)
    +
    public abstract co.aikar.commands.RootCommand createRootCommand(String cmd)
  • @@ -903,7 +921,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:
    @@ -916,7 +934,7 @@ public void 
  • usingPerIssuerLocale

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

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

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

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

    -
    public abstract CommandCompletionContext createCompletionContext(RegisteredCommand command,
    +
    public abstract CommandCompletionContext createCompletionContext(RegisteredCommand command,
                                                                      CommandIssuer sender,
                                                                      String input,
                                                                      String config,
    @@ -971,7 +989,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)
  • @@ -982,7 +1000,7 @@ public void 
  • log

    -
    public void log(co.aikar.commands.LogLevel level,
    +
    public void log(co.aikar.commands.LogLevel level,
                     String message)
  • @@ -992,7 +1010,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. @@ -1011,7 +1029,7 @@ public void 
  • hasPermission

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

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

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

    -
    public RegisteredCommand createRegisteredCommand(BaseCommand command,
    +
    public RegisteredCommand createRegisteredCommand(BaseCommand command,
                                                      String cmdName,
                                                      Method method,
                                                      String prefSubCommand)
    @@ -1053,7 +1071,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:
    @@ -1067,7 +1085,7 @@ public void 
  • getDefaultExceptionHandler

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

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

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

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

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

    -
    public void onLocaleChange(IssuerLocaleChangedCallback<I> onChange)
    +
    public void onLocaleChange(IssuerLocaleChangedCallback<I> onChange)
  • @@ -1143,18 +1161,30 @@ public void 
  • notifyLocaleChange

    -
    public void notifyLocaleChange(I issuer,
    +
    public void notifyLocaleChange(I issuer,
                                    Locale oldLocale,
                                    Locale newLocale)
  • + + + + + + @@ -1163,7 +1193,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
    @@ -1177,7 +1207,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.
    @@ -1194,7 +1224,7 @@ public void 
  • registerDependency

    -
    public <T> void registerDependency(Class<? extends T> clazz,
    +
    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 @@ -1216,7 +1246,7 @@ public void 
  • registerDependency

    -
    public <T> void registerDependency(Class<? extends T> clazz,
    +
    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.
    @@ -1239,7 +1269,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/class-use/AnnotationProcessor.html b/docs/acf-core/co/aikar/commands/class-use/AnnotationProcessor.html new file mode 100644 index 00000000..3ceb7aeb --- /dev/null +++ b/docs/acf-core/co/aikar/commands/class-use/AnnotationProcessor.html @@ -0,0 +1,165 @@ + + + + + + +Uses of Interface co.aikar.commands.AnnotationProcessor (ACF (Core) 0.5.0-SNAPSHOT API) + + + + + + + + + + +
    +

    Uses of Interface
    co.aikar.commands.AnnotationProcessor

    +
    +
    + +
    + + + + +

    Copyright © 2018. All rights reserved.

    + + diff --git a/docs/acf-core/co/aikar/commands/class-use/BaseCommand.html b/docs/acf-core/co/aikar/commands/class-use/BaseCommand.html index 77cec406..6a7e2f71 100644 --- a/docs/acf-core/co/aikar/commands/class-use/BaseCommand.html +++ b/docs/acf-core/co/aikar/commands/class-use/BaseCommand.html @@ -159,6 +159,13 @@ Throwable t)  +default void +AnnotationProcessor.onBaseCommandRegister(BaseCommand command, + T annotation) +
    Deprecated. 
    +  + + abstract void CommandManager.registerCommand(BaseCommand command)
    Registers a command with ACF
    diff --git a/docs/acf-core/co/aikar/commands/class-use/CommandExecutionContext.html b/docs/acf-core/co/aikar/commands/class-use/CommandExecutionContext.html index 4752f0d3..b7134d1d 100644 --- a/docs/acf-core/co/aikar/commands/class-use/CommandExecutionContext.html +++ b/docs/acf-core/co/aikar/commands/class-use/CommandExecutionContext.html @@ -89,6 +89,10 @@ co.aikar.commands.contexts   + +co.aikar.commands.processors +  +
  • @@ -149,6 +153,28 @@ + + + + + + + + + + + + + + + + +
    Methods in co.aikar.commands with parameters of type CommandExecutionContext 
    Modifier and TypeMethod and Description
    default voidAnnotationProcessor.onPostContextResolution(CommandExecutionContext context, + Object resolvedValue) +
    Deprecated. 
    default voidAnnotationProcessor.onPreContextResolution(CommandExecutionContext context) +
    Deprecated. 
  • @@ -192,6 +218,27 @@
  • +
  • + + +

    Uses of CommandExecutionContext in co.aikar.commands.processors

    + + + + + + + + + + + + +
    Methods in co.aikar.commands.processors with parameters of type CommandExecutionContext 
    Modifier and TypeMethod and Description
    voidConditionsProcessor.onPostContextResolution(CommandExecutionContext context, + Object resolvedValue) +
    Deprecated. 
    +
  • diff --git a/docs/acf-core/co/aikar/commands/class-use/CommandOperationContext.html b/docs/acf-core/co/aikar/commands/class-use/CommandOperationContext.html index fa9bd8b9..fc5cd9b7 100644 --- a/docs/acf-core/co/aikar/commands/class-use/CommandOperationContext.html +++ b/docs/acf-core/co/aikar/commands/class-use/CommandOperationContext.html @@ -85,6 +85,10 @@ co.aikar.commands   + +co.aikar.commands.processors +  +
  • @@ -107,6 +111,47 @@ + + + + + + + + + + + + + + + + +
    Methods in co.aikar.commands with parameters of type CommandOperationContext 
    Modifier and TypeMethod and Description
    default voidAnnotationProcessor.onPostComand(CommandOperationContext context) +
    Deprecated. 
    default voidAnnotationProcessor.onPreComand(CommandOperationContext context) +
    Deprecated. 
    +
  • +
  • + + +

    Uses of CommandOperationContext in co.aikar.commands.processors

    + + + + + + + + + + + + +
    Methods in co.aikar.commands.processors with parameters of type CommandOperationContext 
    Modifier and TypeMethod and Description
    voidConditionsProcessor.onPreComand(CommandOperationContext context) +
    Deprecated. 
  • diff --git a/docs/acf-core/co/aikar/commands/class-use/RegisteredCommand.html b/docs/acf-core/co/aikar/commands/class-use/RegisteredCommand.html index 76d34e95..ba83104a 100644 --- a/docs/acf-core/co/aikar/commands/class-use/RegisteredCommand.html +++ b/docs/acf-core/co/aikar/commands/class-use/RegisteredCommand.html @@ -172,6 +172,22 @@ Throwable t)  +default void +AnnotationProcessor.onCommandRegistered(RegisteredCommand command, + T annotation) +
    Deprecated. 
    +  + + +default void +AnnotationProcessor.onParameterRegistered(RegisteredCommand command, + int parameterIndex, + Parameter p, + T annotation) +
    Deprecated. 
    +  + + void CommandOperationContext.setRegisteredCommand(RegisteredCommand registeredCommand)  diff --git a/docs/acf-core/co/aikar/commands/contexts/package-summary.html b/docs/acf-core/co/aikar/commands/contexts/package-summary.html index 03c84158..0d5bf672 100644 --- a/docs/acf-core/co/aikar/commands/contexts/package-summary.html +++ b/docs/acf-core/co/aikar/commands/contexts/package-summary.html @@ -43,7 +43,7 @@
  • @@ -892,6 +912,8 @@
    A context resolver that will never consume input, and only resolves using the context of the issuer of the command
    +
    issuersLocale - Variable in class co.aikar.commands.CommandManager
    +
     
    isThrowableNested() - Static method in class co.aikar.commands.apachecommonslang.ApacheCommonsExceptionUtil
    Checks if the Throwable class has a getCause method.
    @@ -1119,10 +1141,46 @@
    obtainRootCommand(String) - Method in class co.aikar.commands.CommandManager
     
    +
    onBaseCommandRegister(BaseCommand, T) - Method in interface co.aikar.commands.AnnotationProcessor
    +
    +
    Deprecated.
    +
    onCommandRegistered(RegisteredCommand, T) - Method in interface co.aikar.commands.AnnotationProcessor
    +
    +
    Deprecated.
    onIssuerLocaleChange(I, Locale, Locale) - Method in interface co.aikar.commands.IssuerLocaleChangedCallback
     
    onLocaleChange(IssuerLocaleChangedCallback<I>) - Method in class co.aikar.commands.CommandManager
     
    +
    onParameterRegistered(RegisteredCommand, int, Parameter, T) - Method in interface co.aikar.commands.AnnotationProcessor
    +
    +
    Deprecated.
    +
    onPostComand(CommandOperationContext) - Method in interface co.aikar.commands.AnnotationProcessor
    +
    +
    Deprecated.
    +
    onPostContextResolution(CommandExecutionContext, Object) - Method in interface co.aikar.commands.AnnotationProcessor
    +
    +
    Deprecated.
    +
    onPostContextResolution(CommandExecutionContext, Object) - Method in class co.aikar.commands.processors.ConditionsProcessor
    +
    +
    Deprecated.
    +
    onPreComand(CommandOperationContext) - Method in interface co.aikar.commands.AnnotationProcessor
    +
    +
    Deprecated.
    +
    onPreComand(CommandOperationContext) - Method in class co.aikar.commands.processors.ConditionsProcessor
    +
    +
    Deprecated.
    +
    onPreContextResolution(CommandExecutionContext) - Method in interface co.aikar.commands.AnnotationProcessor
    +
    +
    Deprecated.
    Optional - Annotation Type in co.aikar.commands.annotation
     
    OptionalContextResolver<T,C extends CommandExecutionContext<?,? extends CommandIssuer>> - Interface in co.aikar.commands.contexts
    @@ -1139,6 +1197,8 @@
     
    padRight(String, int) - Static method in class co.aikar.commands.ACFUtil
     
    +
    parseBigNumber(String, boolean) - Static method in class co.aikar.commands.ACFUtil
    +
     
    parseDouble(String) - Static method in class co.aikar.commands.ACFUtil
     
    parseDouble(String, Double) - Static method in class co.aikar.commands.ACFUtil
    @@ -1393,6 +1453,8 @@
     
    setFormat(MessageType, int, FT) - Method in class co.aikar.commands.CommandManager
     
    +
    setIssuerLocale(IT, Locale) - Method in class co.aikar.commands.CommandManager
    +
     
    setPage(int) - Method in class co.aikar.commands.CommandHelp
     
    setPage(int, int) - Method in class co.aikar.commands.CommandHelp
    diff --git a/docs/acf-core/overview-frame.html b/docs/acf-core/overview-frame.html index 4b45caaa..e7501e1c 100644 --- a/docs/acf-core/overview-frame.html +++ b/docs/acf-core/overview-frame.html @@ -17,6 +17,7 @@
  • co.aikar.commands.annotation
  • co.aikar.commands.apachecommonslang
  • co.aikar.commands.contexts
  • +
  • co.aikar.commands.processors
  •  

    diff --git a/docs/acf-core/overview-summary.html b/docs/acf-core/overview-summary.html index aa07bd66..3fae4d50 100644 --- a/docs/acf-core/overview-summary.html +++ b/docs/acf-core/overview-summary.html @@ -95,6 +95,10 @@ co.aikar.commands.contexts   + +co.aikar.commands.processors +  + diff --git a/docs/acf-core/overview-tree.html b/docs/acf-core/overview-tree.html index 66843017..4648f568 100644 --- a/docs/acf-core/overview-tree.html +++ b/docs/acf-core/overview-tree.html @@ -75,7 +75,8 @@
  • co.aikar.commands,
  • co.aikar.commands.annotation,
  • co.aikar.commands.apachecommonslang,
  • -
  • co.aikar.commands.contexts
  • +
  • co.aikar.commands.contexts,
  • +
  • co.aikar.commands.processors
  • @@ -101,6 +102,7 @@
  • co.aikar.commands.CommandOperationContext<I>
  • co.aikar.commands.CommandReplacements
  • co.aikar.commands.ConditionContext<I>
  • +
  • co.aikar.commands.processors.ConditionsProcessor (implements co.aikar.commands.AnnotationProcessor<T>)
  • co.aikar.commands.HelpEntry
  • co.aikar.commands.Locales
  • co.aikar.commands.MessageFormatter<FT>
  • @@ -132,6 +134,7 @@

    Interface Hierarchy

      +
    • co.aikar.commands.AnnotationProcessor<T>
    • co.aikar.commands.apachecommonslang.ApacheCommonsExceptionUtil.Nestable
    • co.aikar.commands.CommandCompletions.CommandCompletionHandler<C>
        diff --git a/docs/acf-core/package-list b/docs/acf-core/package-list index 6a9c4b6d..f3b5b277 100644 --- a/docs/acf-core/package-list +++ b/docs/acf-core/package-list @@ -2,3 +2,4 @@ co.aikar.commands co.aikar.commands.annotation co.aikar.commands.apachecommonslang co.aikar.commands.contexts +co.aikar.commands.processors diff --git a/docs/acf-core/src-html/co/aikar/commands/ACFUtil.html b/docs/acf-core/src-html/co/aikar/commands/ACFUtil.html index e8550a95..1d572352 100644 --- a/docs/acf-core/src-html/co/aikar/commands/ACFUtil.html +++ b/docs/acf-core/src-html/co/aikar/commands/ACFUtil.html @@ -443,150 +443,184 @@ 435 436 437 public static Number parseNumber(String num, boolean suffixes) { -438 double mod = 1; -439 if (suffixes) { -440 switch (num.charAt(num.length()-1)) { -441 case 'M': -442 case 'm': -443 mod = 1000000D; -444 num = num.substring(0, num.length()-1); -445 break; -446 case 'K': -447 case 'k': -448 mod = 1000D; -449 num = num.substring(0, num.length()-1); -450 } -451 } -452 -453 return Double.parseDouble(num) * mod; -454 } -455 -456 public static <T> boolean hasIntersection(Collection<T> list1, Collection<T> list2) { -457 for (T t : list1) { -458 if (list2.contains(t)) { -459 return true; -460 } -461 } -462 -463 return false; -464 } -465 -466 public static <T> Collection<T> intersection(Collection<T> list1, Collection<T> list2) { -467 List<T> list = new ArrayList<>(); -468 -469 for (T t : list1) { -470 if(list2.contains(t)) { -471 list.add(t); -472 } -473 } -474 -475 return list; -476 } -477 -478 public static int rand(int min, int max) { -479 return min + RANDOM.nextInt(max - min + 1); -480 } -481 -482 /** -483 * Calculate random between 2 points, excluding a center -484 * ex: Util.rand(-12, -6, 6, 12) would not return -5 to 5 -485 * @param min1 -486 * @param max1 -487 * @param min2 -488 * @param max2 -489 * @return -490 */ -491 public static int rand(int min1, int max1, int min2, int max2) { -492 return randBool() ? rand(min1, max1) : rand(min2, max2); -493 } -494 -495 public static double rand(double min, double max) { -496 return RANDOM.nextDouble() * (max - min) + min; -497 } -498 -499 public static boolean isNumber(String str) { -500 return ApacheCommonsLangUtil.isNumeric(str); -501 } -502 -503 public static String intToRoman(int integer) { -504 if (integer == 1) { -505 return "I"; -506 } -507 if (integer == 2) { -508 return "II"; -509 } -510 if (integer == 3) { -511 return "III"; -512 } -513 if (integer == 4) { -514 return "IV"; -515 } -516 if (integer == 5) { -517 return "V"; -518 } -519 if (integer == 6) { -520 return "VI"; -521 } -522 if (integer == 7) { -523 return "VII"; -524 } -525 if (integer == 8) { -526 return "VIII"; -527 } -528 if (integer == 9) { -529 return "IX"; -530 } -531 if (integer == 10) { -532 return "X"; -533 } -534 return null; -535 } -536 -537 public static boolean isInteger(String string) { -538 return ACFPatterns.INTEGER.matcher(string).matches(); -539 } -540 -541 public static boolean isFloat(String string) { -542 try { -543 //noinspection ResultOfMethodCallIgnored -544 Float.parseFloat(string); -545 return true; -546 } catch (Exception e) { -547 return false; -548 } -549 } -550 -551 public static boolean isDouble(String string) { -552 try { -553 //noinspection ResultOfMethodCallIgnored -554 Double.parseDouble(string); -555 return true; -556 } catch (Exception e) { -557 return false; -558 } -559 } -560 -561 public static boolean isBetween(float num, double min, double max) { -562 return num >= min && num <= max; -563 } -564 -565 @SuppressWarnings("SameParameterValue") -566 public static double precision(double x, int p) { -567 double pow = Math.pow(10, p); -568 return Math.round(x * pow) / pow; -569 } -570 -571 public static void sneaky(Throwable t) { -572 //noinspection RedundantTypeArguments -573 throw ACFUtil.<RuntimeException>superSneaky( t ); -574 } -575 -576 private static <T extends Throwable> T superSneaky(Throwable t) throws T { -577 //noinspection ConstantConditions,unchecked -578 throw (T) t; -579 } -580 -581} +438 ApplyModifierToNumber applyModifierToNumber = new ApplyModifierToNumber(num, suffixes).invoke(); +439 num = applyModifierToNumber.getNum(); +440 double mod = applyModifierToNumber.getMod(); +441 +442 return Double.parseDouble(num) * mod; +443 } +444 +445 public static BigDecimal parseBigNumber(String num, boolean suffixes) { +446 ApplyModifierToNumber applyModifierToNumber = new ApplyModifierToNumber(num, suffixes).invoke(); +447 num = applyModifierToNumber.getNum(); +448 double mod = applyModifierToNumber.getMod(); +449 +450 BigDecimal big = new BigDecimal(num); +451 return (mod == 1) ? big : big.multiply(new BigDecimal(mod)); +452 } +453 +454 public static <T> boolean hasIntersection(Collection<T> list1, Collection<T> list2) { +455 for (T t : list1) { +456 if (list2.contains(t)) { +457 return true; +458 } +459 } +460 +461 return false; +462 } +463 +464 public static <T> Collection<T> intersection(Collection<T> list1, Collection<T> list2) { +465 List<T> list = new ArrayList<>(); +466 +467 for (T t : list1) { +468 if(list2.contains(t)) { +469 list.add(t); +470 } +471 } +472 +473 return list; +474 } +475 +476 public static int rand(int min, int max) { +477 return min + RANDOM.nextInt(max - min + 1); +478 } +479 +480 /** +481 * Calculate random between 2 points, excluding a center +482 * ex: Util.rand(-12, -6, 6, 12) would not return -5 to 5 +483 * @param min1 +484 * @param max1 +485 * @param min2 +486 * @param max2 +487 * @return +488 */ +489 public static int rand(int min1, int max1, int min2, int max2) { +490 return randBool() ? rand(min1, max1) : rand(min2, max2); +491 } +492 +493 public static double rand(double min, double max) { +494 return RANDOM.nextDouble() * (max - min) + min; +495 } +496 +497 public static boolean isNumber(String str) { +498 return ApacheCommonsLangUtil.isNumeric(str); +499 } +500 +501 public static String intToRoman(int integer) { +502 if (integer == 1) { +503 return "I"; +504 } +505 if (integer == 2) { +506 return "II"; +507 } +508 if (integer == 3) { +509 return "III"; +510 } +511 if (integer == 4) { +512 return "IV"; +513 } +514 if (integer == 5) { +515 return "V"; +516 } +517 if (integer == 6) { +518 return "VI"; +519 } +520 if (integer == 7) { +521 return "VII"; +522 } +523 if (integer == 8) { +524 return "VIII"; +525 } +526 if (integer == 9) { +527 return "IX"; +528 } +529 if (integer == 10) { +530 return "X"; +531 } +532 return null; +533 } +534 +535 public static boolean isInteger(String string) { +536 return ACFPatterns.INTEGER.matcher(string).matches(); +537 } +538 +539 public static boolean isFloat(String string) { +540 try { +541 //noinspection ResultOfMethodCallIgnored +542 Float.parseFloat(string); +543 return true; +544 } catch (Exception e) { +545 return false; +546 } +547 } +548 +549 public static boolean isDouble(String string) { +550 try { +551 //noinspection ResultOfMethodCallIgnored +552 Double.parseDouble(string); +553 return true; +554 } catch (Exception e) { +555 return false; +556 } +557 } +558 +559 public static boolean isBetween(float num, double min, double max) { +560 return num >= min && num <= max; +561 } +562 +563 @SuppressWarnings("SameParameterValue") +564 public static double precision(double x, int p) { +565 double pow = Math.pow(10, p); +566 return Math.round(x * pow) / pow; +567 } +568 +569 public static void sneaky(Throwable t) { +570 //noinspection RedundantTypeArguments +571 throw ACFUtil.<RuntimeException>superSneaky( t ); +572 } +573 +574 private static <T extends Throwable> T superSneaky(Throwable t) throws T { +575 //noinspection ConstantConditions,unchecked +576 throw (T) t; +577 } +578 +579 private static class ApplyModifierToNumber { +580 private String num; +581 private boolean suffixes; +582 private double mod; +583 +584 public ApplyModifierToNumber(String num, boolean suffixes) { +585 this.num = num; +586 this.suffixes = suffixes; +587 } +588 +589 public String getNum() { +590 return num; +591 } +592 +593 public double getMod() { +594 return mod; +595 } +596 +597 public ApplyModifierToNumber invoke() { +598 mod = 1; +599 if (suffixes) { +600 switch (num.charAt(num.length()-1)) { +601 case 'M': +602 case 'm': +603 mod = 1000000D; +604 num = num.substring(0, num.length()-1); +605 break; +606 case 'K': +607 case 'k': +608 mod = 1000D; +609 num = num.substring(0, num.length()-1); +610 } +611 } +612 return this; +613 } +614 } +615} diff --git a/docs/acf-core/src-html/co/aikar/commands/AnnotationProcessor.html b/docs/acf-core/src-html/co/aikar/commands/AnnotationProcessor.html new file mode 100644 index 00000000..07e8b025 --- /dev/null +++ b/docs/acf-core/src-html/co/aikar/commands/AnnotationProcessor.html @@ -0,0 +1,134 @@ + + + +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
        +026import org.jetbrains.annotations.Nullable;
        +027
        +028import java.lang.annotation.Annotation;
        +029import java.lang.reflect.Parameter;
        +030import java.util.Set;
        +031
        +032@Deprecated /* @deprecated UNFINISHED */
        +033public interface AnnotationProcessor <T extends Annotation> {
        +034
        +035    @Nullable
        +036    default Set<Class<?>> getApplicableParameters() {
        +037        return null;
        +038    }
        +039
        +040    default void onBaseCommandRegister(BaseCommand command, T annotation) {
        +041
        +042    }
        +043    default void onCommandRegistered(RegisteredCommand command, T annotation) {
        +044
        +045    }
        +046    default void onParameterRegistered(RegisteredCommand command, int parameterIndex, Parameter p, T annotation) {
        +047
        +048    }
        +049    default void onPreComand(CommandOperationContext context) {
        +050
        +051    }
        +052    default void onPostComand(CommandOperationContext context) {
        +053
        +054    }
        +055    default void onPreContextResolution(CommandExecutionContext context) {
        +056
        +057    }
        +058    default void onPostContextResolution(CommandExecutionContext context, Object resolvedValue) {
        +059
        +060    }
        +061
        +062}
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        + + 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 0e63a6c7..f00c26d5 100644 --- a/docs/acf-core/src-html/co/aikar/commands/BaseCommand.html +++ b/docs/acf-core/src-html/co/aikar/commands/BaseCommand.html @@ -290,406 +290,410 @@ 282 283 // Strip pipes off for auto complete addition 284 for (int i = 0; i < subCommandParts.length; i++) { -285 subCommandParts[i] = ACFPatterns.PIPE.split(subCommandParts[i])[0]; -286 } -287 String prefSubCommand = ApacheCommonsLangUtil.join(subCommandParts, " "); -288 final CommandAlias cmdAlias = method.getAnnotation(CommandAlias.class); -289 -290 final String[] aliasNames = cmdAlias != null ? ACFPatterns.PIPE.split(manager.getCommandReplacements().replace(cmdAlias.value().toLowerCase())) : null; -291 String cmdName = aliasNames != null ? aliasNames[0] : this.commandName + " "; -292 RegisteredCommand cmd = manager.createRegisteredCommand(this, cmdName, method, prefSubCommand); +285 String[] split = ACFPatterns.PIPE.split(subCommandParts[i]); +286 if (split.length == 0 || split[0].isEmpty()) { +287 throw new IllegalArgumentException("Invalid @Subcommand configuration for " + method.getName() + " - parts can not start with | or be empty"); +288 } +289 subCommandParts[i] = split[0]; +290 } +291 String prefSubCommand = ApacheCommonsLangUtil.join(subCommandParts, " "); +292 final CommandAlias cmdAlias = method.getAnnotation(CommandAlias.class); 293 -294 for (String subcmd : cmdList) { -295 subCommands.put(subcmd, cmd); -296 } -297 cmd.addSubcommands(cmdList); -298 -299 if (aliasNames != null) { -300 for (String name : aliasNames) { -301 register(name, new ForwardingCommand(this, subCommandParts)); -302 } -303 } -304 } -305 -306 /** -307 * Takes a string like "foo|bar baz|qux" and generates a list of -308 * - foo baz -309 * - foo qux -310 * - bar baz -311 * - bar qux -312 * -313 * For every possible sub command combination -314 * -315 * @param subCommandParts -316 * @return List of all sub command possibilities -317 */ -318 private static Set<String> getSubCommandPossibilityList(String[] subCommandParts) { -319 int i = 0; -320 Set<String> current = null; -321 while (true) { -322 Set<String> newList = new HashSet<>(); -323 -324 if (i < subCommandParts.length) { -325 for (String s1 : ACFPatterns.PIPE.split(subCommandParts[i])) { -326 if (current != null) { -327 newList.addAll(current.stream().map(s -> s + " " + s1).collect(Collectors.toList())); -328 } else { -329 newList.add(s1); -330 } -331 } -332 } -333 -334 if (i + 1 < subCommandParts.length) { -335 current = newList; -336 i = i + 1; -337 continue; -338 } -339 -340 return newList; -341 } -342 } +294 final String[] aliasNames = cmdAlias != null ? ACFPatterns.PIPE.split(manager.getCommandReplacements().replace(cmdAlias.value().toLowerCase())) : null; +295 String cmdName = aliasNames != null ? aliasNames[0] : this.commandName + " "; +296 RegisteredCommand cmd = manager.createRegisteredCommand(this, cmdName, method, prefSubCommand); +297 +298 for (String subcmd : cmdList) { +299 subCommands.put(subcmd, cmd); +300 } +301 cmd.addSubcommands(cmdList); +302 +303 if (aliasNames != null) { +304 for (String name : aliasNames) { +305 register(name, new ForwardingCommand(this, subCommandParts)); +306 } +307 } +308 } +309 +310 /** +311 * Takes a string like "foo|bar baz|qux" and generates a list of +312 * - foo baz +313 * - foo qux +314 * - bar baz +315 * - bar qux +316 * +317 * For every possible sub command combination +318 * +319 * @param subCommandParts +320 * @return List of all sub command possibilities +321 */ +322 private static Set<String> getSubCommandPossibilityList(String[] subCommandParts) { +323 int i = 0; +324 Set<String> current = null; +325 while (true) { +326 Set<String> newList = new HashSet<>(); +327 +328 if (i < subCommandParts.length) { +329 for (String s1 : ACFPatterns.PIPE.split(subCommandParts[i])) { +330 if (current != null) { +331 newList.addAll(current.stream().map(s -> s + " " + s1).collect(Collectors.toList())); +332 } else { +333 newList.add(s1); +334 } +335 } +336 } +337 +338 if (i + 1 < subCommandParts.length) { +339 current = newList; +340 i = i + 1; +341 continue; +342 } 343 -344 public void execute(CommandIssuer issuer, String commandLabel, String[] args) { -345 commandLabel = commandLabel.toLowerCase(); -346 try { -347 CommandOperationContext commandContext = preCommandOperation(issuer, commandLabel, args, false); -348 -349 if (args.length > 0) { -350 CommandSearch cmd = findSubCommand(args); -351 if (cmd != null) { -352 execSubcommand = cmd.getCheckSub(); -353 final String[] execargs = Arrays.copyOfRange(args, cmd.argIndex, args.length); -354 executeCommand(commandContext, issuer, execargs, cmd.cmd); -355 return; -356 } -357 } -358 -359 if (subCommands.get(DEFAULT) != null && args.length == 0) { -360 executeSubcommand(commandContext, DEFAULT, 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) { -366 executeSubcommand(commandContext, DEFAULT, issuer, args); -367 } -368 -369 } finally { -370 postCommandOperation(); -371 } -372 } -373 -374 RegisteredCommand<?> getRegisteredCommand(String[] args) { -375 final CommandSearch cmd = findSubCommand(args); -376 return cmd != null ? cmd.cmd : null; -377 } -378 -379 private void postCommandOperation() { -380 CommandManager.commandOperationContext.get().pop(); -381 execSubcommand = null; -382 execLabel = null; -383 origArgs = new String[]{}; -384 } -385 -386 private CommandOperationContext preCommandOperation(CommandIssuer issuer, String commandLabel, String[] args, boolean isAsync) { -387 Stack<CommandOperationContext> contexts = CommandManager.commandOperationContext.get(); -388 CommandOperationContext context = this.manager.createCommandOperationContext(this, issuer, commandLabel, args, isAsync); -389 contexts.push(context); -390 lastCommandOperationContext = context; -391 execSubcommand = null; -392 execLabel = commandLabel; -393 origArgs = args; -394 return context; -395 } -396 -397 public CommandIssuer getCurrentCommandIssuer() { -398 return CommandManager.getCurrentCommandIssuer(); +344 return newList; +345 } +346 } +347 +348 public void execute(CommandIssuer issuer, String commandLabel, String[] args) { +349 commandLabel = commandLabel.toLowerCase(); +350 try { +351 CommandOperationContext commandContext = preCommandOperation(issuer, commandLabel, args, false); +352 +353 if (args.length > 0) { +354 CommandSearch cmd = findSubCommand(args); +355 if (cmd != null) { +356 execSubcommand = cmd.getCheckSub(); +357 final String[] execargs = Arrays.copyOfRange(args, cmd.argIndex, args.length); +358 executeCommand(commandContext, issuer, execargs, cmd.cmd); +359 return; +360 } +361 } +362 +363 if (subCommands.get(DEFAULT) != null && args.length == 0) { +364 executeSubcommand(commandContext, DEFAULT, issuer, args); +365 } else if (subCommands.get(CATCHUNKNOWN) != null) { +366 if (!executeSubcommand(commandContext, CATCHUNKNOWN, issuer, args)) { +367 help(issuer, args); +368 } +369 } else if (subCommands.get(DEFAULT) != null) { +370 executeSubcommand(commandContext, DEFAULT, issuer, args); +371 } +372 +373 } finally { +374 postCommandOperation(); +375 } +376 } +377 +378 RegisteredCommand<?> getRegisteredCommand(String[] args) { +379 final CommandSearch cmd = findSubCommand(args); +380 return cmd != null ? cmd.cmd : null; +381 } +382 +383 private void postCommandOperation() { +384 CommandManager.commandOperationContext.get().pop(); +385 execSubcommand = null; +386 execLabel = null; +387 origArgs = new String[]{}; +388 } +389 +390 private CommandOperationContext preCommandOperation(CommandIssuer issuer, String commandLabel, String[] args, boolean isAsync) { +391 Stack<CommandOperationContext> contexts = CommandManager.commandOperationContext.get(); +392 CommandOperationContext context = this.manager.createCommandOperationContext(this, issuer, commandLabel, args, isAsync); +393 contexts.push(context); +394 lastCommandOperationContext = context; +395 execSubcommand = null; +396 execLabel = commandLabel; +397 origArgs = args; +398 return context; 399 } -400 public CommandManager getCurrentCommandManager() { -401 return CommandManager.getCurrentCommandManager(); -402 } -403 -404 private CommandSearch findSubCommand(String[] args) { -405 return findSubCommand(args, false); +400 +401 public CommandIssuer getCurrentCommandIssuer() { +402 return CommandManager.getCurrentCommandIssuer(); +403 } +404 public CommandManager getCurrentCommandManager() { +405 return CommandManager.getCurrentCommandManager(); 406 } -407 private CommandSearch findSubCommand(String[] args, boolean completion) { -408 for (int i = args.length; i >= 0; i--) { -409 String checkSub = ApacheCommonsLangUtil.join(args, " ", 0, i).toLowerCase(); -410 Set<RegisteredCommand> cmds = subCommands.get(checkSub); -411 -412 final int extraArgs = args.length - i; -413 if (!cmds.isEmpty()) { -414 RegisteredCommand cmd = null; -415 if (cmds.size() == 1) { -416 cmd = Iterables.getOnlyElement(cmds); -417 } else { -418 Optional<RegisteredCommand> optCmd = cmds.stream().filter(c -> { -419 int required = c.requiredResolvers; -420 int optional = c.optionalResolvers; -421 return extraArgs <= required + optional && (completion || extraArgs >= required); -422 }).sorted((c1, c2) -> { -423 int a = c1.requiredResolvers + c1.optionalResolvers; -424 int b = c2.requiredResolvers + c2.optionalResolvers; -425 -426 if (a == b) { -427 return 0; -428 } -429 return a < b ? 1 : -1; -430 }).findFirst(); -431 if (optCmd.isPresent()) { -432 cmd = optCmd.get(); -433 } -434 } -435 if (cmd != null) { -436 return new CommandSearch(cmd, i, checkSub); -437 } -438 } -439 } -440 return null; -441 } -442 -443 private void executeCommand(CommandOperationContext commandOperationContext, -444 CommandIssuer issuer, String[] args, RegisteredCommand cmd) { -445 if (cmd.hasPermission(issuer)) { -446 commandOperationContext.setRegisteredCommand(cmd); -447 if (checkPrecommand(commandOperationContext, cmd, issuer, args)) { -448 return; -449 } -450 List<String> sargs = Lists.newArrayList(args); -451 cmd.invoke(issuer, sargs, commandOperationContext); -452 } else { -453 issuer.sendMessage(MessageType.ERROR, MessageKeys.PERMISSION_DENIED); -454 } -455 } -456 -457 public boolean canExecute(CommandIssuer issuer, RegisteredCommand<?> cmd) { -458 return true; +407 +408 private CommandSearch findSubCommand(String[] args) { +409 return findSubCommand(args, false); +410 } +411 private CommandSearch findSubCommand(String[] args, boolean completion) { +412 for (int i = args.length; i >= 0; i--) { +413 String checkSub = ApacheCommonsLangUtil.join(args, " ", 0, i).toLowerCase(); +414 Set<RegisteredCommand> cmds = subCommands.get(checkSub); +415 +416 final int extraArgs = args.length - i; +417 if (!cmds.isEmpty()) { +418 RegisteredCommand cmd = null; +419 if (cmds.size() == 1) { +420 cmd = Iterables.getOnlyElement(cmds); +421 } else { +422 Optional<RegisteredCommand> optCmd = cmds.stream().filter(c -> { +423 int required = c.requiredResolvers; +424 int optional = c.optionalResolvers; +425 return extraArgs <= required + optional && (completion || extraArgs >= required); +426 }).sorted((c1, c2) -> { +427 int a = c1.requiredResolvers + c1.optionalResolvers; +428 int b = c2.requiredResolvers + c2.optionalResolvers; +429 +430 if (a == b) { +431 return 0; +432 } +433 return a < b ? 1 : -1; +434 }).findFirst(); +435 if (optCmd.isPresent()) { +436 cmd = optCmd.get(); +437 } +438 } +439 if (cmd != null) { +440 return new CommandSearch(cmd, i, checkSub); +441 } +442 } +443 } +444 return null; +445 } +446 +447 private void executeCommand(CommandOperationContext commandOperationContext, +448 CommandIssuer issuer, String[] args, RegisteredCommand cmd) { +449 if (cmd.hasPermission(issuer)) { +450 commandOperationContext.setRegisteredCommand(cmd); +451 if (checkPrecommand(commandOperationContext, cmd, issuer, args)) { +452 return; +453 } +454 List<String> sargs = Lists.newArrayList(args); +455 cmd.invoke(issuer, sargs, commandOperationContext); +456 } else { +457 issuer.sendMessage(MessageType.ERROR, MessageKeys.PERMISSION_DENIED); +458 } 459 } 460 -461 public List<String> tabComplete(CommandIssuer issuer, String commandLabel, String[] args) { -462 return tabComplete(issuer, commandLabel, args, false); +461 public boolean canExecute(CommandIssuer issuer, RegisteredCommand<?> cmd) { +462 return true; 463 } -464 public List<String> tabComplete(CommandIssuer issuer, String commandLabel, String[] args, boolean isAsync) -465 throws IllegalArgumentException { -466 -467 commandLabel = commandLabel.toLowerCase(); -468 if (args.length == 0) { -469 args = new String[]{""}; -470 } -471 try { -472 CommandOperationContext commandOperationContext = preCommandOperation(issuer, commandLabel, args, isAsync); -473 -474 final CommandSearch search = findSubCommand(args, true); -475 -476 -477 final List<String> cmds = new ArrayList<>(); -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(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 } -486 -487 return filterTabComplete(args[args.length - 1], cmds); -488 } finally { -489 postCommandOperation(); -490 } -491 } -492 -493 List<String> getCommandsForCompletion(CommandIssuer issuer, String[] args) { -494 final Set<String> cmds = new HashSet<>(); -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) && !CATCHUNKNOWN.equals(key) && !DEFAULT.equals(key)) { -499 final RegisteredCommand value = entry.getValue(); -500 if (!value.hasPermission(issuer)) { -501 continue; -502 } -503 -504 String[] split = ACFPatterns.SPACE.split(value.prefSubCommand); -505 cmds.add(split[args.length - 1]); -506 } -507 } -508 return new ArrayList<>(cmds); -509 } -510 -511 private List<String> completeCommand(CommandIssuer issuer, RegisteredCommand cmd, String[] args, String commandLabel, boolean isAsync) { -512 if (!cmd.hasPermission(issuer) || args.length > cmd.requiredResolvers + cmd.optionalResolvers || args.length == 0 -513 || cmd.complete == null) { -514 return ImmutableList.of(); -515 } -516 -517 String[] completions = ACFPatterns.SPACE.split(cmd.complete); -518 -519 List<String> cmds = manager.getCommandCompletions().of(cmd, issuer, completions, args, isAsync); -520 return filterTabComplete(args[args.length-1], cmds); -521 } +464 +465 public List<String> tabComplete(CommandIssuer issuer, String commandLabel, String[] args) { +466 return tabComplete(issuer, commandLabel, args, false); +467 } +468 public List<String> tabComplete(CommandIssuer issuer, String commandLabel, String[] args, boolean isAsync) +469 throws IllegalArgumentException { +470 +471 commandLabel = commandLabel.toLowerCase(); +472 if (args.length == 0) { +473 args = new String[]{""}; +474 } +475 try { +476 CommandOperationContext commandOperationContext = preCommandOperation(issuer, commandLabel, args, isAsync); +477 +478 final CommandSearch search = findSubCommand(args, true); +479 +480 +481 final List<String> cmds = new ArrayList<>(); +482 +483 if (search != null) { +484 cmds.addAll(completeCommand(issuer, search.cmd, Arrays.copyOfRange(args, search.argIndex, args.length), commandLabel, isAsync)); +485 } else if (subCommands.get(CATCHUNKNOWN).size() == 1) { +486 cmds.addAll(completeCommand(issuer, Iterables.getOnlyElement(subCommands.get(CATCHUNKNOWN)), args, commandLabel, isAsync)); +487 } else if (subCommands.get(DEFAULT).size() == 1) { +488 cmds.addAll(completeCommand(issuer, Iterables.getOnlyElement(subCommands.get(DEFAULT)), args, commandLabel, isAsync)); +489 } +490 +491 return filterTabComplete(args[args.length - 1], cmds); +492 } finally { +493 postCommandOperation(); +494 } +495 } +496 +497 List<String> getCommandsForCompletion(CommandIssuer issuer, String[] args) { +498 final Set<String> cmds = new HashSet<>(); +499 String argString = ApacheCommonsLangUtil.join(args, " ").toLowerCase(); +500 for (Map.Entry<String, RegisteredCommand> entry : subCommands.entries()) { +501 final String key = entry.getKey(); +502 if (key.startsWith(argString) && !CATCHUNKNOWN.equals(key) && !DEFAULT.equals(key)) { +503 final RegisteredCommand value = entry.getValue(); +504 if (!value.hasPermission(issuer)) { +505 continue; +506 } +507 +508 String[] split = ACFPatterns.SPACE.split(value.prefSubCommand); +509 cmds.add(split[args.length - 1]); +510 } +511 } +512 return new ArrayList<>(cmds); +513 } +514 +515 private List<String> completeCommand(CommandIssuer issuer, RegisteredCommand cmd, String[] args, String commandLabel, boolean isAsync) { +516 if (!cmd.hasPermission(issuer) || args.length > cmd.requiredResolvers + cmd.optionalResolvers || args.length == 0 +517 || cmd.complete == null) { +518 return ImmutableList.of(); +519 } +520 +521 String[] completions = ACFPatterns.SPACE.split(cmd.complete); 522 -523 private static List<String> filterTabComplete(String arg, List<String> cmds) { -524 return cmds.stream() -525 .distinct() -526 .filter(cmd -> cmd != null && (arg.isEmpty() || ApacheCommonsLangUtil.startsWithIgnoreCase(cmd, arg))) -527 .collect(Collectors.toList()); -528 } -529 -530 RegisteredCommand getSubcommand(String subcommand) { -531 return getSubcommand(subcommand, false); +523 List<String> cmds = manager.getCommandCompletions().of(cmd, issuer, completions, args, isAsync); +524 return filterTabComplete(args[args.length-1], cmds); +525 } +526 +527 private static List<String> filterTabComplete(String arg, List<String> cmds) { +528 return cmds.stream() +529 .distinct() +530 .filter(cmd -> cmd != null && (arg.isEmpty() || ApacheCommonsLangUtil.startsWithIgnoreCase(cmd, arg))) +531 .collect(Collectors.toList()); 532 } 533 -534 RegisteredCommand getSubcommand(String subcommand, boolean requireOne) { -535 final Set<RegisteredCommand> commands = subCommands.get(subcommand); -536 if (!commands.isEmpty() && (!requireOne || commands.size() == 1)) { -537 return commands.iterator().next(); -538 } -539 return null; -540 } -541 -542 private boolean executeSubcommand(CommandOperationContext commandContext, String subcommand, CommandIssuer issuer, String... args) { -543 final RegisteredCommand cmd = this.getSubcommand(subcommand); -544 if (cmd != null) { -545 executeCommand(commandContext, issuer, args, cmd); -546 return true; -547 } -548 -549 return false; -550 } -551 -552 private boolean checkPrecommand(CommandOperationContext commandOperationContext, RegisteredCommand cmd, CommandIssuer issuer, String[] args) { -553 Method pre = this.preCommandHandler; -554 if (pre != null) { -555 try { -556 Class<?>[] types = pre.getParameterTypes(); -557 Object[] parameters = new Object[pre.getParameterCount()]; -558 for (int i = 0; i < parameters.length; i++) { -559 Class<?> type = types[i]; -560 Object issuerObject = issuer.getIssuer(); -561 if (manager.isCommandIssuer(type) && type.isAssignableFrom(issuerObject.getClass())) { -562 parameters[i] = issuerObject; -563 } else if (CommandIssuer.class.isAssignableFrom(type)) { -564 parameters[i] = issuer; -565 } else if (RegisteredCommand.class.isAssignableFrom(type)) { -566 parameters[i] = cmd; -567 } else if (String[].class.isAssignableFrom((type))) { -568 parameters[i] = args; -569 } else { -570 parameters[i] = null; -571 } -572 } -573 -574 return (boolean) pre.invoke(this, parameters); -575 } catch (IllegalAccessException | InvocationTargetException e) { -576 this.manager.log(LogLevel.ERROR, "Exception encountered while command pre-processing", e); -577 } -578 } -579 return false; -580 } -581 -582 /** @deprecated Unstable API */ @Deprecated @UnstableAPI -583 public CommandHelp getCommandHelp() { -584 return manager.generateCommandHelp(); -585 } -586 -587 /** @deprecated Unstable API */ @Deprecated @UnstableAPI -588 public void showCommandHelp() { -589 getCommandHelp().showHelp(); -590 } -591 -592 public void help(Object issuer, String[] args) { -593 help(manager.getCommandIssuer(issuer), args); +534 RegisteredCommand getSubcommand(String subcommand) { +535 return getSubcommand(subcommand, false); +536 } +537 +538 RegisteredCommand getSubcommand(String subcommand, boolean requireOne) { +539 final Set<RegisteredCommand> commands = subCommands.get(subcommand); +540 if (!commands.isEmpty() && (!requireOne || commands.size() == 1)) { +541 return commands.iterator().next(); +542 } +543 return null; +544 } +545 +546 private boolean executeSubcommand(CommandOperationContext commandContext, String subcommand, CommandIssuer issuer, String... args) { +547 final RegisteredCommand cmd = this.getSubcommand(subcommand); +548 if (cmd != null) { +549 executeCommand(commandContext, issuer, args, cmd); +550 return true; +551 } +552 +553 return false; +554 } +555 +556 private boolean checkPrecommand(CommandOperationContext commandOperationContext, RegisteredCommand cmd, CommandIssuer issuer, String[] args) { +557 Method pre = this.preCommandHandler; +558 if (pre != null) { +559 try { +560 Class<?>[] types = pre.getParameterTypes(); +561 Object[] parameters = new Object[pre.getParameterCount()]; +562 for (int i = 0; i < parameters.length; i++) { +563 Class<?> type = types[i]; +564 Object issuerObject = issuer.getIssuer(); +565 if (manager.isCommandIssuer(type) && type.isAssignableFrom(issuerObject.getClass())) { +566 parameters[i] = issuerObject; +567 } else if (CommandIssuer.class.isAssignableFrom(type)) { +568 parameters[i] = issuer; +569 } else if (RegisteredCommand.class.isAssignableFrom(type)) { +570 parameters[i] = cmd; +571 } else if (String[].class.isAssignableFrom((type))) { +572 parameters[i] = args; +573 } else { +574 parameters[i] = null; +575 } +576 } +577 +578 return (boolean) pre.invoke(this, parameters); +579 } catch (IllegalAccessException | InvocationTargetException e) { +580 this.manager.log(LogLevel.ERROR, "Exception encountered while command pre-processing", e); +581 } +582 } +583 return false; +584 } +585 +586 /** @deprecated Unstable API */ @Deprecated @UnstableAPI +587 public CommandHelp getCommandHelp() { +588 return manager.generateCommandHelp(); +589 } +590 +591 /** @deprecated Unstable API */ @Deprecated @UnstableAPI +592 public void showCommandHelp() { +593 getCommandHelp().showHelp(); 594 } -595 public void help(CommandIssuer issuer, String[] args) { -596 issuer.sendMessage(MessageType.ERROR, MessageKeys.UNKNOWN_COMMAND); -597 } -598 public void doHelp(Object issuer, String... args) { -599 doHelp(manager.getCommandIssuer(issuer), args); -600 } -601 public void doHelp(CommandIssuer issuer, String... args) { -602 help(issuer, args); -603 } -604 -605 public void showSyntax(CommandIssuer issuer, RegisteredCommand<?> cmd) { -606 issuer.sendMessage(MessageType.SYNTAX, MessageKeys.INVALID_SYNTAX, -607 "{command}", "/" + cmd.command, -608 "{syntax}", cmd.syntaxText -609 ); -610 } -611 -612 public boolean hasPermission(Object issuer) { -613 return hasPermission(manager.getCommandIssuer(issuer)); +595 +596 public void help(Object issuer, String[] args) { +597 help(manager.getCommandIssuer(issuer), args); +598 } +599 public void help(CommandIssuer issuer, String[] args) { +600 issuer.sendMessage(MessageType.ERROR, MessageKeys.UNKNOWN_COMMAND); +601 } +602 public void doHelp(Object issuer, String... args) { +603 doHelp(manager.getCommandIssuer(issuer), args); +604 } +605 public void doHelp(CommandIssuer issuer, String... args) { +606 help(issuer, args); +607 } +608 +609 public void showSyntax(CommandIssuer issuer, RegisteredCommand<?> cmd) { +610 issuer.sendMessage(MessageType.SYNTAX, MessageKeys.INVALID_SYNTAX, +611 "{command}", "/" + cmd.command, +612 "{syntax}", cmd.syntaxText +613 ); 614 } 615 -616 public boolean hasPermission(CommandIssuer issuer) { -617 return permission == null || permission.isEmpty() || (manager.hasPermission(issuer, permission) && (parentCommand == null || parentCommand.hasPermission(issuer))); +616 public boolean hasPermission(Object issuer) { +617 return hasPermission(manager.getCommandIssuer(issuer)); 618 } 619 -620 -621 public Set<String> getRequiredPermissions() { -622 if (this.permission == null || this.permission.isEmpty()) { -623 return ImmutableSet.of(); -624 } -625 return Sets.newHashSet(ACFPatterns.COMMA.split(this.permission)); -626 } -627 -628 public boolean requiresPermission(String permission) { -629 return getRequiredPermissions().contains(permission) || this.parentCommand != null && parentCommand.requiresPermission(permission); +620 public boolean hasPermission(CommandIssuer issuer) { +621 return permission == null || permission.isEmpty() || (manager.hasPermission(issuer, permission) && (parentCommand == null || parentCommand.hasPermission(issuer))); +622 } +623 +624 +625 public Set<String> getRequiredPermissions() { +626 if (this.permission == null || this.permission.isEmpty()) { +627 return ImmutableSet.of(); +628 } +629 return Sets.newHashSet(ACFPatterns.COMMA.split(this.permission)); 630 } 631 -632 public String getName() { -633 return commandName; +632 public boolean requiresPermission(String permission) { +633 return getRequiredPermissions().contains(permission) || this.parentCommand != null && parentCommand.requiresPermission(permission); 634 } 635 -636 public ExceptionHandler getExceptionHandler() { -637 return exceptionHandler; +636 public String getName() { +637 return commandName; 638 } 639 -640 public BaseCommand setExceptionHandler(ExceptionHandler exceptionHandler) { -641 this.exceptionHandler = exceptionHandler; -642 return this; -643 } -644 -645 public RegisteredCommand getDefaultRegisteredCommand() { -646 return this.getSubcommand(DEFAULT); +640 public ExceptionHandler getExceptionHandler() { +641 return exceptionHandler; +642 } +643 +644 public BaseCommand setExceptionHandler(ExceptionHandler exceptionHandler) { +645 this.exceptionHandler = exceptionHandler; +646 return this; 647 } 648 -649 public String setContextFlags(Class<?> cls, String flags) { -650 return this.contextFlags.put(cls, flags); +649 public RegisteredCommand getDefaultRegisteredCommand() { +650 return this.getSubcommand(DEFAULT); 651 } 652 -653 public String getContextFlags(Class<?> cls) { -654 return this.contextFlags.get(cls); +653 public String setContextFlags(Class<?> cls, String flags) { +654 return this.contextFlags.put(cls, flags); 655 } 656 -657 private static class CommandSearch { RegisteredCommand cmd; int argIndex; String checkSub; -658 -659 CommandSearch(RegisteredCommand cmd, int argIndex, String checkSub) { -660 this.cmd = cmd; -661 this.argIndex = argIndex; -662 this.checkSub = checkSub; -663 } -664 -665 String getCheckSub() { -666 return this.checkSub; +657 public String getContextFlags(Class<?> cls) { +658 return this.contextFlags.get(cls); +659 } +660 +661 private static class CommandSearch { RegisteredCommand cmd; int argIndex; String checkSub; +662 +663 CommandSearch(RegisteredCommand cmd, int argIndex, String checkSub) { +664 this.cmd = cmd; +665 this.argIndex = argIndex; +666 this.checkSub = checkSub; 667 } 668 -669 @Override -670 public boolean equals(Object o) { -671 if (this == o) return true; -672 if (o == null || getClass() != o.getClass()) return false; -673 CommandSearch that = (CommandSearch) o; -674 return argIndex == that.argIndex && -675 Objects.equals(cmd, that.cmd) && -676 Objects.equals(checkSub, that.checkSub); -677 } -678 -679 @Override -680 public int hashCode() { -681 return Objects.hash(cmd, argIndex, checkSub); -682 } -683 } -684} +669 String getCheckSub() { +670 return this.checkSub; +671 } +672 +673 @Override +674 public boolean equals(Object o) { +675 if (this == o) return true; +676 if (o == null || getClass() != o.getClass()) return false; +677 CommandSearch that = (CommandSearch) o; +678 return argIndex == that.argIndex && +679 Objects.equals(cmd, that.cmd) && +680 Objects.equals(checkSub, that.checkSub); +681 } +682 +683 @Override +684 public int hashCode() { +685 return Objects.hash(cmd, argIndex, checkSub); +686 } +687 } +688} diff --git a/docs/acf-core/src-html/co/aikar/commands/CommandContexts.html b/docs/acf-core/src-html/co/aikar/commands/CommandContexts.html index fcf3ce78..e7eebc86 100644 --- a/docs/acf-core/src-html/co/aikar/commands/CommandContexts.html +++ b/docs/acf-core/src-html/co/aikar/commands/CommandContexts.html @@ -41,264 +41,281 @@ 033import com.google.common.collect.Maps; 034import org.jetbrains.annotations.NotNull; 035 -036import java.util.List; -037import java.util.Map; -038 -039@SuppressWarnings("WeakerAccess") -040public class CommandContexts <R extends CommandExecutionContext<?, ? extends CommandIssuer>> { -041 protected final Map<Class<?>, ContextResolver<?, R>> contextMap = Maps.newHashMap(); -042 protected final CommandManager manager; -043 -044 CommandContexts(CommandManager manager) { -045 this.manager = manager; -046 registerContext(Short.class, (c) -> { -047 try { -048 return parseAndValidateNumber(c, Short.MAX_VALUE).shortValue(); -049 } catch (NumberFormatException e) { -050 throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER); -051 } -052 }); -053 registerContext(short.class, (c) -> { -054 try { -055 return parseAndValidateNumber(c, Short.MAX_VALUE).shortValue(); -056 } catch (NumberFormatException e) { -057 throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER); -058 } -059 }); -060 registerContext(Integer.class, (c) -> { -061 try { -062 return parseAndValidateNumber(c, Integer.MAX_VALUE).intValue(); -063 } catch (NumberFormatException e) { -064 throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER); -065 } -066 }); -067 registerContext(int.class, (c) -> { -068 try { -069 return parseAndValidateNumber(c, Integer.MAX_VALUE).intValue(); -070 } catch (NumberFormatException e) { -071 throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER); -072 } -073 }); -074 registerContext(Long.class, (c) -> { -075 try { -076 return parseAndValidateNumber(c, Long.MAX_VALUE).longValue(); -077 } catch (NumberFormatException e) { -078 throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER); -079 } -080 }); -081 registerContext(long.class, (c) -> { -082 try { -083 return parseAndValidateNumber(c, Long.MAX_VALUE).longValue(); -084 } catch (NumberFormatException e) { -085 throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER); -086 } -087 }); -088 registerContext(Float.class, (c) -> { -089 try { -090 return parseAndValidateNumber(c, Float.MAX_VALUE).floatValue(); -091 } catch (NumberFormatException e) { -092 throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER); -093 } -094 }); -095 registerContext(float.class, (c) -> { -096 try { -097 return parseAndValidateNumber(c, Float.MAX_VALUE).floatValue(); -098 } catch (NumberFormatException e) { -099 throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER); -100 } -101 }); -102 registerContext(Double.class, (c) -> { -103 try { -104 return parseAndValidateNumber(c, Double.MAX_VALUE).doubleValue(); -105 } catch (NumberFormatException e) { -106 throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER); -107 } -108 }); -109 registerContext(double.class, (c) -> { -110 try { -111 return parseAndValidateNumber(c, Double.MAX_VALUE).doubleValue(); -112 } catch (NumberFormatException e) { -113 throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER); -114 } -115 }); -116 registerContext(Number.class, (c) -> { -117 try { -118 return parseAndValidateNumber(c, Double.MAX_VALUE); -119 } catch (NumberFormatException e) { -120 throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER); -121 } -122 }); -123 registerContext(Boolean.class, (c) -> ACFUtil.isTruthy(c.popFirstArg())); -124 registerContext(boolean.class, (c) -> ACFUtil.isTruthy(c.popFirstArg())); -125 registerContext(char.class, c -> { -126 String s = c.popFirstArg(); -127 if (s.length() > 1) { -128 throw new InvalidCommandArgument(MessageKeys.MUST_BE_MAX_LENGTH, "{max}", String.valueOf(1)); -129 } -130 return s.charAt(0); +036import java.math.BigDecimal; +037import java.math.BigInteger; +038import java.util.List; +039import java.util.Map; +040 +041@SuppressWarnings("WeakerAccess") +042public class CommandContexts <R extends CommandExecutionContext<?, ? extends CommandIssuer>> { +043 protected final Map<Class<?>, ContextResolver<?, R>> contextMap = Maps.newHashMap(); +044 protected final CommandManager manager; +045 +046 CommandContexts(CommandManager manager) { +047 this.manager = manager; +048 registerContext(Short.class, (c) -> { +049 try { +050 return parseAndValidateNumber(c, Short.MAX_VALUE).shortValue(); +051 } catch (NumberFormatException e) { +052 throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER); +053 } +054 }); +055 registerContext(short.class, (c) -> { +056 try { +057 return parseAndValidateNumber(c, Short.MAX_VALUE).shortValue(); +058 } catch (NumberFormatException e) { +059 throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER); +060 } +061 }); +062 registerContext(Integer.class, (c) -> { +063 try { +064 return parseAndValidateNumber(c, Integer.MAX_VALUE).intValue(); +065 } catch (NumberFormatException e) { +066 throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER); +067 } +068 }); +069 registerContext(int.class, (c) -> { +070 try { +071 return parseAndValidateNumber(c, Integer.MAX_VALUE).intValue(); +072 } catch (NumberFormatException e) { +073 throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER); +074 } +075 }); +076 registerContext(Long.class, (c) -> { +077 try { +078 return parseAndValidateNumber(c, Long.MAX_VALUE).longValue(); +079 } catch (NumberFormatException e) { +080 throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER); +081 } +082 }); +083 registerContext(long.class, (c) -> { +084 try { +085 return parseAndValidateNumber(c, Long.MAX_VALUE).longValue(); +086 } catch (NumberFormatException e) { +087 throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER); +088 } +089 }); +090 registerContext(Float.class, (c) -> { +091 try { +092 return parseAndValidateNumber(c, Float.MAX_VALUE).floatValue(); +093 } catch (NumberFormatException e) { +094 throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER); +095 } +096 }); +097 registerContext(float.class, (c) -> { +098 try { +099 return parseAndValidateNumber(c, Float.MAX_VALUE).floatValue(); +100 } catch (NumberFormatException e) { +101 throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER); +102 } +103 }); +104 registerContext(Double.class, (c) -> { +105 try { +106 return parseAndValidateNumber(c, Double.MAX_VALUE).doubleValue(); +107 } catch (NumberFormatException e) { +108 throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER); +109 } +110 }); +111 registerContext(double.class, (c) -> { +112 try { +113 return parseAndValidateNumber(c, Double.MAX_VALUE).doubleValue(); +114 } catch (NumberFormatException e) { +115 throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER); +116 } +117 }); +118 registerContext(Number.class, (c) -> { +119 try { +120 return parseAndValidateNumber(c, Double.MAX_VALUE); +121 } catch (NumberFormatException e) { +122 throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER); +123 } +124 }); +125 registerContext(BigDecimal.class, (c) -> { +126 try { +127 return ACFUtil.parseBigNumber(c.popFirstArg(), c.hasFlag("suffixes")); +128 } catch (NumberFormatException e) { +129 throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER); +130 } 131 }); -132 registerContext(String.class, (c) -> { -133 final Values values = c.getParam().getAnnotation(Values.class); -134 if (values != null) { -135 return c.popFirstArg(); -136 } -137 String ret = (c.isLastArg() && c.getParam().getAnnotation(Single.class) == null) ? -138 ACFUtil.join(c.getArgs()) -139 : -140 c.popFirstArg(); -141 -142 Integer minLen = c.getFlagValue("minlen", (Integer) null); -143 Integer maxLen = c.getFlagValue("maxlen", (Integer) null); -144 if (minLen != null) { -145 if (ret.length() < minLen) { -146 throw new InvalidCommandArgument(MessageKeys.MUST_BE_MIN_LENGTH, "{min}", String.valueOf(minLen)); -147 } -148 } -149 if (maxLen != null) { -150 if (ret.length() > maxLen) { -151 throw new InvalidCommandArgument(MessageKeys.MUST_BE_MAX_LENGTH, "{max}", String.valueOf(maxLen)); -152 } -153 } -154 -155 return ret; -156 }); -157 registerContext(String[].class, (c) -> { -158 String val; -159 // Go home IDEA, you're drunk -160 //noinspection unchecked -161 List<String> args = c.getArgs(); -162 if (c.isLastArg() && c.getParam().getAnnotation(Single.class) == null) { -163 val = ACFUtil.join(args); -164 } else { -165 val = c.popFirstArg(); -166 } -167 Split split = c.getParam().getAnnotation(Split.class); -168 if (split != null) { -169 if (val.isEmpty()) { -170 throw new InvalidCommandArgument(); -171 } -172 return ACFPatterns.getPattern(split.value()).split(val); -173 } else if (!c.isLastArg()) { -174 ACFUtil.sneaky(new IllegalStateException("Weird Command signature... String[] should be last or @Split")); -175 } -176 -177 String[] result = args.toArray(new String[args.size()]); -178 args.clear(); -179 return result; -180 }); -181 -182 registerContext(Enum.class, (c) -> { -183 final String first = c.popFirstArg(); -184 //noinspection unchecked -185 Class<? extends Enum<?>> enumCls = (Class<? extends Enum<?>>) c.getParam().getType(); -186 Enum<?> match = ACFUtil.simpleMatch(enumCls, first); -187 if (match == null) { -188 List<String> names = ACFUtil.enumNames(enumCls); -189 throw new InvalidCommandArgument(MessageKeys.PLEASE_SPECIFY_ONE_OF, "{valid}", ACFUtil.join(names)); -190 } -191 return match; -192 }); -193 registerOptionalContext(CommandHelp.class, (c) -> { -194 String first = c.getFirstArg(); -195 String last = c.getLastArg(); -196 int page = 1; -197 List<String> search = null; -198 if (last != null && ACFUtil.isInteger(last)) { -199 c.popLastArg(); -200 page = ACFUtil.parseInt(last); -201 if (!c.getArgs().isEmpty()) { -202 search = c.getArgs(); -203 } -204 } else if (first != null && ACFUtil.isInteger(first)) { -205 c.popFirstArg(); -206 page = ACFUtil.parseInt(first); -207 if (!c.getArgs().isEmpty()) { -208 search = c.getArgs(); -209 } -210 } else if (!c.getArgs().isEmpty()) { -211 search = c.getArgs(); -212 } -213 CommandHelp commandHelp = manager.generateCommandHelp(); -214 commandHelp.setPage(page); -215 Integer perPage = c.getFlagValue("perpage", (Integer) null); -216 if (perPage != null) { -217 commandHelp.setPerPage(perPage); -218 } -219 commandHelp.setSearch(search); -220 return commandHelp; -221 }); -222 } -223 -224 @NotNull -225 private Number parseAndValidateNumber(R c, Number maxValue) throws InvalidCommandArgument { -226 Number val = ACFUtil.parseNumber(c.popFirstArg(), c.hasFlag("suffixes")); -227 if (maxValue != null && val.doubleValue() > maxValue.doubleValue()) { -228 throw new InvalidCommandArgument(MessageKeys.PLEASE_SPECIFY_AT_MOST, "{max}", String.valueOf(maxValue)); -229 } -230 return val; -231 } -232 -233 /** -234 * @deprecated Please switch to {@link #registerIssuerAwareContext(Class, IssuerAwareContextResolver)} -235 * as the core wants to use the platform agnostic term of "Issuer" instead of Sender -236 * @see #registerIssuerAwareContext(Class, IssuerAwareContextResolver) -237 */ -238 @Deprecated -239 public <T> void registerSenderAwareContext(Class<T> context, IssuerAwareContextResolver<T, R> supplier) { -240 contextMap.put(context, supplier); -241 } -242 -243 /** -244 * Registers a context resolver that may conditionally consume input, falling back to using the context of the -245 * issuer to potentially fulfill this context. -246 * You may call {@link CommandExecutionContext#getFirstArg()} and then conditionally call {@link CommandExecutionContext#popFirstArg()} -247 * if you want to consume that input. -248 */ -249 public <T> void registerIssuerAwareContext(Class<T> context, IssuerAwareContextResolver<T, R> supplier) { -250 contextMap.put(context, supplier); -251 } -252 -253 /** -254 * Registers a context resolver that will never consume input. It will always satisfy its context based on the -255 * issuer of the command, so it will not appear in syntax strings. -256 */ -257 public <T> void registerIssuerOnlyContext(Class<T> context, IssuerOnlyContextResolver<T, R> supplier) { -258 contextMap.put(context, supplier); -259 } -260 -261 /** -262 * Registers a context that can safely accept a null input from the command issuer to resolve. This resolver should always -263 * call {@link CommandExecutionContext#popFirstArg()} -264 */ -265 public <T> void registerOptionalContext(Class<T> context, OptionalContextResolver<T, R> supplier) { -266 contextMap.put(context, supplier); -267 } -268 -269 /** -270 * Registers a context that requires input from the command issuer to resolve. This resolver should always -271 * call {@link CommandExecutionContext#popFirstArg()} -272 */ -273 public <T> void registerContext(Class<T> context, ContextResolver<T, R> supplier) { -274 contextMap.put(context, supplier); -275 } -276 -277 public ContextResolver<?, R> getResolver(Class<?> type) { -278 Class<?> rootType = type; -279 do { -280 if (type == Object.class) { -281 break; -282 } -283 -284 final ContextResolver<?, R> resolver = contextMap.get(type); -285 if (resolver != null) { -286 return resolver; -287 } -288 } while ((type = type.getSuperclass()) != null); -289 -290 this.manager.log(LogLevel.ERROR, "Could not find context resolver", new IllegalStateException("No context resolver defined for " + rootType.getName())); -291 return null; +132 registerContext(BigInteger.class, (c) -> { +133 try { +134 return ACFUtil.parseBigNumber(c.popFirstArg(), c.hasFlag("suffixes")).toBigIntegerExact(); +135 } catch (NumberFormatException e) { +136 throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER); +137 } +138 }); +139 registerContext(Boolean.class, (c) -> ACFUtil.isTruthy(c.popFirstArg())); +140 registerContext(boolean.class, (c) -> ACFUtil.isTruthy(c.popFirstArg())); +141 registerContext(char.class, c -> { +142 String s = c.popFirstArg(); +143 if (s.length() > 1) { +144 throw new InvalidCommandArgument(MessageKeys.MUST_BE_MAX_LENGTH, "{max}", String.valueOf(1)); +145 } +146 return s.charAt(0); +147 }); +148 registerContext(String.class, (c) -> { +149 final Values values = c.getParam().getAnnotation(Values.class); +150 if (values != null) { +151 return c.popFirstArg(); +152 } +153 String ret = (c.isLastArg() && c.getParam().getAnnotation(Single.class) == null) ? +154 ACFUtil.join(c.getArgs()) +155 : +156 c.popFirstArg(); +157 +158 Integer minLen = c.getFlagValue("minlen", (Integer) null); +159 Integer maxLen = c.getFlagValue("maxlen", (Integer) null); +160 if (minLen != null) { +161 if (ret.length() < minLen) { +162 throw new InvalidCommandArgument(MessageKeys.MUST_BE_MIN_LENGTH, "{min}", String.valueOf(minLen)); +163 } +164 } +165 if (maxLen != null) { +166 if (ret.length() > maxLen) { +167 throw new InvalidCommandArgument(MessageKeys.MUST_BE_MAX_LENGTH, "{max}", String.valueOf(maxLen)); +168 } +169 } +170 +171 return ret; +172 }); +173 registerContext(String[].class, (c) -> { +174 String val; +175 // Go home IDEA, you're drunk +176 //noinspection unchecked +177 List<String> args = c.getArgs(); +178 if (c.isLastArg() && c.getParam().getAnnotation(Single.class) == null) { +179 val = ACFUtil.join(args); +180 } else { +181 val = c.popFirstArg(); +182 } +183 Split split = c.getParam().getAnnotation(Split.class); +184 if (split != null) { +185 if (val.isEmpty()) { +186 throw new InvalidCommandArgument(); +187 } +188 return ACFPatterns.getPattern(split.value()).split(val); +189 } else if (!c.isLastArg()) { +190 ACFUtil.sneaky(new IllegalStateException("Weird Command signature... String[] should be last or @Split")); +191 } +192 +193 String[] result = args.toArray(new String[args.size()]); +194 args.clear(); +195 return result; +196 }); +197 +198 registerContext(Enum.class, (c) -> { +199 final String first = c.popFirstArg(); +200 //noinspection unchecked +201 Class<? extends Enum<?>> enumCls = (Class<? extends Enum<?>>) c.getParam().getType(); +202 Enum<?> match = ACFUtil.simpleMatch(enumCls, first); +203 if (match == null) { +204 List<String> names = ACFUtil.enumNames(enumCls); +205 throw new InvalidCommandArgument(MessageKeys.PLEASE_SPECIFY_ONE_OF, "{valid}", ACFUtil.join(names)); +206 } +207 return match; +208 }); +209 registerOptionalContext(CommandHelp.class, (c) -> { +210 String first = c.getFirstArg(); +211 String last = c.getLastArg(); +212 int page = 1; +213 List<String> search = null; +214 if (last != null && ACFUtil.isInteger(last)) { +215 c.popLastArg(); +216 page = ACFUtil.parseInt(last); +217 if (!c.getArgs().isEmpty()) { +218 search = c.getArgs(); +219 } +220 } else if (first != null && ACFUtil.isInteger(first)) { +221 c.popFirstArg(); +222 page = ACFUtil.parseInt(first); +223 if (!c.getArgs().isEmpty()) { +224 search = c.getArgs(); +225 } +226 } else if (!c.getArgs().isEmpty()) { +227 search = c.getArgs(); +228 } +229 CommandHelp commandHelp = manager.generateCommandHelp(); +230 commandHelp.setPage(page); +231 Integer perPage = c.getFlagValue("perpage", (Integer) null); +232 if (perPage != null) { +233 commandHelp.setPerPage(perPage); +234 } +235 commandHelp.setSearch(search); +236 return commandHelp; +237 }); +238 } +239 +240 @NotNull +241 private Number parseAndValidateNumber(R c, Number maxValue) throws InvalidCommandArgument { +242 Number val = ACFUtil.parseNumber(c.popFirstArg(), c.hasFlag("suffixes")); +243 if (maxValue != null && val.doubleValue() > maxValue.doubleValue()) { +244 throw new InvalidCommandArgument(MessageKeys.PLEASE_SPECIFY_AT_MOST, "{max}", String.valueOf(maxValue)); +245 } +246 return val; +247 } +248 +249 +250 /** +251 * @deprecated Please switch to {@link #registerIssuerAwareContext(Class, IssuerAwareContextResolver)} +252 * as the core wants to use the platform agnostic term of "Issuer" instead of Sender +253 * @see #registerIssuerAwareContext(Class, IssuerAwareContextResolver) +254 */ +255 @Deprecated +256 public <T> void registerSenderAwareContext(Class<T> context, IssuerAwareContextResolver<T, R> supplier) { +257 contextMap.put(context, supplier); +258 } +259 +260 /** +261 * Registers a context resolver that may conditionally consume input, falling back to using the context of the +262 * issuer to potentially fulfill this context. +263 * You may call {@link CommandExecutionContext#getFirstArg()} and then conditionally call {@link CommandExecutionContext#popFirstArg()} +264 * if you want to consume that input. +265 */ +266 public <T> void registerIssuerAwareContext(Class<T> context, IssuerAwareContextResolver<T, R> supplier) { +267 contextMap.put(context, supplier); +268 } +269 +270 /** +271 * Registers a context resolver that will never consume input. It will always satisfy its context based on the +272 * issuer of the command, so it will not appear in syntax strings. +273 */ +274 public <T> void registerIssuerOnlyContext(Class<T> context, IssuerOnlyContextResolver<T, R> supplier) { +275 contextMap.put(context, supplier); +276 } +277 +278 /** +279 * Registers a context that can safely accept a null input from the command issuer to resolve. This resolver should always +280 * call {@link CommandExecutionContext#popFirstArg()} +281 */ +282 public <T> void registerOptionalContext(Class<T> context, OptionalContextResolver<T, R> supplier) { +283 contextMap.put(context, supplier); +284 } +285 +286 /** +287 * Registers a context that requires input from the command issuer to resolve. This resolver should always +288 * call {@link CommandExecutionContext#popFirstArg()} +289 */ +290 public <T> void registerContext(Class<T> context, ContextResolver<T, R> supplier) { +291 contextMap.put(context, supplier); 292 } -293} +293 +294 public ContextResolver<?, R> getResolver(Class<?> type) { +295 Class<?> rootType = type; +296 do { +297 if (type == Object.class) { +298 break; +299 } +300 +301 final ContextResolver<?, R> resolver = contextMap.get(type); +302 if (resolver != null) { +303 return resolver; +304 } +305 } while ((type = type.getSuperclass()) != null); +306 +307 this.manager.log(LogLevel.ERROR, "Could not find context resolver", new IllegalStateException("No context resolver defined for " + rootType.getName())); +308 return null; +309 } +310} diff --git a/docs/acf-core/src-html/co/aikar/commands/CommandIssuer.html b/docs/acf-core/src-html/co/aikar/commands/CommandIssuer.html index c8e4c74f..62edfc0a 100644 --- a/docs/acf-core/src-html/co/aikar/commands/CommandIssuer.html +++ b/docs/acf-core/src-html/co/aikar/commands/CommandIssuer.html @@ -33,70 +33,78 @@ 025 026import co.aikar.locales.MessageKey; 027import co.aikar.locales.MessageKeyProvider; -028 -029public interface CommandIssuer { -030 /** -031 * Gets the issuer in the platforms native object -032 * @param <T> -033 * @return -034 */ -035 <T> T getIssuer(); -036 -037 CommandManager getManager(); -038 -039 /** -040 * Is this issue a player, or server/console sender -041 * @return -042 */ -043 boolean isPlayer(); -044 -045 /** -046 * Send the Command Issuer a message -047 * @param message -048 */ -049 default void sendMessage(String message) { -050 getManager().sendMessage(this, MessageType.INFO, MessageKeys.INFO_MESSAGE, "{message}", message); -051 } -052 -053 /** -054 * Has permission node -055 * @param permission -056 * @return -057 */ -058 boolean hasPermission(String permission); -059 -060 default void sendError(MessageKeyProvider key, String... replacements) { -061 sendMessage(MessageType.ERROR, key.getMessageKey(), replacements); -062 } -063 default void sendSyntax(MessageKeyProvider key, String... replacements) { -064 sendMessage(MessageType.SYNTAX, key.getMessageKey(), replacements); -065 } -066 default void sendInfo(MessageKeyProvider key, String... replacements) { -067 sendMessage(MessageType.INFO, key.getMessageKey(), replacements); -068 } -069 default void sendError(MessageKey key, String... replacements) { -070 sendMessage(MessageType.ERROR, key, replacements); -071 } -072 default void sendSyntax(MessageKey key, String... replacements) { -073 sendMessage(MessageType.SYNTAX, key, replacements); -074 } -075 default void sendInfo(MessageKey key, String... replacements) { -076 sendMessage(MessageType.INFO, key, replacements); -077 } -078 default void sendMessage(MessageType type, MessageKeyProvider key, String... replacements) { -079 sendMessage(type, key.getMessageKey(), replacements); -080 } -081 default void sendMessage(MessageType type, MessageKey key, String... replacements) { -082 getManager().sendMessage(this, type, key, replacements); -083 } -084 -085 /** -086 * @deprecated Do not call this, for internal use. Not considered part of the API and may break. -087 * @param message -088 */ -089 @Deprecated -090 void sendMessageInternal(String message); -091} +028import org.jetbrains.annotations.NotNull; +029 +030import java.util.UUID; +031 +032public interface CommandIssuer { +033 /** +034 * Gets the issuer in the platforms native object +035 * @param <T> +036 * @return +037 */ +038 <T> T getIssuer(); +039 +040 CommandManager getManager(); +041 +042 /** +043 * Is this issue a player, or server/console sender +044 * @return +045 */ +046 boolean isPlayer(); +047 +048 /** +049 * Send the Command Issuer a message +050 * @param message +051 */ +052 default void sendMessage(String message) { +053 getManager().sendMessage(this, MessageType.INFO, MessageKeys.INFO_MESSAGE, "{message}", message); +054 } +055 +056 /** +057 * @return the unique id of that issuer +058 */ +059 @NotNull UUID getUniqueId(); +060 +061 /** +062 * Has permission node +063 * @param permission +064 * @return +065 */ +066 boolean hasPermission(String permission); +067 +068 default void sendError(MessageKeyProvider key, String... replacements) { +069 sendMessage(MessageType.ERROR, key.getMessageKey(), replacements); +070 } +071 default void sendSyntax(MessageKeyProvider key, String... replacements) { +072 sendMessage(MessageType.SYNTAX, key.getMessageKey(), replacements); +073 } +074 default void sendInfo(MessageKeyProvider key, String... replacements) { +075 sendMessage(MessageType.INFO, key.getMessageKey(), replacements); +076 } +077 default void sendError(MessageKey key, String... replacements) { +078 sendMessage(MessageType.ERROR, key, replacements); +079 } +080 default void sendSyntax(MessageKey key, String... replacements) { +081 sendMessage(MessageType.SYNTAX, key, replacements); +082 } +083 default void sendInfo(MessageKey key, String... replacements) { +084 sendMessage(MessageType.INFO, key, replacements); +085 } +086 default void sendMessage(MessageType type, MessageKeyProvider key, String... replacements) { +087 sendMessage(type, key.getMessageKey(), replacements); +088 } +089 default void sendMessage(MessageType type, MessageKey key, String... replacements) { +090 getManager().sendMessage(this, type, key, replacements); +091 } +092 +093 /** +094 * @deprecated Do not call this, for internal use. Not considered part of the API and may break. +095 * @param message +096 */ +097 @Deprecated +098 void sendMessageInternal(String message); +099} 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 8edd5cf3..8a6ab13b 100644 --- a/docs/acf-core/src-html/co/aikar/commands/CommandManager.html +++ b/docs/acf-core/src-html/co/aikar/commands/CommandManager.html @@ -35,444 +35,467 @@ 027import co.aikar.locales.MessageKeyProvider; 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; +030import com.google.common.collect.Maps; +031import com.google.common.collect.Sets; +032import com.google.common.collect.Table; +033import org.jetbrains.annotations.NotNull; +034 +035import java.lang.reflect.Field; +036import java.lang.reflect.InvocationTargetException; +037import java.lang.reflect.Method; +038import java.lang.reflect.Parameter; 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; +044import java.util.Objects; +045import java.util.Set; +046import java.util.Stack; +047import java.util.UUID; +048 +049 +050@SuppressWarnings("WeakerAccess") +051public abstract class CommandManager < +052 IT, +053 I extends CommandIssuer, +054 FT, +055 MF extends MessageFormatter<FT>, +056 CEC extends CommandExecutionContext<CEC, I>, +057 CC extends ConditionContext<I> +058 > { +059 +060 /** +061 * This is a stack incase a command calls a command +062 */ +063 static ThreadLocal<Stack<CommandOperationContext>> commandOperationContext = ThreadLocal.withInitial(() -> new Stack<CommandOperationContext>() { +064 @Override +065 public synchronized CommandOperationContext peek() { +066 return super.size() == 0 ? null : super.peek(); +067 } +068 }); +069 protected Map<String, RootCommand> rootCommands = new HashMap<>(); +070 protected final CommandReplacements replacements = new CommandReplacements(this); +071 protected final CommandConditions<I, CEC, CC> conditions = new CommandConditions<>(this); +072 protected ExceptionHandler defaultExceptionHandler = null; +073 protected Table<Class<?>, String, Object> dependencies = HashBasedTable.create(); +074 +075 protected boolean usePerIssuerLocale = false; +076 protected List<IssuerLocaleChangedCallback<I>> localeChangedCallbacks = Lists.newArrayList(); +077 protected Set<Locale> supportedLanguages = Sets.newHashSet(Locales.ENGLISH, Locales.GERMAN, Locales.SPANISH, Locales.CZECH, Locales.PORTUGUESE); +078 protected Map<MessageType, MF> formatters = new IdentityHashMap<>(); +079 protected MF defaultFormatter; +080 protected int defaultHelpPerPage = 10; +081 +082 protected Map<UUID, Locale> issuersLocale = Maps.newConcurrentMap(); +083 +084 private Set<String> unstableAPIs = Sets.newHashSet(); +085 +086 public static CommandOperationContext getCurrentCommandOperationContext() { +087 return commandOperationContext.get().peek(); 088 } 089 -090 public static CommandManager getCurrentCommandManager() { +090 public static CommandIssuer getCurrentCommandIssuer() { 091 CommandOperationContext context = commandOperationContext.get().peek(); -092 return context != null ? context.getCommandManager() : null; +092 return context != null ? context.getCommandIssuer() : 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); +095 public static CommandManager getCurrentCommandManager() { +096 CommandOperationContext context = commandOperationContext.get().peek(); +097 return context != null ? context.getCommandManager() : null; +098 } +099 +100 public MF setFormat(MessageType type, MF formatter) { +101 return formatters.put(type, formatter); +102 } +103 +104 public MF getFormat(MessageType type) { +105 return formatters.getOrDefault(type, defaultFormatter); +106 } +107 +108 public void setFormat(MessageType type, FT... colors) { +109 MF format = getFormat(type); +110 for (int i = 1; i <= colors.length; i++) { +111 format.setColor(i, colors[i-1]); +112 } 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 // 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); +115 public void setFormat(MessageType type, int i, FT color) { +116 MF format = getFormat(type); +117 format.setColor(i, color); +118 } +119 +120 public MF getDefaultFormatter() { +121 return defaultFormatter; +122 } +123 +124 public void setDefaultFormatter(MF defaultFormatter) { +125 this.defaultFormatter = defaultFormatter; +126 } +127 +128 public CommandConditions<I, CEC, CC> getCommandConditions() { +129 return conditions; +130 } +131 +132 /** +133 * Gets the command contexts manager +134 * @return Command Contexts +135 */ +136 public abstract CommandContexts<?> getCommandContexts(); +137 +138 /** +139 * Gets the command completions manager +140 * @return Command Completions +141 */ +142 public abstract CommandCompletions<?> getCommandCompletions(); +143 +144 /** @deprecated Unstable API */ @Deprecated @UnstableAPI +145 public CommandHelp generateCommandHelp(@NotNull String command) { +146 verifyUnstableAPI("help"); +147 CommandOperationContext context = getCurrentCommandOperationContext(); +148 if (context == null) { +149 throw new IllegalStateException("This method can only be called as part of a command execution."); +150 } +151 return generateCommandHelp(context.getCommandIssuer(), command); +152 } +153 +154 /** @deprecated Unstable API */ @Deprecated @UnstableAPI +155 public CommandHelp generateCommandHelp(CommandIssuer issuer, @NotNull String command) { +156 verifyUnstableAPI("help"); +157 return generateCommandHelp(issuer, obtainRootCommand(command)); +158 } +159 +160 /** @deprecated Unstable API */ @Deprecated @UnstableAPI +161 public CommandHelp generateCommandHelp() { +162 verifyUnstableAPI("help"); +163 CommandOperationContext context = getCurrentCommandOperationContext(); +164 if (context == null) { +165 throw new IllegalStateException("This method can only be called as part of a command execution."); +166 } +167 String commandLabel = context.getCommandLabel(); +168 return generateCommandHelp(context.getCommandIssuer(), this.obtainRootCommand(commandLabel)); +169 } +170 +171 /** @deprecated Unstable API */ @Deprecated @UnstableAPI +172 public CommandHelp generateCommandHelp(CommandIssuer issuer, RootCommand rootCommand) { +173 verifyUnstableAPI("help"); +174 return new CommandHelp(this, rootCommand, issuer); +175 } +176 +177 /** @deprecated Unstable API */ @Deprecated @UnstableAPI +178 public int getDefaultHelpPerPage() { +179 verifyUnstableAPI("help"); +180 return defaultHelpPerPage; +181 } +182 +183 /** @deprecated Unstable API */ @Deprecated @UnstableAPI +184 public void setDefaultHelpPerPage(int defaultHelpPerPage) { +185 verifyUnstableAPI("help"); +186 this.defaultHelpPerPage = defaultHelpPerPage; +187 } +188 +189 /** +190 * Registers a command with ACF +191 * +192 * @param command The command to register +193 * @return boolean +194 */ +195 public abstract void registerCommand(BaseCommand command); +196 public abstract boolean hasRegisteredCommands(); +197 public abstract boolean isCommandIssuer(Class<?> type); 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); +199 // TODO: Change this to IT if we make a breaking change +200 public abstract I getCommandIssuer(Object issuer); +201 +202 public abstract RootCommand createRootCommand(String cmd); +203 +204 /** +205 * Returns a Locales Manager to add and modify language tables for your commands. +206 * @return +207 */ +208 public abstract Locales getLocales(); +209 +210 public boolean usingPerIssuerLocale() { +211 return usePerIssuerLocale; +212 } +213 +214 public boolean usePerIssuerLocale(boolean setting) { +215 boolean old = usePerIssuerLocale; +216 usePerIssuerLocale = setting; +217 return old; 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 } +220 public ConditionContext createConditionContext(CommandIssuer issuer, String config) { +221 //noinspection unchecked +222 return new ConditionContext(issuer, config); +223 } +224 +225 public abstract CommandExecutionContext createCommandContext(RegisteredCommand command, Parameter parameter, CommandIssuer sender, List<String> args, int i, Map<String, Object> passedArgs); +226 +227 public abstract CommandCompletionContext createCompletionContext(RegisteredCommand command, CommandIssuer sender, String input, String config, String[] args); +228 +229 public abstract void log(final LogLevel level, final String message, final Throwable throwable); +230 +231 public void log(final LogLevel level, final String message) { +232 log(level, message, null); +233 } +234 +235 /** +236 * Lets you add custom string replacements that can be applied to annotation values, +237 * to reduce duplication/repetition of common values such as permission nodes and command prefixes. +238 * +239 * Any replacement registered starts with a % +240 * +241 * So for ex @CommandPermission("%staff") +242 * @return Replacements Manager +243 */ +244 public CommandReplacements getCommandReplacements() { +245 return replacements; +246 } +247 +248 public boolean hasPermission(CommandIssuer issuer, String permission) { +249 if (permission == null || permission.isEmpty()) { +250 return true; 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 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 } +252 for (String perm : ACFPatterns.COMMA.split(permission)) { +253 if (!perm.isEmpty() && !issuer.hasPermission(perm)) { +254 return false; +255 } +256 } +257 return true; +258 } +259 +260 BaseCommand getBaseCommand(String commandLabel, @NotNull String[] args) { +261 RootCommand rootCommand = obtainRootCommand(commandLabel); +262 if (rootCommand == null) { +263 return null; +264 } +265 return rootCommand.getBaseCommand(args); +266 } +267 +268 public synchronized RootCommand getRootCommand(@NotNull String cmd) { +269 return rootCommands.get(ACFPatterns.SPACE.split(cmd.toLowerCase(), 2)[0]); +270 } +271 +272 public synchronized RootCommand obtainRootCommand(@NotNull String cmd) { +273 return rootCommands.computeIfAbsent(ACFPatterns.SPACE.split(cmd.toLowerCase(), 2)[0], this::createRootCommand); +274 } +275 +276 public RegisteredCommand createRegisteredCommand(BaseCommand command, String cmdName, Method method, String prefSubCommand) { +277 return new RegisteredCommand(command, cmdName, method, prefSubCommand); +278 } +279 +280 /** +281 * 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. +282 * +283 * @param exceptionHandler the handler that should handle uncaught exceptions +284 */ +285 public void setDefaultExceptionHandler(ExceptionHandler exceptionHandler) { +286 defaultExceptionHandler = exceptionHandler; +287 } +288 +289 /** +290 * Gets the current default exception handler, might be null. +291 * +292 * @return the default exception handler +293 */ +294 public ExceptionHandler getDefaultExceptionHandler() { +295 return defaultExceptionHandler; +296 } +297 +298 protected boolean handleUncaughtException(BaseCommand scope, RegisteredCommand registeredCommand, CommandIssuer sender, List<String> args, Throwable t) { +299 if (t instanceof InvocationTargetException && t.getCause() != null) { +300 t = t.getCause(); +301 } +302 boolean result = false; +303 if (scope.getExceptionHandler() != null) { +304 result = scope.getExceptionHandler().execute(scope, registeredCommand, sender, args, t); +305 } else if (defaultExceptionHandler != null) { +306 result = defaultExceptionHandler.execute(scope, registeredCommand, sender, args, t); +307 } +308 return result; +309 } +310 +311 public void sendMessage(IT issuerArg, MessageType type, MessageKeyProvider key, String... replacements) { +312 sendMessage(getCommandIssuer(issuerArg), type, key, replacements); +313 } +314 +315 public void sendMessage(CommandIssuer issuer, MessageType type, MessageKeyProvider key, String... replacements) { +316 String message = formatMessage(issuer, type, key, replacements); 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 ); +318 for (String msg : ACFPatterns.NEWLINE.split(message)) { +319 issuer.sendMessageInternal(ACFUtil.rtrim(msg)); +320 } +321 } +322 +323 public String formatMessage(CommandIssuer issuer, MessageType type, MessageKeyProvider key, String... replacements) { +324 String message = getLocales().getMessage(issuer, key.getMessageKey()); +325 if (replacements.length > 0) { +326 message = ACFUtil.replaceStrings(message, replacements); +327 } +328 +329 message = getCommandReplacements().replace(message); +330 +331 MessageFormatter formatter = formatters.getOrDefault(type, defaultFormatter); +332 if (formatter != null) { +333 message = formatter.format(message); +334 } +335 return message; +336 } +337 +338 public void onLocaleChange(IssuerLocaleChangedCallback<I> onChange) { +339 localeChangedCallbacks.add(onChange); +340 } +341 +342 public void notifyLocaleChange(I issuer, Locale oldLocale, Locale newLocale) { +343 localeChangedCallbacks.forEach(cb -> { +344 try { +345 cb.onIssuerLocaleChange(issuer, oldLocale, newLocale); +346 } catch (Exception e) { +347 this.log(LogLevel.ERROR, "Error in notifyLocaleChange", e); +348 } +349 }); +350 } +351 +352 public Locale setIssuerLocale(IT issuer, Locale locale) { +353 I commandIssuer = getCommandIssuer(issuer); +354 +355 Locale old = issuersLocale.put(commandIssuer.getUniqueId(), locale); +356 if (!Objects.equals(old, locale)) { +357 this.notifyLocaleChange(commandIssuer, old, locale); +358 } +359 +360 return old; 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 } +363 public Locale getIssuerLocale(CommandIssuer issuer) { +364 if (usingPerIssuerLocale()) { +365 Locale locale = issuersLocale.get(issuer.getUniqueId()); +366 if (locale != null) { +367 return locale; +368 } +369 } +370 +371 return getLocales().getDefaultLocale(); +372 } +373 +374 CommandOperationContext<I> createCommandOperationContext(BaseCommand command, CommandIssuer issuer, String commandLabel, String[] args, boolean isAsync) { +375 //noinspection unchecked +376 return new CommandOperationContext<>( +377 this, +378 (I) issuer, +379 command, +380 commandLabel, +381 args, +382 isAsync +383 ); +384 } +385 +386 /** +387 * Gets a list of all currently supported languages for this manager. +388 * These locales will be automatically loaded from +389 * @return +390 */ +391 public Set<Locale> getSupportedLanguages() { +392 return supportedLanguages; +393 } +394 +395 /** +396 * Adds a new locale to the list of automatic Locales to load Message Bundles for. +397 * All bundles loaded under the previous supported languages will now automatically load for this new locale too. +398 * +399 * @param locale +400 */ +401 public void addSupportedLanguage(Locale locale) { +402 supportedLanguages.add(locale); +403 getLocales().loadMissingBundles(); +404 } +405 +406 /** +407 * Registers an instance of a class to be registered as an injectable dependency.<br> +408 * The command manager will attempt to inject all fields in a command class that are annotated with +409 * {@link co.aikar.commands.annotation.Dependency} with the provided instance. +410 * +411 * @param clazz the class the injector should look for when injecting +412 * @param instance the instance of the class that should be injected +413 * @throws IllegalStateException when there is already an instance for the provided class registered +414 */ +415 public <T> void registerDependency(Class<? extends T> clazz, T instance){ +416 registerDependency(clazz, clazz.getName(), instance); +417 } +418 +419 /** +420 * Registers an instance of a class to be registered as an injectable dependency.<br> +421 * The command manager will attempt to inject all fields in a command class that are annotated with +422 * {@link co.aikar.commands.annotation.Dependency} with the provided instance. +423 * +424 * @param clazz the class the injector should look for when injecting +425 * @param key the key which needs to be present if that +426 * @param instance the instance of the class that should be injected +427 * @throws IllegalStateException when there is already an instance for the provided class registered +428 */ +429 public <T> void registerDependency(Class<? extends T> clazz, String key, T instance){ +430 if(dependencies.containsRow(clazz) && dependencies.containsColumn(key)){ +431 throw new IllegalStateException("There is already an instance of " + clazz.getName() + " with the key " + key + " registered!"); +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} +434 dependencies.put(clazz, key, instance); +435 } +436 +437 /** +438 * Attempts to inject instances of classes registered with {@link CommandManager#registerDependency(Class, Object)} +439 * into all fields of the class and its superclasses that are marked with {@link Dependency}. +440 * +441 * @param baseCommand the instance which fields should be filled +442 */ +443 void injectDependencies(BaseCommand baseCommand) { +444 Class clazz = baseCommand.getClass(); +445 do { +446 for (Field field : clazz.getDeclaredFields()) { +447 if (field.isAnnotationPresent(Dependency.class)) { +448 Dependency dependency = field.getAnnotation(Dependency.class); +449 String key = (key = dependency.value()).equals("") ? field.getType().getName() : key; +450 Object object = dependencies.row(field.getType()).get(key); +451 if (object == null) { +452 throw new UnresolvedDependencyException("Could not find a registered instance of " + +453 field.getType().getName() + " with key " + key + " for field " + field.getName() + +454 " in class " + baseCommand.getClass().getName()); +455 } +456 +457 try { +458 boolean accessible = field.isAccessible(); +459 if (!accessible) { +460 field.setAccessible(true); +461 } +462 field.set(baseCommand, object); +463 field.setAccessible(accessible); +464 } catch (IllegalAccessException e) { +465 e.printStackTrace(); //TODO should we print our own exception here to make a more descriptive error? +466 } +467 } +468 } +469 clazz = clazz.getSuperclass(); +470 } while (!clazz.equals(BaseCommand.class)); +471 } +472 +473 /** +474 * @deprecated Use this with caution! If you enable and use Unstable API's, your next compile using ACF +475 * may require you to update your implementation to those unstable API's +476 */ +477 @Deprecated +478 public void enableUnstableAPI(String api) { +479 unstableAPIs.add(api); +480 } +481 void verifyUnstableAPI(String api) { +482 if (!unstableAPIs.contains(api)) { +483 throw new IllegalStateException("Using an unstable API that has not been enabled ( " + api + "). See https://acfunstable.emc.gs"); +484 } +485 } +486 +487 boolean hasUnstableAPI(String api) { +488 return unstableAPIs.contains(api); +489 } +490} diff --git a/docs/acf-core/src-html/co/aikar/commands/processors/ConditionsProcessor.html b/docs/acf-core/src-html/co/aikar/commands/processors/ConditionsProcessor.html new file mode 100644 index 00000000..3b2d4c95 --- /dev/null +++ b/docs/acf-core/src-html/co/aikar/commands/processors/ConditionsProcessor.html @@ -0,0 +1,115 @@ + + + +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.processors;
        +025
        +026import co.aikar.commands.AnnotationProcessor;
        +027import co.aikar.commands.CommandExecutionContext;
        +028import co.aikar.commands.CommandOperationContext;
        +029import co.aikar.commands.annotation.Conditions;
        +030
        +031@Deprecated /* @deprecated UNFINISHED */
        +032public class ConditionsProcessor implements AnnotationProcessor<Conditions> {
        +033
        +034    @Override
        +035    public void onPreComand(CommandOperationContext context) {
        +036
        +037    }
        +038
        +039    @Override
        +040    public void onPostContextResolution(CommandExecutionContext context, Object resolvedValue) {
        +041
        +042    }
        +043}
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        + + diff --git a/docs/acf-jda/co/aikar/commands/JDACommandEvent.html b/docs/acf-jda/co/aikar/commands/JDACommandEvent.html index 2cc4e833..5a8e7a60 100644 --- a/docs/acf-jda/co/aikar/commands/JDACommandEvent.html +++ b/docs/acf-jda/co/aikar/commands/JDACommandEvent.html @@ -18,7 +18,7 @@ catch(err) { } //--> -var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10}; +var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10}; var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]}; var altColor = "altColor"; var rowColor = "rowColor"; @@ -111,7 +111,7 @@ var activeTableTab = "activeTableTab";


    -
    public class JDACommandEvent
    +
    public class JDACommandEvent
     extends Object
     implements co.aikar.commands.CommandIssuer
  • @@ -163,23 +163,27 @@ implements co.aikar.commands.CommandIssuer
  • getManager()  -boolean -hasPermission(String permission)  +@NotNull UUID +getUniqueId()  boolean -isPlayer()  +hasPermission(String permission)  -void -sendMessage(net.dv8tion.jda.core.entities.Message message)  +boolean +isPlayer()  void -sendMessage(net.dv8tion.jda.core.entities.MessageEmbed message)  +sendMessage(net.dv8tion.jda.core.entities.Message message)  void +sendMessage(net.dv8tion.jda.core.entities.MessageEmbed message)  + + +void sendMessageInternal(String message)  @@ -217,7 +221,7 @@ implements co.aikar.commands.CommandIssuer
  • @@ -235,7 +239,7 @@ implements co.aikar.commands.CommandIssuer
    • getEvent

      -
      public net.dv8tion.jda.core.events.message.MessageReceivedEvent getEvent()
      +
      public net.dv8tion.jda.core.events.message.MessageReceivedEvent getEvent()
    @@ -244,7 +248,7 @@ implements co.aikar.commands.CommandIssuer
    • getManager

      -
      public co.aikar.commands.CommandManager getManager()
      +
      public co.aikar.commands.CommandManager getManager()
      Specified by:
      getManager in interface co.aikar.commands.CommandIssuer
      @@ -270,20 +274,34 @@ implements co.aikar.commands.CommandIssuer
      • isPlayer

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

        getUniqueId

        +
        @NotNull
        +public @NotNull UUID getUniqueId()
        +
        +
        Specified by:
        +
        getUniqueId in interface co.aikar.commands.CommandIssuer
        +
        +
      • +
      • hasPermission

        -
        public boolean hasPermission(String permission)
        +
        public boolean hasPermission(String permission)
        Specified by:
        hasPermission in interface co.aikar.commands.CommandIssuer
        @@ -296,7 +314,7 @@ implements co.aikar.commands.CommandIssuer
        • sendMessageInternal

          -
          public void sendMessageInternal(String message)
          +
          public void sendMessageInternal(String message)
          Specified by:
          sendMessageInternal in interface co.aikar.commands.CommandIssuer
          @@ -309,7 +327,7 @@ implements co.aikar.commands.CommandIssuer
          • sendMessage

            -
            public void sendMessage(net.dv8tion.jda.core.entities.Message message)
            +
            public void sendMessage(net.dv8tion.jda.core.entities.Message message)
          @@ -318,7 +336,7 @@ implements co.aikar.commands.CommandIssuer
        • diff --git a/docs/acf-jda/co/aikar/commands/JDACommandManager.html b/docs/acf-jda/co/aikar/commands/JDACommandManager.html index fa042a30..2cf2865f 100644 --- a/docs/acf-jda/co/aikar/commands/JDACommandManager.html +++ b/docs/acf-jda/co/aikar/commands/JDACommandManager.html @@ -154,7 +154,7 @@ extends co.aikar.commands.CommandManager<net.dv8tion.jda.core.events.message.

          Fields inherited from class co.aikar.commands.CommandManager

          -conditions, defaultExceptionHandler, defaultFormatter, defaultHelpPerPage, dependencies, formatters, localeChangedCallbacks, replacements, rootCommands, supportedLanguages, usePerIssuerLocale +conditions, defaultExceptionHandler, defaultFormatter, defaultHelpPerPage, dependencies, formatters, issuersLocale, localeChangedCallbacks, replacements, rootCommands, supportedLanguages, usePerIssuerLocale
      @@ -292,7 +292,7 @@ extends co.aikar.commands.CommandManager<net.dv8tion.jda.core.events.message.

      Methods inherited from class co.aikar.commands.CommandManager

      -addSupportedLanguage, createConditionContext, createRegisteredCommand, 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
    • +addSupportedLanguage, createConditionContext, createRegisteredCommand, enableUnstableAPI, formatMessage, generateCommandHelp, generateCommandHelp, generateCommandHelp, generateCommandHelp, getCommandConditions, getCommandReplacements, getCurrentCommandIssuer, getCurrentCommandManager, getCurrentCommandOperationContext, getDefaultExceptionHandler, getDefaultFormatter, getDefaultHelpPerPage, getFormat, getIssuerLocale, getRootCommand, getSupportedLanguages, handleUncaughtException, hasPermission, log, notifyLocaleChange, obtainRootCommand, onLocaleChange, registerDependency, registerDependency, sendMessage, sendMessage, setDefaultExceptionHandler, setDefaultFormatter, setDefaultHelpPerPage, setFormat, setFormat, setFormat, setIssuerLocale, usePerIssuerLocale, usingPerIssuerLocale
  • diff --git a/docs/acf-jda/src-html/co/aikar/commands/JDACommandEvent.html b/docs/acf-jda/src-html/co/aikar/commands/JDACommandEvent.html index 1b508426..9829e58c 100644 --- a/docs/acf-jda/src-html/co/aikar/commands/JDACommandEvent.html +++ b/docs/acf-jda/src-html/co/aikar/commands/JDACommandEvent.html @@ -11,55 +11,66 @@ 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; +006import org.jetbrains.annotations.NotNull; +007 +008import java.util.UUID; +009 +010public class JDACommandEvent implements CommandIssuer { 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(); +012 private MessageReceivedEvent event; +013 private JDACommandManager manager; +014 +015 public JDACommandEvent(JDACommandManager manager, MessageReceivedEvent event) { +016 +017 this.manager = manager; +018 this.event = event; +019 } +020 +021 public MessageReceivedEvent getEvent() { +022 return event; +023 } +024 +025 @Override +026 public MessageReceivedEvent getIssuer() { +027 return event; +028 } +029 +030 @Override +031 public CommandManager getManager() { +032 return this.manager; +033 } +034 +035 @Override +036 public boolean isPlayer() { +037 return false; +038 } +039 +040 @Override +041 public @NotNull UUID getUniqueId() { +042 // Discord id only have 64 bit width (long) while UUIDs have twice the size. +043 // In order to keep it unique we use 0L for the first 64 bit. +044 long authorId = event.getAuthor().getIdLong(); +045 return new UUID(0, authorId); 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} +048 @Override +049 public boolean hasPermission(String permission) { +050 CommandPermissionResolver permissionResolver = this.manager.getPermissionResolver(); +051 return permissionResolver == null || permissionResolver.hasPermission(this, permission); +052 } +053 +054 @Override +055 public void sendMessageInternal(String message) { +056 this.event.getChannel().sendMessage(message).queue(); +057 } +058 +059 public void sendMessage(Message message) { +060 this.event.getChannel().sendMessage(message).queue(); +061 } +062 public void sendMessage(MessageEmbed message) { +063 this.event.getChannel().sendMessage(message).queue(); +064 } +065} diff --git a/docs/acf-paper/co/aikar/commands/PaperCommandManager.html b/docs/acf-paper/co/aikar/commands/PaperCommandManager.html index 638a8ef9..06662266 100644 --- a/docs/acf-paper/co/aikar/commands/PaperCommandManager.html +++ b/docs/acf-paper/co/aikar/commands/PaperCommandManager.html @@ -136,14 +136,14 @@ extends co.aikar.commands.BukkitCommandManager

    Fields inherited from class co.aikar.commands.BukkitCommandManager

    -autoDetectFromClient, completions, contexts, issuersLocale, knownCommands, locales, plugin, registeredCommands
  • +autoDetectFromClient, completions, contexts, knownCommands, locales, plugin, registeredCommands
    • Fields inherited from class co.aikar.commands.CommandManager

      -conditions, defaultExceptionHandler, defaultFormatter, defaultHelpPerPage, dependencies, formatters, localeChangedCallbacks, replacements, rootCommands, supportedLanguages, usePerIssuerLocale
    • +conditions, defaultExceptionHandler, defaultFormatter, defaultHelpPerPage, dependencies, formatters, issuersLocale, localeChangedCallbacks, replacements, rootCommands, supportedLanguages, usePerIssuerLocale
  • @@ -190,14 +190,14 @@ extends co.aikar.commands.BukkitCommandManager

    Methods inherited from class co.aikar.commands.BukkitCommandManager

    -createCommandContext, createCompletionContext, createConditionContext, createRegisteredCommand, createRootCommand, getCommandIssuer, getIssuerLocale, getLocales, getPlugin, getTimings, hasRegisteredCommands, isCommandIssuer, log, registerCommand, registerCommand, setPlayerLocale, unregisterCommand, unregisterCommand, unregisterCommands, usePerIssuerLocale
  • +createCommandContext, createCompletionContext, createConditionContext, createRegisteredCommand, createRootCommand, getCommandIssuer, getLocales, getPlugin, getTimings, hasRegisteredCommands, isCommandIssuer, log, registerCommand, registerCommand, setPlayerLocale, unregisterCommand, unregisterCommand, unregisterCommands, usePerIssuerLocale
    • 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, registerDependency, registerDependency, 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, setIssuerLocale, usePerIssuerLocale, usingPerIssuerLocale
    • diff --git a/docs/acf-sponge/allclasses-frame.html b/docs/acf-sponge/allclasses-frame.html index 8e740990..ca8a03b1 100644 --- a/docs/acf-sponge/allclasses-frame.html +++ b/docs/acf-sponge/allclasses-frame.html @@ -12,6 +12,7 @@

      All Classes

        +
      • ACFSpongeListener
      • ACFSpongeUtil
      • CommandResultSupplier
      • MinecraftMessageKeys
      • diff --git a/docs/acf-sponge/allclasses-noframe.html b/docs/acf-sponge/allclasses-noframe.html index a0d4ace4..89502ced 100644 --- a/docs/acf-sponge/allclasses-noframe.html +++ b/docs/acf-sponge/allclasses-noframe.html @@ -12,6 +12,7 @@

        All Classes

          +
        • ACFSpongeListener
        • ACFSpongeUtil
        • CommandResultSupplier
        • MinecraftMessageKeys
        • diff --git a/docs/acf-sponge/co/aikar/commands/ACFSpongeListener.html b/docs/acf-sponge/co/aikar/commands/ACFSpongeListener.html new file mode 100644 index 00000000..1c560f51 --- /dev/null +++ b/docs/acf-sponge/co/aikar/commands/ACFSpongeListener.html @@ -0,0 +1,287 @@ + + + + + + +ACFSpongeListener (ACF (Sponge) 0.5.0-SNAPSHOT API) + + + + + + + + + + + +
          +
          co.aikar.commands
          +

          Class ACFSpongeListener

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

              Method Detail

              + + + +
                +
              • +

                onSettingsChange

                +
                public void onSettingsChange(org.spongepowered.api.event.entity.living.humanoid.player.PlayerChangeClientSettingsEvent changeSettingsEvent,
                +                             org.spongepowered.api.entity.living.player.Player targetPlayer)
                +
              • +
              + + + +
                +
              • +

                onDisconnectCleanup

                +
                public void onDisconnectCleanup(org.spongepowered.api.event.network.ClientConnectionEvent.Disconnect disconnectEvent,
                +                                org.spongepowered.api.entity.living.player.Player player)
                +
              • +
              +
            • +
            +
          • +
          +
          +
          + + + + + +

          Copyright © 2018. All rights reserved.

          + + diff --git a/docs/acf-sponge/co/aikar/commands/ACFSpongeUtil.html b/docs/acf-sponge/co/aikar/commands/ACFSpongeUtil.html index d998373e..858cd412 100644 --- a/docs/acf-sponge/co/aikar/commands/ACFSpongeUtil.html +++ b/docs/acf-sponge/co/aikar/commands/ACFSpongeUtil.html @@ -48,7 +48,7 @@ var activeTableTab = "activeTableTab";


    -
    public class SpongeCommandIssuer
    +
    public class SpongeCommandIssuer
     extends Object
     implements co.aikar.commands.CommandIssuer
  • @@ -150,18 +150,22 @@ implements co.aikar.commands.CommandIssuer getPlayer()  +@NotNull UUID +getUniqueId()  + + int hashCode()  - + boolean hasPermission(String permission)  - + boolean isPlayer()  - + void sendMessageInternal(String message)  @@ -200,7 +204,7 @@ implements co.aikar.commands.CommandIssuer
    • isPlayer

      -
      public boolean isPlayer()
      +
      public boolean isPlayer()
      Specified by:
      isPlayer in interface co.aikar.commands.CommandIssuer
      @@ -213,20 +217,34 @@ implements co.aikar.commands.CommandIssuer
      • getIssuer

        -
        public org.spongepowered.api.command.CommandSource getIssuer()
        +
        public org.spongepowered.api.command.CommandSource getIssuer()
        Specified by:
        getIssuer in interface co.aikar.commands.CommandIssuer
      + + + +
        +
      • +

        getUniqueId

        +
        @NotNull
        +public @NotNull UUID getUniqueId()
        +
        +
        Specified by:
        +
        getUniqueId in interface co.aikar.commands.CommandIssuer
        +
        +
      • +
      • getPlayer

        -
        public org.spongepowered.api.entity.living.player.Player getPlayer()
        +
        public org.spongepowered.api.entity.living.player.Player getPlayer()
      @@ -235,7 +253,7 @@ implements co.aikar.commands.CommandIssuer
      • getManager

        -
        public co.aikar.commands.CommandManager getManager()
        +
        public co.aikar.commands.CommandManager getManager()
        Specified by:
        getManager in interface co.aikar.commands.CommandIssuer
        @@ -248,7 +266,7 @@ implements co.aikar.commands.CommandIssuer
        • sendMessageInternal

          -
          public void sendMessageInternal(String message)
          +
          public void sendMessageInternal(String message)
          Specified by:
          sendMessageInternal in interface co.aikar.commands.CommandIssuer
          @@ -261,7 +279,7 @@ implements co.aikar.commands.CommandIssuer
          • hasPermission

            -
            public boolean hasPermission(String permission)
            +
            public boolean hasPermission(String permission)
            Specified by:
            hasPermission in interface co.aikar.commands.CommandIssuer
            @@ -274,7 +292,7 @@ implements co.aikar.commands.CommandIssuer
            • equals

              -
              public boolean equals(Object o)
              +
              public boolean equals(Object o)
              Overrides:
              equals in class Object
              @@ -287,7 +305,7 @@ implements co.aikar.commands.CommandIssuer
              • hashCode

                -
                public int hashCode()
                +
                public int hashCode()
                Overrides:
                hashCode in class Object
                diff --git a/docs/acf-sponge/co/aikar/commands/SpongeCommandManager.html b/docs/acf-sponge/co/aikar/commands/SpongeCommandManager.html index f6f29799..4d97b035 100644 --- a/docs/acf-sponge/co/aikar/commands/SpongeCommandManager.html +++ b/docs/acf-sponge/co/aikar/commands/SpongeCommandManager.html @@ -159,7 +159,7 @@ extends co.aikar.commands.CommandManager<org.spongepowered.api.command.Comman

                Fields inherited from class co.aikar.commands.CommandManager

                -conditions, defaultExceptionHandler, defaultFormatter, defaultHelpPerPage, dependencies, formatters, localeChangedCallbacks, replacements, rootCommands, supportedLanguages, usePerIssuerLocale
              • +conditions, defaultExceptionHandler, defaultFormatter, defaultHelpPerPage, dependencies, formatters, issuersLocale, localeChangedCallbacks, replacements, rootCommands, supportedLanguages, usePerIssuerLocale
            @@ -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, registerDependency, registerDependency, 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, setIssuerLocale, 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/co/aikar/commands/class-use/ACFSpongeListener.html b/docs/acf-sponge/co/aikar/commands/class-use/ACFSpongeListener.html new file mode 100644 index 00000000..8721fe8b --- /dev/null +++ b/docs/acf-sponge/co/aikar/commands/class-use/ACFSpongeListener.html @@ -0,0 +1,123 @@ + + + + + + +Uses of Class co.aikar.commands.ACFSpongeListener (ACF (Sponge) 0.5.0-SNAPSHOT API) + + + + + + + + + + +
                                      +

                                      Uses of Class
                                      co.aikar.commands.ACFSpongeListener

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

                                      Copyright © 2018. All rights reserved.

                                      + + diff --git a/docs/acf-sponge/co/aikar/commands/class-use/SpongeCommandManager.html b/docs/acf-sponge/co/aikar/commands/class-use/SpongeCommandManager.html index b087e9e1..efb0aa6b 100644 --- a/docs/acf-sponge/co/aikar/commands/class-use/SpongeCommandManager.html +++ b/docs/acf-sponge/co/aikar/commands/class-use/SpongeCommandManager.html @@ -101,12 +101,15 @@ -SpongeCommandCompletions(SpongeCommandManager manager)  +ACFSpongeListener(SpongeCommandManager manager)  -SpongeCommandContexts(SpongeCommandManager manager)  +SpongeCommandCompletions(SpongeCommandManager manager)  +SpongeCommandContexts(SpongeCommandManager manager)  + + SpongeLocales(SpongeCommandManager manager)  diff --git a/docs/acf-sponge/co/aikar/commands/package-frame.html b/docs/acf-sponge/co/aikar/commands/package-frame.html index 59459402..c0eea342 100644 --- a/docs/acf-sponge/co/aikar/commands/package-frame.html +++ b/docs/acf-sponge/co/aikar/commands/package-frame.html @@ -13,6 +13,7 @@

                                      Classes

                                        +
                                      • ACFSpongeListener
                                      • ACFSpongeUtil
                                      • SpongeCommandCompletionContext
                                      • SpongeCommandCompletions
                                      • diff --git a/docs/acf-sponge/co/aikar/commands/package-summary.html b/docs/acf-sponge/co/aikar/commands/package-summary.html index 6be78be6..17b228e1 100644 --- a/docs/acf-sponge/co/aikar/commands/package-summary.html +++ b/docs/acf-sponge/co/aikar/commands/package-summary.html @@ -82,54 +82,58 @@ +ACFSpongeListener +  + + ACFSpongeUtil   - + SpongeCommandCompletionContext   - + SpongeCommandCompletions   - + SpongeCommandContexts   - + SpongeCommandExecutionContext   - + SpongeCommandIssuer   - + SpongeCommandManager   - + SpongeCommandOperationContext   - + SpongeConditionContext   - + SpongeLocales   - + SpongeMessageFormatter   - + SpongeRegisteredCommand   - + SpongeRootCommand   diff --git a/docs/acf-sponge/co/aikar/commands/package-tree.html b/docs/acf-sponge/co/aikar/commands/package-tree.html index 301b84fb..77a18d17 100644 --- a/docs/acf-sponge/co/aikar/commands/package-tree.html +++ b/docs/acf-sponge/co/aikar/commands/package-tree.html @@ -80,6 +80,7 @@
                                        • java.lang.Object
                                            +
                                          • co.aikar.commands.ACFSpongeListener
                                          • co.aikar.commands.ACFSpongeUtil
                                          • co.aikar.commands.CommandCompletionContext<I>
                                              diff --git a/docs/acf-sponge/index-all.html b/docs/acf-sponge/index-all.html index d4e791b9..0fb82fbf 100644 --- a/docs/acf-sponge/index-all.html +++ b/docs/acf-sponge/index-all.html @@ -75,6 +75,10 @@
                                              accept(CommandResult) - Method in class co.aikar.commands.contexts.CommandResultSupplier
                                               
                                              +
                                              ACFSpongeListener - Class in co.aikar.commands
                                              +
                                               
                                              +
                                              ACFSpongeListener(SpongeCommandManager) - Constructor for class co.aikar.commands.ACFSpongeListener
                                              +
                                               
                                              ACFSpongeUtil - Class in co.aikar.commands
                                               
                                              ACFSpongeUtil() - Constructor for class co.aikar.commands.ACFSpongeUtil
                                              @@ -187,6 +191,8 @@
                                               
                                              getSuggestions(CommandSource, String, Location<World>) - Method in class co.aikar.commands.SpongeRootCommand
                                               
                                              +
                                              getUniqueId() - Method in class co.aikar.commands.SpongeCommandIssuer
                                              +
                                               
                                              getUsage(CommandSource) - Method in class co.aikar.commands.SpongeRootCommand
                                               
                                              @@ -243,10 +249,14 @@

                                              O

                                              +
                                              onDisconnectCleanup(ClientConnectionEvent.Disconnect, Player) - Method in class co.aikar.commands.ACFSpongeListener
                                              +
                                               
                                              OnlinePlayer - Class in co.aikar.commands.contexts
                                               
                                              OnlinePlayer(Player) - Constructor for class co.aikar.commands.contexts.OnlinePlayer
                                               
                                              +
                                              onSettingsChange(PlayerChangeClientSettingsEvent, Player) - Method in class co.aikar.commands.ACFSpongeListener
                                              +
                                               
                                              diff --git a/docs/acf-sponge/overview-tree.html b/docs/acf-sponge/overview-tree.html index bf79bd0f..179d74d7 100644 --- a/docs/acf-sponge/overview-tree.html +++ b/docs/acf-sponge/overview-tree.html @@ -81,6 +81,7 @@
                                              • java.lang.Object
                                                  +
                                                • co.aikar.commands.ACFSpongeListener
                                                • co.aikar.commands.ACFSpongeUtil
                                                • co.aikar.commands.CommandCompletionContext<I>
                                                    diff --git a/docs/acf-sponge/src-html/co/aikar/commands/ACFSpongeListener.html b/docs/acf-sponge/src-html/co/aikar/commands/ACFSpongeListener.html new file mode 100644 index 00000000..d0fa24c7 --- /dev/null +++ b/docs/acf-sponge/src-html/co/aikar/commands/ACFSpongeListener.html @@ -0,0 +1,100 @@ + + + +Source code + + + +
                                                    +
                                                    001package co.aikar.commands;
                                                    +002
                                                    +003import org.spongepowered.api.entity.living.player.Player;
                                                    +004import org.spongepowered.api.event.Listener;
                                                    +005import org.spongepowered.api.event.Order;
                                                    +006import org.spongepowered.api.event.entity.living.humanoid.player.PlayerChangeClientSettingsEvent;
                                                    +007import org.spongepowered.api.event.filter.cause.First;
                                                    +008import org.spongepowered.api.event.network.ClientConnectionEvent;
                                                    +009
                                                    +010public class ACFSpongeListener {
                                                    +011
                                                    +012    private final SpongeCommandManager manager;
                                                    +013
                                                    +014    public ACFSpongeListener(SpongeCommandManager manager) {
                                                    +015        this.manager = manager;
                                                    +016    }
                                                    +017
                                                    +018    @Listener(order = Order.POST)
                                                    +019    public void onSettingsChange(PlayerChangeClientSettingsEvent changeSettingsEvent, @First Player targetPlayer) {
                                                    +020        //this event will be fired on join as well as every time the player changes it
                                                    +021        manager.setIssuerLocale(targetPlayer, targetPlayer.getLocale());
                                                    +022    }
                                                    +023
                                                    +024    @Listener
                                                    +025    public void onDisconnectCleanup(ClientConnectionEvent.Disconnect disconnectEvent, @First Player player) {
                                                    +026        manager.issuersLocale.remove(player.getUniqueId());
                                                    +027    }
                                                    +028}
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    + + diff --git a/docs/acf-sponge/src-html/co/aikar/commands/SpongeCommandIssuer.html b/docs/acf-sponge/src-html/co/aikar/commands/SpongeCommandIssuer.html index e2dda575..8a49bdc2 100644 --- a/docs/acf-sponge/src-html/co/aikar/commands/SpongeCommandIssuer.html +++ b/docs/acf-sponge/src-html/co/aikar/commands/SpongeCommandIssuer.html @@ -31,65 +31,79 @@ 023 024package co.aikar.commands; 025 -026import org.spongepowered.api.command.CommandSource; -027import org.spongepowered.api.entity.living.player.Player; -028import org.spongepowered.api.text.serializer.TextSerializers; -029 -030import java.util.Objects; -031 -032public class SpongeCommandIssuer implements CommandIssuer { -033 -034 private final SpongeCommandManager manager; -035 private final CommandSource source; +026import org.jetbrains.annotations.NotNull; +027import org.spongepowered.api.command.CommandSource; +028import org.spongepowered.api.command.source.ConsoleSource; +029import org.spongepowered.api.entity.living.player.Player; +030import org.spongepowered.api.text.serializer.TextSerializers; +031import org.spongepowered.api.util.Identifiable; +032 +033import java.nio.charset.StandardCharsets; +034import java.util.Objects; +035import java.util.UUID; 036 -037 SpongeCommandIssuer(SpongeCommandManager manager, final CommandSource source) { -038 this.manager = manager; -039 this.source = source; -040 } +037public class SpongeCommandIssuer implements CommandIssuer { +038 +039 private final SpongeCommandManager manager; +040 private final CommandSource source; 041 -042 @Override -043 public boolean isPlayer() { -044 return this.source instanceof Player; +042 SpongeCommandIssuer(SpongeCommandManager manager, final CommandSource source) { +043 this.manager = manager; +044 this.source = source; 045 } 046 047 @Override -048 public CommandSource getIssuer() { -049 return this.source; +048 public boolean isPlayer() { +049 return this.source instanceof Player; 050 } 051 -052 public Player getPlayer() { -053 return isPlayer() ? (Player) source : null; -054 } -055 -056 @Override -057 public CommandManager getManager() { -058 return manager; -059 } -060 -061 @Override -062 public void sendMessageInternal(String message) { -063 this.source.sendMessage(TextSerializers.LEGACY_FORMATTING_CODE.deserialize(message)); -064 } -065 -066 @Override -067 public boolean hasPermission(final String permission) { -068 return this.source.hasPermission(permission); +052 @Override +053 public CommandSource getIssuer() { +054 return this.source; +055 } +056 +057 @Override +058 public @NotNull UUID getUniqueId() { +059 if (this.source instanceof Identifiable) { +060 return ((Identifiable) source).getUniqueId(); +061 } +062 +063 //generate a unique id based of the name (like for the console command sender) +064 return UUID.nameUUIDFromBytes(source.getName().getBytes(StandardCharsets.UTF_8)); +065 } +066 +067 public Player getPlayer() { +068 return isPlayer() ? (Player) source : null; 069 } 070 -071 -072 @Override -073 public boolean equals(Object o) { -074 if (this == o) return true; -075 if (o == null || getClass() != o.getClass()) return false; -076 SpongeCommandIssuer that = (SpongeCommandIssuer) o; -077 return Objects.equals(source, that.source); -078 } -079 -080 @Override -081 public int hashCode() { -082 return Objects.hash(source); -083 } -084} +071 @Override +072 public CommandManager getManager() { +073 return manager; +074 } +075 +076 @Override +077 public void sendMessageInternal(String message) { +078 this.source.sendMessage(TextSerializers.LEGACY_FORMATTING_CODE.deserialize(message)); +079 } +080 +081 @Override +082 public boolean hasPermission(final String permission) { +083 return this.source.hasPermission(permission); +084 } +085 +086 @Override +087 public boolean equals(Object o) { +088 if (this == o) return true; +089 if (o == null || getClass() != o.getClass()) return false; +090 SpongeCommandIssuer that = (SpongeCommandIssuer) o; +091 return Objects.equals(source, that.source); +092 } +093 +094 @Override +095 public int hashCode() { +096 return Objects.hash(source); +097 } +098} 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 2d13465a..cc49ce3d 100644 --- a/docs/acf-sponge/src-html/co/aikar/commands/SpongeCommandManager.html +++ b/docs/acf-sponge/src-html/co/aikar/commands/SpongeCommandManager.html @@ -76,136 +76,137 @@ 068 this.formatters.put(MessageType.HELP, new SpongeMessageFormatter(TextColors.AQUA, TextColors.GREEN, TextColors.YELLOW)); 069 getLocales(); // auto load locales 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} +071 Sponge.getEventManager().registerListeners(plugin, new ACFSpongeListener(this)); +072 +073 //TODO more default dependencies for sponge +074 registerDependency(plugin.getClass(), plugin); +075 } +076 +077 public PluginContainer getPlugin() { +078 return plugin; +079 } +080 +081 @Override +082 public boolean isCommandIssuer(Class<?> type) { +083 return CommandSource.class.isAssignableFrom(type); +084 } +085 +086 @Override +087 public synchronized CommandContexts<SpongeCommandExecutionContext> getCommandContexts() { +088 if (this.contexts == null) { +089 this.contexts = new SpongeCommandContexts(this); +090 } +091 return contexts; +092 } +093 +094 @Override +095 public synchronized CommandCompletions<SpongeCommandCompletionContext> getCommandCompletions() { +096 if (this.completions == null) { +097 this.completions = new SpongeCommandCompletions(this); +098 } +099 return completions; +100 } +101 +102 @Override +103 public SpongeLocales getLocales() { +104 if (this.locales == null) { +105 this.locales = new SpongeLocales(this); +106 this.locales.loadLanguages(); +107 } +108 return locales; +109 } +110 +111 @Override +112 public boolean hasRegisteredCommands() { +113 return !registeredCommands.isEmpty(); +114 } +115 +116 @Override +117 public void registerCommand(BaseCommand command) { +118 command.onRegister(this); +119 +120 for (Map.Entry<String, RootCommand> entry : command.registeredCommands.entrySet()) { +121 String commandName = entry.getKey().toLowerCase(); +122 SpongeRootCommand spongeCommand = (SpongeRootCommand) entry.getValue(); +123 if (!spongeCommand.isRegistered) { +124 Sponge.getCommandManager().register(this.plugin, spongeCommand, commandName); +125 } +126 spongeCommand.isRegistered = true; +127 registeredCommands.put(commandName, spongeCommand); +128 } +129 } +130 +131 public Timing createTiming(final String name) { +132 return Timings.of(this.plugin, name, this.commandTiming); +133 } +134 +135 @Override +136 public RootCommand createRootCommand(String cmd) { +137 return new SpongeRootCommand(this, cmd); +138 } +139 +140 @Override +141 public SpongeCommandIssuer getCommandIssuer(Object issuer) { +142 if (!(issuer instanceof CommandSource)) { +143 throw new IllegalArgumentException(issuer.getClass().getName() + " is not a Command Issuer."); +144 } +145 return new SpongeCommandIssuer(this, (CommandSource) issuer); +146 } +147 +148 @Override +149 public SpongeCommandExecutionContext createCommandContext(RegisteredCommand command, Parameter parameter, CommandIssuer sender, List<String> args, int i, Map<String, Object> passedArgs) { +150 return new SpongeCommandExecutionContext(command, parameter, (SpongeCommandIssuer) sender, args, i, passedArgs); +151 } +152 +153 @Override +154 public CommandCompletionContext createCompletionContext(RegisteredCommand command, CommandIssuer sender, String input, String config, String[] args) { +155 return new SpongeCommandCompletionContext(command, (SpongeCommandIssuer) sender, input, config, args); +156 } +157 +158 @Override +159 public RegisteredCommand createRegisteredCommand(BaseCommand command, String cmdName, Method method, String prefSubCommand) { +160 return new SpongeRegisteredCommand(command, cmdName, method, prefSubCommand); +161 } +162 +163 @Override +164 public void log(final LogLevel level, final String message, final Throwable throwable) { +165 Logger logger = this.plugin.getLogger(); +166 switch(level) { +167 case INFO: +168 logger.info(LogLevel.LOG_PREFIX + message); +169 if (throwable != null) { +170 for (String line : ACFPatterns.NEWLINE.split(ApacheCommonsExceptionUtil.getFullStackTrace(throwable))) { +171 logger.info(LogLevel.LOG_PREFIX + line); +172 } +173 } +174 return; +175 case ERROR: +176 logger.error(LogLevel.LOG_PREFIX + message); +177 if (throwable != null) { +178 for (String line : ACFPatterns.NEWLINE.split(ApacheCommonsExceptionUtil.getFullStackTrace(throwable))) { +179 logger.error(LogLevel.LOG_PREFIX + line); +180 } +181 } +182 } +183 } +184 +185 @Override +186 CommandOperationContext createCommandOperationContext(BaseCommand command, CommandIssuer issuer, String commandLabel, String[] args, boolean isAsync) { +187 return new SpongeCommandOperationContext( +188 this, +189 issuer, +190 command, +191 commandLabel, +192 args, +193 isAsync +194 ); +195 } +196 +197 @Override +198 public SpongeConditionContext createConditionContext(CommandIssuer issuer, String config) { +199 return new SpongeConditionContext((SpongeCommandIssuer) issuer, config); +200 } +201}