diff --git a/docs/acf-bukkit/allclasses-frame.html b/docs/acf-bukkit/allclasses-frame.html index a53ebecd..bedc5318 100644 --- a/docs/acf-bukkit/allclasses-frame.html +++ b/docs/acf-bukkit/allclasses-frame.html @@ -25,6 +25,7 @@
public class BukkitCommandContexts +public class BukkitCommandContexts extends co.aikar.commands.CommandContexts<BukkitCommandExecutionContext>
public BukkitCommandContexts(BukkitCommandManager manager)+
public BukkitCommandContexts(BukkitCommandManager manager)
public class BukkitCommandManager +public class BukkitCommandManager extends co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,BukkitCommandIssuer,org.bukkit.ChatColor,BukkitMessageFormatter,BukkitCommandExecutionContext,BukkitConditionContext>
locales
IntegermcMinorVersion IntegermcPatchVersion protected org.bukkit.plugin.Pluginplugin protected final org.bukkit.plugin.Plugin plugin+
protected final org.bukkit.plugin.Plugin plugin+
public final Integer mcMinorVersion+
public final Integer mcPatchVersion
protected Map<String,org.bukkit.command.Command> knownCommands+
protected Map<String,org.bukkit.command.Command> knownCommands
protected Map<String,BukkitRootCommand> registeredCommands+
protected Map<String,BukkitRootCommand> registeredCommands
protected BukkitCommandContexts contexts+
protected BukkitCommandContexts contexts
protected BukkitCommandCompletions completions+
protected BukkitCommandCompletions completions
protected BukkitLocales locales+
protected BukkitLocales locales
protected boolean autoDetectFromClient+
protected boolean autoDetectFromClient
public BukkitCommandManager(org.bukkit.plugin.Plugin plugin)+
public BukkitCommandManager(org.bukkit.plugin.Plugin plugin)
public org.bukkit.plugin.Plugin getPlugin()+
public org.bukkit.plugin.Plugin getPlugin()
public boolean isCommandIssuer(Class<?> type)+
public boolean isCommandIssuer(Class<?> type)
isCommandIssuer in class co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,BukkitCommandIssuer,org.bukkit.ChatColor,BukkitMessageFormatter,BukkitCommandExecutionContext,BukkitConditionContext>public co.aikar.commands.CommandContexts<BukkitCommandExecutionContext> getCommandContexts()+
public co.aikar.commands.CommandContexts<BukkitCommandExecutionContext> getCommandContexts()
getCommandContexts in class co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,BukkitCommandIssuer,org.bukkit.ChatColor,BukkitMessageFormatter,BukkitCommandExecutionContext,BukkitConditionContext>public co.aikar.commands.CommandCompletions<BukkitCommandCompletionContext> getCommandCompletions()+
public co.aikar.commands.CommandCompletions<BukkitCommandCompletionContext> getCommandCompletions()
getCommandCompletions in class co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,BukkitCommandIssuer,org.bukkit.ChatColor,BukkitMessageFormatter,BukkitCommandExecutionContext,BukkitConditionContext>public BukkitLocales getLocales()+
public BukkitLocales getLocales()
getLocales in class co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,BukkitCommandIssuer,org.bukkit.ChatColor,BukkitMessageFormatter,BukkitCommandExecutionContext,BukkitConditionContext>public boolean hasRegisteredCommands()+
public boolean hasRegisteredCommands()
hasRegisteredCommands in class co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,BukkitCommandIssuer,org.bukkit.ChatColor,BukkitMessageFormatter,BukkitCommandExecutionContext,BukkitConditionContext>public void registerCommand(co.aikar.commands.BaseCommand command, +public void registerCommand(co.aikar.commands.BaseCommand command, boolean force)
public void registerCommand(co.aikar.commands.BaseCommand command)+
public void registerCommand(co.aikar.commands.BaseCommand command)
registerCommand in class co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,BukkitCommandIssuer,org.bukkit.ChatColor,BukkitMessageFormatter,BukkitCommandExecutionContext,BukkitConditionContext>public void unregisterCommand(co.aikar.commands.BaseCommand command)+
public void unregisterCommand(co.aikar.commands.BaseCommand command)
@Deprecated -public void unregisterCommand(BukkitRootCommand command)+public void unregisterCommand(BukkitRootCommand command)
public void unregisterCommands()+
public void unregisterCommands()
public Locale setPlayerLocale(org.bukkit.entity.Player player, +public Locale setPlayerLocale(org.bukkit.entity.Player player, Locale locale)
public co.aikar.timings.lib.TimingManager getTimings()+
public co.aikar.timings.lib.TimingManager getTimings()
public co.aikar.commands.RootCommand createRootCommand(String cmd)+
public co.aikar.commands.RootCommand createRootCommand(String cmd)
createRootCommand in class co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,BukkitCommandIssuer,org.bukkit.ChatColor,BukkitMessageFormatter,BukkitCommandExecutionContext,BukkitConditionContext>public Collection<co.aikar.commands.RootCommand> getRegisteredRootCommands()+
public Collection<co.aikar.commands.RootCommand> getRegisteredRootCommands()
getRegisteredRootCommands in class co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,BukkitCommandIssuer,org.bukkit.ChatColor,BukkitMessageFormatter,BukkitCommandExecutionContext,BukkitConditionContext>public BukkitCommandIssuer getCommandIssuer(Object issuer)+
public BukkitCommandIssuer getCommandIssuer(Object issuer)
getCommandIssuer in class co.aikar.commands.CommandManager<org.bukkit.command.CommandSender,BukkitCommandIssuer,org.bukkit.ChatColor,BukkitMessageFormatter,BukkitCommandExecutionContext,BukkitConditionContext>public BukkitCommandExecutionContext createCommandContext(co.aikar.commands.RegisteredCommand command, +public BukkitCommandExecutionContext createCommandContext(co.aikar.commands.RegisteredCommand command, co.aikar.commands.CommandParameter parameter, co.aikar.commands.CommandIssuer sender, List<String> args, @@ -651,7 +677,7 @@ public voidcreateCompletionContext
-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, @@ -668,7 +694,7 @@ public voidcreateRegisteredCommand
-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)@@ -684,7 +710,7 @@ public voidcreateConditionContext
-public BukkitConditionContext createConditionContext(co.aikar.commands.CommandIssuer issuer, +public BukkitConditionContext createConditionContext(co.aikar.commands.CommandIssuer issuer, String config)
- Overrides:
@@ -698,7 +724,7 @@ public voidlog
-public void log(co.aikar.commands.LogLevel level, +public void log(co.aikar.commands.LogLevel level, String message, Throwable throwable)@@ -713,7 +739,7 @@ public void
- @@ -723,7 +749,7 @@ public void
usePerIssuerLocale
-public boolean usePerIssuerLocale(boolean usePerIssuerLocale, +public boolean usePerIssuerLocale(boolean usePerIssuerLocale, boolean autoDetectFromClient)- @@ -158,29 +159,13 @@ extends -
getCommandPrefix
-public String getCommandPrefix(co.aikar.commands.CommandIssuer issuer)+public String getCommandPrefix(co.aikar.commands.CommandIssuer issuer)
- Overrides:
- @@ -736,7 +762,7 @@ public void
getCommandPrefixin classco.aikar.commands.CommandManager<org.bukkit.command.CommandSender,BukkitCommandIssuer,org.bukkit.ChatColor,BukkitMessageFormatter,BukkitCommandExecutionContext,BukkitConditionContext>- @@ -147,7 +146,9 @@ extends Constructor and Description
handleUncaughtException
-protected boolean handleUncaughtException(co.aikar.commands.BaseCommand scope, +protected boolean handleUncaughtException(co.aikar.commands.BaseCommand scope, co.aikar.commands.RegisteredCommand registeredCommand, co.aikar.commands.CommandIssuer sender, List<String> args, diff --git a/docs/acf-bukkit/co/aikar/commands/bukkit/contexts/OnlinePlayer.html b/docs/acf-bukkit/co/aikar/commands/bukkit/contexts/OnlinePlayer.html new file mode 100644 index 00000000..d2226802 --- /dev/null +++ b/docs/acf-bukkit/co/aikar/commands/bukkit/contexts/OnlinePlayer.html @@ -0,0 +1,361 @@ + + + + + + +OnlinePlayer (ACF (Bukkit) 0.5.0-SNAPSHOT API) + + + + + + + + + + + +++co.aikar.commands.bukkit.contexts+Class OnlinePlayer
+++ + + + + ++
+- java.lang.Object
+- +
++
+- co.aikar.commands.bukkit.contexts.OnlinePlayer
++++
+- +
++
+- Direct Known Subclasses:
+- OnlinePlayer
+
+
+public class OnlinePlayer +extends Object+++ ++
+- + +
++
+ +- + + +
+Field Summary
++
+Fields ++ +Modifier and Type +Field and Description ++ ++ org.bukkit.entity.Player+ player+
+ +- + + +
+Constructor Summary
++
+Constructors ++ +Constructor and Description ++ ++ OnlinePlayer(org.bukkit.entity.Player player)+
+- + + +
+Method Summary
++
+ +All Methods Instance Methods Concrete Methods ++ +Modifier and Type +Method and Description ++ ++ boolean+ equals(Object o)+ ++ org.bukkit.entity.Player+ getPlayer()+ ++ int+ hashCode()+ ++ String+ toString()Copyright © 2019. All rights reserved.
+ + diff --git a/docs/acf-bukkit/co/aikar/commands/bukkit/contexts/class-use/OnlinePlayer.html b/docs/acf-bukkit/co/aikar/commands/bukkit/contexts/class-use/OnlinePlayer.html new file mode 100644 index 00000000..bddf4b5b --- /dev/null +++ b/docs/acf-bukkit/co/aikar/commands/bukkit/contexts/class-use/OnlinePlayer.html @@ -0,0 +1,167 @@ + + + + + + +Uses of Class co.aikar.commands.bukkit.contexts.OnlinePlayer (ACF (Bukkit) 0.5.0-SNAPSHOT API) + + + + + + + + + + +++Uses of Class
+
co.aikar.commands.bukkit.contexts.OnlinePlayer++ + + + ++
+- +
++
+Packages that use OnlinePlayer ++ + +Package +Description ++ + +co.aikar.commands.contexts ++ - +
++
+- + + +
+Uses of OnlinePlayer in co.aikar.commands.contexts
++
+Subclasses of OnlinePlayer in co.aikar.commands.contexts ++ + +Modifier and Type +Class and Description ++ + ++ class+ OnlinePlayer+Deprecated. ++Use+insteadCopyright © 2019. All rights reserved.
+ + diff --git a/docs/acf-bukkit/co/aikar/commands/bukkit/contexts/package-frame.html b/docs/acf-bukkit/co/aikar/commands/bukkit/contexts/package-frame.html new file mode 100644 index 00000000..e61fb353 --- /dev/null +++ b/docs/acf-bukkit/co/aikar/commands/bukkit/contexts/package-frame.html @@ -0,0 +1,20 @@ + + + + + + +co.aikar.commands.bukkit.contexts (ACF (Bukkit) 0.5.0-SNAPSHOT API) + + + + +co.aikar.commands.bukkit.contexts
+++ + diff --git a/docs/acf-bukkit/co/aikar/commands/bukkit/contexts/package-summary.html b/docs/acf-bukkit/co/aikar/commands/bukkit/contexts/package-summary.html new file mode 100644 index 00000000..83ab4d29 --- /dev/null +++ b/docs/acf-bukkit/co/aikar/commands/bukkit/contexts/package-summary.html @@ -0,0 +1,141 @@ + + + + + + +Classes
++
+- OnlinePlayer
+co.aikar.commands.bukkit.contexts (ACF (Bukkit) 0.5.0-SNAPSHOT API) + + + + + + + + + + +++Package co.aikar.commands.bukkit.contexts
+++ + + + ++
+- +
++
+Class Summary ++ + +Class +Description ++ + +OnlinePlayer ++ Copyright © 2019. All rights reserved.
+ + diff --git a/docs/acf-bukkit/co/aikar/commands/bukkit/contexts/package-tree.html b/docs/acf-bukkit/co/aikar/commands/bukkit/contexts/package-tree.html new file mode 100644 index 00000000..1933cc70 --- /dev/null +++ b/docs/acf-bukkit/co/aikar/commands/bukkit/contexts/package-tree.html @@ -0,0 +1,136 @@ + + + + + + +co.aikar.commands.bukkit.contexts Class Hierarchy (ACF (Bukkit) 0.5.0-SNAPSHOT API) + + + + + + + + + + + +++ + + + +Class Hierarchy
++
+- java.lang.Object +
++
+- co.aikar.commands.bukkit.contexts.OnlinePlayer
+Copyright © 2019. All rights reserved.
+ + diff --git a/docs/acf-bukkit/co/aikar/commands/bukkit/contexts/package-use.html b/docs/acf-bukkit/co/aikar/commands/bukkit/contexts/package-use.html new file mode 100644 index 00000000..75ef09bc --- /dev/null +++ b/docs/acf-bukkit/co/aikar/commands/bukkit/contexts/package-use.html @@ -0,0 +1,156 @@ + + + + + + +Uses of Package co.aikar.commands.bukkit.contexts (ACF (Bukkit) 0.5.0-SNAPSHOT API) + + + + + + + + + + +++Uses of Package
+
co.aikar.commands.bukkit.contexts++ + + + ++
+- +
++
+Packages that use co.aikar.commands.bukkit.contexts ++ + +Package +Description ++ + +co.aikar.commands.contexts ++ - + + +
++
+Classes in co.aikar.commands.bukkit.contexts used by co.aikar.commands.contexts ++ + +Class and Description ++ + +OnlinePlayer +Copyright © 2019. All rights reserved.
+ + diff --git a/docs/acf-bukkit/co/aikar/commands/contexts/OnlinePlayer.html b/docs/acf-bukkit/co/aikar/commands/contexts/OnlinePlayer.html index a9f80ed6..69a1bb41 100644 --- a/docs/acf-bukkit/co/aikar/commands/contexts/OnlinePlayer.html +++ b/docs/acf-bukkit/co/aikar/commands/contexts/OnlinePlayer.html @@ -18,12 +18,6 @@ catch(err) { } //--> -var methods = {"i0":10,"i1":10,"i2":10,"i3":10}; -var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]}; -var altColor = "altColor"; -var rowColor = "rowColor"; -var tableTab = "tableTab"; -var activeTableTab = "activeTableTab";- + OnlinePlayer(org.bukkit.entity.Player player)OnlinePlayer(org.bukkit.entity.Player player)+Deprecated.+All Methods Instance Methods Concrete Methods -- -Modifier and Type -Method and Description -- -- boolean- equals(Object o)- -- org.bukkit.entity.Player- getPlayer()- -- int- hashCode()- - +- String- toString()+
- + + +
+Methods inherited from class co.aikar.commands.bukkit.contexts.OnlinePlayer
+equals, getPlayer, hashCode, toString
- @@ -196,23 +181,6 @@ extends
- - diff --git a/docs/acf-bukkit/co/aikar/commands/contexts/package-summary.html b/docs/acf-bukkit/co/aikar/commands/contexts/package-summary.html index a014ba2e..e1f631e3 100644 --- a/docs/acf-bukkit/co/aikar/commands/contexts/package-summary.html +++ b/docs/acf-bukkit/co/aikar/commands/contexts/package-summary.html @@ -42,7 +42,7 @@
- - - -
--
- Prev Package
+- Prev Package
- Next Package
@@ -83,7 +83,9 @@
@@ -110,7 +112,7 @@ OnlinePlayer -+ Deprecated + Use+instead-
- Prev Package
+- Prev Package
- Next Package
diff --git a/docs/acf-bukkit/co/aikar/commands/contexts/package-tree.html b/docs/acf-bukkit/co/aikar/commands/contexts/package-tree.html index 63c90c16..cbb93fc4 100644 --- a/docs/acf-bukkit/co/aikar/commands/contexts/package-tree.html +++ b/docs/acf-bukkit/co/aikar/commands/contexts/package-tree.html @@ -42,7 +42,7 @@
@@ -80,10 +80,14 @@
- java.lang.Object
++
+- co.aikar.commands.bukkit.contexts.OnlinePlayer +
- co.aikar.commands.contexts.OnlinePlayer
diff --git a/docs/acf-bukkit/co/aikar/commands/package-summary.html b/docs/acf-bukkit/co/aikar/commands/package-summary.html index 109f7eba..bea76260 100644 --- a/docs/acf-bukkit/co/aikar/commands/package-summary.html +++ b/docs/acf-bukkit/co/aikar/commands/package-summary.html @@ -43,7 +43,7 @@
diff --git a/docs/acf-bungee/co/aikar/commands/contexts/package-summary.html b/docs/acf-bungee/co/aikar/commands/contexts/package-summary.html index f2cd9995..450b4d17 100644 --- a/docs/acf-bungee/co/aikar/commands/contexts/package-summary.html +++ b/docs/acf-bungee/co/aikar/commands/contexts/package-summary.html @@ -42,7 +42,7 @@
- Prev Package
-- Next Package
+- Next Package
- Frames
@@ -170,7 +170,7 @@@@ -99,17 +93,26 @@ var activeTableTab = "activeTableTab";
- Prev Package
-- Next Package
+- Next Package
diff --git a/docs/acf-bungee/co/aikar/commands/bungee/contexts/OnlinePlayer.html b/docs/acf-bungee/co/aikar/commands/bungee/contexts/OnlinePlayer.html new file mode 100644 index 00000000..3ad36d68 --- /dev/null +++ b/docs/acf-bungee/co/aikar/commands/bungee/contexts/OnlinePlayer.html @@ -0,0 +1,361 @@ + + + + + + +
- Frames
diff --git a/docs/acf-bukkit/co/aikar/commands/package-tree.html b/docs/acf-bukkit/co/aikar/commands/package-tree.html index 9f43b05c..55202b65 100644 --- a/docs/acf-bukkit/co/aikar/commands/package-tree.html +++ b/docs/acf-bukkit/co/aikar/commands/package-tree.html @@ -43,7 +43,7 @@diff --git a/docs/acf-bungee/co/aikar/commands/BungeeCommandContexts.html b/docs/acf-bungee/co/aikar/commands/BungeeCommandContexts.html index 778c9f67..04dbc036 100644 --- a/docs/acf-bungee/co/aikar/commands/BungeeCommandContexts.html +++ b/docs/acf-bungee/co/aikar/commands/BungeeCommandContexts.html @@ -107,7 +107,7 @@+
- Frames
@@ -169,7 +169,7 @@-
- Frames
diff --git a/docs/acf-bukkit/deprecated-list.html b/docs/acf-bukkit/deprecated-list.html index f9ea670d..b98d4110 100644 --- a/docs/acf-bukkit/deprecated-list.html +++ b/docs/acf-bukkit/deprecated-list.html @@ -72,10 +72,31 @@Deprecated API
Contents
+@@ -128,7 +129,11 @@+ + +diff --git a/docs/acf-bukkit/overview-summary.html b/docs/acf-bukkit/overview-summary.html index 465d1c8d..835bf0cf 100644 --- a/docs/acf-bukkit/overview-summary.html +++ b/docs/acf-bukkit/overview-summary.html @@ -84,6 +84,10 @@+
+- +
++
+Deprecated Classes ++ + +Class and Description ++ + +co.aikar.commands.contexts.OnlinePlayer + +Use+insteaddiff --git a/docs/acf-bukkit/index-all.html b/docs/acf-bukkit/index-all.html index 94513cde..40e20b62 100644 --- a/docs/acf-bukkit/index-all.html +++ b/docs/acf-bukkit/index-all.html @@ -129,6 +129,8 @@
- co.aikar.commands - package co.aikar.commands
- +
- co.aikar.commands.bukkit.contexts - package co.aikar.commands.bukkit.contexts
+- co.aikar.commands.contexts - package co.aikar.commands.contexts
- color(String) - Static method in class co.aikar.commands.ACFBukkitUtil
@@ -167,9 +169,9 @@E
-
- equals(Object) - Method in class co.aikar.commands.BukkitCommandIssuer
+- equals(Object) - Method in class co.aikar.commands.bukkit.contexts.OnlinePlayer
- -
- equals(Object) - Method in class co.aikar.commands.contexts.OnlinePlayer
+- equals(Object) - Method in class co.aikar.commands.BukkitCommandIssuer
- execute(CommandSender, String, String[]) - Method in class co.aikar.commands.BukkitRootCommand
- @@ -221,6 +223,8 @@
- getMessageKey() - Method in enum co.aikar.commands.MinecraftMessageKeys
- +
- getPlayer() - Method in class co.aikar.commands.bukkit.contexts.OnlinePlayer
+- getPlayer() - Method in class co.aikar.commands.BukkitCommandCompletionContext
Returns the Player object if this Issuer is a Player@@ -233,8 +237,6 @@- getPlayer() - Method in class co.aikar.commands.BukkitConditionContext
- -
- getPlayer() - Method in class co.aikar.commands.contexts.OnlinePlayer
-- getPlugin() - Method in class co.aikar.commands.BukkitCommandManager
- getRandLoc(Location, int) - Static method in class co.aikar.commands.ACFBukkitUtil
@@ -271,9 +273,9 @@
- handleUncaughtException(BaseCommand, RegisteredCommand, CommandIssuer, List<String>, Throwable) - Method in class co.aikar.commands.BukkitCommandManager
- -
- hashCode() - Method in class co.aikar.commands.BukkitCommandIssuer
+- hashCode() - Method in class co.aikar.commands.bukkit.contexts.OnlinePlayer
- -
- hashCode() - Method in class co.aikar.commands.contexts.OnlinePlayer
+- hashCode() - Method in class co.aikar.commands.BukkitCommandIssuer
- hasPermission(String) - Method in class co.aikar.commands.BukkitCommandIssuer
- @@ -333,6 +335,10 @@
M
+
@@ -341,17 +347,27 @@- mcMinorVersion - Variable in class co.aikar.commands.BukkitCommandManager
+- +
- mcPatchVersion - Variable in class co.aikar.commands.BukkitCommandManager
+- MinecraftMessageKeys - Enum in co.aikar.commands
O
+
- OnlinePlayer - Class in co.aikar.commands.bukkit.contexts
+- +
- OnlinePlayer(Player) - Constructor for class co.aikar.commands.bukkit.contexts.OnlinePlayer
+- OnlinePlayer - Class in co.aikar.commands.contexts
-- +
- +
Deprecated. ++Use+instead- OnlinePlayer(Player) - Constructor for class co.aikar.commands.contexts.OnlinePlayer
-- +
- +
Deprecated.+P
-
diff --git a/docs/acf-bukkit/overview-frame.html b/docs/acf-bukkit/overview-frame.html index 711e04f0..66f8a6d7 100644 --- a/docs/acf-bukkit/overview-frame.html +++ b/docs/acf-bukkit/overview-frame.html @@ -14,6 +14,7 @@- player - Variable in class co.aikar.commands.contexts.OnlinePlayer
+- player - Variable in class co.aikar.commands.bukkit.contexts.OnlinePlayer
- plugin - Variable in class co.aikar.commands.BukkitCommandManager
- @@ -405,7 +421,7 @@
- testPermissionSilent(CommandSender) - Method in class co.aikar.commands.BukkitRootCommand
- -
- toString() - Method in class co.aikar.commands.contexts.OnlinePlayer
+- toString() - Method in class co.aikar.commands.bukkit.contexts.OnlinePlayer
Packages
+ +co.aikar.commands.bukkit.contexts ++ diff --git a/docs/acf-bukkit/overview-tree.html b/docs/acf-bukkit/overview-tree.html index 550a222f..edb67b30 100644 --- a/docs/acf-bukkit/overview-tree.html +++ b/docs/acf-bukkit/overview-tree.html @@ -73,6 +73,7 @@ Package Hierarchies: co.aikar.commands.contexts - co.aikar.commands.BukkitMessageFormatter
- co.aikar.commands.bukkit.contexts.OnlinePlayer +
+
- co.aikar.commands.contexts.OnlinePlayer
+- co.aikar.commands.RegisteredCommand<CEC>
- co.aikar.commands.BukkitRegisteredCommand
diff --git a/docs/acf-bukkit/package-list b/docs/acf-bukkit/package-list index 105851a3..e2fac2bc 100644 --- a/docs/acf-bukkit/package-list +++ b/docs/acf-bukkit/package-list @@ -1,2 +1,3 @@ co.aikar.commands +co.aikar.commands.bukkit.contexts co.aikar.commands.contexts diff --git a/docs/acf-bukkit/src-html/co/aikar/commands/BukkitCommandContexts.html b/docs/acf-bukkit/src-html/co/aikar/commands/BukkitCommandContexts.html index bc4232aa..515066e7 100644 --- a/docs/acf-bukkit/src-html/co/aikar/commands/BukkitCommandContexts.html +++ b/docs/acf-bukkit/src-html/co/aikar/commands/BukkitCommandContexts.html @@ -31,236 +31,232 @@ 023 024package co.aikar.commands; 025 -026import co.aikar.commands.annotation.Optional; -027import co.aikar.commands.contexts.OnlinePlayer; -028import org.bukkit.Bukkit; -029import org.bukkit.ChatColor; -030import org.bukkit.Location; -031import org.bukkit.OfflinePlayer; -032import org.bukkit.World; -033import org.bukkit.command.BlockCommandSender; -034import org.bukkit.command.CommandSender; -035import org.bukkit.entity.Entity; -036import org.bukkit.entity.Player; -037import org.bukkit.inventory.PlayerInventory; -038import org.jetbrains.annotations.Nullable; -039 -040import java.util.HashSet; -041import java.util.Set; -042import java.util.UUID; -043import java.util.regex.Matcher; -044import java.util.regex.Pattern; -045import java.util.stream.Collectors; -046import java.util.stream.Stream; -047 -048@SuppressWarnings("WeakerAccess") -049public class BukkitCommandContexts extends CommandContexts<BukkitCommandExecutionContext> { -050 -051 public BukkitCommandContexts(BukkitCommandManager manager) { -052 super(manager); -053 -054 registerContext(OnlinePlayer.class, c -> getOnlinePlayer(c.getIssuer(), c.popFirstArg(), c.hasAnnotation(Optional.class))); -055 registerContext(OnlinePlayer[].class, (c) -> { -056 BukkitCommandIssuer issuer = c.getIssuer(); -057 final String search = c.popFirstArg(); -058 boolean allowMissing = c.hasFlag("allowmissing"); -059 Set<OnlinePlayer> players = new HashSet<>(); -060 Pattern split = ACFPatterns.COMMA; -061 String splitter = c.getFlagValue("splitter", (String) null); -062 if (splitter != null) { -063 split = Pattern.compile(Pattern.quote(splitter)); -064 } -065 for (String lookup : split.split(search)) { -066 OnlinePlayer player = getOnlinePlayer(issuer, lookup, allowMissing); -067 if (player != null) { -068 players.add(player); -069 } -070 } -071 if (players.isEmpty() && !c.hasFlag("allowempty")) { -072 issuer.sendError(MinecraftMessageKeys.NO_PLAYER_FOUND_SERVER, -073 "{search}", search); -074 -075 throw new InvalidCommandArgument(false); -076 } -077 return players.toArray(new OnlinePlayer[players.size()]); -078 }); -079 registerIssuerAwareContext(World.class, (c) -> { -080 String firstArg = c.getFirstArg(); -081 World world = firstArg != null ? Bukkit.getWorld(firstArg) : null; -082 if (world != null) { -083 c.popFirstArg(); -084 } -085 if (world == null && c.getSender() instanceof Player) { -086 world = ((Entity) c.getSender()).getWorld(); -087 } -088 if (world == null) { -089 throw new InvalidCommandArgument(MinecraftMessageKeys.INVALID_WORLD); -090 } -091 return world; -092 }); -093 registerIssuerAwareContext(CommandSender.class, BukkitCommandExecutionContext::getSender); -094 registerIssuerAwareContext(Player.class, (c) -> { -095 boolean isOptional = c.hasAnnotation(Optional.class); -096 CommandSender sender = c.getSender(); -097 boolean isPlayerSender = sender instanceof Player; -098 if (!c.hasFlag("other")) { -099 Player player = isPlayerSender ? (Player) sender : null; -100 if (player == null && !isOptional) { -101 throw new InvalidCommandArgument(MessageKeys.NOT_ALLOWED_ON_CONSOLE, false); -102 } -103 PlayerInventory inventory = player != null ? player.getInventory() : null; -104 if (inventory != null && c.hasFlag("itemheld") && !ACFBukkitUtil.isValidItem(inventory.getItem(inventory.getHeldItemSlot()))) { -105 throw new InvalidCommandArgument(MinecraftMessageKeys.YOU_MUST_BE_HOLDING_ITEM, false); -106 } -107 return player; -108 } else { -109 String arg = c.popFirstArg(); -110 if (arg == null && isOptional) { -111 if (c.hasFlag("defaultself")) { -112 if (isPlayerSender) { -113 return (Player) sender; -114 } else { -115 throw new InvalidCommandArgument(MessageKeys.NOT_ALLOWED_ON_CONSOLE, false); -116 } -117 } else { -118 return null; -119 } -120 } else if (arg == null) { -121 throw new InvalidCommandArgument(); -122 } -123 -124 OnlinePlayer onlinePlayer = getOnlinePlayer(c.getIssuer(), arg, isOptional); -125 return onlinePlayer != null ? onlinePlayer.getPlayer() : null; -126 } -127 }); -128 registerContext(OfflinePlayer.class, c -> { -129 String name = c.popFirstArg(); -130 UUID uuid = null; -131 if (c.hasFlag("uuid")) { -132 uuid = UUID.fromString(name); -133 } -134 OfflinePlayer offlinePlayer = uuid != null ? Bukkit.getOfflinePlayer(uuid) : Bukkit.getOfflinePlayer(name); -135 if (offlinePlayer == null || (!offlinePlayer.hasPlayedBefore() && !offlinePlayer.isOnline())) { -136 throw new InvalidCommandArgument(MinecraftMessageKeys.NO_PLAYER_FOUND_OFFLINE, -137 "{search}", name); -138 } -139 return offlinePlayer; -140 }); -141 registerContext(ChatColor.class, c -> { -142 String first = c.popFirstArg(); -143 Stream<ChatColor> colors = Stream.of(ChatColor.values()); -144 if (c.hasFlag("colorsonly")) { -145 colors = colors.filter(color -> color.ordinal() <= 0xF); -146 } -147 String filter = c.getFlagValue("filter", (String) null); -148 if (filter != null) { -149 filter = ACFUtil.simplifyString(filter); -150 String finalFilter = filter; -151 colors = colors.filter(color -> finalFilter.equals(ACFUtil.simplifyString(color.name()))); -152 } -153 -154 ChatColor match = ACFUtil.simpleMatch(ChatColor.class, first); -155 if (match == null) { -156 String valid = colors -157 .map(color -> "<c2>" + ACFUtil.simplifyString(color.name()) + "</c2>") -158 .collect(Collectors.joining("<c1>,</c1> ")); -159 -160 throw new InvalidCommandArgument(MessageKeys.PLEASE_SPECIFY_ONE_OF, "{valid}", valid); -161 } -162 return match; -163 }); -164 registerContext(Location.class, c -> { -165 String input = c.popFirstArg(); -166 CommandSender sender = c.getSender(); -167 String[] split = ACFPatterns.COLON.split(input, 2); -168 if (split.length == 0) { -169 throw new InvalidCommandArgument(true); -170 } -171 if (split.length < 2 && !(sender instanceof Player) && !(sender instanceof BlockCommandSender)) { -172 throw new InvalidCommandArgument(MinecraftMessageKeys.LOCATION_PLEASE_SPECIFY_WORLD); -173 } -174 final String world; -175 final String rest; -176 Location sourceLoc = null; -177 if (split.length == 2) { -178 world = split[0]; -179 rest = split[1]; -180 } else if (sender instanceof Player) { -181 sourceLoc = ((Player) sender).getLocation(); -182 world = sourceLoc.getWorld().getName(); -183 rest = split[0]; -184 } else if (sender instanceof BlockCommandSender) { -185 sourceLoc = ((BlockCommandSender) sender).getBlock().getLocation(); -186 world = sourceLoc.getWorld().getName(); -187 rest = split[0]; -188 } else { -189 throw new InvalidCommandArgument(true); -190 } -191 -192 boolean rel = rest.startsWith("~"); -193 split = ACFPatterns.COMMA.split(rel ? rest.substring(1) : rest); -194 if (split.length < 3) { -195 throw new InvalidCommandArgument(MinecraftMessageKeys.LOCATION_PLEASE_SPECIFY_XYZ); -196 } -197 -198 Double x = ACFUtil.parseDouble(split[0]); -199 Double y = ACFUtil.parseDouble(split[1]); -200 Double z = ACFUtil.parseDouble(split[2]); -201 -202 if (sourceLoc != null && rel) { -203 x += sourceLoc.getX(); -204 y += sourceLoc.getY(); -205 z += sourceLoc.getZ(); -206 } else if (rel) { -207 throw new InvalidCommandArgument(MinecraftMessageKeys.LOCATION_CONSOLE_NOT_RELATIVE); -208 } -209 -210 if (x == null || y == null || z == null) { -211 throw new InvalidCommandArgument(MinecraftMessageKeys.LOCATION_PLEASE_SPECIFY_XYZ); -212 } -213 -214 World worldObj = Bukkit.getWorld(world); -215 if (worldObj == null) { -216 throw new InvalidCommandArgument(MinecraftMessageKeys.INVALID_WORLD); -217 } -218 -219 if (split.length >= 5) { -220 Float yaw = ACFUtil.parseFloat(split[3]); -221 Float pitch = ACFUtil.parseFloat(split[4]); -222 -223 if (pitch == null || yaw == null) { -224 throw new InvalidCommandArgument(MinecraftMessageKeys.LOCATION_PLEASE_SPECIFY_XYZ); -225 } -226 return new Location(worldObj, x, y, z, yaw, pitch); -227 } else { -228 return new Location(worldObj, x, y, z); -229 } -230 }); -231 Pattern versionPattern = Pattern.compile("\\(MC: (\\d)\\.(\\d+)\\.?.*?\\)"); -232 Matcher matcher = versionPattern.matcher(Bukkit.getVersion()); -233 if (matcher.find()) { -234 int mcMajorVersion = ACFUtil.parseInt(matcher.toMatchResult().group(1), 0); -235 int mcMinorVersion = ACFUtil.parseInt(matcher.toMatchResult().group(2), 0); -236 manager.log(LogLevel.INFO, "Minecraft Version: " + mcMajorVersion + "." + mcMinorVersion); -237 if (mcMajorVersion >= 1 && mcMinorVersion >= 12) { -238 BukkitCommandContexts_1_12.register(this); -239 } -240 } -241 } -242 -243 @Nullable -244 OnlinePlayer getOnlinePlayer(BukkitCommandIssuer issuer, String lookup, boolean allowMissing) throws InvalidCommandArgument { -245 Player player = ACFBukkitUtil.findPlayerSmart(issuer, lookup); -246 //noinspection Duplicates -247 if (player == null) { -248 if (allowMissing) { -249 return null; -250 } -251 throw new InvalidCommandArgument(false); -252 } -253 return new OnlinePlayer(player); -254 } -255} +026import co.aikar.commands.bukkit.contexts.OnlinePlayer; +027import org.bukkit.Bukkit; +028import org.bukkit.ChatColor; +029import org.bukkit.Location; +030import org.bukkit.OfflinePlayer; +031import org.bukkit.World; +032import org.bukkit.command.BlockCommandSender; +033import org.bukkit.command.CommandSender; +034import org.bukkit.entity.Entity; +035import org.bukkit.entity.Player; +036import org.bukkit.inventory.PlayerInventory; +037import org.jetbrains.annotations.Nullable; +038 +039import java.util.HashSet; +040import java.util.Set; +041import java.util.UUID; +042import java.util.regex.Pattern; +043import java.util.stream.Collectors; +044import java.util.stream.Stream; +045 +046@SuppressWarnings("WeakerAccess") +047public class BukkitCommandContexts extends CommandContexts<BukkitCommandExecutionContext> { +048 +049 public BukkitCommandContexts(BukkitCommandManager manager) { +050 super(manager); +051 +052 registerContext(OnlinePlayer.class, c -> getOnlinePlayer(c.getIssuer(), c.popFirstArg(), c.isOptional())); +053 registerContext(co.aikar.commands.contexts.OnlinePlayer.class, c -> { +054 OnlinePlayer onlinePlayer = getOnlinePlayer(c.getIssuer(), c.popFirstArg(), c.isOptional()); +055 return onlinePlayer != null ? new co.aikar.commands.contexts.OnlinePlayer(onlinePlayer.getPlayer()) : null; +056 }); +057 registerContext(OnlinePlayer[].class, (c) -> { +058 BukkitCommandIssuer issuer = c.getIssuer(); +059 final String search = c.popFirstArg(); +060 boolean allowMissing = c.hasFlag("allowmissing"); +061 Set<OnlinePlayer> players = new HashSet<>(); +062 Pattern split = ACFPatterns.COMMA; +063 String splitter = c.getFlagValue("splitter", (String) null); +064 if (splitter != null) { +065 split = Pattern.compile(Pattern.quote(splitter)); +066 } +067 for (String lookup : split.split(search)) { +068 OnlinePlayer player = getOnlinePlayer(issuer, lookup, allowMissing); +069 if (player != null) { +070 players.add(player); +071 } +072 } +073 if (players.isEmpty() && !c.hasFlag("allowempty")) { +074 issuer.sendError(MinecraftMessageKeys.NO_PLAYER_FOUND_SERVER, +075 "{search}", search); +076 +077 throw new InvalidCommandArgument(false); +078 } +079 return players.toArray(new OnlinePlayer[players.size()]); +080 }); +081 registerIssuerAwareContext(World.class, (c) -> { +082 String firstArg = c.getFirstArg(); +083 World world = firstArg != null ? Bukkit.getWorld(firstArg) : null; +084 if (world != null) { +085 c.popFirstArg(); +086 } +087 if (world == null && c.getSender() instanceof Player) { +088 world = ((Entity) c.getSender()).getWorld(); +089 } +090 if (world == null) { +091 throw new InvalidCommandArgument(MinecraftMessageKeys.INVALID_WORLD); +092 } +093 return world; +094 }); +095 registerIssuerAwareContext(CommandSender.class, BukkitCommandExecutionContext::getSender); +096 registerIssuerAwareContext(Player.class, (c) -> { +097 boolean isOptional = c.isOptional(); +098 CommandSender sender = c.getSender(); +099 boolean isPlayerSender = sender instanceof Player; +100 if (!c.hasFlag("other")) { +101 Player player = isPlayerSender ? (Player) sender : null; +102 if (player == null && !isOptional) { +103 throw new InvalidCommandArgument(MessageKeys.NOT_ALLOWED_ON_CONSOLE, false); +104 } +105 PlayerInventory inventory = player != null ? player.getInventory() : null; +106 if (inventory != null && c.hasFlag("itemheld") && !ACFBukkitUtil.isValidItem(inventory.getItem(inventory.getHeldItemSlot()))) { +107 throw new InvalidCommandArgument(MinecraftMessageKeys.YOU_MUST_BE_HOLDING_ITEM, false); +108 } +109 return player; +110 } else { +111 String arg = c.popFirstArg(); +112 if (arg == null && isOptional) { +113 if (c.hasFlag("defaultself")) { +114 if (isPlayerSender) { +115 return (Player) sender; +116 } else { +117 throw new InvalidCommandArgument(MessageKeys.NOT_ALLOWED_ON_CONSOLE, false); +118 } +119 } else { +120 return null; +121 } +122 } else if (arg == null) { +123 throw new InvalidCommandArgument(); +124 } +125 +126 OnlinePlayer onlinePlayer = getOnlinePlayer(c.getIssuer(), arg, isOptional); +127 return onlinePlayer != null ? onlinePlayer.getPlayer() : null; +128 } +129 }); +130 registerContext(OfflinePlayer.class, c -> { +131 String name = c.popFirstArg(); +132 UUID uuid = null; +133 if (c.hasFlag("uuid")) { +134 uuid = UUID.fromString(name); +135 } +136 OfflinePlayer offlinePlayer = uuid != null ? Bukkit.getOfflinePlayer(uuid) : Bukkit.getOfflinePlayer(name); +137 if (offlinePlayer == null || (!offlinePlayer.hasPlayedBefore() && !offlinePlayer.isOnline())) { +138 throw new InvalidCommandArgument(MinecraftMessageKeys.NO_PLAYER_FOUND_OFFLINE, +139 "{search}", name); +140 } +141 return offlinePlayer; +142 }); +143 registerContext(ChatColor.class, c -> { +144 String first = c.popFirstArg(); +145 Stream<ChatColor> colors = Stream.of(ChatColor.values()); +146 if (c.hasFlag("colorsonly")) { +147 colors = colors.filter(color -> color.ordinal() <= 0xF); +148 } +149 String filter = c.getFlagValue("filter", (String) null); +150 if (filter != null) { +151 filter = ACFUtil.simplifyString(filter); +152 String finalFilter = filter; +153 colors = colors.filter(color -> finalFilter.equals(ACFUtil.simplifyString(color.name()))); +154 } +155 +156 ChatColor match = ACFUtil.simpleMatch(ChatColor.class, first); +157 if (match == null) { +158 String valid = colors +159 .map(color -> "<c2>" + ACFUtil.simplifyString(color.name()) + "</c2>") +160 .collect(Collectors.joining("<c1>,</c1> ")); +161 +162 throw new InvalidCommandArgument(MessageKeys.PLEASE_SPECIFY_ONE_OF, "{valid}", valid); +163 } +164 return match; +165 }); +166 registerContext(Location.class, c -> { +167 String input = c.popFirstArg(); +168 CommandSender sender = c.getSender(); +169 String[] split = ACFPatterns.COLON.split(input, 2); +170 if (split.length == 0) { +171 throw new InvalidCommandArgument(true); +172 } +173 if (split.length < 2 && !(sender instanceof Player) && !(sender instanceof BlockCommandSender)) { +174 throw new InvalidCommandArgument(MinecraftMessageKeys.LOCATION_PLEASE_SPECIFY_WORLD); +175 } +176 final String world; +177 final String rest; +178 Location sourceLoc = null; +179 if (split.length == 2) { +180 world = split[0]; +181 rest = split[1]; +182 } else if (sender instanceof Player) { +183 sourceLoc = ((Player) sender).getLocation(); +184 world = sourceLoc.getWorld().getName(); +185 rest = split[0]; +186 } else if (sender instanceof BlockCommandSender) { +187 sourceLoc = ((BlockCommandSender) sender).getBlock().getLocation(); +188 world = sourceLoc.getWorld().getName(); +189 rest = split[0]; +190 } else { +191 throw new InvalidCommandArgument(true); +192 } +193 +194 boolean rel = rest.startsWith("~"); +195 split = ACFPatterns.COMMA.split(rel ? rest.substring(1) : rest); +196 if (split.length < 3) { +197 throw new InvalidCommandArgument(MinecraftMessageKeys.LOCATION_PLEASE_SPECIFY_XYZ); +198 } +199 +200 Double x = ACFUtil.parseDouble(split[0]); +201 Double y = ACFUtil.parseDouble(split[1]); +202 Double z = ACFUtil.parseDouble(split[2]); +203 +204 if (sourceLoc != null && rel) { +205 x += sourceLoc.getX(); +206 y += sourceLoc.getY(); +207 z += sourceLoc.getZ(); +208 } else if (rel) { +209 throw new InvalidCommandArgument(MinecraftMessageKeys.LOCATION_CONSOLE_NOT_RELATIVE); +210 } +211 +212 if (x == null || y == null || z == null) { +213 throw new InvalidCommandArgument(MinecraftMessageKeys.LOCATION_PLEASE_SPECIFY_XYZ); +214 } +215 +216 World worldObj = Bukkit.getWorld(world); +217 if (worldObj == null) { +218 throw new InvalidCommandArgument(MinecraftMessageKeys.INVALID_WORLD); +219 } +220 +221 if (split.length >= 5) { +222 Float yaw = ACFUtil.parseFloat(split[3]); +223 Float pitch = ACFUtil.parseFloat(split[4]); +224 +225 if (pitch == null || yaw == null) { +226 throw new InvalidCommandArgument(MinecraftMessageKeys.LOCATION_PLEASE_SPECIFY_XYZ); +227 } +228 return new Location(worldObj, x, y, z, yaw, pitch); +229 } else { +230 return new Location(worldObj, x, y, z); +231 } +232 }); +233 +234 if (manager.mcMinorVersion >= 12) { +235 BukkitCommandContexts_1_12.register(this); +236 } +237 } +238 +239 @Nullable +240 OnlinePlayer getOnlinePlayer(BukkitCommandIssuer issuer, String lookup, boolean allowMissing) throws InvalidCommandArgument { +241 Player player = ACFBukkitUtil.findPlayerSmart(issuer, lookup); +242 //noinspection Duplicates +243 if (player == null) { +244 if (allowMissing) { +245 return null; +246 } +247 throw new InvalidCommandArgument(false); +248 } +249 return new OnlinePlayer(player); +250 } +251} 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 3d127ab6..e048a8d6 100644 --- a/docs/acf-bukkit/src-html/co/aikar/commands/BukkitCommandManager.html +++ b/docs/acf-bukkit/src-html/co/aikar/commands/BukkitCommandManager.html @@ -64,325 +64,339 @@ 056import java.util.Objects; 057import java.util.logging.Level; 058import java.util.logging.Logger; -059 -060@SuppressWarnings("WeakerAccess") -061public class BukkitCommandManager extends CommandManager< -062 CommandSender, -063 BukkitCommandIssuer, -064 ChatColor, -065 BukkitMessageFormatter, -066 BukkitCommandExecutionContext, -067 BukkitConditionContext -068 > { -069 -070 @SuppressWarnings("WeakerAccess") -071 protected final Plugin plugin; -072 private final CommandMap commandMap; -073 private final TimingManager timingManager; -074 private final BukkitTask localeTask; -075 private final Logger logger; -076 protected Map<String, Command> knownCommands = new HashMap<>(); -077 protected Map<String, BukkitRootCommand> registeredCommands = new HashMap<>(); -078 protected BukkitCommandContexts contexts; -079 protected BukkitCommandCompletions completions; -080 MCTiming commandTiming; -081 protected BukkitLocales locales; -082 private boolean cantReadLocale = false; -083 protected boolean autoDetectFromClient = true; -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 -097 Bukkit.getPluginManager().registerEvents(new ACFBukkitListener(this, plugin), plugin); -098 -099 getLocales(); // auto load locales -100 this.localeTask = Bukkit.getScheduler().runTaskTimer(plugin, () -> { -101 if (this.cantReadLocale || !this.autoDetectFromClient) { -102 return; -103 } -104 Bukkit.getOnlinePlayers().forEach(this::readPlayerLocale); -105 }, 5, 5); -106 -107 registerDependency(plugin.getClass(), plugin); -108 registerDependency(Plugin.class, plugin); -109 registerDependency(JavaPlugin.class, plugin); -110 registerDependency(PluginManager.class, Bukkit.getPluginManager()); -111 registerDependency(Server.class, Bukkit.getServer()); -112 registerDependency(BukkitScheduler.class, Bukkit.getScheduler()); -113 registerDependency(ScoreboardManager.class, Bukkit.getScoreboardManager()); -114 registerDependency(ItemFactory.class, Bukkit.getItemFactory()); -115 } -116 -117 @NotNull private CommandMap hookCommandMap() { -118 CommandMap commandMap = null; -119 try { -120 Server server = Bukkit.getServer(); -121 Method getCommandMap = server.getClass().getDeclaredMethod("getCommandMap"); -122 getCommandMap.setAccessible(true); -123 commandMap = (CommandMap) getCommandMap.invoke(server); -124 if (!SimpleCommandMap.class.isAssignableFrom(commandMap.getClass())) { -125 this.log(LogLevel.ERROR, "ERROR: CommandMap has been hijacked! Offending command map is located at: " + commandMap.getClass().getName()); -126 this.log(LogLevel.ERROR, "We are going to try to hijack it back and resolve this, but you are now in dangerous territory."); -127 this.log(LogLevel.ERROR, "We can not guarantee things are going to work."); -128 Field cmField = server.getClass().getDeclaredField("commandMap"); -129 commandMap = new ProxyCommandMap(this, commandMap); -130 cmField.set(server, commandMap); -131 this.log(LogLevel.INFO, "Injected Proxy Command Map... good luck..."); -132 } -133 Field knownCommands = SimpleCommandMap.class.getDeclaredField("knownCommands"); -134 knownCommands.setAccessible(true); -135 //noinspection unchecked -136 this.knownCommands = (Map<String, Command>) knownCommands.get(commandMap); -137 } catch (Exception e) { -138 this.log(LogLevel.ERROR, "Failed to get Command Map. ACF will not function."); -139 ACFUtil.sneaky(e); -140 } -141 return commandMap; -142 } -143 -144 public Plugin getPlugin() { -145 return this.plugin; -146 } -147 -148 @Override -149 public boolean isCommandIssuer(Class<?> type) { -150 return CommandSender.class.isAssignableFrom(type); -151 } -152 -153 @Override -154 public synchronized CommandContexts<BukkitCommandExecutionContext> getCommandContexts() { -155 if (this.contexts == null) { -156 this.contexts = new BukkitCommandContexts(this); -157 } -158 return contexts; -159 } -160 -161 @Override -162 public synchronized CommandCompletions<BukkitCommandCompletionContext> getCommandCompletions() { -163 if (this.completions == null) { -164 this.completions = new BukkitCommandCompletions(this); -165 } -166 return completions; -167 } -168 -169 -170 @Override -171 public BukkitLocales getLocales() { -172 if (this.locales == null) { -173 this.locales = new BukkitLocales(this); -174 this.locales.loadLanguages(); -175 } -176 return locales; -177 } -178 -179 -180 @Override -181 public boolean hasRegisteredCommands() { -182 return !registeredCommands.isEmpty(); -183 } -184 -185 public void registerCommand(BaseCommand command, boolean force) { -186 final String plugin = this.plugin.getName().toLowerCase(); -187 command.onRegister(this); -188 for (Map.Entry<String, RootCommand> entry : command.registeredCommands.entrySet()) { -189 String commandName = entry.getKey().toLowerCase(); -190 BukkitRootCommand bukkitCommand = (BukkitRootCommand) entry.getValue(); -191 if (!bukkitCommand.isRegistered) { -192 Command oldCommand = commandMap.getCommand(commandName); -193 if (oldCommand instanceof PluginIdentifiableCommand && ((PluginIdentifiableCommand) oldCommand).getPlugin() == this.plugin) { -194 knownCommands.remove(commandName); -195 oldCommand.unregister(commandMap); -196 } else if (oldCommand != null && force) { -197 knownCommands.remove(commandName); -198 for (Map.Entry<String, Command> ce : knownCommands.entrySet()) { -199 String key = ce.getKey(); -200 Command value = ce.getValue(); -201 if (key.contains(":") && oldCommand.equals(value)) { -202 String[] split = ACFPatterns.COLON.split(key, 2); -203 if (split.length > 1) { -204 oldCommand.unregister(commandMap); -205 oldCommand.setLabel(split[0] + ":" + command.getName()); -206 oldCommand.register(commandMap); -207 } -208 } -209 } -210 } -211 commandMap.register(commandName, plugin, bukkitCommand); -212 } -213 bukkitCommand.isRegistered = true; -214 registeredCommands.put(commandName, bukkitCommand); -215 } -216 } -217 -218 @Override -219 public void registerCommand(BaseCommand command) { -220 registerCommand(command, false); -221 } -222 -223 public void unregisterCommand(BaseCommand command) { -224 for (RootCommand rootcommand : command.registeredCommands.values()) { -225 BukkitRootCommand bukkitCommand = (BukkitRootCommand) rootcommand; -226 bukkitCommand.getSubCommands().values().removeAll(command.subCommands.values()); -227 if (bukkitCommand.isRegistered && bukkitCommand.getSubCommands().isEmpty()) { -228 unregisterCommand(bukkitCommand); -229 bukkitCommand.isRegistered = false; -230 } -231 } -232 } -233 -234 /** -235 * @deprecated Use unregisterCommand(BaseCommand) - this will be visibility reduced later. -236 * @param command -237 */ -238 @Deprecated -239 public void unregisterCommand(BukkitRootCommand command) { -240 final String plugin = this.plugin.getName().toLowerCase(); -241 command.unregister(commandMap); -242 String key = command.getName(); -243 Command registered = knownCommands.get(key); -244 if (command.equals(registered)) { -245 knownCommands.remove(key); -246 } -247 knownCommands.remove(plugin + ":" + key); -248 } -249 -250 public void unregisterCommands() { -251 for (Map.Entry<String, BukkitRootCommand> entry : registeredCommands.entrySet()) { -252 unregisterCommand(entry.getValue()); -253 } -254 this.registeredCommands.clear(); -255 } -256 -257 -258 private Field getEntityField(Player player) throws NoSuchFieldException { -259 Class cls = player.getClass(); -260 while (cls != Object.class) { -261 if (cls.getName().endsWith("CraftEntity")) { -262 Field field = cls.getDeclaredField("entity"); -263 field.setAccessible(true); -264 return field; -265 } -266 cls = cls.getSuperclass(); +059import java.util.regex.Matcher; +060import java.util.regex.Pattern; +061 +062@SuppressWarnings("WeakerAccess") +063public class BukkitCommandManager extends CommandManager< +064 CommandSender, +065 BukkitCommandIssuer, +066 ChatColor, +067 BukkitMessageFormatter, +068 BukkitCommandExecutionContext, +069 BukkitConditionContext +070 > { +071 +072 @SuppressWarnings("WeakerAccess") +073 protected final Plugin plugin; +074 private final CommandMap commandMap; +075 private final TimingManager timingManager; +076 private final BukkitTask localeTask; +077 private final Logger logger; +078 public final Integer mcMinorVersion; +079 public final Integer mcPatchVersion; +080 protected Map<String, Command> knownCommands = new HashMap<>(); +081 protected Map<String, BukkitRootCommand> registeredCommands = new HashMap<>(); +082 protected BukkitCommandContexts contexts; +083 protected BukkitCommandCompletions completions; +084 MCTiming commandTiming; +085 protected BukkitLocales locales; +086 private boolean cantReadLocale = false; +087 protected boolean autoDetectFromClient = true; +088 +089 @SuppressWarnings("JavaReflectionMemberAccess") +090 public BukkitCommandManager(Plugin plugin) { +091 this.plugin = plugin; +092 this.logger = Logger.getLogger(this.plugin.getName()); +093 this.timingManager = TimingManager.of(plugin); +094 this.commandTiming = this.timingManager.of("Commands"); +095 this.commandMap = hookCommandMap(); +096 this.formatters.put(MessageType.ERROR, defaultFormatter = new BukkitMessageFormatter(ChatColor.RED, ChatColor.YELLOW, ChatColor.RED)); +097 this.formatters.put(MessageType.SYNTAX, new BukkitMessageFormatter(ChatColor.YELLOW, ChatColor.GREEN, ChatColor.WHITE)); +098 this.formatters.put(MessageType.INFO, new BukkitMessageFormatter(ChatColor.BLUE, ChatColor.DARK_GREEN, ChatColor.GREEN)); +099 this.formatters.put(MessageType.HELP, new BukkitMessageFormatter(ChatColor.AQUA, ChatColor.GREEN, ChatColor.YELLOW)); +100 Pattern versionPattern = Pattern.compile("\\(MC: (\\d)\\.(\\d+)\\.?(\\d+?)?\\)"); +101 Matcher matcher = versionPattern.matcher(Bukkit.getVersion()); +102 if (matcher.find()) { +103 this.mcMinorVersion = ACFUtil.parseInt(matcher.toMatchResult().group(2), 0); +104 this.mcPatchVersion = ACFUtil.parseInt(matcher.toMatchResult().group(3), 0); +105 } else { +106 this.mcMinorVersion = -1; +107 this.mcPatchVersion = -1; +108 } +109 +110 Bukkit.getPluginManager().registerEvents(new ACFBukkitListener(this, plugin), plugin); +111 +112 getLocales(); // auto load locales +113 this.localeTask = Bukkit.getScheduler().runTaskTimer(plugin, () -> { +114 if (this.cantReadLocale || !this.autoDetectFromClient) { +115 return; +116 } +117 Bukkit.getOnlinePlayers().forEach(this::readPlayerLocale); +118 }, 5, 5); +119 +120 registerDependency(plugin.getClass(), plugin); +121 registerDependency(Plugin.class, plugin); +122 registerDependency(JavaPlugin.class, plugin); +123 registerDependency(PluginManager.class, Bukkit.getPluginManager()); +124 registerDependency(Server.class, Bukkit.getServer()); +125 registerDependency(BukkitScheduler.class, Bukkit.getScheduler()); +126 registerDependency(ScoreboardManager.class, Bukkit.getScoreboardManager()); +127 registerDependency(ItemFactory.class, Bukkit.getItemFactory()); +128 } +129 +130 @NotNull +131 private CommandMap hookCommandMap() { +132 CommandMap commandMap = null; +133 try { +134 Server server = Bukkit.getServer(); +135 Method getCommandMap = server.getClass().getDeclaredMethod("getCommandMap"); +136 getCommandMap.setAccessible(true); +137 commandMap = (CommandMap) getCommandMap.invoke(server); +138 if (!SimpleCommandMap.class.isAssignableFrom(commandMap.getClass())) { +139 this.log(LogLevel.ERROR, "ERROR: CommandMap has been hijacked! Offending command map is located at: " + commandMap.getClass().getName()); +140 this.log(LogLevel.ERROR, "We are going to try to hijack it back and resolve this, but you are now in dangerous territory."); +141 this.log(LogLevel.ERROR, "We can not guarantee things are going to work."); +142 Field cmField = server.getClass().getDeclaredField("commandMap"); +143 commandMap = new ProxyCommandMap(this, commandMap); +144 cmField.set(server, commandMap); +145 this.log(LogLevel.INFO, "Injected Proxy Command Map... good luck..."); +146 } +147 Field knownCommands = SimpleCommandMap.class.getDeclaredField("knownCommands"); +148 knownCommands.setAccessible(true); +149 //noinspection unchecked +150 this.knownCommands = (Map<String, Command>) knownCommands.get(commandMap); +151 } catch (Exception e) { +152 this.log(LogLevel.ERROR, "Failed to get Command Map. ACF will not function."); +153 ACFUtil.sneaky(e); +154 } +155 return commandMap; +156 } +157 +158 public Plugin getPlugin() { +159 return this.plugin; +160 } +161 +162 @Override +163 public boolean isCommandIssuer(Class<?> type) { +164 return CommandSender.class.isAssignableFrom(type); +165 } +166 +167 @Override +168 public synchronized CommandContexts<BukkitCommandExecutionContext> getCommandContexts() { +169 if (this.contexts == null) { +170 this.contexts = new BukkitCommandContexts(this); +171 } +172 return contexts; +173 } +174 +175 @Override +176 public synchronized CommandCompletions<BukkitCommandCompletionContext> getCommandCompletions() { +177 if (this.completions == null) { +178 this.completions = new BukkitCommandCompletions(this); +179 } +180 return completions; +181 } +182 +183 +184 @Override +185 public BukkitLocales getLocales() { +186 if (this.locales == null) { +187 this.locales = new BukkitLocales(this); +188 this.locales.loadLanguages(); +189 } +190 return locales; +191 } +192 +193 +194 @Override +195 public boolean hasRegisteredCommands() { +196 return !registeredCommands.isEmpty(); +197 } +198 +199 public void registerCommand(BaseCommand command, boolean force) { +200 final String plugin = this.plugin.getName().toLowerCase(); +201 command.onRegister(this); +202 for (Map.Entry<String, RootCommand> entry : command.registeredCommands.entrySet()) { +203 String commandName = entry.getKey().toLowerCase(); +204 BukkitRootCommand bukkitCommand = (BukkitRootCommand) entry.getValue(); +205 if (!bukkitCommand.isRegistered) { +206 Command oldCommand = commandMap.getCommand(commandName); +207 if (oldCommand instanceof PluginIdentifiableCommand && ((PluginIdentifiableCommand) oldCommand).getPlugin() == this.plugin) { +208 knownCommands.remove(commandName); +209 oldCommand.unregister(commandMap); +210 } else if (oldCommand != null && force) { +211 knownCommands.remove(commandName); +212 for (Map.Entry<String, Command> ce : knownCommands.entrySet()) { +213 String key = ce.getKey(); +214 Command value = ce.getValue(); +215 if (key.contains(":") && oldCommand.equals(value)) { +216 String[] split = ACFPatterns.COLON.split(key, 2); +217 if (split.length > 1) { +218 oldCommand.unregister(commandMap); +219 oldCommand.setLabel(split[0] + ":" + command.getName()); +220 oldCommand.register(commandMap); +221 } +222 } +223 } +224 } +225 commandMap.register(commandName, plugin, bukkitCommand); +226 } +227 bukkitCommand.isRegistered = true; +228 registeredCommands.put(commandName, bukkitCommand); +229 } +230 } +231 +232 @Override +233 public void registerCommand(BaseCommand command) { +234 registerCommand(command, false); +235 } +236 +237 public void unregisterCommand(BaseCommand command) { +238 for (RootCommand rootcommand : command.registeredCommands.values()) { +239 BukkitRootCommand bukkitCommand = (BukkitRootCommand) rootcommand; +240 bukkitCommand.getSubCommands().values().removeAll(command.subCommands.values()); +241 if (bukkitCommand.isRegistered && bukkitCommand.getSubCommands().isEmpty()) { +242 unregisterCommand(bukkitCommand); +243 bukkitCommand.isRegistered = false; +244 } +245 } +246 } +247 +248 /** +249 * @param command +250 * @deprecated Use unregisterCommand(BaseCommand) - this will be visibility reduced later. +251 */ +252 @Deprecated +253 public void unregisterCommand(BukkitRootCommand command) { +254 final String plugin = this.plugin.getName().toLowerCase(); +255 command.unregister(commandMap); +256 String key = command.getName(); +257 Command registered = knownCommands.get(key); +258 if (command.equals(registered)) { +259 knownCommands.remove(key); +260 } +261 knownCommands.remove(plugin + ":" + key); +262 } +263 +264 public void unregisterCommands() { +265 for (Map.Entry<String, BukkitRootCommand> entry : registeredCommands.entrySet()) { +266 unregisterCommand(entry.getValue()); 267 } -268 return null; +268 this.registeredCommands.clear(); 269 } 270 -271 public Locale setPlayerLocale(Player player, Locale locale) { -272 return this.setIssuerLocale(player, locale); -273 } -274 -275 void readPlayerLocale(Player player) { -276 if (!player.isOnline() || cantReadLocale) { -277 return; -278 } -279 try { -280 Field entityField = getEntityField(player); -281 if (entityField == null) { -282 return; -283 } -284 Object nmsPlayer = entityField.get(player); -285 if (nmsPlayer != null) { -286 Field localeField = nmsPlayer.getClass().getDeclaredField("locale"); -287 Object localeString = localeField.get(nmsPlayer); -288 if (localeString instanceof String) { -289 String[] split = ACFPatterns.UNDERSCORE.split((String) localeString); -290 Locale locale = split.length > 1 ? new Locale(split[0], split[1]) : new Locale(split[0]); -291 Locale prev = issuersLocale.put(player.getUniqueId(), locale); -292 if (!Objects.equals(locale, prev)) { -293 this.notifyLocaleChange(getCommandIssuer(player), prev, locale); -294 } -295 } -296 } -297 } catch (Exception e) { -298 cantReadLocale = true; -299 this.localeTask.cancel(); -300 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); -301 } -302 } -303 -304 public TimingManager getTimings() { -305 return timingManager; -306 } -307 -308 @Override -309 public RootCommand createRootCommand(String cmd) { -310 return new BukkitRootCommand(this, cmd); -311 } -312 -313 @Override -314 public Collection<RootCommand> getRegisteredRootCommands() { -315 return Collections.unmodifiableCollection(registeredCommands.values()); +271 +272 private Field getEntityField(Player player) throws NoSuchFieldException { +273 Class cls = player.getClass(); +274 while (cls != Object.class) { +275 if (cls.getName().endsWith("CraftEntity")) { +276 Field field = cls.getDeclaredField("entity"); +277 field.setAccessible(true); +278 return field; +279 } +280 cls = cls.getSuperclass(); +281 } +282 return null; +283 } +284 +285 public Locale setPlayerLocale(Player player, Locale locale) { +286 return this.setIssuerLocale(player, locale); +287 } +288 +289 void readPlayerLocale(Player player) { +290 if (!player.isOnline() || cantReadLocale) { +291 return; +292 } +293 try { +294 Field entityField = getEntityField(player); +295 if (entityField == null) { +296 return; +297 } +298 Object nmsPlayer = entityField.get(player); +299 if (nmsPlayer != null) { +300 Field localeField = nmsPlayer.getClass().getDeclaredField("locale"); +301 Object localeString = localeField.get(nmsPlayer); +302 if (localeString instanceof String) { +303 String[] split = ACFPatterns.UNDERSCORE.split((String) localeString); +304 Locale locale = split.length > 1 ? new Locale(split[0], split[1]) : new Locale(split[0]); +305 Locale prev = issuersLocale.put(player.getUniqueId(), locale); +306 if (!Objects.equals(locale, prev)) { +307 this.notifyLocaleChange(getCommandIssuer(player), prev, locale); +308 } +309 } +310 } +311 } catch (Exception e) { +312 cantReadLocale = true; +313 this.localeTask.cancel(); +314 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); +315 } 316 } -317 -318 @Override -319 public BukkitCommandIssuer getCommandIssuer(Object issuer) { -320 if (!(issuer instanceof CommandSender)) { -321 throw new IllegalArgumentException(issuer.getClass().getName() + " is not a Command Issuer."); -322 } -323 return new BukkitCommandIssuer(this, (CommandSender) issuer); -324 } -325 -326 @Override -327 public BukkitCommandExecutionContext createCommandContext(RegisteredCommand command, CommandParameter parameter, CommandIssuer sender, List<String> args, int i, Map<String, Object> passedArgs) { -328 return new BukkitCommandExecutionContext(command, parameter, (BukkitCommandIssuer) sender, args, i, passedArgs); -329 } -330 -331 @Override -332 public BukkitCommandCompletionContext createCompletionContext(RegisteredCommand command, CommandIssuer sender, String input, String config, String[] args) { -333 return new BukkitCommandCompletionContext(command, (BukkitCommandIssuer) sender, input, config, args); -334 } -335 -336 @Override -337 public RegisteredCommand createRegisteredCommand(BaseCommand command, String cmdName, Method method, String prefSubCommand) { -338 return new BukkitRegisteredCommand(command, cmdName, method, prefSubCommand); -339 } -340 -341 @Override -342 public BukkitConditionContext createConditionContext(CommandIssuer issuer, String config) { -343 return new BukkitConditionContext((BukkitCommandIssuer) issuer, config); -344 } -345 -346 -347 @Override -348 public void log(LogLevel level, String message, Throwable throwable) { -349 Level logLevel = level == LogLevel.INFO ? Level.INFO : Level.SEVERE; -350 logger.log(logLevel, LogLevel.LOG_PREFIX + message); -351 if (throwable != null) { -352 for (String line : ACFPatterns.NEWLINE.split(ApacheCommonsExceptionUtil.getFullStackTrace(throwable))) { -353 logger.log(logLevel, LogLevel.LOG_PREFIX + line); -354 } -355 } -356 } -357 -358 public boolean usePerIssuerLocale(boolean usePerIssuerLocale, boolean autoDetectFromClient) { -359 boolean old = this.usePerIssuerLocale; -360 this.usePerIssuerLocale = usePerIssuerLocale; -361 this.autoDetectFromClient = autoDetectFromClient; -362 return old; -363 } -364 -365 @Override -366 public String getCommandPrefix(CommandIssuer issuer) { -367 return issuer.isPlayer() ? "/" : ""; -368 } -369 -370 @Override -371 protected boolean handleUncaughtException(BaseCommand scope, RegisteredCommand registeredCommand, CommandIssuer sender, List<String> args, Throwable t) { -372 if (t instanceof CommandException && t.getCause() != null && t.getMessage().startsWith("Unhandled exception")) { -373 t = t.getCause(); -374 } -375 return super.handleUncaughtException(scope, registeredCommand, sender, args, t); -376 } -377} +317 +318 public TimingManager getTimings() { +319 return timingManager; +320 } +321 +322 @Override +323 public RootCommand createRootCommand(String cmd) { +324 return new BukkitRootCommand(this, cmd); +325 } +326 +327 @Override +328 public Collection<RootCommand> getRegisteredRootCommands() { +329 return Collections.unmodifiableCollection(registeredCommands.values()); +330 } +331 +332 @Override +333 public BukkitCommandIssuer getCommandIssuer(Object issuer) { +334 if (!(issuer instanceof CommandSender)) { +335 throw new IllegalArgumentException(issuer.getClass().getName() + " is not a Command Issuer."); +336 } +337 return new BukkitCommandIssuer(this, (CommandSender) issuer); +338 } +339 +340 @Override +341 public BukkitCommandExecutionContext createCommandContext(RegisteredCommand command, CommandParameter parameter, CommandIssuer sender, List<String> args, int i, Map<String, Object> passedArgs) { +342 return new BukkitCommandExecutionContext(command, parameter, (BukkitCommandIssuer) sender, args, i, passedArgs); +343 } +344 +345 @Override +346 public BukkitCommandCompletionContext createCompletionContext(RegisteredCommand command, CommandIssuer sender, String input, String config, String[] args) { +347 return new BukkitCommandCompletionContext(command, (BukkitCommandIssuer) sender, input, config, args); +348 } +349 +350 @Override +351 public RegisteredCommand createRegisteredCommand(BaseCommand command, String cmdName, Method method, String prefSubCommand) { +352 return new BukkitRegisteredCommand(command, cmdName, method, prefSubCommand); +353 } +354 +355 @Override +356 public BukkitConditionContext createConditionContext(CommandIssuer issuer, String config) { +357 return new BukkitConditionContext((BukkitCommandIssuer) issuer, config); +358 } +359 +360 +361 @Override +362 public void log(LogLevel level, String message, Throwable throwable) { +363 Level logLevel = level == LogLevel.INFO ? Level.INFO : Level.SEVERE; +364 logger.log(logLevel, LogLevel.LOG_PREFIX + message); +365 if (throwable != null) { +366 for (String line : ACFPatterns.NEWLINE.split(ApacheCommonsExceptionUtil.getFullStackTrace(throwable))) { +367 logger.log(logLevel, LogLevel.LOG_PREFIX + line); +368 } +369 } +370 } +371 +372 public boolean usePerIssuerLocale(boolean usePerIssuerLocale, boolean autoDetectFromClient) { +373 boolean old = this.usePerIssuerLocale; +374 this.usePerIssuerLocale = usePerIssuerLocale; +375 this.autoDetectFromClient = autoDetectFromClient; +376 return old; +377 } +378 +379 @Override +380 public String getCommandPrefix(CommandIssuer issuer) { +381 return issuer.isPlayer() ? "/" : ""; +382 } +383 +384 @Override +385 protected boolean handleUncaughtException(BaseCommand scope, RegisteredCommand registeredCommand, CommandIssuer sender, List<String> args, Throwable t) { +386 if (t instanceof CommandException && t.getCause() != null && t.getMessage().startsWith("Unhandled exception")) { +387 t = t.getCause(); +388 } +389 return super.handleUncaughtException(scope, registeredCommand, sender, args, t); +390 } +391} diff --git a/docs/acf-bukkit/src-html/co/aikar/commands/bukkit/contexts/OnlinePlayer.html b/docs/acf-bukkit/src-html/co/aikar/commands/bukkit/contexts/OnlinePlayer.html new file mode 100644 index 00000000..84d942cc --- /dev/null +++ b/docs/acf-bukkit/src-html/co/aikar/commands/bukkit/contexts/OnlinePlayer.html @@ -0,0 +1,130 @@ + + + +Source code + + + +++ + diff --git a/docs/acf-bukkit/src-html/co/aikar/commands/contexts/OnlinePlayer.html b/docs/acf-bukkit/src-html/co/aikar/commands/contexts/OnlinePlayer.html index 067d858d..eb8f98a1 100644 --- a/docs/acf-bukkit/src-html/co/aikar/commands/contexts/OnlinePlayer.html +++ b/docs/acf-bukkit/src-html/co/aikar/commands/contexts/OnlinePlayer.html @@ -7,7 +7,7 @@001/* +002 * Copyright (c) 2016-2019 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.bukkit.contexts; +025 +026import org.bukkit.entity.Player; +027 +028import java.util.Objects; +029 +030public class OnlinePlayer { +031 public final Player player; +032 +033 public OnlinePlayer(Player player) { +034 this.player = player; +035 } +036 +037 public Player getPlayer() { +038 return this.player; +039 } +040 +041 @Override +042 public boolean equals(Object o) { +043 if (this == o) return true; +044 if (o == null || getClass() != o.getClass()) return false; +045 OnlinePlayer that = (OnlinePlayer) o; +046 return Objects.equals(player, that.player); +047 } +048 +049 @Override +050 public int hashCode() { +051 return Objects.hash(player); +052 } +053 +054 @Override +055 public String toString() { +056 return "OnlinePlayer{player=" + player + '}'; +057 } +058} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ++diff --git a/docs/acf-bungee/allclasses-noframe.html b/docs/acf-bungee/allclasses-noframe.html index dafb2984..6d7d390e 100644 --- a/docs/acf-bungee/allclasses-noframe.html +++ b/docs/acf-bungee/allclasses-noframe.html @@ -26,6 +26,7 @@001/* -002 * Copyright (c) 2016-2017 Daniel Ennis (Aikar) - MIT License +002 * Copyright (c) 2016-2019 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 @@ -33,39 +33,15 @@ 025 026import org.bukkit.entity.Player; 027 -028import java.util.Objects; -029 -030public class OnlinePlayer { -031 public final Player player; -032 +028/** +029 * @deprecated Use {@link co.aikar.commands.bukkit.contexts.OnlinePlayer instead} +030 */ +031@Deprecated +032public class OnlinePlayer extends co.aikar.commands.bukkit.contexts.OnlinePlayer { 033 public OnlinePlayer(Player player) { -034 this.player = player; +034 super(player); 035 } -036 -037 public Player getPlayer() { -038 return this.player; -039 } -040 -041 @Override -042 public boolean equals(Object o) { -043 if (this == o) return true; -044 if (o == null || getClass() != o.getClass()) return false; -045 OnlinePlayer that = (OnlinePlayer) o; -046 return Objects.equals(player, that.player); -047 } -048 -049 @Override -050 public int hashCode() { -051 return Objects.hash(player); -052 } -053 -054 @Override -055 public String toString() { -056 return "OnlinePlayer{" + -057 "player=" + player + -058 '}'; -059 } -060} +036} diff --git a/docs/acf-bungee/allclasses-frame.html b/docs/acf-bungee/allclasses-frame.html index 9a5237dd..a87f7716 100644 --- a/docs/acf-bungee/allclasses-frame.html +++ b/docs/acf-bungee/allclasses-frame.html @@ -26,6 +26,7 @@- BungeeRegisteredCommand
- BungeeRootCommand
- MinecraftMessageKeys
+- OnlinePlayer
- OnlineProxiedPlayer
- BungeeRegisteredCommand
- BungeeRootCommand
- MinecraftMessageKeys
+- OnlinePlayer
- OnlineProxiedPlayer
-public class BungeeCommandContexts +public class BungeeCommandContexts extends co.aikar.commands.CommandContexts<BungeeCommandExecutionContext>OnlinePlayer (ACF (Bungee) 0.5.0-SNAPSHOT API) + + + + + + + + + + + +++co.aikar.commands.bungee.contexts+Class OnlinePlayer
+++ + + + + ++
+- java.lang.Object
+- +
++
+- co.aikar.commands.bungee.contexts.OnlinePlayer
++++
+- +
++
+- Direct Known Subclasses:
+- OnlineProxiedPlayer
+
+
+public class OnlinePlayer +extends Object++++
+- + +
++
+ +- + + +
+Field Summary
++
+Fields ++ +Modifier and Type +Field and Description ++ ++ net.md_5.bungee.api.connection.ProxiedPlayer+ player+
+ +- + + +
+Constructor Summary
++
+Constructors ++ +Constructor and Description ++ ++ OnlinePlayer(net.md_5.bungee.api.connection.ProxiedPlayer player)+
+- + + +
+Method Summary
++
+ +All Methods Instance Methods Concrete Methods ++ +Modifier and Type +Method and Description ++ ++ boolean+ equals(Object o)+ ++ net.md_5.bungee.api.connection.ProxiedPlayer+ getPlayer()+ ++ int+ hashCode()+ ++ String+ toString()+++
+- + +
++
+ +- + + +
+Field Detail
+ + + ++
+- +
+player
+public final net.md_5.bungee.api.connection.ProxiedPlayer player++
+ + +- + + +
+Constructor Detail
+ + + ++
+- +
+OnlinePlayer
+public OnlinePlayer(net.md_5.bungee.api.connection.ProxiedPlayer player)+Copyright © 2019. All rights reserved.
+ + diff --git a/docs/acf-bungee/co/aikar/commands/bungee/contexts/class-use/OnlinePlayer.html b/docs/acf-bungee/co/aikar/commands/bungee/contexts/class-use/OnlinePlayer.html new file mode 100644 index 00000000..b5627f06 --- /dev/null +++ b/docs/acf-bungee/co/aikar/commands/bungee/contexts/class-use/OnlinePlayer.html @@ -0,0 +1,167 @@ + + + + + + +Uses of Class co.aikar.commands.bungee.contexts.OnlinePlayer (ACF (Bungee) 0.5.0-SNAPSHOT API) + + + + + + + + + + +++Uses of Class
+
co.aikar.commands.bungee.contexts.OnlinePlayer++ + + + ++
+- +
++
+Packages that use OnlinePlayer ++ + +Package +Description ++ + +co.aikar.commands.contexts ++ - +
++
+- + + +
+Uses of OnlinePlayer in co.aikar.commands.contexts
++
+Subclasses of OnlinePlayer in co.aikar.commands.contexts ++ + +Modifier and Type +Class and Description ++ + ++ class+ OnlineProxiedPlayer+Deprecated. ++Use+OnlinePlayerCopyright © 2019. All rights reserved.
+ + diff --git a/docs/acf-bungee/co/aikar/commands/bungee/contexts/package-frame.html b/docs/acf-bungee/co/aikar/commands/bungee/contexts/package-frame.html new file mode 100644 index 00000000..b6bec14d --- /dev/null +++ b/docs/acf-bungee/co/aikar/commands/bungee/contexts/package-frame.html @@ -0,0 +1,20 @@ + + + + + + +co.aikar.commands.bungee.contexts (ACF (Bungee) 0.5.0-SNAPSHOT API) + + + + +co.aikar.commands.bungee.contexts
+++ + diff --git a/docs/acf-bungee/co/aikar/commands/bungee/contexts/package-summary.html b/docs/acf-bungee/co/aikar/commands/bungee/contexts/package-summary.html new file mode 100644 index 00000000..fd0c9d31 --- /dev/null +++ b/docs/acf-bungee/co/aikar/commands/bungee/contexts/package-summary.html @@ -0,0 +1,141 @@ + + + + + + +Classes
++
+- OnlinePlayer
+co.aikar.commands.bungee.contexts (ACF (Bungee) 0.5.0-SNAPSHOT API) + + + + + + + + + + +++Package co.aikar.commands.bungee.contexts
+++ + + + ++
+- +
++
+Class Summary ++ + +Class +Description ++ + +OnlinePlayer ++ Copyright © 2019. All rights reserved.
+ + diff --git a/docs/acf-bungee/co/aikar/commands/bungee/contexts/package-tree.html b/docs/acf-bungee/co/aikar/commands/bungee/contexts/package-tree.html new file mode 100644 index 00000000..ffbcd1e0 --- /dev/null +++ b/docs/acf-bungee/co/aikar/commands/bungee/contexts/package-tree.html @@ -0,0 +1,136 @@ + + + + + + +co.aikar.commands.bungee.contexts Class Hierarchy (ACF (Bungee) 0.5.0-SNAPSHOT API) + + + + + + + + + + + +++ + + + +Class Hierarchy
++
+- java.lang.Object +
++
+- co.aikar.commands.bungee.contexts.OnlinePlayer
+Copyright © 2019. All rights reserved.
+ + diff --git a/docs/acf-bungee/co/aikar/commands/bungee/contexts/package-use.html b/docs/acf-bungee/co/aikar/commands/bungee/contexts/package-use.html new file mode 100644 index 00000000..2dbd7598 --- /dev/null +++ b/docs/acf-bungee/co/aikar/commands/bungee/contexts/package-use.html @@ -0,0 +1,156 @@ + + + + + + +Uses of Package co.aikar.commands.bungee.contexts (ACF (Bungee) 0.5.0-SNAPSHOT API) + + + + + + + + + + +++Uses of Package
+
co.aikar.commands.bungee.contexts++ + + + ++
+- +
++
+Packages that use co.aikar.commands.bungee.contexts ++ + +Package +Description ++ + +co.aikar.commands.contexts ++ - + + +
++
+Classes in co.aikar.commands.bungee.contexts used by co.aikar.commands.contexts ++ + +Class and Description ++ + +OnlinePlayer +Copyright © 2019. All rights reserved.
+ + diff --git a/docs/acf-bungee/co/aikar/commands/contexts/OnlineProxiedPlayer.html b/docs/acf-bungee/co/aikar/commands/contexts/OnlineProxiedPlayer.html index f9e4c500..998da405 100644 --- a/docs/acf-bungee/co/aikar/commands/contexts/OnlineProxiedPlayer.html +++ b/docs/acf-bungee/co/aikar/commands/contexts/OnlineProxiedPlayer.html @@ -18,12 +18,6 @@ catch(err) { } //--> -var methods = {"i0":10,"i1":10,"i2":10,"i3":10}; -var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]}; -var altColor = "altColor"; -var rowColor = "rowColor"; -var tableTab = "tableTab"; -var activeTableTab = "activeTableTab";- java.lang.Object
- +
+
+- co.aikar.commands.bungee.contexts.OnlinePlayer
+- +
- co.aikar.commands.contexts.OnlineProxiedPlayer
@@ -122,17 +125,13 @@ extends -
+Deprecated. +Use+OnlinePlayer
-public class OnlineProxiedPlayer -extends Object+@Deprecated +public class OnlineProxiedPlayer +extends OnlinePlayerFields -- -Modifier and Type -Field and Description -- - +- net.md_5.bungee.api.connection.ProxiedPlayer- player+
@@ -147,7 +146,9 @@ extends Constructor and Description- + + +
+Fields inherited from class co.aikar.commands.bungee.contexts.OnlinePlayer
+player- @@ -158,29 +159,13 @@ extends -+ OnlineProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer player)OnlineProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer player)+Deprecated.+All Methods Instance Methods Concrete Methods -- -Modifier and Type -Method and Description -- -- boolean- equals(Object o)- -- net.md_5.bungee.api.connection.ProxiedPlayer- getPlayer()- -- int- hashCode()- - +- String- toString()+
- + + +
+Methods inherited from class co.aikar.commands.bungee.contexts.OnlinePlayer
+equals, getPlayer, hashCode, toString
- @@ -196,23 +181,6 @@ extends
- -
- - - -
--
- - - -
@@ -337,15 +250,15 @@ extendsMethod Detail
- - - --
- - - - - - - - - - - -- -
-getPlayer
-public net.md_5.bungee.api.connection.ProxiedPlayer getPlayer()--
- -
toString
-public String toString()- +public OnlineProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer player)+Deprecated.- Summary:
- Nested |
-- Field |
+- Field |
- Constr |
-- Method
+- Method
-
- Prev Package
+- Prev Package
- Next Package
@@ -83,7 +83,9 @@
@@ -110,7 +112,7 @@ OnlineProxiedPlayer -+ Deprecated + Use+OnlinePlayer-
- Prev Package
+- Prev Package
- Next Package
diff --git a/docs/acf-bungee/co/aikar/commands/contexts/package-tree.html b/docs/acf-bungee/co/aikar/commands/contexts/package-tree.html index bb6a1a02..78ec32a1 100644 --- a/docs/acf-bungee/co/aikar/commands/contexts/package-tree.html +++ b/docs/acf-bungee/co/aikar/commands/contexts/package-tree.html @@ -42,7 +42,7 @@
@@ -80,10 +80,14 @@
- java.lang.Object
++
+- co.aikar.commands.bungee.contexts.OnlinePlayer +
- co.aikar.commands.contexts.OnlineProxiedPlayer
diff --git a/docs/acf-bungee/co/aikar/commands/package-summary.html b/docs/acf-bungee/co/aikar/commands/package-summary.html index 31a96edd..27a1cb08 100644 --- a/docs/acf-bungee/co/aikar/commands/package-summary.html +++ b/docs/acf-bungee/co/aikar/commands/package-summary.html @@ -43,7 +43,7 @@
- Prev Package
-- Next Package
+- Next Package
- Frames
@@ -174,7 +174,7 @@diff --git a/docs/acf-sponge/co/aikar/commands/contexts/package-summary.html b/docs/acf-sponge/co/aikar/commands/contexts/package-summary.html index 57c7418b..cd10eee5 100644 --- a/docs/acf-sponge/co/aikar/commands/contexts/package-summary.html +++ b/docs/acf-sponge/co/aikar/commands/contexts/package-summary.html @@ -43,7 +43,7 @@
- Prev Package
-- Next Package
+- Next Package
- Frames
diff --git a/docs/acf-bungee/co/aikar/commands/package-tree.html b/docs/acf-bungee/co/aikar/commands/package-tree.html index c1cadc58..26542d74 100644 --- a/docs/acf-bungee/co/aikar/commands/package-tree.html +++ b/docs/acf-bungee/co/aikar/commands/package-tree.html @@ -43,7 +43,7 @@@@ -99,17 +93,26 @@ var activeTableTab = "activeTableTab";+
- Frames
@@ -170,7 +170,7 @@-
- Frames
diff --git a/docs/acf-bungee/deprecated-list.html b/docs/acf-bungee/deprecated-list.html index 9210ff5f..f7656db1 100644 --- a/docs/acf-bungee/deprecated-list.html +++ b/docs/acf-bungee/deprecated-list.html @@ -72,10 +72,31 @@Deprecated API
Contents
+@@ -129,7 +130,11 @@+ + +diff --git a/docs/acf-bungee/overview-summary.html b/docs/acf-bungee/overview-summary.html index e26e2802..2447f33e 100644 --- a/docs/acf-bungee/overview-summary.html +++ b/docs/acf-bungee/overview-summary.html @@ -84,6 +84,10 @@+
+- +
++
+Deprecated Classes ++ + +Class and Description ++ + +co.aikar.commands.contexts.OnlineProxiedPlayer + +Use+OnlinePlayerdiff --git a/docs/acf-bungee/index-all.html b/docs/acf-bungee/index-all.html index f874d6a6..01e929dd 100644 --- a/docs/acf-bungee/index-all.html +++ b/docs/acf-bungee/index-all.html @@ -127,6 +127,8 @@
- co.aikar.commands - package co.aikar.commands
- +
- co.aikar.commands.bungee.contexts - package co.aikar.commands.bungee.contexts
+- co.aikar.commands.contexts - package co.aikar.commands.contexts
- color(String) - Static method in class co.aikar.commands.ACFBungeeUtil
@@ -153,9 +155,9 @@E
-
- equals(Object) - Method in class co.aikar.commands.BungeeCommandIssuer
+- equals(Object) - Method in class co.aikar.commands.bungee.contexts.OnlinePlayer
- -
- equals(Object) - Method in class co.aikar.commands.contexts.OnlineProxiedPlayer
+- equals(Object) - Method in class co.aikar.commands.BungeeCommandIssuer
- execute(CommandSender, String[]) - Method in class co.aikar.commands.BungeeRootCommand
- @@ -205,6 +207,8 @@
- getPermission() - Method in class co.aikar.commands.BungeeRootCommand
- +
- getPlayer() - Method in class co.aikar.commands.bungee.contexts.OnlinePlayer
+- getPlayer() - Method in class co.aikar.commands.BungeeCommandCompletionContext
- getPlayer() - Method in class co.aikar.commands.BungeeCommandExecutionContext
@@ -213,8 +217,6 @@- getPlayer() - Method in class co.aikar.commands.BungeeConditionContext
- -
- getPlayer() - Method in class co.aikar.commands.contexts.OnlineProxiedPlayer
-- getPlugin() - Method in class co.aikar.commands.BungeeCommandManager
- getRegisteredRootCommands() - Method in class co.aikar.commands.BungeeCommandManager
@@ -235,9 +237,9 @@H
-
- hashCode() - Method in class co.aikar.commands.BungeeCommandIssuer
+- hashCode() - Method in class co.aikar.commands.bungee.contexts.OnlinePlayer
- -
- hashCode() - Method in class co.aikar.commands.contexts.OnlineProxiedPlayer
+- hashCode() - Method in class co.aikar.commands.BungeeCommandIssuer
- hasPermission(String) - Method in class co.aikar.commands.BungeeCommandIssuer
- @@ -285,10 +287,20 @@
- onDisconnect(PlayerDisconnectEvent) - Method in class co.aikar.commands.ACFBungeeListener
- +
- OnlinePlayer - Class in co.aikar.commands.bungee.contexts
+- +
- OnlinePlayer(ProxiedPlayer) - Constructor for class co.aikar.commands.bungee.contexts.OnlinePlayer
+- OnlineProxiedPlayer - Class in co.aikar.commands.contexts
-- +
- +
Deprecated. ++Use+OnlinePlayer- OnlineProxiedPlayer(ProxiedPlayer) - Constructor for class co.aikar.commands.contexts.OnlineProxiedPlayer
-- +
- +
Deprecated.+- onPlayerJoin(PostLoginEvent) - Method in class co.aikar.commands.ACFBungeeListener
- onTabComplete(CommandSender, String[]) - Method in class co.aikar.commands.BungeeRootCommand
@@ -299,7 +311,7 @@P
-
- player - Variable in class co.aikar.commands.contexts.OnlineProxiedPlayer
+- player - Variable in class co.aikar.commands.bungee.contexts.OnlinePlayer
- plugin - Variable in class co.aikar.commands.BungeeCommandManager
- @@ -343,7 +355,7 @@
T
-
diff --git a/docs/acf-bungee/overview-frame.html b/docs/acf-bungee/overview-frame.html index 21c33cdc..db4d1c17 100644 --- a/docs/acf-bungee/overview-frame.html +++ b/docs/acf-bungee/overview-frame.html @@ -14,6 +14,7 @@- toString() - Method in class co.aikar.commands.contexts.OnlineProxiedPlayer
+- toString() - Method in class co.aikar.commands.bungee.contexts.OnlinePlayer
Packages
+ +co.aikar.commands.bungee.contexts ++ diff --git a/docs/acf-bungee/overview-tree.html b/docs/acf-bungee/overview-tree.html index 23b68363..ed31aac9 100644 --- a/docs/acf-bungee/overview-tree.html +++ b/docs/acf-bungee/overview-tree.html @@ -73,6 +73,7 @@ Package Hierarchies: co.aikar.commands.contexts - co.aikar.commands.BungeeMessageFormatter
- co.aikar.commands.bungee.contexts.OnlinePlayer +
+
- co.aikar.commands.contexts.OnlineProxiedPlayer
+- co.aikar.commands.RegisteredCommand<CEC>
- co.aikar.commands.BungeeRegisteredCommand
diff --git a/docs/acf-bungee/package-list b/docs/acf-bungee/package-list index 105851a3..4972251f 100644 --- a/docs/acf-bungee/package-list +++ b/docs/acf-bungee/package-list @@ -1,2 +1,3 @@ co.aikar.commands +co.aikar.commands.bungee.contexts co.aikar.commands.contexts diff --git a/docs/acf-bungee/src-html/co/aikar/commands/BungeeCommandContexts.html b/docs/acf-bungee/src-html/co/aikar/commands/BungeeCommandContexts.html index 1c559b32..a76fda0a 100644 --- a/docs/acf-bungee/src-html/co/aikar/commands/BungeeCommandContexts.html +++ b/docs/acf-bungee/src-html/co/aikar/commands/BungeeCommandContexts.html @@ -33,62 +33,70 @@ 025 026 027import co.aikar.commands.annotation.Optional; -028import co.aikar.commands.contexts.OnlineProxiedPlayer; +028import co.aikar.commands.bungee.contexts.OnlinePlayer; 029import net.md_5.bungee.api.ChatColor; 030import net.md_5.bungee.api.CommandSender; 031import net.md_5.bungee.api.connection.ProxiedPlayer; -032 -033import java.util.stream.Collectors; -034import java.util.stream.Stream; -035 -036public class BungeeCommandContexts extends CommandContexts<BungeeCommandExecutionContext> { -037 -038 BungeeCommandContexts(CommandManager manager) { -039 super(manager); -040 registerContext(OnlineProxiedPlayer.class, (c) -> { -041 ProxiedPlayer proxiedPlayer = ACFBungeeUtil.findPlayerSmart(c.getIssuer(), c.popFirstArg()); -042 if (proxiedPlayer == null) { -043 if (c.hasAnnotation(Optional.class)) { -044 return null; -045 } -046 throw new InvalidCommandArgument(false); -047 } -048 return new OnlineProxiedPlayer(proxiedPlayer); -049 }); -050 registerIssuerAwareContext(CommandSender.class, BungeeCommandExecutionContext::getSender); -051 registerIssuerAwareContext(ProxiedPlayer.class, (c) -> { -052 ProxiedPlayer proxiedPlayer = c.getSender() instanceof ProxiedPlayer ? (ProxiedPlayer) c.getSender() : null; -053 if (proxiedPlayer == null && !c.hasAnnotation(Optional.class)) { -054 throw new InvalidCommandArgument(MessageKeys.NOT_ALLOWED_ON_CONSOLE, false); -055 } -056 return proxiedPlayer; -057 }); -058 -059 registerContext(ChatColor.class, c -> { -060 String first = c.popFirstArg(); -061 Stream<ChatColor> colors = Stream.of(ChatColor.values()); -062 if (c.hasFlag("colorsonly")) { -063 colors = colors.filter(color -> color.ordinal() <= 0xF); -064 } -065 String filter = c.getFlagValue("filter", (String) null); -066 if (filter != null) { -067 filter = ACFUtil.simplifyString(filter); -068 String finalFilter = filter; -069 colors = colors.filter(color -> finalFilter.equals(ACFUtil.simplifyString(color.name()))); -070 } -071 -072 ChatColor match = ACFUtil.simpleMatch(ChatColor.class, first); -073 if (match == null) { -074 String valid = colors -075 .map(color -> "<c2>" + ACFUtil.simplifyString(color.name()) + "</c2>") -076 .collect(Collectors.joining("<c1>,</c1> ")); -077 -078 throw new InvalidCommandArgument(MessageKeys.PLEASE_SPECIFY_ONE_OF, "{valid}", valid); -079 } -080 return match; -081 }); -082 } -083} +032import org.jetbrains.annotations.Nullable; +033 +034import java.util.stream.Collectors; +035import java.util.stream.Stream; +036 +037public class BungeeCommandContexts extends CommandContexts<BungeeCommandExecutionContext> { +038 +039 BungeeCommandContexts(CommandManager manager) { +040 super(manager); +041 registerContext(OnlinePlayer.class, this::getOnlinePlayer); +042 registerContext(co.aikar.commands.contexts.OnlineProxiedPlayer.class, c -> { +043 OnlinePlayer onlinePlayer = getOnlinePlayer(c); +044 return onlinePlayer != null ? new co.aikar.commands.contexts.OnlineProxiedPlayer(onlinePlayer.getPlayer()) : null; +045 }); +046 registerIssuerAwareContext(CommandSender.class, BungeeCommandExecutionContext::getSender); +047 registerIssuerAwareContext(ProxiedPlayer.class, (c) -> { +048 ProxiedPlayer proxiedPlayer = c.getSender() instanceof ProxiedPlayer ? (ProxiedPlayer) c.getSender() : null; +049 if (proxiedPlayer == null && !c.hasAnnotation(Optional.class)) { +050 throw new InvalidCommandArgument(MessageKeys.NOT_ALLOWED_ON_CONSOLE, false); +051 } +052 return proxiedPlayer; +053 }); +054 +055 registerContext(ChatColor.class, c -> { +056 String first = c.popFirstArg(); +057 Stream<ChatColor> colors = Stream.of(ChatColor.values()); +058 if (c.hasFlag("colorsonly")) { +059 colors = colors.filter(color -> color.ordinal() <= 0xF); +060 } +061 String filter = c.getFlagValue("filter", (String) null); +062 if (filter != null) { +063 filter = ACFUtil.simplifyString(filter); +064 String finalFilter = filter; +065 colors = colors.filter(color -> finalFilter.equals(ACFUtil.simplifyString(color.name()))); +066 } +067 +068 ChatColor match = ACFUtil.simpleMatch(ChatColor.class, first); +069 if (match == null) { +070 String valid = colors +071 .map(color -> "<c2>" + ACFUtil.simplifyString(color.name()) + "</c2>") +072 .collect(Collectors.joining("<c1>,</c1> ")); +073 +074 throw new InvalidCommandArgument(MessageKeys.PLEASE_SPECIFY_ONE_OF, "{valid}", valid); +075 } +076 return match; +077 }); +078 } +079 +080 @Nullable +081 private co.aikar.commands.contexts.OnlineProxiedPlayer getOnlinePlayer(BungeeCommandExecutionContext c) throws InvalidCommandArgument { +082 ProxiedPlayer proxiedPlayer = ACFBungeeUtil.findPlayerSmart(c.getIssuer(), c.popFirstArg()); +083 if (proxiedPlayer == null) { +084 if (c.hasAnnotation(Optional.class)) { +085 return null; +086 } +087 throw new InvalidCommandArgument(false); +088 } +089 return new co.aikar.commands.contexts.OnlineProxiedPlayer(proxiedPlayer); +090 } +091} diff --git a/docs/acf-bungee/src-html/co/aikar/commands/bungee/contexts/OnlinePlayer.html b/docs/acf-bungee/src-html/co/aikar/commands/bungee/contexts/OnlinePlayer.html new file mode 100644 index 00000000..5808d113 --- /dev/null +++ b/docs/acf-bungee/src-html/co/aikar/commands/bungee/contexts/OnlinePlayer.html @@ -0,0 +1,131 @@ + + + +Source code + + + +++ + diff --git a/docs/acf-bungee/src-html/co/aikar/commands/contexts/OnlineProxiedPlayer.html b/docs/acf-bungee/src-html/co/aikar/commands/contexts/OnlineProxiedPlayer.html index 050222c4..eca0c2b5 100644 --- a/docs/acf-bungee/src-html/co/aikar/commands/contexts/OnlineProxiedPlayer.html +++ b/docs/acf-bungee/src-html/co/aikar/commands/contexts/OnlineProxiedPlayer.html @@ -6,67 +6,20 @@001/* +002 * Copyright (c) 2016-2017 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.bungee.contexts; +025 +026import net.md_5.bungee.api.connection.ProxiedPlayer; +027 +028import java.util.Objects; +029 +030public class OnlinePlayer { +031 +032 public final ProxiedPlayer player; +033 +034 public OnlinePlayer(ProxiedPlayer player) { +035 this.player = player; +036 } +037 +038 public ProxiedPlayer getPlayer() { +039 return player; +040 } +041 +042 @Override +043 public boolean equals(Object o) { +044 if (this == o) return true; +045 if (o == null || getClass() != o.getClass()) return false; +046 OnlinePlayer that = (OnlinePlayer) o; +047 return Objects.equals(player, that.player); +048 } +049 +050 @Override +051 public int hashCode() { +052 return Objects.hash(player); +053 } +054 +055 @Override +056 public String toString() { +057 return "OnlinePlayer{player=" + player + '}'; +058 } +059} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ++-@@ -221,7 +221,7 @@ var activeTableTab = "activeTableTab";001/* -002 * Copyright (c) 2016-2017 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.contexts; -025 -026import net.md_5.bungee.api.connection.ProxiedPlayer; -027 -028import java.util.Objects; -029 -030public class OnlineProxiedPlayer { -031 -032 public final ProxiedPlayer player; -033 -034 public OnlineProxiedPlayer(ProxiedPlayer player) { -035 this.player = player; -036 } -037 -038 public ProxiedPlayer getPlayer(){ -039 return player; -040 } -041 -042 @Override -043 public boolean equals(Object o) { -044 if (this == o) return true; -045 if (o == null || getClass() != o.getClass()) return false; -046 OnlineProxiedPlayer that = (OnlineProxiedPlayer) o; -047 return Objects.equals(player, that.player); -048 } -049 -050 @Override -051 public int hashCode() { -052 return Objects.hash(player); -053 } -054 -055 @Override -056 public String toString() { -057 return "OnlineProxiedPlayer{" + -058 "proxiedPlayer=" + player + -059 '}'; -060 } -061} +001package co.aikar.commands.contexts; +002 +003import co.aikar.commands.bungee.contexts.OnlinePlayer; +004import net.md_5.bungee.api.connection.ProxiedPlayer; +005 +006/** +007 * @deprecated Use {@link OnlinePlayer} +008 */ +009@Deprecated +010public class OnlineProxiedPlayer extends OnlinePlayer { +011 public OnlineProxiedPlayer(ProxiedPlayer player) { +012 super(player); +013 } +014} diff --git a/docs/acf-core/co/aikar/commands/RootCommand.html b/docs/acf-core/co/aikar/commands/RootCommand.html index 78d89184..aa95b170 100644 --- a/docs/acf-core/co/aikar/commands/RootCommand.html +++ b/docs/acf-core/co/aikar/commands/RootCommand.html @@ -100,7 +100,7 @@ var activeTableTab = "activeTableTab";
-public interface RootCommand+public interface RootCommand@@ -230,7 +230,7 @@ var activeTableTab = "activeTableTab";
addChild
-void addChild(BaseCommand command)+void addChild(BaseCommand command)@@ -239,7 +239,7 @@ var activeTableTab = "activeTableTab";
getManager
-CommandManager getManager()+CommandManager getManager()@@ -248,7 +248,7 @@ var activeTableTab = "activeTableTab";
getSubCommands
-com.google.common.collect.SetMultimap<String,RegisteredCommand> getSubCommands()+com.google.common.collect.SetMultimap<String,RegisteredCommand> getSubCommands()@@ -257,7 +257,7 @@ var activeTableTab = "activeTableTab";
getChildren
-List<BaseCommand> getChildren()+List<BaseCommand> getChildren()@@ -266,7 +266,7 @@ var activeTableTab = "activeTableTab";
getCommandName
-String getCommandName()+String getCommandName()
- @@ -277,7 +277,7 @@ var activeTableTab = "activeTableTab";
addChildShared
-default void addChildShared(List<BaseCommand> children, +default void addChildShared(List<BaseCommand> children, com.google.common.collect.SetMultimap<String,RegisteredCommand> subCommands, BaseCommand command)
- +
getUniquePermission
-default String getUniquePermission()+default String getUniquePermission()
- Returns:
- If this root command can be summarized to a single required permission node to use it, returns that value. If any RegisteredCommand is permission-less, or has multiple required permission nodes, null is returned.
@@ -290,7 +290,7 @@ var activeTableTab = "activeTableTab";@@ -299,7 +299,7 @@ var activeTableTab = "activeTableTab";
hasAnyPermission
-default boolean hasAnyPermission(CommandIssuer issuer)+default boolean hasAnyPermission(CommandIssuer issuer)
- @@ -310,7 +310,7 @@ var activeTableTab = "activeTableTab";
execute
-default BaseCommand execute(CommandIssuer sender, +default BaseCommand execute(CommandIssuer sender, String commandLabel, String[] args)@@ -319,7 +319,7 @@ var activeTableTab = "activeTableTab";
getBaseCommand
-default BaseCommand getBaseCommand(String[] args)+default BaseCommand getBaseCommand(String[] args)
- @@ -330,7 +330,7 @@ var activeTableTab = "activeTableTab";
getTabCompletions
-default List<String> getTabCompletions(CommandIssuer sender, +default List<String> getTabCompletions(CommandIssuer sender, String alias, String[] args)
getTabCompletions
-default List<String> getTabCompletions(CommandIssuer sender, +default List<String> getTabCompletions(CommandIssuer sender, String alias, String[] args, boolean commandsOnly)@@ -342,7 +342,7 @@ var activeTableTab = "activeTableTab";
- 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 a7de3aff..ff123dd6 100644 --- a/docs/acf-core/src-html/co/aikar/commands/BaseCommand.html +++ b/docs/acf-core/src-html/co/aikar/commands/BaseCommand.html @@ -529,14 +529,14 @@ 521 } 522 } 523 -524 if (subCommands.get(DEFAULT) != null && args.length == 0) { -525 findAndExecuteCommand(commandContext, DEFAULT, issuer, args); -526 } else if (subCommands.get(CATCHUNKNOWN) != null) { -527 if (!findAndExecuteCommand(commandContext, CATCHUNKNOWN, issuer, args)) { -528 help(issuer, args); -529 } -530 } else if (subCommands.get(DEFAULT) != null) { -531 findAndExecuteCommand(commandContext, DEFAULT, issuer, args); +524 Set<RegisteredCommand> defaultCommands = subCommands.get(DEFAULT); +525 RegisteredCommand defCommand = !defaultCommands.isEmpty() ? ACFUtil.getFirstElement(defaultCommands) : null; +526 if (defCommand != null && (args.length == 0 || defCommand.consumeInputResolvers > 0)) { +527 findAndExecuteCommand(commandContext, DEFAULT, issuer, args); +528 } else if (subCommands.get(CATCHUNKNOWN) != null) { +529 if (!findAndExecuteCommand(commandContext, CATCHUNKNOWN, issuer, args)) { +530 help(issuer, args); +531 } 532 } 533 534 } finally { @@ -974,40 +974,39 @@ 966 List<RegisteredCommand> registeredCommands = new ArrayList<>(); 967 registeredCommands.addAll(this.subCommands.values()); 968 return registeredCommands; -969 -970 } -971 -972 private static class CommandSearch { -973 RegisteredCommand cmd; -974 int argIndex; -975 String checkSub; -976 -977 CommandSearch(RegisteredCommand cmd, int argIndex, String checkSub) { -978 this.cmd = cmd; -979 this.argIndex = argIndex; -980 this.checkSub = checkSub; -981 } -982 -983 String getCheckSub() { -984 return this.checkSub; -985 } -986 -987 @Override -988 public boolean equals(Object o) { -989 if (this == o) return true; -990 if (o == null || getClass() != o.getClass()) return false; -991 CommandSearch that = (CommandSearch) o; -992 return argIndex == that.argIndex && -993 Objects.equals(cmd, that.cmd) && -994 Objects.equals(checkSub, that.checkSub); -995 } -996 -997 @Override -998 public int hashCode() { -999 return Objects.hash(cmd, argIndex, checkSub); -1000 } -1001 } -1002} +969 } +970 +971 private static class CommandSearch { +972 RegisteredCommand cmd; +973 int argIndex; +974 String checkSub; +975 +976 CommandSearch(RegisteredCommand cmd, int argIndex, String checkSub) { +977 this.cmd = cmd; +978 this.argIndex = argIndex; +979 this.checkSub = checkSub; +980 } +981 +982 String getCheckSub() { +983 return this.checkSub; +984 } +985 +986 @Override +987 public boolean equals(Object o) { +988 if (this == o) return true; +989 if (o == null || getClass() != o.getClass()) return false; +990 CommandSearch that = (CommandSearch) o; +991 return argIndex == that.argIndex && +992 Objects.equals(cmd, that.cmd) && +993 Objects.equals(checkSub, that.checkSub); +994 } +995 +996 @Override +997 public int hashCode() { +998 return Objects.hash(cmd, argIndex, checkSub); +999 } +1000 } +1001} diff --git a/docs/acf-core/src-html/co/aikar/commands/RegisteredCommand.html b/docs/acf-core/src-html/co/aikar/commands/RegisteredCommand.html index ec164034..139f0e4c 100644 --- a/docs/acf-core/src-html/co/aikar/commands/RegisteredCommand.html +++ b/docs/acf-core/src-html/co/aikar/commands/RegisteredCommand.html @@ -105,7 +105,7 @@ 097 //noinspection unchecked 098 this.parameters = new CommandParameter[parameters.length]; 099 -100 this.isPrivate = annotations.hasAnnotation(method, Private.class); +100 this.isPrivate = annotations.hasAnnotation(method, Private.class) || annotations.getAnnotationFromClass(scope.getClass(), Private.class) != null; 101 102 int requiredResolvers = 0; 103 int consumeInputResolvers = 0; diff --git a/docs/acf-core/src-html/co/aikar/commands/RootCommand.html b/docs/acf-core/src-html/co/aikar/commands/RootCommand.html index bbdfd59f..be340351 100644 --- a/docs/acf-core/src-html/co/aikar/commands/RootCommand.html +++ b/docs/acf-core/src-html/co/aikar/commands/RootCommand.html @@ -39,150 +39,166 @@ 031import java.util.List; 032import java.util.Set; 033 -034public interface RootCommand { -035 void addChild(BaseCommand command); +034import static co.aikar.commands.BaseCommand.CATCHUNKNOWN; +035import static co.aikar.commands.BaseCommand.DEFAULT; 036 -037 CommandManager getManager(); -038 -039 SetMultimap<String, RegisteredCommand> getSubCommands(); -040 -041 List<BaseCommand> getChildren(); -042 -043 String getCommandName(); -044 -045 default void addChildShared(List<BaseCommand> children, SetMultimap<String, RegisteredCommand> subCommands, BaseCommand command) { -046 command.subCommands.entries().forEach(e -> { -047 String key = e.getKey(); -048 RegisteredCommand registeredCommand = e.getValue(); -049 if (key.equals(BaseCommand.DEFAULT) || key.equals(BaseCommand.CATCHUNKNOWN)) { -050 return; -051 } -052 Set<RegisteredCommand> registered = subCommands.get(key); -053 if (!registered.isEmpty()) { -054 BaseCommand prevBase = registered.iterator().next().scope; -055 if (prevBase != registeredCommand.scope) { -056 this.getManager().log(LogLevel.ERROR, "ACF Error: " + command.getName() + " registered subcommand " + key + " for root command " + getCommandName() + " - but it is already defined in " + prevBase.getName()); -057 this.getManager().log(LogLevel.ERROR, "2 subcommands of the same prefix may not be spread over 2 different classes. Ignoring this."); -058 return; -059 } -060 } -061 subCommands.put(key, registeredCommand); -062 }); -063 -064 children.add(command); -065 } +037public interface RootCommand { +038 void addChild(BaseCommand command); +039 +040 CommandManager getManager(); +041 +042 SetMultimap<String, RegisteredCommand> getSubCommands(); +043 +044 List<BaseCommand> getChildren(); +045 +046 String getCommandName(); +047 +048 default void addChildShared(List<BaseCommand> children, SetMultimap<String, RegisteredCommand> subCommands, BaseCommand command) { +049 command.subCommands.entries().forEach(e -> { +050 String key = e.getKey(); +051 RegisteredCommand registeredCommand = e.getValue(); +052 if (key.equals(DEFAULT) || key.equals(BaseCommand.CATCHUNKNOWN)) { +053 return; +054 } +055 Set<RegisteredCommand> registered = subCommands.get(key); +056 if (!registered.isEmpty()) { +057 BaseCommand prevBase = registered.iterator().next().scope; +058 if (prevBase != registeredCommand.scope) { +059 this.getManager().log(LogLevel.ERROR, "ACF Error: " + command.getName() + " registered subcommand " + key + " for root command " + getCommandName() + " - but it is already defined in " + prevBase.getName()); +060 this.getManager().log(LogLevel.ERROR, "2 subcommands of the same prefix may not be spread over 2 different classes. Ignoring this."); +061 return; +062 } +063 } +064 subCommands.put(key, registeredCommand); +065 }); 066 -067 /** -068 * @return If this root command can be summarized to a single required permission node to use it, returns that value. If any RegisteredCommand is permission-less, or has multiple required permission nodes, null is returned. -069 */ -070 default String getUniquePermission() { -071 Set<String> permissions = new HashSet<>(); -072 for (BaseCommand child : getChildren()) { -073 for (RegisteredCommand<?> value : child.subCommands.values()) { -074 Set<String> requiredPermissions = value.getRequiredPermissions(); -075 if (requiredPermissions.isEmpty()) { -076 return null; -077 } else { -078 permissions.addAll(requiredPermissions); -079 } -080 } -081 } -082 return permissions.size() == 1 ? permissions.iterator().next() : null; -083 } -084 -085 default boolean hasAnyPermission(CommandIssuer issuer) { -086 List<BaseCommand> children = getChildren(); -087 if (children.isEmpty()) { -088 return true; -089 } -090 -091 for (BaseCommand child : children) { -092 if (!child.hasPermission(issuer)) { -093 continue; -094 } -095 for (RegisteredCommand value : child.getRegisteredCommands()) { -096 if (value.hasPermission(issuer)) { -097 return true; -098 } -099 } -100 } -101 return false; -102 } -103 -104 default BaseCommand execute(CommandIssuer sender, String commandLabel, String[] args) { -105 BaseCommand command = getBaseCommand(args); +067 children.add(command); +068 } +069 +070 /** +071 * @return If this root command can be summarized to a single required permission node to use it, returns that value. If any RegisteredCommand is permission-less, or has multiple required permission nodes, null is returned. +072 */ +073 default String getUniquePermission() { +074 Set<String> permissions = new HashSet<>(); +075 for (BaseCommand child : getChildren()) { +076 for (RegisteredCommand<?> value : child.subCommands.values()) { +077 Set<String> requiredPermissions = value.getRequiredPermissions(); +078 if (requiredPermissions.isEmpty()) { +079 return null; +080 } else { +081 permissions.addAll(requiredPermissions); +082 } +083 } +084 } +085 return permissions.size() == 1 ? permissions.iterator().next() : null; +086 } +087 +088 default boolean hasAnyPermission(CommandIssuer issuer) { +089 List<BaseCommand> children = getChildren(); +090 if (children.isEmpty()) { +091 return true; +092 } +093 +094 for (BaseCommand child : children) { +095 if (!child.hasPermission(issuer)) { +096 continue; +097 } +098 for (RegisteredCommand value : child.getRegisteredCommands()) { +099 if (value.hasPermission(issuer)) { +100 return true; +101 } +102 } +103 } +104 return false; +105 } 106 -107 command.execute(sender, commandLabel, args); -108 return command; -109 } -110 -111 default BaseCommand getBaseCommand(String[] args) { -112 BaseCommand command = getDefCommand(); -113 for (int i = args.length; i >= 0; i--) { -114 String checkSub = ApacheCommonsLangUtil.join(args, " ", 0, i).toLowerCase(); -115 Set<RegisteredCommand> registeredCommands = getSubCommands().get(checkSub); -116 if (!registeredCommands.isEmpty()) { -117 command = registeredCommands.iterator().next().scope; -118 break; -119 } -120 } -121 return command; -122 } -123 -124 default List<String> getTabCompletions(CommandIssuer sender, String alias, String[] args) { -125 return getTabCompletions(sender, alias, args, false); -126 } -127 -128 default List<String> getTabCompletions(CommandIssuer sender, String alias, String[] args, boolean commandsOnly) { -129 return getTabCompletions(sender, alias, args, commandsOnly, false); -130 } -131 -132 default List<String> getTabCompletions(CommandIssuer sender, String alias, String[] args, boolean commandsOnly, boolean isAsync) { -133 Set<String> completions = new HashSet<>(); -134 getChildren().forEach(child -> { -135 if (!commandsOnly) { -136 completions.addAll(child.tabComplete(sender, alias, args, isAsync)); -137 } -138 completions.addAll(child.getCommandsForCompletion(sender, args)); -139 }); -140 return new ArrayList<>(completions); -141 } -142 +107 default BaseCommand execute(CommandIssuer sender, String commandLabel, String[] args) { +108 BaseCommand command = getBaseCommand(args); +109 +110 command.execute(sender, commandLabel, args); +111 return command; +112 } +113 +114 default BaseCommand getBaseCommand(String[] args) { +115 SetMultimap<String, RegisteredCommand> subCommands = getSubCommands(); +116 Set<RegisteredCommand> registeredCommands; +117 for (int i = args.length; i >= 0; i--) { +118 String checkSub = ApacheCommonsLangUtil.join(args, " ", 0, i).toLowerCase(); +119 registeredCommands = subCommands.get(checkSub); +120 if (!registeredCommands.isEmpty()) { +121 return ACFUtil.getFirstElement(registeredCommands).scope; +122 } +123 } +124 +125 registeredCommands = subCommands.get(DEFAULT); +126 if (!registeredCommands.isEmpty()) { +127 RegisteredCommand command = ACFUtil.getFirstElement(registeredCommands); +128 if (args.length == 0 || command.consumeInputResolvers > 0) { +129 return command.scope; +130 } +131 } +132 +133 registeredCommands = subCommands.get(CATCHUNKNOWN); +134 if (!registeredCommands.isEmpty()) { +135 return ACFUtil.getFirstElement(registeredCommands).scope; +136 } +137 return getDefCommand(); +138 } +139 +140 default List<String> getTabCompletions(CommandIssuer sender, String alias, String[] args) { +141 return getTabCompletions(sender, alias, args, false); +142 } 143 -144 default RegisteredCommand getDefaultRegisteredCommand() { -145 BaseCommand defCommand = this.getDefCommand(); -146 if (defCommand != null) { -147 return defCommand.getDefaultRegisteredCommand(); -148 } -149 return null; -150 } -151 -152 default BaseCommand getDefCommand() { -153 return null; -154 } -155 -156 -157 default String getDescription() { -158 final RegisteredCommand cmd = this.getDefaultRegisteredCommand(); -159 if (cmd != null) { -160 return cmd.getHelpText(); -161 } -162 BaseCommand defCommand = getDefCommand(); -163 if (defCommand != null && defCommand.description != null) { -164 return defCommand.description; -165 } -166 return ""; -167 } -168 -169 -170 default String getUsage() { -171 final RegisteredCommand cmd = this.getDefaultRegisteredCommand(); -172 if (cmd != null) { -173 return cmd.syntaxText != null ? cmd.syntaxText : ""; -174 } -175 return ""; -176 } -177} +144 default List<String> getTabCompletions(CommandIssuer sender, String alias, String[] args, boolean commandsOnly) { +145 return getTabCompletions(sender, alias, args, commandsOnly, false); +146 } +147 +148 default List<String> getTabCompletions(CommandIssuer sender, String alias, String[] args, boolean commandsOnly, boolean isAsync) { +149 Set<String> completions = new HashSet<>(); +150 getChildren().forEach(child -> { +151 if (!commandsOnly) { +152 completions.addAll(child.tabComplete(sender, alias, args, isAsync)); +153 } +154 completions.addAll(child.getCommandsForCompletion(sender, args)); +155 }); +156 return new ArrayList<>(completions); +157 } +158 +159 +160 default RegisteredCommand getDefaultRegisteredCommand() { +161 BaseCommand defCommand = this.getDefCommand(); +162 if (defCommand != null) { +163 return defCommand.getDefaultRegisteredCommand(); +164 } +165 return null; +166 } +167 +168 default BaseCommand getDefCommand() { +169 return null; +170 } +171 +172 +173 default String getDescription() { +174 final RegisteredCommand cmd = this.getDefaultRegisteredCommand(); +175 if (cmd != null) { +176 return cmd.getHelpText(); +177 } +178 BaseCommand defCommand = getDefCommand(); +179 if (defCommand != null && defCommand.description != null) { +180 return defCommand.description; +181 } +182 return ""; +183 } +184 +185 +186 default String getUsage() { +187 final RegisteredCommand cmd = this.getDefaultRegisteredCommand(); +188 if (cmd != null) { +189 return cmd.syntaxText != null ? cmd.syntaxText : ""; +190 } +191 return ""; +192 } +193} diff --git a/docs/acf-paper/co/aikar/commands/PaperCommandManager.html b/docs/acf-paper/co/aikar/commands/PaperCommandManager.html index 540275ce..1d64225e 100644 --- a/docs/acf-paper/co/aikar/commands/PaperCommandManager.html +++ b/docs/acf-paper/co/aikar/commands/PaperCommandManager.html @@ -136,7 +136,7 @@ extends co.aikar.commands.BukkitCommandManager
getTabCompletions
-default List<String> getTabCompletions(CommandIssuer sender, +default List<String> getTabCompletions(CommandIssuer sender, String alias, String[] args, boolean commandsOnly, @@ -355,7 +355,7 @@ var activeTableTab = "activeTableTab";@@ -364,7 +364,7 @@ var activeTableTab = "activeTableTab";
getDefaultRegisteredCommand
-default RegisteredCommand getDefaultRegisteredCommand()+default RegisteredCommand getDefaultRegisteredCommand()@@ -373,7 +373,7 @@ var activeTableTab = "activeTableTab";
getDefCommand
-default BaseCommand getDefCommand()+default BaseCommand getDefCommand()@@ -382,7 +382,7 @@ var activeTableTab = "activeTableTab";
getDescription
-default String getDescription()+default String getDescription()Fields inherited from class co.aikar.commands.BukkitCommandManager
-autoDetectFromClient, completions, contexts, knownCommands, locales, plugin, registeredCommandsautoDetectFromClient, completions, contexts, knownCommands, locales, mcMinorVersion, mcPatchVersion, plugin, registeredCommands
- diff --git a/docs/acf-sponge/allclasses-frame.html b/docs/acf-sponge/allclasses-frame.html index ca8a03b1..4b0ae21f 100644 --- a/docs/acf-sponge/allclasses-frame.html +++ b/docs/acf-sponge/allclasses-frame.html @@ -17,6 +17,7 @@
- CommandResultSupplier
- MinecraftMessageKeys
- OnlinePlayer
+- OnlinePlayer
- SpongeCommandCompletionContext
- SpongeCommandCompletions
- SpongeCommandContexts
diff --git a/docs/acf-sponge/allclasses-noframe.html b/docs/acf-sponge/allclasses-noframe.html index 89502ced..ccab8913 100644 --- a/docs/acf-sponge/allclasses-noframe.html +++ b/docs/acf-sponge/allclasses-noframe.html @@ -17,6 +17,7 @@- CommandResultSupplier
- MinecraftMessageKeys
- OnlinePlayer
+- OnlinePlayer
- SpongeCommandCompletionContext
- SpongeCommandCompletions
- SpongeCommandContexts
diff --git a/docs/acf-sponge/co/aikar/commands/contexts/OnlinePlayer.html b/docs/acf-sponge/co/aikar/commands/contexts/OnlinePlayer.html index 033df562..b51535c5 100644 --- a/docs/acf-sponge/co/aikar/commands/contexts/OnlinePlayer.html +++ b/docs/acf-sponge/co/aikar/commands/contexts/OnlinePlayer.html @@ -18,12 +18,6 @@ catch(err) { } //--> -var methods = {"i0":10,"i1":10,"i2":10,"i3":10}; -var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]}; -var altColor = "altColor"; -var rowColor = "rowColor"; -var tableTab = "tableTab"; -var activeTableTab = "activeTableTab";- java.lang.Object
- +
+
+- co.aikar.commands.sponge.contexts.OnlinePlayer
+- +
- co.aikar.commands.contexts.OnlinePlayer
@@ -122,17 +125,13 @@ extends -
+Deprecated. +Use+instead
-public class OnlinePlayer -extends Object+@Deprecated +public class OnlinePlayer +extends OnlinePlayerFields -- -Modifier and Type -Field and Description -- - +- org.spongepowered.api.entity.living.player.Player- player+
@@ -147,7 +146,9 @@ extends Constructor and Description- + + +
+Fields inherited from class co.aikar.commands.sponge.contexts.OnlinePlayer
+player- @@ -158,29 +159,13 @@ extends -+ OnlinePlayer(org.spongepowered.api.entity.living.player.Player player)OnlinePlayer(org.spongepowered.api.entity.living.player.Player player)+Deprecated.+All Methods Instance Methods Concrete Methods -- -Modifier and Type -Method and Description -- -- boolean- equals(Object o)- -- org.spongepowered.api.entity.living.player.Player- getPlayer()- -- int- hashCode()- - +- String- toString()+
- + + +
+Methods inherited from class co.aikar.commands.sponge.contexts.OnlinePlayer
+equals, getPlayer, hashCode, toString
- @@ -196,23 +181,6 @@ extends
- -
- - - -
-
- Prev Package
-- Next Package
+- Next Package
- Frames
@@ -87,7 +87,9 @@@@ -115,7 +117,7 @@ OnlinePlayer -+ Deprecated + Use+instead
- Prev Package
-- Next Package
+- Next Package
- Frames
diff --git a/docs/acf-sponge/co/aikar/commands/contexts/package-tree.html b/docs/acf-sponge/co/aikar/commands/contexts/package-tree.html index f9bd87f2..946c944f 100644 --- a/docs/acf-sponge/co/aikar/commands/contexts/package-tree.html +++ b/docs/acf-sponge/co/aikar/commands/contexts/package-tree.html @@ -43,7 +43,7 @@
- Frames
@@ -81,10 +81,14 @@- java.lang.Object
++
- co.aikar.commands.contexts.CommandResultSupplier (implements java.util.function.Consumer<T>)
+- co.aikar.commands.sponge.contexts.OnlinePlayer +
- co.aikar.commands.contexts.OnlinePlayer
@@ -107,7 +111,7 @@diff --git a/docs/acf-sponge/overview-tree.html b/docs/acf-sponge/overview-tree.html index 1976d93f..d9d0affe 100644 --- a/docs/acf-sponge/overview-tree.html +++ b/docs/acf-sponge/overview-tree.html @@ -73,7 +73,8 @@ Package Hierarchies:
- Frames
diff --git a/docs/acf-sponge/co/aikar/commands/sponge/contexts/OnlinePlayer.html b/docs/acf-sponge/co/aikar/commands/sponge/contexts/OnlinePlayer.html new file mode 100644 index 00000000..e281fdca --- /dev/null +++ b/docs/acf-sponge/co/aikar/commands/sponge/contexts/OnlinePlayer.html @@ -0,0 +1,361 @@ + + + + + + +OnlinePlayer (ACF (Sponge) 0.5.0-SNAPSHOT API) + + + + + + + + + + + +++co.aikar.commands.sponge.contexts+Class OnlinePlayer
+++ + + + + ++
+- java.lang.Object
+- +
++
+- co.aikar.commands.sponge.contexts.OnlinePlayer
++++
+- +
++
+- Direct Known Subclasses:
+- OnlinePlayer
+
+
+public class OnlinePlayer +extends Object++++
+- + +
++
+ +- + + +
+Field Summary
++
+Fields ++ +Modifier and Type +Field and Description ++ ++ org.spongepowered.api.entity.living.player.Player+ player+
+ +- + + +
+Constructor Summary
++
+Constructors ++ +Constructor and Description ++ ++ OnlinePlayer(org.spongepowered.api.entity.living.player.Player player)+
+- + + +
+Method Summary
++
+ +All Methods Instance Methods Concrete Methods ++ +Modifier and Type +Method and Description ++ ++ boolean+ equals(Object o)+ ++ org.spongepowered.api.entity.living.player.Player+ getPlayer()+ ++ int+ hashCode()+ ++ String+ toString()+++
+- + +
++
+ +- + + +
+Field Detail
+ + + ++
+- +
+player
+public final org.spongepowered.api.entity.living.player.Player player++
+ + +- + + +
+Constructor Detail
+ + + ++
+- +
+OnlinePlayer
+public OnlinePlayer(org.spongepowered.api.entity.living.player.Player player)+Copyright © 2019. All rights reserved.
+ + diff --git a/docs/acf-sponge/co/aikar/commands/sponge/contexts/class-use/OnlinePlayer.html b/docs/acf-sponge/co/aikar/commands/sponge/contexts/class-use/OnlinePlayer.html new file mode 100644 index 00000000..010bd4c7 --- /dev/null +++ b/docs/acf-sponge/co/aikar/commands/sponge/contexts/class-use/OnlinePlayer.html @@ -0,0 +1,167 @@ + + + + + + +Uses of Class co.aikar.commands.sponge.contexts.OnlinePlayer (ACF (Sponge) 0.5.0-SNAPSHOT API) + + + + + + + + + + +++Uses of Class
+
co.aikar.commands.sponge.contexts.OnlinePlayer++ + + + ++
+- +
++
+Packages that use OnlinePlayer ++ + +Package +Description ++ + +co.aikar.commands.contexts ++ - +
++
+- + + +
+Uses of OnlinePlayer in co.aikar.commands.contexts
++
+Subclasses of OnlinePlayer in co.aikar.commands.contexts ++ + +Modifier and Type +Class and Description ++ + ++ class+ OnlinePlayer+Deprecated. ++Use+insteadCopyright © 2019. All rights reserved.
+ + diff --git a/docs/acf-sponge/co/aikar/commands/sponge/contexts/package-frame.html b/docs/acf-sponge/co/aikar/commands/sponge/contexts/package-frame.html new file mode 100644 index 00000000..c0f6457d --- /dev/null +++ b/docs/acf-sponge/co/aikar/commands/sponge/contexts/package-frame.html @@ -0,0 +1,20 @@ + + + + + + +co.aikar.commands.sponge.contexts (ACF (Sponge) 0.5.0-SNAPSHOT API) + + + + +co.aikar.commands.sponge.contexts
+++ + diff --git a/docs/acf-sponge/co/aikar/commands/sponge/contexts/package-summary.html b/docs/acf-sponge/co/aikar/commands/sponge/contexts/package-summary.html new file mode 100644 index 00000000..b6d9a553 --- /dev/null +++ b/docs/acf-sponge/co/aikar/commands/sponge/contexts/package-summary.html @@ -0,0 +1,141 @@ + + + + + + +Classes
++
+- OnlinePlayer
+co.aikar.commands.sponge.contexts (ACF (Sponge) 0.5.0-SNAPSHOT API) + + + + + + + + + + +++Package co.aikar.commands.sponge.contexts
+++ + + + ++
+- +
++
+Class Summary ++ + +Class +Description ++ + +OnlinePlayer ++ Copyright © 2019. All rights reserved.
+ + diff --git a/docs/acf-sponge/co/aikar/commands/sponge/contexts/package-tree.html b/docs/acf-sponge/co/aikar/commands/sponge/contexts/package-tree.html new file mode 100644 index 00000000..eeb1f03a --- /dev/null +++ b/docs/acf-sponge/co/aikar/commands/sponge/contexts/package-tree.html @@ -0,0 +1,136 @@ + + + + + + +co.aikar.commands.sponge.contexts Class Hierarchy (ACF (Sponge) 0.5.0-SNAPSHOT API) + + + + + + + + + + + +++ + + + +Class Hierarchy
++
+- java.lang.Object +
++
+- co.aikar.commands.sponge.contexts.OnlinePlayer
+Copyright © 2019. All rights reserved.
+ + diff --git a/docs/acf-sponge/co/aikar/commands/sponge/contexts/package-use.html b/docs/acf-sponge/co/aikar/commands/sponge/contexts/package-use.html new file mode 100644 index 00000000..2cd60869 --- /dev/null +++ b/docs/acf-sponge/co/aikar/commands/sponge/contexts/package-use.html @@ -0,0 +1,156 @@ + + + + + + +Uses of Package co.aikar.commands.sponge.contexts (ACF (Sponge) 0.5.0-SNAPSHOT API) + + + + + + + + + + +++Uses of Package
+
co.aikar.commands.sponge.contexts++ + + + ++
+- +
++
+Packages that use co.aikar.commands.sponge.contexts ++ + +Package +Description ++ + +co.aikar.commands.contexts ++ - + + +
++
+Classes in co.aikar.commands.sponge.contexts used by co.aikar.commands.contexts ++ + +Class and Description ++ + +OnlinePlayer +Copyright © 2019. All rights reserved.
+ + diff --git a/docs/acf-sponge/deprecated-list.html b/docs/acf-sponge/deprecated-list.html index 195606e2..cafcf456 100644 --- a/docs/acf-sponge/deprecated-list.html +++ b/docs/acf-sponge/deprecated-list.html @@ -71,6 +71,30 @@ ++ + ++
- +
++
+Deprecated Classes ++ + +Class and Description ++ + +co.aikar.commands.contexts.OnlinePlayer + +Use+insteaddiff --git a/docs/acf-sponge/index-all.html b/docs/acf-sponge/index-all.html index 99becc3e..34a8fe20 100644 --- a/docs/acf-sponge/index-all.html +++ b/docs/acf-sponge/index-all.html @@ -95,6 +95,8 @@- co.aikar.commands.contexts - package co.aikar.commands.contexts
- +
- co.aikar.commands.sponge.contexts - package co.aikar.commands.sponge.contexts
+- CommandResultSupplier - Class in co.aikar.commands.contexts
- CommandResultSupplier() - Constructor for class co.aikar.commands.contexts.CommandResultSupplier
@@ -121,7 +123,7 @@E
-
- equals(Object) - Method in class co.aikar.commands.contexts.OnlinePlayer
+- equals(Object) - Method in class co.aikar.commands.sponge.contexts.OnlinePlayer
- equals(Object) - Method in class co.aikar.commands.SpongeCommandIssuer
- @@ -167,7 +169,7 @@
- getMessageKey() - Method in enum co.aikar.commands.MinecraftMessageKeys
- -
- getPlayer() - Method in class co.aikar.commands.contexts.OnlinePlayer
+- getPlayer() - Method in class co.aikar.commands.sponge.contexts.OnlinePlayer
- getPlayer() - Method in class co.aikar.commands.SpongeCommandCompletionContext
- @@ -205,7 +207,7 @@
H
-
- hashCode() - Method in class co.aikar.commands.contexts.OnlinePlayer
+- hashCode() - Method in class co.aikar.commands.sponge.contexts.OnlinePlayer
- hashCode() - Method in class co.aikar.commands.SpongeCommandIssuer
- @@ -256,8 +258,18 @@
- onDisconnectCleanup(ClientConnectionEvent.Disconnect, Player) - Method in class co.aikar.commands.ACFSpongeListener
- OnlinePlayer - Class in co.aikar.commands.contexts
-- +
- +
Deprecated. ++Use+instead- OnlinePlayer(Player) - Constructor for class co.aikar.commands.contexts.OnlinePlayer
+- +
+Deprecated.+- OnlinePlayer - Class in co.aikar.commands.sponge.contexts
+- +
- OnlinePlayer(Player) - Constructor for class co.aikar.commands.sponge.contexts.OnlinePlayer
- onSettingsChange(PlayerChangeClientSettingsEvent, Player) - Method in class co.aikar.commands.ACFSpongeListener
- @@ -267,7 +279,7 @@
P
-
- player - Variable in class co.aikar.commands.contexts.OnlinePlayer
+- player - Variable in class co.aikar.commands.sponge.contexts.OnlinePlayer
- plugin - Variable in class co.aikar.commands.SpongeCommandManager
- @@ -339,7 +351,7 @@
diff --git a/docs/acf-sponge/overview-frame.html b/docs/acf-sponge/overview-frame.html index f0e2e6f0..08f6f622 100644 --- a/docs/acf-sponge/overview-frame.html +++ b/docs/acf-sponge/overview-frame.html @@ -15,6 +15,7 @@
- testPermission(CommandSource) - Method in class co.aikar.commands.SpongeRootCommand
- -
- toString() - Method in class co.aikar.commands.contexts.OnlinePlayer
+- toString() - Method in class co.aikar.commands.sponge.contexts.OnlinePlayer
diff --git a/docs/acf-sponge/overview-summary.html b/docs/acf-sponge/overview-summary.html index e6b7ad4f..f7d3a7e3 100644 --- a/docs/acf-sponge/overview-summary.html +++ b/docs/acf-sponge/overview-summary.html @@ -87,6 +87,10 @@
co.aikar.commands.contexts + + co.aikar.commands.sponge.contexts ++ @@ -129,7 +130,11 @@diff --git a/docs/acf-velocity/co/aikar/commands/contexts/package-summary.html b/docs/acf-velocity/co/aikar/commands/contexts/package-summary.html index 482a5b8b..7ab2c72e 100644 --- a/docs/acf-velocity/co/aikar/commands/contexts/package-summary.html +++ b/docs/acf-velocity/co/aikar/commands/contexts/package-summary.html @@ -43,7 +43,7 @@- co.aikar.commands.SpongeMessageFormatter
+- co.aikar.commands.sponge.contexts.OnlinePlayer +
+
- co.aikar.commands.contexts.OnlinePlayer
+- co.aikar.commands.RegisteredCommand<CEC>
@@ -147,7 +146,9 @@ extends Constructor and Description
- co.aikar.commands.SpongeRegisteredCommand
diff --git a/docs/acf-sponge/package-list b/docs/acf-sponge/package-list index 105851a3..8eb6f0df 100644 --- a/docs/acf-sponge/package-list +++ b/docs/acf-sponge/package-list @@ -1,2 +1,3 @@ co.aikar.commands co.aikar.commands.contexts +co.aikar.commands.sponge.contexts diff --git a/docs/acf-sponge/src-html/co/aikar/commands/SpongeCommandContexts.html b/docs/acf-sponge/src-html/co/aikar/commands/SpongeCommandContexts.html index 2abef271..9f19bbbb 100644 --- a/docs/acf-sponge/src-html/co/aikar/commands/SpongeCommandContexts.html +++ b/docs/acf-sponge/src-html/co/aikar/commands/SpongeCommandContexts.html @@ -32,7 +32,7 @@ 024package co.aikar.commands; 025 026import co.aikar.commands.contexts.CommandResultSupplier; -027import co.aikar.commands.contexts.OnlinePlayer; +027import co.aikar.commands.sponge.contexts.OnlinePlayer; 028import org.jetbrains.annotations.Nullable; 029import org.spongepowered.api.Sponge; 030import org.spongepowered.api.command.CommandSource; @@ -58,129 +58,132 @@ 050 051 registerIssuerOnlyContext(CommandResultSupplier.class, c -> new CommandResultSupplier()); 052 registerContext(OnlinePlayer.class, c -> getOnlinePlayer(c.getIssuer(), c.popFirstArg(), c.isOptional())); -053 registerContext(User.class, c -> { -054 String name = c.popFirstArg(); -055 // try online players first -056 Optional<Player> targetPlayer = Sponge.getGame().getServer().getPlayer(name); -057 if (targetPlayer.isPresent()) { -058 return targetPlayer.get(); -059 } -060 -061 Optional<UserStorageService> service = Sponge.getGame().getServiceManager().provide(UserStorageService.class); -062 if (!service.isPresent()) { -063 manager.log(LogLevel.ERROR, "No UserStorageService is available", new Error()); -064 throw new InvalidCommandArgument(MessageKeys.ERROR_GENERIC_LOGGED, false); -065 } -066 Optional<User> user = service.get().get(name); -067 if (user.isPresent()) { -068 return user.get(); +053 registerContext(co.aikar.commands.contexts.OnlinePlayer.class, c -> { +054 OnlinePlayer onlinePlayer = getOnlinePlayer(c.getIssuer(), c.popFirstArg(), c.isOptional()); +055 return onlinePlayer != null ? new co.aikar.commands.contexts.OnlinePlayer(onlinePlayer.getPlayer()) : null; +056 }); +057 registerContext(User.class, c -> { +058 String name = c.popFirstArg(); +059 // try online players first +060 Optional<Player> targetPlayer = Sponge.getGame().getServer().getPlayer(name); +061 if (targetPlayer.isPresent()) { +062 return targetPlayer.get(); +063 } +064 +065 Optional<UserStorageService> service = Sponge.getGame().getServiceManager().provide(UserStorageService.class); +066 if (!service.isPresent()) { +067 manager.log(LogLevel.ERROR, "No UserStorageService is available", new Error()); +068 throw new InvalidCommandArgument(MessageKeys.ERROR_GENERIC_LOGGED, false); 069 } -070 if (!c.isOptional()) { -071 throw new InvalidCommandArgument(MinecraftMessageKeys.NO_PLAYER_FOUND, false, "{search}", name); -072 } -073 -074 return null; -075 }); -076 registerContext(TextColor.class, c -> { -077 String first = c.popFirstArg(); -078 Stream<TextColor> colours = Sponge.getRegistry().getAllOf(TextColor.class).stream(); -079 String filter = c.getFlagValue("filter", (String) null); -080 if (filter != null) { -081 filter = ACFUtil.simplifyString(filter); -082 String finalFilter = filter; -083 colours = colours.filter(colour -> finalFilter.equals(ACFUtil.simplifyString(colour.getName()))); -084 } -085 Stream<TextColor> finalColours = colours; -086 return Sponge.getRegistry().getType(TextColor.class, ACFUtil.simplifyString(first)).orElseThrow(() -> { -087 String valid = finalColours -088 .map(colour -> "<c2>" + ACFUtil.simplifyString(colour.getName()) + "</c2>") -089 .collect(Collectors.joining("<c1>,</c1> ")); -090 return new InvalidCommandArgument(MessageKeys.PLEASE_SPECIFY_ONE_OF, "{valid}", valid); -091 }); -092 }); -093 registerContext(TextStyle.Base.class, c -> { -094 String first = c.popFirstArg(); -095 Stream<TextStyle.Base> styles = Sponge.getRegistry().getAllOf(TextStyle.Base.class).stream(); -096 String filter = c.getFlagValue("filter", (String) null); -097 if (filter != null) { -098 filter = ACFUtil.simplifyString(filter); -099 String finalFilter = filter; -100 styles = styles.filter(style -> finalFilter.equals(ACFUtil.simplifyString(style.getName()))); -101 } -102 Stream<TextStyle.Base> finalStyles = styles; -103 return Sponge.getRegistry().getType(TextStyle.Base.class, ACFUtil.simplifyString(first)).orElseThrow(() -> { -104 String valid = finalStyles -105 .map(style -> "<c2>" + ACFUtil.simplifyString(style.getName()) + "</c2>") -106 .collect(Collectors.joining("<c1>,</c1> ")); -107 return new InvalidCommandArgument(MessageKeys.PLEASE_SPECIFY_ONE_OF, "{valid}", valid); -108 }); -109 }); -110 -111 registerIssuerAwareContext(CommandSource.class, SpongeCommandExecutionContext::getSource); -112 registerIssuerAwareContext(Player.class, (c) -> { -113 Player player = c.getSource() instanceof Player ? (Player) c.getSource() : null; -114 if (player == null && !c.isOptional()) { -115 throw new InvalidCommandArgument(MessageKeys.NOT_ALLOWED_ON_CONSOLE, false); -116 } -117 /*PlayerInventory inventory = player != null ? player.getInventory() : null; -118 if (inventory != null && c.hasFlag("itemheld") && !ACFBukkitUtil.isValidItem(inventory.getItem(inventory.getHeldItemSlot()))) { -119 throw new InvalidCommandArgument(MinecraftMessageKeys.YOU_MUST_BE_HOLDING_ITEM, false); -120 }*/ -121 return player; -122 }); -123 registerContext(OnlinePlayer[].class, (c) -> { -124 SpongeCommandIssuer issuer = c.getIssuer(); -125 final String search = c.popFirstArg(); -126 boolean allowMissing = c.hasFlag("allowmissing"); -127 Set<OnlinePlayer> players = new HashSet<>(); -128 Pattern split = ACFPatterns.COMMA; -129 String splitter = c.getFlagValue("splitter", (String) null); -130 if (splitter != null) { -131 split = Pattern.compile(Pattern.quote(splitter)); -132 } -133 for (String lookup : split.split(search)) { -134 OnlinePlayer player = getOnlinePlayer(issuer, lookup, allowMissing); -135 if (player != null) { -136 players.add(player); -137 } -138 } -139 if (players.isEmpty() && !c.hasFlag("allowempty")) { -140 issuer.sendError(MinecraftMessageKeys.NO_PLAYER_FOUND_SERVER, -141 "{search}", search); -142 -143 throw new InvalidCommandArgument(false); -144 } -145 return players.toArray(new OnlinePlayer[players.size()]); -146 }); -147 registerIssuerAwareContext(World.class, (c) -> { -148 String firstArg = c.getFirstArg(); -149 java.util.Optional<World> world = firstArg != null ? Sponge.getServer().getWorld(firstArg) : java.util.Optional.empty(); -150 if (world.isPresent()) { -151 c.popFirstArg(); -152 } -153 if (!world.isPresent() && c.getSource() instanceof Player) { -154 world = java.util.Optional.of(((Player) c.getSource()).getWorld()); -155 } -156 if (!world.isPresent()) { -157 throw new InvalidCommandArgument(MinecraftMessageKeys.INVALID_WORLD); -158 } -159 return world.get(); -160 }); -161 } -162 -163 @Nullable -164 OnlinePlayer getOnlinePlayer(SpongeCommandIssuer issuer, String lookup, boolean allowMissing) throws InvalidCommandArgument { -165 Player player = ACFSpongeUtil.findPlayerSmart(issuer, lookup); -166 //noinspection Duplicates -167 if (player == null) { -168 if (allowMissing) { -169 return null; -170 } -171 throw new InvalidCommandArgument(false); -172 } -173 return new OnlinePlayer(player); -174 } -175} +070 Optional<User> user = service.get().get(name); +071 if (user.isPresent()) { +072 return user.get(); +073 } +074 if (!c.isOptional()) { +075 throw new InvalidCommandArgument(MinecraftMessageKeys.NO_PLAYER_FOUND, false, "{search}", name); +076 } +077 +078 return null; +079 }); +080 registerContext(TextColor.class, c -> { +081 String first = c.popFirstArg(); +082 Stream<TextColor> colours = Sponge.getRegistry().getAllOf(TextColor.class).stream(); +083 String filter = c.getFlagValue("filter", (String) null); +084 if (filter != null) { +085 filter = ACFUtil.simplifyString(filter); +086 String finalFilter = filter; +087 colours = colours.filter(colour -> finalFilter.equals(ACFUtil.simplifyString(colour.getName()))); +088 } +089 Stream<TextColor> finalColours = colours; +090 return Sponge.getRegistry().getType(TextColor.class, ACFUtil.simplifyString(first)).orElseThrow(() -> { +091 String valid = finalColours +092 .map(colour -> "<c2>" + ACFUtil.simplifyString(colour.getName()) + "</c2>") +093 .collect(Collectors.joining("<c1>,</c1> ")); +094 return new InvalidCommandArgument(MessageKeys.PLEASE_SPECIFY_ONE_OF, "{valid}", valid); +095 }); +096 }); +097 registerContext(TextStyle.Base.class, c -> { +098 String first = c.popFirstArg(); +099 Stream<TextStyle.Base> styles = Sponge.getRegistry().getAllOf(TextStyle.Base.class).stream(); +100 String filter = c.getFlagValue("filter", (String) null); +101 if (filter != null) { +102 filter = ACFUtil.simplifyString(filter); +103 String finalFilter = filter; +104 styles = styles.filter(style -> finalFilter.equals(ACFUtil.simplifyString(style.getName()))); +105 } +106 Stream<TextStyle.Base> finalStyles = styles; +107 return Sponge.getRegistry().getType(TextStyle.Base.class, ACFUtil.simplifyString(first)).orElseThrow(() -> { +108 String valid = finalStyles +109 .map(style -> "<c2>" + ACFUtil.simplifyString(style.getName()) + "</c2>") +110 .collect(Collectors.joining("<c1>,</c1> ")); +111 return new InvalidCommandArgument(MessageKeys.PLEASE_SPECIFY_ONE_OF, "{valid}", valid); +112 }); +113 }); +114 +115 registerIssuerAwareContext(CommandSource.class, SpongeCommandExecutionContext::getSource); +116 registerIssuerAwareContext(Player.class, (c) -> { +117 Player player = c.getSource() instanceof Player ? (Player) c.getSource() : null; +118 if (player == null && !c.isOptional()) { +119 throw new InvalidCommandArgument(MessageKeys.NOT_ALLOWED_ON_CONSOLE, false); +120 } +121 /*PlayerInventory inventory = player != null ? player.getInventory() : null; +122 if (inventory != null && c.hasFlag("itemheld") && !ACFBukkitUtil.isValidItem(inventory.getItem(inventory.getHeldItemSlot()))) { +123 throw new InvalidCommandArgument(MinecraftMessageKeys.YOU_MUST_BE_HOLDING_ITEM, false); +124 }*/ +125 return player; +126 }); +127 registerContext(OnlinePlayer[].class, (c) -> { +128 SpongeCommandIssuer issuer = c.getIssuer(); +129 final String search = c.popFirstArg(); +130 boolean allowMissing = c.hasFlag("allowmissing"); +131 Set<OnlinePlayer> players = new HashSet<>(); +132 Pattern split = ACFPatterns.COMMA; +133 String splitter = c.getFlagValue("splitter", (String) null); +134 if (splitter != null) { +135 split = Pattern.compile(Pattern.quote(splitter)); +136 } +137 for (String lookup : split.split(search)) { +138 OnlinePlayer player = getOnlinePlayer(issuer, lookup, allowMissing); +139 if (player != null) { +140 players.add(player); +141 } +142 } +143 if (players.isEmpty() && !c.hasFlag("allowempty")) { +144 issuer.sendError(MinecraftMessageKeys.NO_PLAYER_FOUND_SERVER, +145 "{search}", search); +146 +147 throw new InvalidCommandArgument(false); +148 } +149 return players.toArray(new OnlinePlayer[players.size()]); +150 }); +151 registerIssuerAwareContext(World.class, (c) -> { +152 String firstArg = c.getFirstArg(); +153 java.util.Optional<World> world = firstArg != null ? Sponge.getServer().getWorld(firstArg) : java.util.Optional.empty(); +154 if (world.isPresent()) { +155 c.popFirstArg(); +156 } +157 if (!world.isPresent() && c.getSource() instanceof Player) { +158 world = java.util.Optional.of(((Player) c.getSource()).getWorld()); +159 } +160 if (!world.isPresent()) { +161 throw new InvalidCommandArgument(MinecraftMessageKeys.INVALID_WORLD); +162 } +163 return world.get(); +164 }); +165 } +166 +167 @Nullable +168 OnlinePlayer getOnlinePlayer(SpongeCommandIssuer issuer, String lookup, boolean allowMissing) throws InvalidCommandArgument { +169 Player player = ACFSpongeUtil.findPlayerSmart(issuer, lookup); +170 if (player == null) { +171 if (allowMissing) { +172 return null; +173 } +174 throw new InvalidCommandArgument(false); +175 } +176 return new OnlinePlayer(player); +177 } +178} diff --git a/docs/acf-sponge/src-html/co/aikar/commands/contexts/OnlinePlayer.html b/docs/acf-sponge/src-html/co/aikar/commands/contexts/OnlinePlayer.html index f46b5c77..0eba5312 100644 --- a/docs/acf-sponge/src-html/co/aikar/commands/contexts/OnlinePlayer.html +++ b/docs/acf-sponge/src-html/co/aikar/commands/contexts/OnlinePlayer.html @@ -7,7 +7,7 @@@@ -99,17 +93,26 @@ var activeTableTab = "activeTableTab";001/* -002 * Copyright (c) 2016-2017 Daniel Ennis (Aikar) - MIT License +002 * Copyright (c) 2016-2019 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 @@ -33,39 +33,15 @@ 025 026import org.spongepowered.api.entity.living.player.Player; 027 -028import java.util.Objects; -029 -030public class OnlinePlayer { -031 public final Player player; -032 +028/** +029 * @deprecated Use {@link co.aikar.commands.sponge.contexts.OnlinePlayer instead} +030 */ +031@Deprecated +032public class OnlinePlayer extends co.aikar.commands.sponge.contexts.OnlinePlayer { 033 public OnlinePlayer(Player player) { -034 this.player = player; +034 super(player); 035 } -036 -037 public Player getPlayer() { -038 return this.player; -039 } -040 -041 @Override -042 public boolean equals(Object o) { -043 if (this == o) return true; -044 if (o == null || getClass() != o.getClass()) return false; -045 OnlinePlayer that = (OnlinePlayer) o; -046 return Objects.equals(player, that.player); -047 } -048 -049 @Override -050 public int hashCode() { -051 return Objects.hash(player); -052 } -053 -054 @Override -055 public String toString() { -056 return "OnlinePlayer{" + -057 "player=" + player + -058 '}'; -059 } -060} +036} diff --git a/docs/acf-sponge/src-html/co/aikar/commands/sponge/contexts/OnlinePlayer.html b/docs/acf-sponge/src-html/co/aikar/commands/sponge/contexts/OnlinePlayer.html new file mode 100644 index 00000000..b4017acb --- /dev/null +++ b/docs/acf-sponge/src-html/co/aikar/commands/sponge/contexts/OnlinePlayer.html @@ -0,0 +1,130 @@ + + + +Source code + + + +++ + diff --git a/docs/acf-velocity/allclasses-frame.html b/docs/acf-velocity/allclasses-frame.html index b9bf2ec7..d72b08b2 100644 --- a/docs/acf-velocity/allclasses-frame.html +++ b/docs/acf-velocity/allclasses-frame.html @@ -16,6 +16,7 @@001/* +002 * Copyright (c) 2016-2017 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.sponge.contexts; +025 +026import org.spongepowered.api.entity.living.player.Player; +027 +028import java.util.Objects; +029 +030public class OnlinePlayer { +031 public final Player player; +032 +033 public OnlinePlayer(Player player) { +034 this.player = player; +035 } +036 +037 public Player getPlayer() { +038 return this.player; +039 } +040 +041 @Override +042 public boolean equals(Object o) { +043 if (this == o) return true; +044 if (o == null || getClass() != o.getClass()) return false; +045 OnlinePlayer that = (OnlinePlayer) o; +046 return Objects.equals(player, that.player); +047 } +048 +049 @Override +050 public int hashCode() { +051 return Objects.hash(player); +052 } +053 +054 @Override +055 public String toString() { +056 return "OnlinePlayer{player=" + player + '}'; +057 } +058} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ++- ACFVelocityUtil
- MinecraftMessageKeys
- OnlinePlayer
+- OnlinePlayer
- VelocityCommandCompletionContext
- VelocityCommandCompletions
- VelocityCommandContexts
diff --git a/docs/acf-velocity/allclasses-noframe.html b/docs/acf-velocity/allclasses-noframe.html index 42456123..9af6c958 100644 --- a/docs/acf-velocity/allclasses-noframe.html +++ b/docs/acf-velocity/allclasses-noframe.html @@ -16,6 +16,7 @@- ACFVelocityUtil
- MinecraftMessageKeys
- OnlinePlayer
+- OnlinePlayer
- VelocityCommandCompletionContext
- VelocityCommandCompletions
- VelocityCommandContexts
diff --git a/docs/acf-velocity/co/aikar/commands/ACFVelocityUtil.html b/docs/acf-velocity/co/aikar/commands/ACFVelocityUtil.html index c9ba7533..e8dbeaa6 100644 --- a/docs/acf-velocity/co/aikar/commands/ACFVelocityUtil.html +++ b/docs/acf-velocity/co/aikar/commands/ACFVelocityUtil.html @@ -230,7 +230,7 @@ extends- @@ -241,7 +241,7 @@ extends
isValidName
-public static boolean isValidName(String name)+public static boolean isValidName(String name)- diff --git a/docs/acf-velocity/co/aikar/commands/contexts/OnlinePlayer.html b/docs/acf-velocity/co/aikar/commands/contexts/OnlinePlayer.html index 98e65cfe..37b45680 100644 --- a/docs/acf-velocity/co/aikar/commands/contexts/OnlinePlayer.html +++ b/docs/acf-velocity/co/aikar/commands/contexts/OnlinePlayer.html @@ -18,12 +18,6 @@ catch(err) { } //--> -var methods = {"i0":10,"i1":10,"i2":10,"i3":10}; -var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]}; -var altColor = "altColor"; -var rowColor = "rowColor"; -var tableTab = "tableTab"; -var activeTableTab = "activeTableTab";
validate
-public static <T> T validate(T object, +public static <T> T validate(T object, String message, Object... values)- java.lang.Object
- +
+
+- co.aikar.commands.velocity.contexts.OnlinePlayer
+- +
- co.aikar.commands.contexts.OnlinePlayer
@@ -122,17 +125,13 @@ extends -
+Deprecated. +Use+instead
-public class OnlinePlayer -extends Object+@Deprecated +public class OnlinePlayer +extends OnlinePlayerFields -- -Modifier and Type -Field and Description -- - +- com.velocitypowered.api.proxy.Player- player+
- + + +
+Fields inherited from class co.aikar.commands.velocity.contexts.OnlinePlayer
+player- @@ -158,29 +159,13 @@ extends -+ OnlinePlayer(com.velocitypowered.api.proxy.Player player)OnlinePlayer(com.velocitypowered.api.proxy.Player player)+Deprecated.+All Methods Instance Methods Concrete Methods -- -Modifier and Type -Method and Description -- -- boolean- equals(Object o)- -- com.velocitypowered.api.proxy.Player- getPlayer()- -- int- hashCode()- - +- String- toString()+
- + + +
+Methods inherited from class co.aikar.commands.velocity.contexts.OnlinePlayer
+equals, getPlayer, hashCode, toString
- @@ -196,23 +181,6 @@ extends
- -
- - - -
--
- - - -
@@ -337,15 +250,15 @@ extendsMethod Detail
- - - --
- - - - - - - - - - - -- -
-getPlayer
-public com.velocitypowered.api.proxy.Player getPlayer()--
- -
toString
-public String toString()- +public OnlinePlayer(com.velocitypowered.api.proxy.Player player)+Deprecated.- Summary:
- Nested |
-- Field |
+- Field |
- Constr |
-- Method
+- Method
- Prev Package
-- Next Package
+- Next Package
- Frames
@@ -83,7 +83,9 @@@@ -111,7 +113,7 @@ OnlinePlayer -+ Deprecated + Use+instead
- Prev Package
-- Next Package
+- Next Package
- Frames
diff --git a/docs/acf-velocity/co/aikar/commands/contexts/package-tree.html b/docs/acf-velocity/co/aikar/commands/contexts/package-tree.html index 60202395..59775f93 100644 --- a/docs/acf-velocity/co/aikar/commands/contexts/package-tree.html +++ b/docs/acf-velocity/co/aikar/commands/contexts/package-tree.html @@ -43,7 +43,7 @@
- Frames
@@ -80,10 +80,14 @@
- java.lang.Object
++
+- co.aikar.commands.velocity.contexts.OnlinePlayer +
- co.aikar.commands.contexts.OnlinePlayer
@@ -106,7 +110,7 @@diff --git a/docs/acf-velocity/overview-tree.html b/docs/acf-velocity/overview-tree.html index 15ebb3d1..6f471d14 100644 --- a/docs/acf-velocity/overview-tree.html +++ b/docs/acf-velocity/overview-tree.html @@ -73,7 +73,8 @@ Package Hierarchies:
- Frames
diff --git a/docs/acf-velocity/co/aikar/commands/velocity/contexts/OnlinePlayer.html b/docs/acf-velocity/co/aikar/commands/velocity/contexts/OnlinePlayer.html new file mode 100644 index 00000000..5508842e --- /dev/null +++ b/docs/acf-velocity/co/aikar/commands/velocity/contexts/OnlinePlayer.html @@ -0,0 +1,361 @@ + + + + + + +OnlinePlayer (ACF (Velocity) 0.5.0-SNAPSHOT API) + + + + + + + + + + + +++co.aikar.commands.velocity.contexts+Class OnlinePlayer
+++ + + + + ++
+- java.lang.Object
+- +
++
+- co.aikar.commands.velocity.contexts.OnlinePlayer
++++
+- +
++
+- Direct Known Subclasses:
+- OnlinePlayer
+
+
+public class OnlinePlayer +extends Object++++
+- + +
++
+ +- + + +
+Field Summary
++
+Fields ++ +Modifier and Type +Field and Description ++ ++ com.velocitypowered.api.proxy.Player+ player+
+ +- + + +
+Constructor Summary
++
+Constructors ++ +Constructor and Description ++ ++ OnlinePlayer(com.velocitypowered.api.proxy.Player player)+
+- + + +
+Method Summary
++
+ +All Methods Instance Methods Concrete Methods ++ +Modifier and Type +Method and Description ++ ++ boolean+ equals(Object o)+ ++ com.velocitypowered.api.proxy.Player+ getPlayer()+ ++ int+ hashCode()+ ++ String+ toString()+++
+- + +
++
+ +- + + +
+Field Detail
+ + + ++
+- +
+player
+public final com.velocitypowered.api.proxy.Player player++
+ + +- + + +
+Constructor Detail
+ + + ++
+- +
+OnlinePlayer
+public OnlinePlayer(com.velocitypowered.api.proxy.Player player)+Copyright © 2019. All rights reserved.
+ + diff --git a/docs/acf-velocity/co/aikar/commands/velocity/contexts/class-use/OnlinePlayer.html b/docs/acf-velocity/co/aikar/commands/velocity/contexts/class-use/OnlinePlayer.html new file mode 100644 index 00000000..5cce9547 --- /dev/null +++ b/docs/acf-velocity/co/aikar/commands/velocity/contexts/class-use/OnlinePlayer.html @@ -0,0 +1,167 @@ + + + + + + +Uses of Class co.aikar.commands.velocity.contexts.OnlinePlayer (ACF (Velocity) 0.5.0-SNAPSHOT API) + + + + + + + + + + +++Uses of Class
+
co.aikar.commands.velocity.contexts.OnlinePlayer++ + + + ++
+- +
++
+Packages that use OnlinePlayer ++ + +Package +Description ++ + +co.aikar.commands.contexts ++ - +
++
+- + + +
+Uses of OnlinePlayer in co.aikar.commands.contexts
++
+Subclasses of OnlinePlayer in co.aikar.commands.contexts ++ + +Modifier and Type +Class and Description ++ + ++ class+ OnlinePlayer+Deprecated. ++Use+insteadCopyright © 2019. All rights reserved.
+ + diff --git a/docs/acf-velocity/co/aikar/commands/velocity/contexts/package-frame.html b/docs/acf-velocity/co/aikar/commands/velocity/contexts/package-frame.html new file mode 100644 index 00000000..2de6bbe5 --- /dev/null +++ b/docs/acf-velocity/co/aikar/commands/velocity/contexts/package-frame.html @@ -0,0 +1,20 @@ + + + + + + +co.aikar.commands.velocity.contexts (ACF (Velocity) 0.5.0-SNAPSHOT API) + + + + +co.aikar.commands.velocity.contexts
+++ + diff --git a/docs/acf-velocity/co/aikar/commands/velocity/contexts/package-summary.html b/docs/acf-velocity/co/aikar/commands/velocity/contexts/package-summary.html new file mode 100644 index 00000000..43884a8f --- /dev/null +++ b/docs/acf-velocity/co/aikar/commands/velocity/contexts/package-summary.html @@ -0,0 +1,141 @@ + + + + + + +Classes
++
+- OnlinePlayer
+co.aikar.commands.velocity.contexts (ACF (Velocity) 0.5.0-SNAPSHOT API) + + + + + + + + + + +++Package co.aikar.commands.velocity.contexts
+++ + + + ++
+- +
++
+Class Summary ++ + +Class +Description ++ + +OnlinePlayer ++ Copyright © 2019. All rights reserved.
+ + diff --git a/docs/acf-velocity/co/aikar/commands/velocity/contexts/package-tree.html b/docs/acf-velocity/co/aikar/commands/velocity/contexts/package-tree.html new file mode 100644 index 00000000..1e09c4fa --- /dev/null +++ b/docs/acf-velocity/co/aikar/commands/velocity/contexts/package-tree.html @@ -0,0 +1,136 @@ + + + + + + +co.aikar.commands.velocity.contexts Class Hierarchy (ACF (Velocity) 0.5.0-SNAPSHOT API) + + + + + + + + + + +++Hierarchy For Package co.aikar.commands.velocity.contexts
+Package Hierarchies: ++
+- All Packages
+++ + + + +Class Hierarchy
++
+- java.lang.Object +
++
+- co.aikar.commands.velocity.contexts.OnlinePlayer
+Copyright © 2019. All rights reserved.
+ + diff --git a/docs/acf-velocity/co/aikar/commands/velocity/contexts/package-use.html b/docs/acf-velocity/co/aikar/commands/velocity/contexts/package-use.html new file mode 100644 index 00000000..7f58988d --- /dev/null +++ b/docs/acf-velocity/co/aikar/commands/velocity/contexts/package-use.html @@ -0,0 +1,156 @@ + + + + + + +Uses of Package co.aikar.commands.velocity.contexts (ACF (Velocity) 0.5.0-SNAPSHOT API) + + + + + + + + + + +++Uses of Package
+
co.aikar.commands.velocity.contexts++ + + + ++
+- +
++
+Packages that use co.aikar.commands.velocity.contexts ++ + +Package +Description ++ + +co.aikar.commands.contexts ++ - + + +
++
+Classes in co.aikar.commands.velocity.contexts used by co.aikar.commands.contexts ++ + +Class and Description ++ + +OnlinePlayer +Copyright © 2019. All rights reserved.
+ + diff --git a/docs/acf-velocity/deprecated-list.html b/docs/acf-velocity/deprecated-list.html index 8b690cb1..c43f9cd7 100644 --- a/docs/acf-velocity/deprecated-list.html +++ b/docs/acf-velocity/deprecated-list.html @@ -71,6 +71,30 @@ ++ + ++
- +
++
+Deprecated Classes ++ + +Class and Description ++ + +co.aikar.commands.contexts.OnlinePlayer + +Use+insteaddiff --git a/docs/acf-velocity/index-all.html b/docs/acf-velocity/index-all.html index 80c68550..e12748f2 100644 --- a/docs/acf-velocity/index-all.html +++ b/docs/acf-velocity/index-all.html @@ -93,6 +93,8 @@- co.aikar.commands.contexts - package co.aikar.commands.contexts
- +
- co.aikar.commands.velocity.contexts - package co.aikar.commands.velocity.contexts
+- color(String) - Static method in class co.aikar.commands.ACFVelocityUtil
- completions - Variable in class co.aikar.commands.VelocityCommandManager
@@ -115,7 +117,7 @@E
-
- equals(Object) - Method in class co.aikar.commands.contexts.OnlinePlayer
+- equals(Object) - Method in class co.aikar.commands.velocity.contexts.OnlinePlayer
- equals(Object) - Method in class co.aikar.commands.VelocityCommandIssuer
- @@ -159,7 +161,7 @@
- getMessageKey() - Method in enum co.aikar.commands.MinecraftMessageKeys
- -
- getPlayer() - Method in class co.aikar.commands.contexts.OnlinePlayer
+- getPlayer() - Method in class co.aikar.commands.velocity.contexts.OnlinePlayer
- getPlayer() - Method in class co.aikar.commands.VelocityCommandCompletionContext
- @@ -191,7 +193,7 @@
H
-
- hashCode() - Method in class co.aikar.commands.contexts.OnlinePlayer
+- hashCode() - Method in class co.aikar.commands.velocity.contexts.OnlinePlayer
- hashCode() - Method in class co.aikar.commands.VelocityCommandIssuer
- @@ -240,8 +242,18 @@
- onDisconnect(DisconnectEvent) - Method in class co.aikar.commands.ACFVelocityListener
- OnlinePlayer - Class in co.aikar.commands.contexts
-- +
- +
Deprecated. ++Use+instead- OnlinePlayer(Player) - Constructor for class co.aikar.commands.contexts.OnlinePlayer
+- +
+Deprecated.+- OnlinePlayer - Class in co.aikar.commands.velocity.contexts
+- +
- OnlinePlayer(Player) - Constructor for class co.aikar.commands.velocity.contexts.OnlinePlayer
- onPlayerJoin(PostLoginEvent) - Method in class co.aikar.commands.ACFVelocityListener
- @@ -253,7 +265,7 @@
P
-
- player - Variable in class co.aikar.commands.contexts.OnlinePlayer
+- player - Variable in class co.aikar.commands.velocity.contexts.OnlinePlayer
- plugin - Variable in class co.aikar.commands.VelocityCommandManager
- @@ -287,7 +299,7 @@
T
-
diff --git a/docs/acf-velocity/overview-frame.html b/docs/acf-velocity/overview-frame.html index c5e3ca78..0654f687 100644 --- a/docs/acf-velocity/overview-frame.html +++ b/docs/acf-velocity/overview-frame.html @@ -15,6 +15,7 @@- toString() - Method in class co.aikar.commands.contexts.OnlinePlayer
+- toString() - Method in class co.aikar.commands.velocity.contexts.OnlinePlayer
diff --git a/docs/acf-velocity/overview-summary.html b/docs/acf-velocity/overview-summary.html index 7341ea2c..599ae740 100644 --- a/docs/acf-velocity/overview-summary.html +++ b/docs/acf-velocity/overview-summary.html @@ -87,6 +87,10 @@
co.aikar.commands.contexts + + co.aikar.commands.velocity.contexts ++ @@ -123,7 +124,11 @@- co.aikar.commands.VelocityMessageFormatter
+- co.aikar.commands.velocity.contexts.OnlinePlayer +
+
- co.aikar.commands.contexts.OnlinePlayer
+- co.aikar.commands.VelocityCommandIssuer (implements co.aikar.commands.CommandIssuer)
- co.aikar.commands.VelocityRootCommand (implements com.velocitypowered.api.command.Command, co.aikar.commands.RootCommand)
diff --git a/docs/acf-velocity/package-list b/docs/acf-velocity/package-list index 105851a3..bd174dae 100644 --- a/docs/acf-velocity/package-list +++ b/docs/acf-velocity/package-list @@ -1,2 +1,3 @@ co.aikar.commands co.aikar.commands.contexts +co.aikar.commands.velocity.contexts diff --git a/docs/acf-velocity/src-html/co/aikar/commands/ACFVelocityUtil.html b/docs/acf-velocity/src-html/co/aikar/commands/ACFVelocityUtil.html index 47bc5a81..ff1784f5 100644 --- a/docs/acf-velocity/src-html/co/aikar/commands/ACFVelocityUtil.html +++ b/docs/acf-velocity/src-html/co/aikar/commands/ACFVelocityUtil.html @@ -69,26 +69,27 @@ 061 } 062 063 Optional<Player> exactMatch = server.getPlayer(partialName); -064 if (exactMatch != null) { -065 return Collections.singleton(exactMatch.get()); -066 } -067 -068 return server.getAllPlayers().stream() -069 .filter(player -> player.getUsername().regionMatches(true, 0, partialName, 0, partialName.length())) -070 .collect(Collectors.toList()); -071 } -072 -073 public static boolean isValidName(String name) { -074 return name != null && !name.isEmpty() && ACFPatterns.VALID_NAME_PATTERN.matcher(name).matches(); -075 } -076 -077 public static <T> T validate(T object, String message, Object... values) { -078 if (object == null) { -079 throw new NullPointerException(String.format(message, values)); -080 } -081 return object; -082 } -083} +064 //noinspection OptionalIsPresent +065 if (exactMatch.isPresent()) { +066 return Collections.singleton(exactMatch.get()); +067 } +068 +069 return server.getAllPlayers().stream() +070 .filter(player -> player.getUsername().regionMatches(true, 0, partialName, 0, partialName.length())) +071 .collect(Collectors.toList()); +072 } +073 +074 public static boolean isValidName(String name) { +075 return name != null && !name.isEmpty() && ACFPatterns.VALID_NAME_PATTERN.matcher(name).matches(); +076 } +077 +078 public static <T> T validate(T object, String message, Object... values) { +079 if (object == null) { +080 throw new NullPointerException(String.format(message, values)); +081 } +082 return object; +083 } +084} diff --git a/docs/acf-velocity/src-html/co/aikar/commands/VelocityCommandContexts.html b/docs/acf-velocity/src-html/co/aikar/commands/VelocityCommandContexts.html index 7881a5a6..e5612b08 100644 --- a/docs/acf-velocity/src-html/co/aikar/commands/VelocityCommandContexts.html +++ b/docs/acf-velocity/src-html/co/aikar/commands/VelocityCommandContexts.html @@ -38,59 +38,66 @@ 030import com.velocitypowered.api.proxy.Player; 031import com.velocitypowered.api.proxy.ProxyServer; 032 -033import co.aikar.commands.annotation.Optional; -034import co.aikar.commands.contexts.OnlinePlayer; -035import net.kyori.text.format.TextColor; -036import net.kyori.text.format.TextDecoration; -037import net.kyori.text.format.TextFormat; +033import co.aikar.commands.velocity.contexts.OnlinePlayer; +034import net.kyori.text.format.TextColor; +035import net.kyori.text.format.TextDecoration; +036import net.kyori.text.format.TextFormat; +037import org.jetbrains.annotations.Nullable; 038 039public class VelocityCommandContexts extends CommandContexts<VelocityCommandExecutionContext> { 040 041 VelocityCommandContexts(ProxyServer server, CommandManager manager) { 042 super(manager); -043 registerContext(OnlinePlayer.class, (c) -> { -044 Player proxiedPlayer = ACFVelocityUtil.findPlayerSmart(server, c.getIssuer(), c.popFirstArg()); -045 if (proxiedPlayer == null) { -046 if (c.hasAnnotation(Optional.class)) { -047 return null; -048 } -049 throw new InvalidCommandArgument(false); -050 } -051 return new OnlinePlayer(proxiedPlayer); -052 }); -053 registerIssuerAwareContext(CommandSource.class, VelocityCommandExecutionContext::getSender); -054 registerIssuerAwareContext(Player.class, (c) -> { -055 Player proxiedPlayer = c.getSender() instanceof Player ? (Player) c.getSender() : null; -056 if (proxiedPlayer == null && !c.hasAnnotation(Optional.class)) { -057 throw new InvalidCommandArgument(MessageKeys.NOT_ALLOWED_ON_CONSOLE, false); -058 } -059 return proxiedPlayer; -060 }); -061 -062 registerContext(TextFormat.class, c -> { -063 String first = c.popFirstArg(); -064 Stream<TextFormat> colors = Stream.of(TextColor.values()); -065 if (!c.hasFlag("colorsonly")) { -066 colors = Stream.concat(colors, Stream.of(TextDecoration.values())); -067 } -068 String filter = c.getFlagValue("filter", (String) null); -069 if (filter != null) { -070 filter = ACFUtil.simplifyString(filter); -071 String finalFilter = filter; -072 colors = colors.filter(color -> finalFilter.equals(ACFUtil.simplifyString(color.toString()))); -073 } +043 registerContext(OnlinePlayer.class, (c) -> getOnlinePlayer(server, c)); +044 registerContext(co.aikar.commands.contexts.OnlinePlayer.class, c -> { +045 OnlinePlayer onlinePlayer = getOnlinePlayer(server, c); +046 return onlinePlayer != null ? new co.aikar.commands.contexts.OnlinePlayer(onlinePlayer.getPlayer()) : null; +047 }); +048 registerIssuerAwareContext(CommandSource.class, VelocityCommandExecutionContext::getSender); +049 registerIssuerAwareContext(Player.class, (c) -> { +050 Player proxiedPlayer = c.getSender() instanceof Player ? (Player) c.getSender() : null; +051 if (proxiedPlayer == null && !c.isOptional()) { +052 throw new InvalidCommandArgument(MessageKeys.NOT_ALLOWED_ON_CONSOLE, false); +053 } +054 return proxiedPlayer; +055 }); +056 +057 registerContext(TextFormat.class, c -> { +058 String first = c.popFirstArg(); +059 Stream<TextFormat> colors = Stream.of(TextColor.values()); +060 if (!c.hasFlag("colorsonly")) { +061 colors = Stream.concat(colors, Stream.of(TextDecoration.values())); +062 } +063 String filter = c.getFlagValue("filter", (String) null); +064 if (filter != null) { +065 filter = ACFUtil.simplifyString(filter); +066 String finalFilter = filter; +067 colors = colors.filter(color -> finalFilter.equals(ACFUtil.simplifyString(color.toString()))); +068 } +069 +070 TextColor match = ACFUtil.simpleMatch(TextColor.class, first); +071 if (match == null) { +072 String valid = colors.map(color -> "<c2>" + ACFUtil.simplifyString(color.toString()) + "</c2>") +073 .collect(Collectors.joining("<c1>,</c1> ")); 074 -075 TextColor match = ACFUtil.simpleMatch(TextColor.class, first); -076 if (match == null) { -077 String valid = colors.map(color -> "<c2>" + ACFUtil.simplifyString(color.toString()) + "</c2>") -078 .collect(Collectors.joining("<c1>,</c1> ")); -079 -080 throw new InvalidCommandArgument(MessageKeys.PLEASE_SPECIFY_ONE_OF, "{valid}", valid); -081 } -082 return match; -083 }); -084 } -085} +075 throw new InvalidCommandArgument(MessageKeys.PLEASE_SPECIFY_ONE_OF, "{valid}", valid); +076 } +077 return match; +078 }); +079 } +080 +081 @Nullable +082 private OnlinePlayer getOnlinePlayer(ProxyServer server, VelocityCommandExecutionContext c) throws InvalidCommandArgument { +083 Player proxiedPlayer = ACFVelocityUtil.findPlayerSmart(server, c.getIssuer(), c.popFirstArg()); +084 if (proxiedPlayer == null) { +085 if (c.isOptional()) { +086 return null; +087 } +088 throw new InvalidCommandArgument(false); +089 } +090 return new OnlinePlayer(proxiedPlayer); +091 } +092} diff --git a/docs/acf-velocity/src-html/co/aikar/commands/contexts/OnlinePlayer.html b/docs/acf-velocity/src-html/co/aikar/commands/contexts/OnlinePlayer.html index b0446184..b4b2a41f 100644 --- a/docs/acf-velocity/src-html/co/aikar/commands/contexts/OnlinePlayer.html +++ b/docs/acf-velocity/src-html/co/aikar/commands/contexts/OnlinePlayer.html @@ -7,7 +7,7 @@001/* -002 * Copyright (c) 2016-2017 Daniel Ennis (Aikar) - MIT License +002 * Copyright (c) 2016-2019 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 @@ -31,42 +31,17 @@ 023 024package co.aikar.commands.contexts; 025 -026import java.util.Objects; +026import com.velocitypowered.api.proxy.Player; 027 -028import com.velocitypowered.api.proxy.Player; -029 -030public class OnlinePlayer { -031 -032 public final Player player; -033 -034 public OnlinePlayer(Player player) { -035 this.player = player; -036 } -037 -038 public Player getPlayer(){ -039 return player; -040 } -041 -042 @Override -043 public boolean equals(Object o) { -044 if (this == o) return true; -045 if (o == null || getClass() != o.getClass()) return false; -046 OnlinePlayer that = (OnlinePlayer) o; -047 return Objects.equals(player, that.player); -048 } -049 -050 @Override -051 public int hashCode() { -052 return Objects.hash(player); -053 } -054 -055 @Override -056 public String toString() { -057 return "OnlinePlayer{" + -058 "player=" + player + -059 '}'; -060 } -061} +028/** +029 * @deprecated Use {@link co.aikar.commands.velocity.contexts.OnlinePlayer instead} +030 */ +031@Deprecated +032public class OnlinePlayer extends co.aikar.commands.velocity.contexts.OnlinePlayer { +033 public OnlinePlayer(Player player) { +034 super(player); +035 } +036} diff --git a/docs/acf-velocity/src-html/co/aikar/commands/velocity/contexts/OnlinePlayer.html b/docs/acf-velocity/src-html/co/aikar/commands/velocity/contexts/OnlinePlayer.html new file mode 100644 index 00000000..17c4b479 --- /dev/null +++ b/docs/acf-velocity/src-html/co/aikar/commands/velocity/contexts/OnlinePlayer.html @@ -0,0 +1,131 @@ + + + +Source code + + + +++ +001/* +002 * Copyright (c) 2016-2017 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.velocity.contexts; +025 +026import java.util.Objects; +027 +028import com.velocitypowered.api.proxy.Player; +029 +030public class OnlinePlayer { +031 +032 public final Player player; +033 +034 public OnlinePlayer(Player player) { +035 this.player = player; +036 } +037 +038 public Player getPlayer() { +039 return player; +040 } +041 +042 @Override +043 public boolean equals(Object o) { +044 if (this == o) return true; +045 if (o == null || getClass() != o.getClass()) return false; +046 OnlinePlayer that = (OnlinePlayer) o; +047 return Objects.equals(player, that.player); +048 } +049 +050 @Override +051 public int hashCode() { +052 return Objects.hash(player); +053 } +054 +055 @Override +056 public String toString() { +057 return "OnlinePlayer{player=" + player + '}'; +058 } +059} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ++