Class MiniMessageBridge

java.lang.Object
com.github.darksoulq.abyssallib.common.color.MiniMessageBridge

public class MiniMessageBridge extends Object
A bridge utility connecting the internal color systems with Adventure's MiniMessage.

Provides functionality for parsing MiniMessage strings, converting colors to various hex formats, and rendering dynamic, animated text components using ColorProvider.

  • Constructor Details

    • MiniMessageBridge

      public MiniMessageBridge()
  • Method Details

    • parse

      public static net.kyori.adventure.text.Component parse(String input, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... resolvers)
      Deserializes a MiniMessage string into an Adventure Component.
      Parameters:
      input - The string containing MiniMessage tags.
      resolvers - Optional TagResolvers for custom placeholder handling.
      Returns:
      The parsed Component.
    • toHex

      public static String toHex(org.bukkit.Color color)
      Converts a Bukkit Color into a MiniMessage-compatible hex tag.
      Parameters:
      color - The Color to format.
      Returns:
      A string formatted as <#RRGGBB>.
    • toLegacyHex

      public static String toLegacyHex(org.bukkit.Color color)
      Converts a Bukkit Color into a legacy Bukkit hex code.
      Parameters:
      color - The Color to format.
      Returns:
      A string formatted as &#RRGGBB.
    • convertToLegacy

      public static String convertToLegacy(net.kyori.adventure.text.Component component)
      Serializes an Adventure Component into a legacy Bukkit string.
      Parameters:
      component - The Component to serialize.
      Returns:
      A legacy-formatted string with color codes.
    • stripTags

      public static String stripTags(String input)
      Strips all MiniMessage tags from an input string, leaving only plain text.
      Parameters:
      input - The tagged string.
      Returns:
      The cleaned plain text.
    • generateGradientTag

      public static String generateGradientTag(AbstractGradient gradient, String phase)
      Generates a MiniMessage gradient tag from an AbstractGradient.
      Parameters:
      gradient - The source AbstractGradient.
      phase - An optional phase/offset parameter for the gradient.
      Returns:
      A formatted <gradient:#RRGGBB:#RRGGBB...:phase> tag.
    • render

      public static net.kyori.adventure.text.Component render(String text, ColorProvider provider)
      Renders a string with colors provided by a ColorProvider per character.
      Parameters:
      text - The text to render.
      provider - The ColorProvider logic to apply.
      Returns:
      A Component with procedural coloring.
    • render

      public static net.kyori.adventure.text.Component render(String text, ColorProvider provider, double phase)
      Renders a string with procedural colors and a specific starting phase.
      Parameters:
      text - The text to render.
      provider - The ColorProvider.
      phase - The temporal offset (0.0 to 1.0).
      Returns:
      A Component with procedural coloring.
    • render

      public static net.kyori.adventure.text.Component render(String text, ColorProvider provider, double phase, double frequency)
      Renders a string with procedural colors, phase, and frequency modulation.
      Parameters:
      text - The text to render.
      provider - The ColorProvider.
      phase - The temporal offset (0.0 to 1.0).
      frequency - The spatial frequency (how fast the colors change across the string).
      Returns:
      A Component with procedural coloring.
    • animator

      public static MiniMessageBridge.Animator animator(String text, ColorProvider provider)
      Creates an animator for the specified text and provider.
      Parameters:
      text - The text to animate.
      provider - The ColorProvider providing colors.
      Returns:
      A new MiniMessageBridge.Animator instance.
    • animator

      public static MiniMessageBridge.Animator animator(String text, ColorProvider provider, double speed)
      Creates an animator with a custom animation speed.
      Parameters:
      text - The text to animate.
      provider - The ColorProvider.
      speed - The phase increment per frame.
      Returns:
      A new MiniMessageBridge.Animator instance.
    • toRainbow

      public static String toRainbow(String phase)
      Returns a MiniMessage rainbow tag.
      Parameters:
      phase - The phase/offset for the rainbow.
      Returns:
      A <rainbow:phase> tag.
    • fromMiniMessageGradient

      public static ColorProvider fromMiniMessageGradient(String gradientString)
      Parses a MiniMessage gradient-style string into an internal ColorProvider.
      Parameters:
      gradientString - A colon-separated string of colors (e.g., "#FF0000:blue:white").
      Returns:
      A ColorProvider representing the linear gradient defined by the string.