Interface CaptionFormatter<C,T>

All Known Implementing Classes:
CaptionFormatter.PatternReplacingCaptionFormatter

@API(status=STABLE) public interface CaptionFormatter<C,T>
  • Method Details

    • patternReplacing

      static <C> @NonNull CaptionFormatter<C,String> patternReplacing(@NonNull Pattern pattern)
      Returns a caption formatter that replaces the results from the given pattern with the values from the caption variables.

      The 1st capturing group will be used to determine the name of the variable to use for the replacement.

      Type Parameters:
      C - the command sender type
      Parameters:
      pattern - the pattern
      Returns:
      the formatter
    • placeholderReplacing

      static <C> @NonNull CaptionFormatter<C,String> placeholderReplacing()
      Returns a caption formatter that replaces placeholders in the form of <placeholder> with the caption variables.
      Type Parameters:
      C - the command sender type
      Returns:
      the formatter
    • placeholderPattern

      static Pattern placeholderPattern()
      Returns the pattern for placeholderReplacing(). Replaces variables in the <name> format.
      Returns:
      the pattern for placeholderReplacing()
    • formatCaption

      default @NonNull T formatCaption(@NonNull Caption captionKey, @NonNull C recipient, @NonNull String caption, @NonNull CaptionVariable @NonNull ... variables)
      Formats the caption.
      Parameters:
      captionKey - the caption key
      recipient - the recipient of the message
      caption - the value of the caption
      variables - the caption variables
      Returns:
      the transformed message
    • formatCaption

      @NonNull T formatCaption(@NonNull Caption captionKey, @NonNull C recipient, @NonNull String caption, @NonNull List<@NonNull CaptionVariable> variables)
      Formats the caption.
      Parameters:
      captionKey - the caption key
      recipient - the recipient of the message
      caption - the value of the caption
      variables - the caption variables
      Returns:
      the transformed message