Class TabCompletionManager

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

public class TabCompletionManager extends Object
Central manager for tab completion functionality. Provides a unified API for both old and new command systems.

Tab 补全功能的中央管理器。 为新旧命令系统提供统一的 API。

Since:
6.2.0
Version:
1.0.0
Author:
wisdomme
  • Field Details

  • Constructor Details

    • TabCompletionManager

      private TabCompletionManager()
      Private constructor - use getInstance().
  • Method Details

    • getInstance

      public static TabCompletionManager getInstance()
      Gets the singleton instance. 获取单例实例。
      Returns:
      the tab completion manager instance
    • registerBuiltInCompleters

      private void registerBuiltInCompleters()
      Registers all built-in completers. 注册所有内置补全器。
    • register

      public void register(String key, TabCompleter completer)
      Registers a custom completer with a key. 使用键注册自定义补全器。
      Parameters:
      key - the key to register with (e.g., "@custom")
      completer - the completer to register
    • unregister

      public void unregister(String key)
      Unregisters a completer. 注销补全器。
      Parameters:
      key - the key to unregister
    • getCompleter

      public TabCompleter getCompleter(String key)
      Gets a registered completer by key. 根据键获取已注册的补全器。
      Parameters:
      key - the completer key
      Returns:
      the completer or null if not found
    • suggest

      public List<String> suggest(org.bukkit.entity.Player player, org.bukkit.command.Command command, String[] args)
      Generates suggestions using the appropriate completer. 使用适当的补全器生成建议。
      Parameters:
      player - the player requesting completion
      command - the command
      args - the current arguments
      Returns:
      list of suggestions
    • suggest

      public List<String> suggest(TabCompletionContext context)
      Generates suggestions using the given context. 使用给定的上下文生成建议。
      Parameters:
      context - the completion context
      Returns:
      list of suggestions
    • suggestWith

      public List<String> suggestWith(TabCompletionContext context, String completerKey)
      Suggests completions for a specific parameter type. 为特定参数类型建议补全。
      Parameters:
      context - the completion context
      completerKey - the key of the completer to use
      Returns:
      list of suggestions
    • createContext

      public TabCompletionContext createContext(org.bukkit.entity.Player player, org.bukkit.command.Command command, String[] args)
      Creates a context for tab completion with common defaults. 创建带有常用默认值的 Tab 补全上下文。
      Parameters:
      player - the player
      command - the command
      args - the arguments
      Returns:
      a tab completion context
    • filterByInput

      public static List<String> filterByInput(List<String> suggestions, String input)
      Helper method to filter suggestions by current input. 过滤建议以匹配当前输入的辅助方法。
      Parameters:
      suggestions - the suggestions to filter
      input - the current input
      Returns:
      filtered suggestions
    • suggestFirstArgs

      public List<String> suggestFirstArgs(Map<String,Method> mappings, TabCompletionContext context)
      Suggests command format first arguments from mappings. 从映射中建议命令格式的第一个参数。
      Parameters:
      mappings - the command mappings (format -> method)
      context - the completion context
      Returns:
      list of first argument suggestions