Interface PlainFormat<T>

Type Parameters:
T - the result type produced by this format when applied to input text
All Superinterfaces:
Format<T>
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface PlainFormat<T> extends Format<T>
A specialization of Format for formats that do not rely on regular-expression matching.

PlainFormat is intended for cases where your formatting logic cannot be captured (or need not be captured) by a single regex. By default, the regex-based methods are stubbed out—implementors should override them only if they actually require regex support.

Otherwise, all matching and processing should occur in the Format.accept(Player, String) methods directly.
See Also:
  • Field Details

    • PLACEHOLDER_API

      static final PlainFormat<String> PLACEHOLDER_API
      A PlainFormat implementation that integrates with PlaceholderAPI.

      If the input string is non‑blank and the PlaceholderAPI plugin is present (enabled), it will replace any PlaceholderAPI placeholders in the text for the provided Player; otherwise, it returns the original text.

    • INTERACTIVE_CHAT

      static final PlainFormat<String> INTERACTIVE_CHAT
      A PlainFormat implementation that integrates with InteractiveChat.

      If the input string is non‑blank and the InteractiveChat plugin is present (enabled), it will mark the text so that clicking it in chat triggers an interactive chat action for the provided Player; otherwise, it returns the original text.

    • TRIM_START_SPACES

      static final PlainFormat<String> TRIM_START_SPACES
  • Method Details

    • getRegex

      @NotNull default @NotNull String getRegex()
      Returns the regular expression used for matching format tokens in the input.

      Since PlainFormat implementations typically do not use regex matching, the default implementation returns an empty string. Override only if your plain format needs to expose a regex for some reason.

      Specified by:
      getRegex in interface Format<T>
      Returns:
      an empty string by default
    • matcher

      @NotNull default @NotNull Matcher matcher(String string)
      Creates a Matcher for the given input text.

      The default implementation always throws UnsupportedOperationException because plain formats do not support regex-based matching out of the box. If you need regex matching, override this method with your own Pattern compilation and matching logic.

      Otherwise, perform any necessary matching directly in your accept(...) implementation.

      Specified by:
      matcher in interface Format<T>
      Parameters:
      string - the input text to be matched
      Returns:
      a Matcher for the provided input
      Throws:
      UnsupportedOperationException - always, unless overridden by the implementor
    • isFormatted

      default boolean isFormatted(String string)
      Checks whether this format applies to the given input.

      The default implementation always returns false. If your plain format can detect its pattern without regex (for example, via prefix checks or other heuristics), override this method to provide that logic.

      Specified by:
      isFormatted in interface Format<T>
      Parameters:
      string - the input text to test
      Returns:
      true if this format should process the input; false otherwise
    • removeFormat

      default String removeFormat(String string)
      Removes the formatting syntax from the input text.

      The default implementation returns the input unchanged. If your plain format supports stripping its own custom markers or tokens, override this method to implement the removal logic.

      Specified by:
      removeFormat in interface Format<T>
      Parameters:
      string - the input text from which to remove formatting
      Returns:
      the text with formatting removed