Package dev.jorel.commandapi.arguments
Interface SafeSuggestions<S>
- Type Parameters:
S- the type of the suggestions
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
This class represents safe suggestions. These are parameterized suggestions which can be converted
into a string under a mapping function.
SafeSuggestions instances are best created using the static methods as opposed to functionally.-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> SafeSuggestions<T>empty()Create an empty SafeSuggestions object.static <T> SafeSuggestions<T>suggest(Function<SuggestionInfo, T[]> suggestions) Suggest values as the result of a functionstatic <T> SafeSuggestions<T>suggest(T... suggestions) Hardcode values to suggeststatic <T> SafeSuggestions<T>suggestAsync(Function<SuggestionInfo, CompletableFuture<T[]>> suggestions) Suggest values provided asynchronouslystatic <T> SafeSuggestions<T>Suggest hardcoded values with tooltipsstatic <T> SafeSuggestions<T>tooltips(Function<SuggestionInfo, Tooltip<T>[]> suggestions) Suggest values with tooltips as the result of a functionstatic <T> SafeSuggestions<T>tooltipsAsync(Function<SuggestionInfo, CompletableFuture<Tooltip<T>[]>> suggestions) Suggest values with tooltips asynchronouslytoSuggestions(Function<S, String> mapper) Convert thisSafeSuggestionsobject into anArgumentSuggestionsby mapping the values with a string mapping function.
-
Method Details
-
toSuggestions
Convert thisSafeSuggestionsobject into anArgumentSuggestionsby mapping the values with a string mapping function.- Parameters:
mapper- a function which maps an instance ofSafeSuggestionsto a string.- Returns:
- an
ArgumentSuggestionsobject resulting from this mapping.
-
empty
Create an empty SafeSuggestions object.- Type Parameters:
T- type parameter of the SafeSuggestions object- Returns:
- a SafeSuggestions object resulting in empty suggestions
-
suggest
Hardcode values to suggest- Type Parameters:
T- type of the values- Parameters:
suggestions- hardcoded values- Returns:
- a SafeSuggestions object suggesting the hardcoded suggestions
-
suggest
Suggest values as the result of a function- Type Parameters:
T- type of the values- Parameters:
suggestions- function providing the values- Returns:
- a SafeSuggestion object suggesting the result of the function
-
suggestAsync
static <T> SafeSuggestions<T> suggestAsync(Function<SuggestionInfo, CompletableFuture<T[]>> suggestions) Suggest values provided asynchronously- Type Parameters:
T- type of the values- Parameters:
suggestions- function providing the values asynchronously- Returns:
- a SafeSuggestion object suggestion the result of the asynchronous function
-
tooltips
Suggest hardcoded values with tooltips- Type Parameters:
T- type of the values- Parameters:
suggestions- hardcoded values with their tooltips- Returns:
- a SafeSuggestion object suggesting the hardcoded values
-
tooltips
Suggest values with tooltips as the result of a function- Type Parameters:
T- type of the values- Parameters:
suggestions- function providing the values with tooltips- Returns:
- a SafeSuggestion object suggesting the result of the function
-
tooltipsAsync
static <T> SafeSuggestions<T> tooltipsAsync(Function<SuggestionInfo, CompletableFuture<Tooltip<T>[]>> suggestions) Suggest values with tooltips asynchronously- Type Parameters:
T- type of the values- Parameters:
suggestions- function providing the values with tooltips- Returns:
- a SafeSuggestion suggesting the result of the asynchronous function
-