CommandAPI 9.3.0
An API for the command UI introduced in Minecraft 1.13
dev.jorel.commandapi.Tooltip< S > Class Template Reference

This class represents a suggestion for an argument with a hover tooltip text for that suggestion. More...

+ Inheritance diagram for dev.jorel.commandapi.Tooltip< S >:

Public Member Functions

getSuggestion ()
 Gets the suggestion for this object. More...
 
Message getTooltip ()
 Gets the formatted tooltip for this object. More...
 

Static Public Member Functions

static< S > Tooltip< S > ofString (S object, String tooltip)
 Constructs a Tooltip<S> with a suggestion and a tooltip. More...
 
static< S > Tooltip< S > ofMessage (S object, Message tooltip)
 Constructs a Tooltip<S> with a suggestion and a tooltip. More...
 
static< S > Tooltip< S > none (S object)
 Constructs a Tooltip<S> with a suggestion and no tooltip. More...
 
static< S > Collection< Tooltip< S > > none (S... suggestions)
 Constructs a collection of objects from an array of suggestions, and no tooltips. More...
 
static< S > Collection< Tooltip< S > > none (Collection< S > suggestions)
 Constructs a collection of objects from a collection of suggestions, and no tooltips. More...
 
static< S > Collection< Tooltip< S > > generateStrings (Function< S, String > tooltipGenerator, S... suggestions)
 Constructs a collection of objects from an array of suggestions, and a function which generates a string tooltip for each suggestion. More...
 
static< S > Collection< Tooltip< S > > generateStrings (Function< S, String > tooltipGenerator, Collection< S > suggestions)
 Constructs a collection of objects from a collection of suggestions, and a function which generates a string tooltip for each suggestion. More...
 
static< S > Collection< Tooltip< S > > generateMessages (Function< S, Message > tooltipGenerator, S... suggestions)
 Constructs a collection of objects from an array of suggestions, and a function which generates a formatted tooltip for each suggestion. More...
 
static< S > Collection< Tooltip< S > > generateMessages (Function< S, Message > tooltipGenerator, Collection< S > suggestions)
 Constructs a collection of objects from an collection of suggestions, and a function which generates a formatted tooltip for each suggestion. More...
 
static< S > Tooltip< S >[] arrayOf (Tooltip< S >... tooltips)
 Constructs a Tooltip<S>[] from an array of Tooltip<S> via varargs. More...
 
static< S > Function< Tooltip< S >, StringTooltipbuild (Function< S, String > mapper)
 Constructs a function that maps the current Tooltip<S> into a StringTooltip, using a standard mapping function which is defined for a given argument. More...
 
static Message messageFromString (String string)
 Converts an unformatted string to an unformatted tooltip by wrapping as with a LiteralMessage. More...
 

Protected Member Functions

 Tooltip (S object, Message tooltip)
 
static< S, T > Collection< Tooltip< S > > generate (Function< S, T > tooltipGenerator, BiFunction< S, T, Tooltip< S > > tooltipWrapper, S... suggestions)
 Internal base method for the other generation types, for processing arrays. More...
 

Static Protected Member Functions

static< S, T > Collection< Tooltip< S > > generate (Function< S, T > tooltipGenerator, BiFunction< S, T, Tooltip< S > > tooltipWrapper, Collection< S > suggestions)
 Internal base method for the other generation types, for processing collections. More...
 

Detailed Description

This class represents a suggestion for an argument with a hover tooltip text for that suggestion.

This class is parameterized over some object S that represents the safe cast type for argument suggestions. This class is to be used with safe suggestion overrides, via the SafeOverrideableArgument.safeOverrideSuggestionsT method.

Parameters
<S>the object that the argument suggestions use

Member Function Documentation

◆ arrayOf()

static< S > Tooltip< S >[] dev.jorel.commandapi.Tooltip< S >.arrayOf ( Tooltip< S >...  tooltips)
static

Constructs a Tooltip<S>[] from an array of Tooltip<S> via varargs.

This method takes advantage of Java's varargs to construct a generic array parameterised over S for the purpose of type safety for the safeOverrideSuggestionsT method, because Java doesn't allow you to create generic arrays.

Parameters
<S>the object that the argument suggestions use
tooltipsan array of Tooltip<S> to be converted into Tooltip<S>[]
Returns
a Tooltip<S>[] from the provided Tooltip<S>

◆ build()

static< S > Function< Tooltip< S >, StringTooltip > dev.jorel.commandapi.Tooltip< S >.build ( Function< S, String >  mapper)
static

Constructs a function that maps the current Tooltip<S> into a StringTooltip, using a standard mapping function which is defined for a given argument.

This method is used internally by the CommandAPI.

Parameters
<S>the object that the argument suggestions use
mappera mapping function that converts an S instance into a String
Returns
the mapping function from this tooltip into a StringTooltip

◆ generate() [1/2]

static< S, T > Collection< Tooltip< S > > dev.jorel.commandapi.Tooltip< S >.generate ( Function< S, T >  tooltipGenerator,
BiFunction< S, T, Tooltip< S > >  tooltipWrapper,
Collection< S >  suggestions 
)
staticprotected

Internal base method for the other generation types, for processing collections.

Parameters
<S>the object that the argument suggestions use
<T>the type of the tooltip
tooltipGeneratortooltip generation function
tooltipWrapperfunction which wraps suggestion and tooltip into a object
suggestionscollection of suggestions to provide to the user
Returns
a collection of objects from the provided suggestion, wrapped using the above functions

◆ generate() [2/2]

static< S, T > Collection< Tooltip< S > > dev.jorel.commandapi.Tooltip< S >.generate ( Function< S, T >  tooltipGenerator,
BiFunction< S, T, Tooltip< S > >  tooltipWrapper,
S...  suggestions 
)
protected

Internal base method for the other generation types, for processing arrays.

Parameters
<S>the object that the argument suggestions use
<T>the type of the tooltip
tooltipGeneratortooltip generation function
tooltipWrapperfunction which wraps suggestion and tooltip into a object
suggestionsarray of suggestions to provide to the user
Returns
a collection of objects from the provided suggestion, wrapped using the above functions

◆ generateMessages() [1/2]

static< S > Collection< Tooltip< S > > dev.jorel.commandapi.Tooltip< S >.generateMessages ( Function< S, Message tooltipGenerator,
Collection< S >  suggestions 
)
static

Constructs a collection of objects from an collection of suggestions, and a function which generates a formatted tooltip for each suggestion.

Parameters
<S>the object that the argument suggestions use
tooltipGeneratorfunction which returns a formatted tooltip for the suggestion
suggestionscollection of suggestions to provide to the user
Returns
a collection of objects from the provided suggestions, with the generated formatted tooltips

◆ generateMessages() [2/2]

static< S > Collection< Tooltip< S > > dev.jorel.commandapi.Tooltip< S >.generateMessages ( Function< S, Message tooltipGenerator,
S...  suggestions 
)
static

Constructs a collection of objects from an array of suggestions, and a function which generates a formatted tooltip for each suggestion.

Parameters
<S>the object that the argument suggestions use
tooltipGeneratorfunction which returns a formatted tooltip for the suggestion
suggestionsarray of suggestions to provide to the user
Returns
a collection of objects from the provided suggestions, with the generated formatted tooltips

◆ generateStrings() [1/2]

static< S > Collection< Tooltip< S > > dev.jorel.commandapi.Tooltip< S >.generateStrings ( Function< S, String >  tooltipGenerator,
Collection< S >  suggestions 
)
static

Constructs a collection of objects from a collection of suggestions, and a function which generates a string tooltip for each suggestion.

Parameters
<S>the object that the argument suggestions use
tooltipGeneratorfunction which returns a string tooltip for the suggestion
suggestionscollection of suggestions to provide to the user
Returns
a collection of objects from the provided suggestions, with the generated string tooltips

◆ generateStrings() [2/2]

static< S > Collection< Tooltip< S > > dev.jorel.commandapi.Tooltip< S >.generateStrings ( Function< S, String >  tooltipGenerator,
S...  suggestions 
)
static

Constructs a collection of objects from an array of suggestions, and a function which generates a string tooltip for each suggestion.

Parameters
<S>the object that the argument suggestions use
tooltipGeneratorfunction which returns a string tooltip for the suggestion
suggestionsarray of suggestions to provide to the user
Returns
a collection of objects from the provided suggestions, with the generated string tooltips

◆ getSuggestion()

S dev.jorel.commandapi.Tooltip< S >.getSuggestion ( )

Gets the suggestion for this object.

Returns
the suggestion for this object

◆ getTooltip()

Gets the formatted tooltip for this object.

Returns
the formatted tooltip for this object

◆ messageFromString()

static Message dev.jorel.commandapi.Tooltip< S >.messageFromString ( String  string)
static

Converts an unformatted string to an unformatted tooltip by wrapping as with a LiteralMessage.

If formatting is required, please see the various other messageFromXXX methods.

Parameters
stringunformatted string tooltip
Returns
wrapped tooltip as a LiteralMessage

◆ none() [1/3]

static< S > Collection< Tooltip< S > > dev.jorel.commandapi.Tooltip< S >.none ( Collection< S >  suggestions)
static

Constructs a collection of objects from a collection of suggestions, and no tooltips.

Parameters
<S>the object that the argument suggestions use
suggestionscollection of suggestions to provide to the user
Returns
a collection of objects from the suggestions, with no tooltips

◆ none() [2/3]

static< S > Tooltip< S > dev.jorel.commandapi.Tooltip< S >.none ( object)
static

Constructs a Tooltip<S> with a suggestion and no tooltip.

Parameters
<S>the object that the argument suggestions use
objectthe suggestion to provide to the user
Returns
a Tooltip<S> representing this suggestion

◆ none() [3/3]

static< S > Collection< Tooltip< S > > dev.jorel.commandapi.Tooltip< S >.none ( S...  suggestions)
static

Constructs a collection of objects from an array of suggestions, and no tooltips.

Parameters
<S>the object that the argument suggestions use
suggestionsarray of suggestions to provide to the user
Returns
a collection of objects from the suggestions, with no tooltips

◆ ofMessage()

static< S > Tooltip< S > dev.jorel.commandapi.Tooltip< S >.ofMessage ( object,
Message  tooltip 
)
static

Constructs a Tooltip<S> with a suggestion and a tooltip.

Parameters
<S>the object that the argument suggestions use
objectthe suggestion to provide to the user
tooltipthe tooltip to show to the user when they hover over the suggestion
Returns
a Tooltip<S> representing this suggestion and tooltip

◆ ofString()

static< S > Tooltip< S > dev.jorel.commandapi.Tooltip< S >.ofString ( object,
String  tooltip 
)
static

Constructs a Tooltip<S> with a suggestion and a tooltip.

Parameters
<S>the object that the argument suggestions use
objectthe suggestion to provide to the user
tooltipthe tooltip to show to the user when they hover over the suggestion
Returns
a Tooltip<S> representing this suggestion and tooltip