Class AbstractCommandExecutor
- All Implemented Interfaces:
org.bukkit.command.CommandExecutor,org.bukkit.command.TabCompleter,org.bukkit.command.TabExecutor
- Direct Known Subclasses:
AbstractCommendExecutor,CloudLoginCommand,PluginInstallCommands,UltiToolsCommands
这个抽象类代表了一个命令执行器。 它实现了Bukkit API中的TabExecutor接口。
- Since:
- 6.2.0 deprecated
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classDeprecated, for removal: This API element is subject to removal in a future version.Result object for cooldown tick processing. -
Field Summary
FieldsModifier and TypeFieldDescriptionDeprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version. -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated, for removal: This API element is subject to removal in a future version.Constructor that initializes parsers and scans command mappings. -
Method Summary
Modifier and TypeMethodDescriptionprivate Object[]buildParams(String[] strings, Method method, org.bukkit.command.CommandSender commandSender) Deprecated, for removal: This API element is subject to removal in a future version.Builds the parameters of the command.private booleancheckCD(org.bukkit.command.CommandSender sender) Deprecated, for removal: This API element is subject to removal in a future version.Checks whether the sender need to wait for the command cool down.private booleancheckCmdTargetType(org.bukkit.command.CommandSender sender, CmdTarget cmdTarget) Deprecated, for removal: This API element is subject to removal in a future version.Checks whether the sender is valid.private booleanDeprecated, for removal: This API element is subject to removal in a future version.Checks whether the sender need to wait for the previous command to finish.private booleancheckOp(org.bukkit.command.CommandSender sender) Deprecated, for removal: This API element is subject to removal in a future version.Checks whether the sender need to be an OP.private booleanDeprecated, for removal: This API element is subject to removal in a future version.Checks whether the sender need to be an OP.private booleancheckParameters(String[] args, Method method, org.bukkit.command.CommandSender commandSender, org.bukkit.command.Command command) Deprecated, for removal: This API element is subject to removal in a future version.private booleancheckPermission(org.bukkit.command.CommandSender sender) Deprecated, for removal: This API element is subject to removal in a future version.Checks whether the sender has permission.private booleancheckPermission(org.bukkit.command.CommandSender sender, Method method) Deprecated, for removal: This API element is subject to removal in a future version.Checks whether the sender has permission.private booleancheckSender(org.bukkit.command.CommandSender sender) Deprecated, for removal: This API element is subject to removal in a future version.Checks whether the sender is valid.private booleancheckSender(org.bukkit.command.CommandSender sender, Method method) Deprecated, for removal: This API element is subject to removal in a future version.Checks whether the sender is valid.protected voidexecuteMethodWithLock(org.bukkit.command.CommandSender commandSender, Method method, Object[] params) Deprecated, for removal: This API element is subject to removal in a future version.Execute a method with usage limit lock handling.private StringDeprecated, for removal: This API element is subject to removal in a future version.Gets the argument at the specified index.private voidgetArgSuggestion(org.bukkit.entity.Player player, org.bukkit.command.Command command, String[] strings, Method method, String arg, List<String> completions) Deprecated, for removal: This API element is subject to removal in a future version.Adds suggestion to the list of suggestions.private StringgetFormatByMethod(Method method) Deprecated, for removal: This API element is subject to removal in a future version.Gets the format of the command.protected StringDeprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.Gets the instance of the command executor.private Method[]Deprecated, for removal: This API element is subject to removal in a future version.Gets the suggest method array by the suggest method name from another class.private Method[]Deprecated, for removal: This API element is subject to removal in a future version.Gets the suggest method array by the suggest method name.getMethodsByArg(org.bukkit.entity.Player player, String command) Deprecated, for removal: This API element is subject to removal in a future version.Gets the methods that match the command.Deprecated, for removal: This API element is subject to removal in a future version.Gets a map of parameter match from a command.Deprecated, for removal: This API element is subject to removal in a future version.Gets the parser of the parameter.private Method[]getSuggestMethodByName(String suggestName) Deprecated, for removal: This API element is subject to removal in a future version.Gets the suggest method array by the suggest method name.private StringgetSuggestName(Method method, String paramName) Deprecated, for removal: This API element is subject to removal in a future version.Gets the suggest method name of the parameter.protected abstract voidhandleHelp(org.bukkit.command.CommandSender sender) Deprecated, for removal: This API element is subject to removal in a future version.Abstract method that handles the help command.private voidDeprecated, for removal: This API element is subject to removal in a future version.Initializes the parsers.private Collection<?> invokeSuggestMethod(Object object, Method method, org.bukkit.entity.Player player, org.bukkit.command.Command command, String[] strings) Deprecated, for removal: This API element is subject to removal in a future version.Invokes the suggest method.private booleanmatchesArgument(String formatArg, String actualArg) Deprecated, for removal: This API element is subject to removal in a future version.Compare the actual argument with the format argument.private booleanmatchesLastArgument(String formatArg, String actualArg) Deprecated, for removal: This API element is subject to removal in a future version.Compare the actual argument with the format argument.private MethodmatchMethod(String[] args) Deprecated, for removal: This API element is subject to removal in a future version.Matches the command.booleanonCommand(org.bukkit.command.CommandSender commandSender, org.bukkit.command.Command command, String s, String[] strings) Deprecated, for removal: This API element is subject to removal in a future version.Executes the command, returning its success.onTabComplete(org.bukkit.command.CommandSender commandSender, org.bukkit.command.Command command, String s, String[] strings) Deprecated, for removal: This API element is subject to removal in a future version.Requests a list of possible completions for a command argument.private <T> ObjectDeprecated, for removal: This API element is subject to removal in a future version.Parses the type of the parameter.processCoolDownTick(UUID playerUUID, Method method, int time) Deprecated, for removal: This API element is subject to removal in a future version.Process a single tick of the command cooldown.private voidDeprecated, for removal: This API element is subject to removal in a future version.Scans the command mappings.protected voidsendErrorMessage(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command) Deprecated, for removal: This API element is subject to removal in a future version.Sends the error message.private voidsetCoolDown(org.bukkit.command.CommandSender commandSender, Method method) Deprecated, for removal: This API element is subject to removal in a future version.Sets the cool down of the command.Deprecated, for removal: This API element is subject to removal in a future version.Tab complete method.
-
Field Details
-
mappings
Deprecated, for removal: This API element is subject to removal in a future version. -
senderLock
Deprecated, for removal: This API element is subject to removal in a future version. -
serverLock
Deprecated, for removal: This API element is subject to removal in a future version. -
cmdCoolDown
Deprecated, for removal: This API element is subject to removal in a future version. -
parsers
Deprecated, for removal: This API element is subject to removal in a future version.
-
-
Constructor Details
-
AbstractCommandExecutor
public AbstractCommandExecutor()Deprecated, for removal: This API element is subject to removal in a future version.Constructor that initializes parsers and scans command mappings.构造函数,初始化解析器并扫描命令映射。
-
-
Method Details
-
checkCmdTargetType
Deprecated, for removal: This API element is subject to removal in a future version.Checks whether the sender is valid.检查发送者是否有效。
- Parameters:
sender- The sender of the command.
命令的发送者。cmdTarget- The method that matches the command.
匹配命令的方法。- Returns:
- Whether the sender is valid.
发送者是否有效。
-
getParams
Deprecated, for removal: This API element is subject to removal in a future version.Gets a map of parameter match from a command.从命令中获取参数匹配的映射。
- Parameters:
args- The arguments of the command.
命令的参数。format- The format of the command.
命令的格式。- Returns:
- The map of the parameters.
参数的映射。
-
getInstance
Deprecated, for removal: This API element is subject to removal in a future version.Gets the instance of the command executor.获取命令执行器的实例。
- Returns:
- The instance of the command executor.
命令执行器的实例。
-
initParsers
private void initParsers()Deprecated, for removal: This API element is subject to removal in a future version.Initializes the parsers.初始化解析器。
-
getParser
Deprecated, for removal: This API element is subject to removal in a future version.Gets the parser of the parameter.获取参数的解析器。
- Type Parameters:
T- The type of the parameter.
参数的类型。- Parameters:
type- The type of the parameter.
参数的类型。- Returns:
- The parser of the parameter.
参数的解析器。
-
scanCommandMappings
private void scanCommandMappings()Deprecated, for removal: This API element is subject to removal in a future version.Scans the command mappings.扫描命令映射。
-
matchMethod
Deprecated, for removal: This API element is subject to removal in a future version.Matches the command.匹配命令。
- Parameters:
args- The arguments of the command.
命令的参数。- Returns:
- The method that matches the command.
匹配命令的方法。
-
matchesArgument
Deprecated, for removal: This API element is subject to removal in a future version.Compare the actual argument with the format argument.将实际参数与格式参数进行比较。
- Parameters:
formatArg- The format argument.
格式参数。actualArg- The actual argument.
实际参数。- Returns:
- Whether the actual argument matches the format argument.
实际参数是否与格式参数匹配。
-
matchesLastArgument
Deprecated, for removal: This API element is subject to removal in a future version.Compare the actual argument with the format argument.将实际参数与格式参数进行比较。
- Parameters:
formatArg- The format argument.
格式参数。actualArg- The actual argument.
实际参数。- Returns:
- Whether the actual argument matches the format argument.
实际参数是否与格式参数匹配。
-
checkSender
private boolean checkSender(org.bukkit.command.CommandSender sender) Deprecated, for removal: This API element is subject to removal in a future version.Checks whether the sender is valid.检查发送者是否有效。
- Parameters:
sender- The sender of the command.
命令的发送者。- Returns:
- Whether the sender is valid.
发送者是否有效。
-
checkSender
Deprecated, for removal: This API element is subject to removal in a future version.Checks whether the sender is valid.检查发送者是否有效。
- Parameters:
sender- The sender of the command.
命令的发送者。method- The method that matches the command.
匹配命令的方法。- Returns:
- Whether the sender is valid.
发送者是否有效。
-
checkPermission
private boolean checkPermission(org.bukkit.command.CommandSender sender) Deprecated, for removal: This API element is subject to removal in a future version.Checks whether the sender has permission.检查发送者是否有权限。
- Parameters:
sender- The sender of the command.
命令的发送者。- Returns:
- Whether the sender has permission.
发送者是否有权限。
-
checkPermission
Deprecated, for removal: This API element is subject to removal in a future version.Checks whether the sender has permission.检查发送者是否有权限。
- Parameters:
sender- The sender of the command.
命令的发送者。method- The method that matches the command.
匹配命令的方法。- Returns:
- Whether the sender has permission.
发送者是否有权限。
-
checkOp
private boolean checkOp(org.bukkit.command.CommandSender sender) Deprecated, for removal: This API element is subject to removal in a future version.Checks whether the sender need to be an OP.检查发送者是否需要是OP。
- Parameters:
sender- The sender of the command.
命令的发送者。- Returns:
- Whether the sender need to be an OP.
发送者是否需要是OP。
-
checkOp
Deprecated, for removal: This API element is subject to removal in a future version.Checks whether the sender need to be an OP.检查发送者是否需要是OP。
- Parameters:
sender- The sender of the command.
命令的发送者。method- The method that matches the command.
匹配命令的方法。- Returns:
- Whether the sender need to be an OP.
发送者是否需要是OP。
-
checkLock
Deprecated, for removal: This API element is subject to removal in a future version.Checks whether the sender need to wait for the previous command to finish.检查发送者是否需要等待上一条命令执行完毕。
- Parameters:
sender- The sender of the command.
命令的发送者。method- The method that matches the command.
匹配命令的方法。- Returns:
- Whether the sender need to wait for the previous command to finish.
发送者是否需要等待上一条命令执行完毕。
-
checkCD
private boolean checkCD(org.bukkit.command.CommandSender sender) Deprecated, for removal: This API element is subject to removal in a future version.Checks whether the sender need to wait for the command cool down.检查发送者是否需要等待命令冷却。
- Parameters:
sender- The sender of the command.
命令的发送者。- Returns:
- Whether the sender need to wait for command cool down.
发送者是否需要等待命令冷却。
-
buildParams
private Object[] buildParams(String[] strings, Method method, org.bukkit.command.CommandSender commandSender) Deprecated, for removal: This API element is subject to removal in a future version.Builds the parameters of the command.构建命令的参数。
- Parameters:
strings- The arguments of the command.
命令的参数。method- The method that matches the command.
匹配命令的方法。commandSender- The sender of the command.
命令的发送者。- Returns:
- Parameters of the command.
命令的参数。
-
parseType
Deprecated, for removal: This API element is subject to removal in a future version.Parses the type of the parameter.解析参数的类型。
- Type Parameters:
T- The type of the parameter.
参数的类型。- Parameters:
value- The value of the parameter.
参数的值。type- The type of the parameter.
参数的类型。- Returns:
- The parsed parameter.
解析后的参数。
-
setCoolDown
Deprecated, for removal: This API element is subject to removal in a future version.Sets the cool down of the command.设置命令的冷却。
- Parameters:
commandSender- The sender of the command.
命令的发送者。method- The method that matches the command.
匹配命令的方法。
-
processCoolDownTick
protected AbstractCommandExecutor.CoolDownTickResult processCoolDownTick(UUID playerUUID, Method method, int time) Deprecated, for removal: This API element is subject to removal in a future version.Process a single tick of the command cooldown. This method is extracted from BukkitRunnable for testability.- Parameters:
playerUUID- the UUID of the playermethod- the method that is on cooldowntime- the current remaining time- Returns:
- the result containing whether to cancel and the new remaining time
-
executeMethodWithLock
protected void executeMethodWithLock(org.bukkit.command.CommandSender commandSender, Method method, Object[] params) Deprecated, for removal: This API element is subject to removal in a future version.Execute a method with usage limit lock handling. This method is extracted from BukkitRunnable for testability.- Parameters:
commandSender- the sender of the commandmethod- the method to executeparams- the parameters to pass to the method
-
handleHelp
protected abstract void handleHelp(org.bukkit.command.CommandSender sender) Deprecated, for removal: This API element is subject to removal in a future version.Abstract method that handles the help command.处理帮助命令的抽象方法。
- Parameters:
sender- The sender of the command.
命令的发送者。
-
sendErrorMessage
protected void sendErrorMessage(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command) Deprecated, for removal: This API element is subject to removal in a future version.Sends the error message.发送错误信息。
- Parameters:
sender- The sender of the command.
命令的发送者。command- The command that was executed.
执行的命令。
-
suggest
protected List<String> suggest(org.bukkit.entity.Player player, org.bukkit.command.Command command, String[] strings) Deprecated, for removal: This API element is subject to removal in a future version.Tab complete method. Returns a list of possible completions for the specified command string. By rewriting this method, you can customize the tab completion of the command.补全方法。返回指定命令字符串的可能补全列表。 通过重写此方法,您可以自定义命令的补全。
- Parameters:
player- The player who will see the suggestions.
看到补全的玩家command- The command that was typed in.
需要补全的命令strings- The arguments of the command that was typed in.
目前输入的命令参数- Returns:
- The suggestions.
补全的建议
-
getArgSuggestion
private void getArgSuggestion(org.bukkit.entity.Player player, org.bukkit.command.Command command, String[] strings, Method method, String arg, List<String> completions) Deprecated, for removal: This API element is subject to removal in a future version.Adds suggestion to the list of suggestions. This method is called by the suggest method. Fetch the suggestions by invoking the given method.将建议添加到建议列表中。此方法由suggest方法调用。 通过调用给定的方法获取建议。
- Parameters:
player- The player who will see the suggestions.
看到补全的玩家command- The command that was typed in.
需要补全的命令strings- The arguments of the command that was typed in.
目前输入的命令参数method- The method that matches the command.
匹配命令的方法。arg- The argument that needs to be completed.
需要补全的参数。completions- The suggestions.
补全的建议
-
getFormatByMethod
Deprecated, for removal: This API element is subject to removal in a future version.Gets the format of the command.获取命令的格式。
- Parameters:
method- The method that matches the command.
匹配命令的方法。- Returns:
- The format of the command.
命令的格式。
-
getArgAt
Deprecated, for removal: This API element is subject to removal in a future version.Gets the argument at the specified index.获取指定索引处的参数。
- Parameters:
format- The format of the command.
命令的格式。index- The index of the argument.
参数的索引。- Returns:
- The argument at the specified index.
指定索引处的参数。
-
getSuggestName
Deprecated, for removal: This API element is subject to removal in a future version.Gets the suggest method name of the parameter.获取参数的建议方法名称。
- Parameters:
method- The method that matches the command.
匹配命令的方法。paramName- The name of the parameter.
参数的名称。- Returns:
- The suggest method name of the parameter.
参数的建议方法名称。
-
getSuggestMethodByName
Deprecated, for removal: This API element is subject to removal in a future version.Gets the suggest method array by the suggest method name. If the suggest method name ends with (), remove (). Get the suggest method array from the current class first. If the current class has the CmdSuggest annotation, get the suggest method array from the CmdSuggest annotation.通过建议方法名称获取建议方法数组。 如果建议方法名称以()结尾,则去掉()。 优先从当前类中获取建议方法集合。 如果当前类上有CmdSuggest注解,则从CmdSuggest注解中获取建议方法集合。
- Parameters:
suggestName- The name of the suggest method.
建议方法的名称- Returns:
- The suggest method array.
建议方法数组
-
getMethod
Deprecated, for removal: This API element is subject to removal in a future version.Gets the suggest method array by the suggest method name.通过建议方法名称获取建议方法数组。
- Parameters:
suggestName- The name of the suggest method.
建议方法的名称- Returns:
- The suggest method array.
建议方法数组
-
getMethod
Deprecated, for removal: This API element is subject to removal in a future version.Gets the suggest method array by the suggest method name from another class.从另一个类中通过方法名称获取方法数组。
- Parameters:
clazz- The class of the suggest method.
建议方法的类suggestName- The name of the suggest method.
建议方法的名称- Returns:
- The suggest method array.
建议方法数组
-
invokeSuggestMethod
private Collection<?> invokeSuggestMethod(Object object, Method method, org.bukkit.entity.Player player, org.bukkit.command.Command command, String[] strings) Deprecated, for removal: This API element is subject to removal in a future version.Invokes the suggest method. Inject parameters by parameter type.调用建议方法。按照参数类型注入参数。
- Parameters:
object- The object that the method is invoked from.
方法所在的对象。method- The method that is invoked.
被调用的方法。player- The player who will see the suggestions.
看到补全的玩家command- The command that was typed in.
需要补全的命令strings- The arguments of the command that was typed in.
目前输入的命令参数- Returns:
- The return string list of suggestions of the method.
方法的返回字符串列表。
-
getMethodsByArg
Deprecated, for removal: This API element is subject to removal in a future version.Gets the methods that match the command. Get the perfect match method first. If there is no perfect match method, get the partial match method. If there is no perfect match method and partial match method, return an empty list. If there is a perfect match method, only return the perfect match method.获取匹配命令的方法。 优先获取完全匹配的方法,如果没有完全匹配的方法,则获取部分匹配的方法。 如果没有完全匹配的方法和部分匹配的方法,则返回空列表。 如果有完全匹配的方法,则只返回完全匹配的方法。
- Parameters:
player- The player who will see the suggestions.
看到补全的玩家command- The command that was typed in.
需要补全的命令- Returns:
- The suggestions.
补全的建议
-
getHelpCommand
Deprecated, for removal: This API element is subject to removal in a future version.- Returns:
- The help command.
帮助命令。 - See Also:
-
onCommand
public boolean onCommand(org.bukkit.command.CommandSender commandSender, org.bukkit.command.Command command, String s, String[] strings) Deprecated, for removal: This API element is subject to removal in a future version.Executes the command, returning its success.执行命令,返回是否成功。
- Specified by:
onCommandin interfaceorg.bukkit.command.CommandExecutor- Parameters:
commandSender- Source of the command
命令的发送者command- Command which was executed
命令s- Alias of the command which was used
命令的别名strings- Passed command arguments
命令的参数- Returns:
- true if a valid command, otherwise false
如果是有效的命令则返回true,否则返回false
-
checkParameters
private boolean checkParameters(String[] args, Method method, org.bukkit.command.CommandSender commandSender, org.bukkit.command.Command command) Deprecated, for removal: This API element is subject to removal in a future version. -
onTabComplete
@Nullable public List<String> onTabComplete(org.bukkit.command.CommandSender commandSender, org.bukkit.command.Command command, String s, String[] strings) Deprecated, for removal: This API element is subject to removal in a future version.Requests a list of possible completions for a command argument.请求命令参数的可能补全列表。
- Specified by:
onTabCompletein interfaceorg.bukkit.command.TabCompleter- Parameters:
commandSender- Source of the command. For players tab-completing a command inside of a command block, this will be the player, not the command block.command- Command which was executeds- Alias of the command which was usedstrings- The arguments passed to the command, including final partial argument to be completed- Returns:
- A List of possible completions for the final argument, or null
-
BaseCommandExecutorinstead, which provides better architecture with Chain of Responsibility pattern.此类仅为向后兼容而保留。 请使用
BaseCommandExecutor, 它提供了使用责任链模式的更好架构。