Interface ColorPattern


public interface ColorPattern
Low-level contract for Prismatic color-pattern processors.

Implementations transform raw strings by either applying or stripping Prismatic-specific color syntax such as gradients, rainbows and single RGB markers. Most plugin code should prefer PrismaticAPI rather than interacting with this SPI directly.

The built-in processors are exposed through MULTI, SINGLE and COLOR_PATTERNS.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final List<ColorPattern>
    Immutable ordered list of the built-in processors used by the default Prismatic pipeline.
    static final ColorPattern
    Built-in processor for gradients, rainbows and other multi-color Prismatic tags.
    static final ColorPattern
    Built-in processor for single RGB tokens such as {#ff8800} or &#ff8800.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull String
    apply(String string, boolean legacy)
    Applies this pattern to a string.
    @NotNull String
    strip(String string)
    Removes the syntax handled by this pattern from a string.
  • Field Details

    • MULTI

      static final ColorPattern MULTI
      Built-in processor for gradients, rainbows and other multi-color Prismatic tags.
    • SINGLE

      static final ColorPattern SINGLE
      Built-in processor for single RGB tokens such as {#ff8800} or &#ff8800.
    • COLOR_PATTERNS

      static final List<ColorPattern> COLOR_PATTERNS
      Immutable ordered list of the built-in processors used by the default Prismatic pipeline.

      The order is always:

      1. multi-color (gradients/rainbows)
      2. single-color

  • Method Details

    • strip

      @NotNull @NotNull String strip(String string)
      Removes the syntax handled by this pattern from a string.
      Parameters:
      string - the text from which to remove color formatting
      Returns:
      the plain text string with all color codes removed
    • apply

      @NotNull @NotNull String apply(String string, boolean legacy)
      Applies this pattern to a string.

      The legacy flag allows implementations to choose between exact RGB output and downsampled legacy Bukkit colors.

      Parameters:
      string - the input text to which the color pattern will be applied
      legacy - true if legacy formatting (e.g. 16-color mode) should be used; false for modern RGB support
      Returns:
      the transformed, colorized string