Class TabCompletionContext
java.lang.Object
com.ultikits.ultitools.commands.tabcomplete.TabCompletionContext
Context object containing all information needed for tab completion.
Immutable and thread-safe.
包含 Tab 补全所需所有信息的上下文对象。 不可变且线程安全。
- Since:
- 6.2.0
- Version:
- 1.0.0
- Author:
- wisdomme
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final String[]The current arguments typed by the player.private final org.bukkit.command.CommandThe command being completed.private final intThe index of the current argument being completed (0-based).private final ObjectThe command executor instance for invoking suggestion methods.private final MethodThe matched method for the current command format (may be null).private final StringThe parameter name being completed (from format like <paramName>).private final StringThe partial text of the current argument (may be empty).private final org.bukkit.entity.PlayerThe player requesting completion. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the current partial argument or empty string if none.booleaninputStartsWith(String prefix) Checks if the current input starts with the given prefix (case-insensitive).static TabCompletionContextCreates a context from command arguments.
-
Field Details
-
player
private final org.bukkit.entity.Player playerThe player requesting completion. 请求补全的玩家。 -
command
private final org.bukkit.command.Command commandThe command being completed. 正在补全的命令。 -
args
The current arguments typed by the player. 玩家当前输入的参数。 -
currentArgIndex
private final int currentArgIndexThe index of the current argument being completed (0-based). 当前正在补全的参数索引(从0开始)。 -
partialArg
The partial text of the current argument (may be empty). 当前参数的部分文本(可能为空)。 -
matchedMethod
The matched method for the current command format (may be null). 当前命令格式匹配的方法(可能为null)。 -
parameterName
The parameter name being completed (from format like <paramName>). 正在补全的参数名(从格式如 <paramName> 中提取)。 -
executorInstance
The command executor instance for invoking suggestion methods. 用于调用建议方法的命令执行器实例。
-
-
Constructor Details
-
TabCompletionContext
public TabCompletionContext()
-
-
Method Details
-
getCurrentInput
Gets the current partial argument or empty string if none. 获取当前的部分参数,如果没有则返回空字符串。- Returns:
- the partial argument being typed
-
inputStartsWith
Checks if the current input starts with the given prefix (case-insensitive). 检查当前输入是否以给定前缀开头(不区分大小写)。- Parameters:
prefix- the prefix to check- Returns:
- true if the current input starts with the prefix
-
of
public static TabCompletionContext of(org.bukkit.entity.Player player, org.bukkit.command.Command command, String[] args) Creates a context from command arguments. 从命令参数创建上下文。- Parameters:
player- the playercommand- the commandargs- the arguments- Returns:
- a new context
-