Class StringTooltip

java.lang.Object
dev.jorel.commandapi.StringTooltip
All Implemented Interfaces:
IStringTooltip

public class StringTooltip extends Object implements IStringTooltip
Represents a suggestion for an argument with a hover tooltip text for that suggestion. This class is to be used with normal suggestion overrides, via the Argument.overrideSuggestionsT method.
  • Constructor Details

    • StringTooltip

      protected StringTooltip(String suggestion, com.mojang.brigadier.Message tooltip)
  • Method Details

    • ofString

      public static StringTooltip ofString(String suggestion, String tooltip)
      Constructs a StringTooltip with a suggestion and a string tooltip
      Parameters:
      suggestion - the suggestion to provide to the user
      tooltip - the string tooltip to show to the user when they hover over the suggestion
      Returns:
      a StringTooltip representing this suggestion and tooltip
    • ofMessage

      public static StringTooltip ofMessage(String suggestion, com.mojang.brigadier.Message tooltip)
      Constructs a StringTooltip with a suggestion and a formatted tooltip
      Parameters:
      suggestion - the suggestion to provide to the user
      tooltip - the formatted tooltip to show to the user when they hover over the suggestion
      Returns:
      a StringTooltip representing this suggestion and tooltip
    • none

      public static StringTooltip none(String suggestion)
      Constructs a StringTooltip with a suggestion and no tooltip
      Parameters:
      suggestion - the suggestion to provide to the user
      Returns:
      a StringTooltip representing this suggestion
    • none

      public static Collection<StringTooltip> none(String... suggestions)
      Constructs a collection of StringTooltip objects from an array of suggestions, and no tooltips
      Parameters:
      suggestions - array of suggestions to provide to the user
      Returns:
      a collection of StringTooltip objects from the suggestions, with no tooltips
    • none

      public static Collection<StringTooltip> none(Collection<String> suggestions)
      Constructs a collection of StringTooltip objects from a collection of suggestions, and no tooltips
      Parameters:
      suggestions - collection of suggestions to provide to the user
      Returns:
      a collection of StringTooltip objects from the suggestions, with no tooltips
    • generateStrings

      public static Collection<StringTooltip> generateStrings(UnaryOperator<String> tooltipGenerator, String... suggestions)
      Constructs a collection of StringTooltip objects from an array of suggestions, and a function which generates a string tooltip for each suggestion
      Parameters:
      tooltipGenerator - function which returns a string tooltip for the suggestion
      suggestions - array of suggestions to provide to the user
      Returns:
      a collection of StringTooltip objects from the provided suggestions, with the generated string tooltips
    • generateStrings

      public static Collection<StringTooltip> generateStrings(UnaryOperator<String> tooltipGenerator, Collection<String> suggestions)
      Constructs a collection of StringTooltip objects from a collection of suggestions, and a function which generates a string tooltip for each suggestion
      Parameters:
      tooltipGenerator - function which returns a string tooltip for the suggestion
      suggestions - collection of suggestions to provide to the user
      Returns:
      a collection of StringTooltip objects from the provided suggestions, with the generated string tooltips
    • generateMessages

      public static Collection<StringTooltip> generateMessages(Function<String,com.mojang.brigadier.Message> tooltipGenerator, String... suggestions)
      Constructs a collection of StringTooltip objects from an array of suggestions, and a function which generates a formatted tooltip for each suggestion
      Parameters:
      tooltipGenerator - function which returns a formatted tooltip for the suggestion
      suggestions - array of suggestions to provide to the user
      Returns:
      a collection of StringTooltip objects from the provided suggestions, with the generated formatted tooltips
    • generateMessages

      public static Collection<StringTooltip> generateMessages(Function<String,com.mojang.brigadier.Message> tooltipGenerator, Collection<String> suggestions)
      Constructs a collection of StringTooltip objects from a collection of suggestions, and a function which generates a formatted tooltip for each suggestion
      Parameters:
      tooltipGenerator - function which returns a formatted tooltip for the suggestion
      suggestions - collection of suggestions to provide to the user
      Returns:
      a collection of StringTooltip objects from the provided suggestions, with the generated formatted tooltips
    • generate

      protected static <T> Collection<StringTooltip> generate(Function<String,T> tooltipGenerator, BiFunction<String,T,StringTooltip> tooltipWrapper, String... suggestions)
      Internal base method for the other generation types
      Type Parameters:
      T - the type of the tooltip
      Parameters:
      tooltipGenerator - tooltip generation function
      tooltipWrapper - function which wraps suggestion and tooltip into a StringTooltip object
      suggestions - array of suggestions to provide to the user
      Returns:
      a collection of StringTooltip objects from the provided suggestion, wrapped using the above functions
    • generate

      protected static <T> Collection<StringTooltip> generate(Function<String,T> tooltipGenerator, BiFunction<String,T,StringTooltip> tooltipWrapper, Collection<String> suggestions)
      Internal base method for the other generation types
      Type Parameters:
      T - the type of the tooltip
      Parameters:
      tooltipGenerator - tooltip generation function
      tooltipWrapper - function which wraps suggestion and tooltip into a StringTooltip object
      suggestions - collection of suggestions to provide to the user
      Returns:
      a collection of StringTooltip objects from the provided suggestion, wrapped using the above functions
    • generate

      protected static <T> Collection<StringTooltip> generate(Function<String,T> tooltipGenerator, BiFunction<String,T,StringTooltip> tooltipWrapper, Stream<String> suggestions)
      Internal base method for the other generation types
      Type Parameters:
      T - the type of the tooltip
      Parameters:
      tooltipGenerator - tooltip generation function
      tooltipWrapper - function which wraps suggestion and tooltip into a StringTooltip object
      suggestions - stream of suggestions to provide to the user
      Returns:
      a collection of StringTooltip objects from the provided suggestion, wrapped using the above functions
    • getSuggestion

      public String getSuggestion()
      Returns the current suggestion that this class holds
      Specified by:
      getSuggestion in interface IStringTooltip
      Returns:
      the current suggestion that this class holds
    • getTooltip

      public com.mojang.brigadier.Message getTooltip()
      Returns the current tooltip text that this class holds
      Specified by:
      getTooltip in interface IStringTooltip
      Returns:
      the current tooltip text that this class holds