Class TabCompletionContext

java.lang.Object
com.ultikits.ultitools.commands.tabcomplete.TabCompletionContext

public class TabCompletionContext extends Object
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

    Fields
    Modifier and Type
    Field
    Description
    private final String[]
    The current arguments typed by the player.
    private final org.bukkit.command.Command
    The command being completed.
    private final int
    The index of the current argument being completed (0-based).
    private final Object
    The command executor instance for invoking suggestion methods.
    private final Method
    The matched method for the current command format (may be null).
    private final String
    The parameter name being completed (from format like <paramName>).
    private final String
    The partial text of the current argument (may be empty).
    private final org.bukkit.entity.Player
    The player requesting completion.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the current partial argument or empty string if none.
    boolean
    Checks if the current input starts with the given prefix (case-insensitive).
    of(org.bukkit.entity.Player player, org.bukkit.command.Command command, String[] args)
    Creates a context from command arguments.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • player

      private final org.bukkit.entity.Player player
      The player requesting completion. 请求补全的玩家。
    • command

      private final org.bukkit.command.Command command
      The command being completed. 正在补全的命令。
    • args

      private final String[] args
      The current arguments typed by the player. 玩家当前输入的参数。
    • currentArgIndex

      private final int currentArgIndex
      The index of the current argument being completed (0-based). 当前正在补全的参数索引(从0开始)。
    • partialArg

      private final String partialArg
      The partial text of the current argument (may be empty). 当前参数的部分文本(可能为空)。
    • matchedMethod

      private final Method matchedMethod
      The matched method for the current command format (may be null). 当前命令格式匹配的方法(可能为null)。
    • parameterName

      private final String parameterName
      The parameter name being completed (from format like <paramName>). 正在补全的参数名(从格式如 <paramName> 中提取)。
    • executorInstance

      private final Object executorInstance
      The command executor instance for invoking suggestion methods. 用于调用建议方法的命令执行器实例。
  • Constructor Details

    • TabCompletionContext

      public TabCompletionContext()
  • Method Details

    • getCurrentInput

      public String getCurrentInput()
      Gets the current partial argument or empty string if none. 获取当前的部分参数,如果没有则返回空字符串。
      Returns:
      the partial argument being typed
    • inputStartsWith

      public boolean inputStartsWith(String prefix)
      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 player
      command - the command
      args - the arguments
      Returns:
      a new context