Class Tooltip<S>

java.lang.Object
dev.jorel.commandapi.Tooltip<S>
Type Parameters:
S - the object that the argument suggestions use

public class Tooltip<S> extends Object
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.
  • Method Details

    • of

      public static <S> Tooltip<S> of(S object, String tooltip)
      Constructs a Tooltip<S> with a suggestion and a tooltip
      Type Parameters:
      S - the object that the argument suggestions use
      Parameters:
      object - the suggestion to provide to the user
      tooltip - the tooltip to show to the user when they hover over the suggestion
      Returns:
      a Tooltip<S> representing this suggestion and tooltip
    • none

      public static <S> Tooltip<S> none(S object)
      Constructs a Tooltip<S> with a suggestion and no tooltip
      Type Parameters:
      S - the object that the argument suggestions use
      Parameters:
      object - the suggestion to provide to the user
      Returns:
      a Tooltip<S> representing this suggestion
    • arrayOf

      @SafeVarargs public static <S> Tooltip<S>[] arrayOf(Tooltip<S>... tooltips)
      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.
      Type Parameters:
      S - the object that the argument suggestions use
      Parameters:
      tooltips - an array of Tooltip<S> to be converted into Tooltip<S>[]
      Returns:
      a Tooltip<S>[] from the provided Tooltip<S>
    • build

      public static <S> Function<Tooltip<S>,StringTooltip> build(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. This method is used internally by the CommandAPI.
      Type Parameters:
      S - the object that the argument suggestions use
      Parameters:
      mapper - a mapping function that converts an S instance into a String
      Returns:
      the mapping function from this tooltip into a StringTooltip