CommandAPI 9.7.0
An API for the command UI introduced in Minecraft 1.13
dev.jorel.commandapi.BukkitTooltip< 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.BukkitTooltip< 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 > Collection< Tooltip< S > > generateBaseComponents (Function< S, BaseComponent[]> tooltipGenerator, S... suggestions)
 Constructs a collection of objects from an array of suggestions, and a function which generates a tooltip formatted as an array of BaseComponents for each suggestion. More...
 
static< S > Collection< Tooltip< S > > generateBaseComponents (Function< S, BaseComponent[]> tooltipGenerator, Collection< S > suggestions)
 Constructs a collection of objects from a collection of suggestions, and a function which generates a tooltip formatted as an array of BaseComponents for each suggestion. More...
 
static< S > Collection< Tooltip< S > > generateAdvenureComponents (Function< S, Component > tooltipGenerator, S... suggestions)
 Constructs a collection of objects from an array of suggestions, and a function which generates a tooltip formatted as an adventure Component for each suggestion. More...
 
static< S > Collection< Tooltip< S > > generateAdventureComponents (Function< S, Component > tooltipGenerator, S... suggestions)
 Constructs a collection of objects from an array of suggestions, and a function which generates a tooltip formatted as an adventure Component for each suggestion. More...
 
static< S > Collection< Tooltip< S > > generateAdvenureComponents (Function< S, Component > tooltipGenerator, Collection< S > suggestions)
 Constructs a collection of objects from a collection of suggestions, and a function which generates a tooltip formatted as an adventure Component for each suggestion. More...
 
static< S > Collection< Tooltip< S > > generateAdventureComponents (Function< S, Component > tooltipGenerator, Collection< S > suggestions)
 Constructs a collection of objects from a collection of suggestions, and a function which generates a tooltip formatted as an adventure Component for each suggestion. More...
 
static< S > Tooltip< S > ofBaseComponents (S object, BaseComponent... tooltip)
 Constructs a BukkitTooltip<S> with a suggestion and a formatted tooltip. More...
 
static< S > Tooltip< S > ofAdventureComponent (S object, Component tooltip)
 Constructs a BukkitTooltip<S> with a suggestion and a formatted tooltip. More...
 
static Message messageFromBaseComponents (BaseComponent... components)
 Converts a formatted bungee text component to a native minecraft text component which can be used natively by brigadier. More...
 
static Message messageFromAdventureComponent (Component component)
 Converts a formatted adventure text component to a native minecraft text component which can be used natively by brigadier. More...
 
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

 BukkitTooltip (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)
staticinherited

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)
staticinherited

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 
)
staticprotectedinherited

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 
)
protectedinherited

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

◆ generateAdventureComponents() [1/2]

static< S > Collection< Tooltip< S > > dev.jorel.commandapi.BukkitTooltip< S >.generateAdventureComponents ( Function< S, Component >  tooltipGenerator,
Collection< S >  suggestions 
)
static

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

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

◆ generateAdventureComponents() [2/2]

static< S > Collection< Tooltip< S > > dev.jorel.commandapi.BukkitTooltip< S >.generateAdventureComponents ( Function< S, Component >  tooltipGenerator,
S...  suggestions 
)
static

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

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

◆ generateAdvenureComponents() [1/2]

static< S > Collection< Tooltip< S > > dev.jorel.commandapi.BukkitTooltip< S >.generateAdvenureComponents ( Function< S, Component >  tooltipGenerator,
Collection< S >  suggestions 
)
static

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

Parameters
<S>the object that the argument suggestions use
tooltipGeneratorfunction which returns a formatted tooltip for the suggestion, an adventure Component
suggestionscollection of suggestions to provide to the user
Deprecated:
This method has been deprecated in favour of BukkitTooltip#generateAdventureComponents(Function, Collection)
Returns
a collection of objects from the provided suggestions, with the generated formatted tooltips

◆ generateAdvenureComponents() [2/2]

static< S > Collection< Tooltip< S > > dev.jorel.commandapi.BukkitTooltip< S >.generateAdvenureComponents ( Function< S, Component >  tooltipGenerator,
S...  suggestions 
)
static

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

Parameters
<S>the object that the argument suggestions use
tooltipGeneratorfunction which returns a formatted tooltip for the suggestion, an adventure Component
suggestionsarray of suggestions to provide to the user
Deprecated:
This method has been deprecated in favour of BukkitTooltip#generateAdventureComponents(Function, Object[])
Returns
a collection of objects from the provided suggestions, with the generated formatted tooltips

◆ generateBaseComponents() [1/2]

static< S > Collection< Tooltip< S > > dev.jorel.commandapi.BukkitTooltip< S >.generateBaseComponents ( Function< S, BaseComponent[]>  tooltipGenerator,
Collection< S >  suggestions 
)
static

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

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

◆ generateBaseComponents() [2/2]

static< S > Collection< Tooltip< S > > dev.jorel.commandapi.BukkitTooltip< S >.generateBaseComponents ( Function< S, BaseComponent[]>  tooltipGenerator,
S...  suggestions 
)
static

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

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

◆ generateMessages() [1/2]

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

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 
)
staticinherited

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 
)
staticinherited

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 
)
staticinherited

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 ( )
inherited

Gets the suggestion for this object.

Returns
the suggestion for this object

◆ getTooltip()

Message dev.jorel.commandapi.Tooltip< S >.getTooltip ( )
inherited

Gets the formatted tooltip for this object.

Returns
the formatted tooltip for this object

◆ messageFromAdventureComponent()

static Message dev.jorel.commandapi.BukkitTooltip< S >.messageFromAdventureComponent ( Component  component)
static

Converts a formatted adventure text component to a native minecraft text component which can be used natively by brigadier.

This supports all forms of formatting including entity selectors, scores, click & hover events, translations, keybinds and more.

Parameters
componentadventure text component
Returns
native minecraft message object which can be used natively by brigadier.

◆ messageFromBaseComponents()

static Message dev.jorel.commandapi.BukkitTooltip< S >.messageFromBaseComponents ( BaseComponent...  components)
static

Converts a formatted bungee text component to a native minecraft text component which can be used natively by brigadier.

This supports all forms of formatting including entity selectors, scores, click & hover events, translations, keybinds and more.

Note: the bungee component api is deprecated, and the adventure text component api should be used instead

Parameters
componentsarray of bungee text components
Returns
native minecraft message object which can be used natively by brigadier.

◆ messageFromString()

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

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)
staticinherited

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)
staticinherited

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)
staticinherited

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

◆ ofAdventureComponent()

static< S > Tooltip< S > dev.jorel.commandapi.BukkitTooltip< S >.ofAdventureComponent ( object,
Component  tooltip 
)
static

Constructs a BukkitTooltip<S> with a suggestion and a formatted tooltip.

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

◆ ofBaseComponents()

static< S > Tooltip< S > dev.jorel.commandapi.BukkitTooltip< S >.ofBaseComponents ( object,
BaseComponent...  tooltip 
)
static

Constructs a BukkitTooltip<S> with a suggestion and a formatted tooltip.

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

◆ ofMessage()

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

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 
)
staticinherited

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