Class TabCompletionManager
java.lang.Object
com.ultikits.ultitools.commands.tabcomplete.TabCompletionManager
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringBuilt-in completer prefix for blocks.static final StringBuilt-in completer prefix for boolean values.private final Map<String, TabCompleter> private static TabCompletionManagerstatic final StringBuilt-in completer prefix for items.static final StringBuilt-in completer prefix for materials.private final MethodInvocationCompleterstatic final StringBuilt-in completer prefix for players.static final StringBuilt-in completer prefix for toggle values.static final StringBuilt-in completer prefix for worlds. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatePrivate constructor - use getInstance(). -
Method Summary
Modifier and TypeMethodDescriptioncreateContext(org.bukkit.entity.Player player, org.bukkit.command.Command command, String[] args) Creates a context for tab completion with common defaults.filterByInput(List<String> suggestions, String input) Helper method to filter suggestions by current input.getCompleter(String key) Gets a registered completer by key.static TabCompletionManagerGets the singleton instance.voidregister(String key, TabCompleter completer) Registers a custom completer with a key.private voidRegisters all built-in completers.suggest(TabCompletionContext context) Generates suggestions using the given context.Generates suggestions using the appropriate completer.suggestFirstArgs(Map<String, Method> mappings, TabCompletionContext context) Suggests command format first arguments from mappings.suggestWith(TabCompletionContext context, String completerKey) Suggests completions for a specific parameter type.voidunregister(String key) Unregisters a completer.
-
Field Details
-
PLAYERS
Built-in completer prefix for players.- See Also:
-
WORLDS
Built-in completer prefix for worlds.- See Also:
-
MATERIALS
Built-in completer prefix for materials.- See Also:
-
BLOCKS
Built-in completer prefix for blocks.- See Also:
-
ITEMS
Built-in completer prefix for items.- See Also:
-
BOOLEAN
Built-in completer prefix for boolean values.- See Also:
-
TOGGLE
Built-in completer prefix for toggle values.- See Also:
-
instance
-
completers
-
methodCompleter
-
-
Constructor Details
-
TabCompletionManager
private TabCompletionManager()Private constructor - use getInstance().
-
-
Method Details
-
getInstance
Gets the singleton instance. 获取单例实例。- Returns:
- the tab completion manager instance
-
registerBuiltInCompleters
private void registerBuiltInCompleters()Registers all built-in completers. 注册所有内置补全器。 -
register
Registers a custom completer with a key. 使用键注册自定义补全器。- Parameters:
key- the key to register with (e.g., "@custom")completer- the completer to register
-
unregister
Unregisters a completer. 注销补全器。- Parameters:
key- the key to unregister
-
getCompleter
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 completioncommand- the commandargs- the current arguments- Returns:
- list of suggestions
-
suggest
Generates suggestions using the given context. 使用给定的上下文生成建议。- Parameters:
context- the completion context- Returns:
- list of suggestions
-
suggestWith
Suggests completions for a specific parameter type. 为特定参数类型建议补全。- Parameters:
context- the completion contextcompleterKey- 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 playercommand- the commandargs- the arguments- Returns:
- a tab completion context
-
filterByInput
Helper method to filter suggestions by current input. 过滤建议以匹配当前输入的辅助方法。- Parameters:
suggestions- the suggestions to filterinput- the current input- Returns:
- filtered suggestions
-
suggestFirstArgs
Suggests command format first arguments from mappings. 从映射中建议命令格式的第一个参数。- Parameters:
mappings- the command mappings (format -> method)context- the completion context- Returns:
- list of first argument suggestions
-