Package revxrsal.commands.autocomplete
Interface SuggestionProvider
public interface SuggestionProvider
A provider for tab completions.
Register with AutoCompleter.registerSuggestion(String, SuggestionProvider)
-
Field Summary
Modifier and TypeFieldDescriptionstatic final SuggestionProvider
ASuggestionProvider
that always returns an empty list. -
Method Summary
Modifier and TypeMethodDescriptiondefault SuggestionProvider
compose
(@Nullable SuggestionProvider other) Composes the twoSuggestionProvider
s into one provider that returns the completions from both.@NotNull Collection<String>
getSuggestions
(@NotNull List<String> args, @NotNull CommandActor sender, @NotNull ExecutableCommand command) Returns the suggestionsstatic <T> SuggestionProvider
map
(@NotNull Supplier<Collection<T>> values, Function<T, String> function) Returns aSuggestionProvider
that takes the given collection of values and maps it to strings according to the given function.static SuggestionProvider
of
(@NotNull Supplier<Collection<String>> supplier) Returns aSuggestionProvider
that computes the given supplier every time suggestions are returned.static SuggestionProvider
Returns aSuggestionProvider
that always returns the given valuesstatic SuggestionProvider
of
(@Nullable Collection<String> suggestions) Returns aSuggestionProvider
that always returns the given values
-
Field Details
-
EMPTY
ASuggestionProvider
that always returns an empty list.
-
-
Method Details
-
getSuggestions
@NotNull @NotNull Collection<String> getSuggestions(@NotNull @NotNull List<String> args, @NotNull @NotNull CommandActor sender, @NotNull @NotNull ExecutableCommand command) throws Throwable Returns the suggestions- Parameters:
args
- The command argumentssender
- The command sendercommand
- The handled command- Returns:
- The command suggestions.
- Throws:
Throwable
-
compose
@Contract("null -> this; !null -> new") default SuggestionProvider compose(@Nullable @Nullable SuggestionProvider other) Composes the twoSuggestionProvider
s into one provider that returns the completions from both.- Parameters:
other
- Other provider to merge with- Returns:
- The new provider
-
of
Returns aSuggestionProvider
that always returns the given values- Parameters:
suggestions
- Values to return.- Returns:
- The provider
-
of
Returns aSuggestionProvider
that always returns the given values- Parameters:
suggestions
- Values to return.- Returns:
- The provider
-
of
Returns aSuggestionProvider
that computes the given supplier every time suggestions are returned.- Parameters:
supplier
- The collection supplier- Returns:
- The provider
-
map
static <T> SuggestionProvider map(@NotNull @NotNull Supplier<Collection<T>> values, Function<T, String> function) Returns aSuggestionProvider
that takes the given collection of values and maps it to strings according to the given function.- Type Parameters:
T
- The values type- Parameters:
values
- Values to mapfunction
- Function to remap values with- Returns:
- The provider
-