Package revxrsal.commands.autocomplete
Interface AutoCompleter
public interface AutoCompleter
Represents the handler for registering and providing auto-completion
suggestions.
-
Method Summary
Modifier and TypeMethodDescriptionand()
Returns the containingCommandHandler
of this auto completer.complete
(@NotNull CommandActor actor, @NotNull String buffer) Generates a list of suggestions for the given actor and buffercomplete
(@NotNull CommandActor actor, @NotNull ArgumentStack arguments) Generates a list of suggestions for the given actor and argument listgetSuggestionProvider
(@NotNull String id) Returns the suggestion provider that maps to the specified ID.registerParameterSuggestions
(@NotNull Class<?> parameterType, @NotNull String providerID) Registers aSuggestionProvider
for a specific parameter type.registerParameterSuggestions
(@NotNull Class<?> parameterType, @NotNull SuggestionProvider provider) Registers aSuggestionProvider
for a specific parameter type.registerSuggestion
(@NotNull String providerID, @NotNull String... completions) Registers static completions for the specified ID, for use in commands through theAutoComplete
annotation.registerSuggestion
(@NotNull String providerID, @NotNull Collection<String> completions) Registers static completions for the specified ID, for use in commands through theAutoComplete
annotation.registerSuggestion
(@NotNull String providerID, @NotNull SuggestionProvider provider) Registers aSuggestionProvider
for the specified ID, for use in commands through theAutoComplete
annotation.registerSuggestionFactory
(int priority, @NotNull SuggestionProviderFactory factory) Registers aSuggestionProviderFactory
that creates suggestion providers dynamically for parameters.registerSuggestionFactory
(@NotNull SuggestionProviderFactory factory) Registers aSuggestionProviderFactory
that creates suggestion providers dynamically for parameters.
-
Method Details
-
registerSuggestion
AutoCompleter registerSuggestion(@NotNull @NotNull String providerID, @NotNull @NotNull SuggestionProvider provider) Registers aSuggestionProvider
for the specified ID, for use in commands through theAutoComplete
annotation.- Parameters:
providerID
- The tab suggestion idprovider
- The provider for this suggestion- Returns:
- This auto-completer
-
registerSuggestion
AutoCompleter registerSuggestion(@NotNull @NotNull String providerID, @NotNull @NotNull Collection<String> completions) Registers static completions for the specified ID, for use in commands through theAutoComplete
annotation.- Parameters:
providerID
- The tab suggestion idcompletions
- The static list of suggestion. These will be copied and will no longer be modifiable- Returns:
- This auto-completer
-
registerSuggestion
AutoCompleter registerSuggestion(@NotNull @NotNull String providerID, @NotNull @NotNull String... completions) Registers static completions for the specified ID, for use in commands through theAutoComplete
annotation.- Parameters:
providerID
- The tab suggestion idcompletions
- The static list of suggestion. These will be copied and will no longer be modifiable- Returns:
- This auto-completer
-
registerParameterSuggestions
AutoCompleter registerParameterSuggestions(@NotNull @NotNull Class<?> parameterType, @NotNull @NotNull SuggestionProvider provider) Registers aSuggestionProvider
for a specific parameter type. This way, if the parameter is requested in the command, it will automatically be tab-completed without having to be explicitly defined by anAutoComplete
.- Parameters:
parameterType
- The parameter type to completeprovider
- The tab suggestion provider- Returns:
- This auto-completer
-
registerParameterSuggestions
AutoCompleter registerParameterSuggestions(@NotNull @NotNull Class<?> parameterType, @NotNull @NotNull String providerID) Registers aSuggestionProvider
for a specific parameter type. This way, if the parameter is requested in the command, it will automatically be tab-completed without having to be explicitly defined by anAutoComplete
.- Parameters:
parameterType
- The parameter type to completeproviderID
- The tab suggestion provider id. Must be registered with eitherregisterSuggestion(String, SuggestionProvider)
orregisterSuggestion(String, String...)
.- Returns:
- This auto-completer
-
registerSuggestionFactory
Registers aSuggestionProviderFactory
that creates suggestion providers dynamically for parameters. This allows for checking against custom annotations in parameters.- Parameters:
factory
- Factory to register- Returns:
- This auto-completer
-
registerSuggestionFactory
AutoCompleter registerSuggestionFactory(int priority, @NotNull @NotNull SuggestionProviderFactory factory) Registers aSuggestionProviderFactory
that creates suggestion providers dynamically for parameters. This allows for checking against custom annotations in parameters.- Parameters:
priority
- The resolver priority. Zero represents the highest.factory
- Factory to register- Returns:
- This auto-completer
-
getSuggestionProvider
Returns the suggestion provider that maps to the specified ID.This may return null if no such ID is registered.
- Parameters:
id
- ID to retrieve from- Returns:
- The provider, or null if none is registered
-
complete
List<String> complete(@NotNull @NotNull CommandActor actor, @NotNull @NotNull ArgumentStack arguments) Generates a list of suggestions for the given actor and argument list- Parameters:
actor
- Actor to generate forarguments
- The argument stack. This can contain empty values.- Returns:
- The suggestions list.
-
complete
Generates a list of suggestions for the given actor and buffer- Parameters:
actor
- Actor to generate forbuffer
- The current string input- Returns:
- The suggestions list.
-
and
CommandHandler and()Returns the containingCommandHandler
of this auto completer. This will allow for writing fluent and readable code.- Returns:
- The parent command handler
-