Class TabCompletionContext
java.lang.Object
com.ultikits.ultitools.commands.tabcomplete.TabCompletionContext
Context object containing all information needed for tab completion.
Immutable and thread-safe.
- 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 supplied by legacy callers; null for non-player requests.private final org.bukkit.command.CommandSenderThe requesting sender. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the current partial argument or empty string if none.org.bukkit.entity.PlayerReturns the requesting player, or null for a non-player sender.org.bukkit.command.CommandSenderReturns the requesting sender, including contexts built with the legacy player setter.booleaninputStartsWith(String prefix) Checks if the current input starts with the given prefix (case-insensitive).static TabCompletionContextCreates a completion context for any Bukkit command sender.static TabCompletionContextCreates a context from command arguments.
-
Field Details
-
sender
private final org.bukkit.command.CommandSender senderThe requesting sender. Legacy player-only builders may leave this unset. -
player
private final org.bukkit.entity.Player playerThe player supplied by legacy callers; null for non-player requests. -
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). -
partialArg
The partial text of the current argument (may be empty). -
matchedMethod
The matched method for the current command format (may be null). -
parameterName
The parameter name being completed (from format like <paramName>). -
executorInstance
The command executor instance for invoking suggestion methods.
-
-
Constructor Details
-
TabCompletionContext
-
-
Method Details
-
getSender
public org.bukkit.command.CommandSender getSender()Returns the requesting sender, including contexts built with the legacy player setter. An explicit sender takes precedence if both builder fields are supplied.- Returns:
- the sender, or null if neither sender nor player was supplied
-
getPlayer
public org.bukkit.entity.Player getPlayer()Returns the requesting player, or null for a non-player sender.- Returns:
- the requesting player, when applicable
-
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
-
of
public static TabCompletionContext of(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String[] args) Creates a completion context for any Bukkit command sender.- Parameters:
sender- the requesting sendercommand- the commandargs- the arguments- Returns:
- a new sender-aware context
-