Class MiniMessageBridge
java.lang.Object
com.github.darksoulq.abyssallib.common.color.MiniMessageBridge
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA utility class for handling stateful text color animations. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic MiniMessageBridge.Animatoranimator(String text, ColorProvider provider) Creates an animator for the specified text and provider.static MiniMessageBridge.Animatoranimator(String text, ColorProvider provider, double speed) Creates an animator with a custom animation speed.static StringconvertToLegacy(net.kyori.adventure.text.Component component) Serializes an Adventure Component into a legacy Bukkit string.static ColorProviderfromMiniMessageGradient(String gradientString) Parses a MiniMessage gradient-style string into an internalColorProvider.static StringgenerateGradientTag(AbstractGradient gradient, String phase) Generates a MiniMessage gradient tag from anAbstractGradient.static net.kyori.adventure.text.ComponentDeserializes a MiniMessage string into an AdventureComponent.static net.kyori.adventure.text.Componentrender(String text, ColorProvider provider) Renders a string with colors provided by aColorProviderper character.static net.kyori.adventure.text.Componentrender(String text, ColorProvider provider, double phase) Renders a string with procedural colors and a specific starting phase.static net.kyori.adventure.text.Componentrender(String text, ColorProvider provider, double phase, double frequency) Renders a string with procedural colors, phase, and frequency modulation.static StringStrips all MiniMessage tags from an input string, leaving only plain text.static StringtoHex(org.bukkit.Color color) Converts a Bukkit Color into a MiniMessage-compatible hex tag.static StringtoLegacyHex(org.bukkit.Color color) Converts a Bukkit Color into a legacy Bukkit hex code.static StringReturns a MiniMessage rainbow tag.
-
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 AdventureComponent.- Parameters:
input- The string containing MiniMessage tags.resolvers- OptionalTagResolvers for custom placeholder handling.- Returns:
- The parsed
Component.
-
toHex
Converts a Bukkit Color into a MiniMessage-compatible hex tag.- Parameters:
color- TheColorto format.- Returns:
- A string formatted as
<#RRGGBB>.
-
toLegacyHex
Converts a Bukkit Color into a legacy Bukkit hex code.- Parameters:
color- TheColorto format.- Returns:
- A string formatted as
&#RRGGBB.
-
convertToLegacy
Serializes an Adventure Component into a legacy Bukkit string.- Parameters:
component- TheComponentto serialize.- Returns:
- A legacy-formatted string with color codes.
-
stripTags
-
generateGradientTag
Generates a MiniMessage gradient tag from anAbstractGradient.- Parameters:
gradient- The sourceAbstractGradient.phase- An optional phase/offset parameter for the gradient.- Returns:
- A formatted
<gradient:#RRGGBB:#RRGGBB...:phase>tag.
-
render
Renders a string with colors provided by aColorProviderper character.- Parameters:
text- The text to render.provider- TheColorProviderlogic to apply.- Returns:
- A
Componentwith 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- TheColorProvider.phase- The temporal offset (0.0 to 1.0).- Returns:
- A
Componentwith 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- TheColorProvider.phase- The temporal offset (0.0 to 1.0).frequency- The spatial frequency (how fast the colors change across the string).- Returns:
- A
Componentwith procedural coloring.
-
animator
Creates an animator for the specified text and provider.- Parameters:
text- The text to animate.provider- TheColorProviderproviding colors.- Returns:
- A new
MiniMessageBridge.Animatorinstance.
-
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- TheColorProvider.speed- The phase increment per frame.- Returns:
- A new
MiniMessageBridge.Animatorinstance.
-
toRainbow
-
fromMiniMessageGradient
Parses a MiniMessage gradient-style string into an internalColorProvider.- Parameters:
gradientString- A colon-separated string of colors (e.g., "#FF0000:blue:white").- Returns:
- A
ColorProviderrepresenting the linear gradient defined by the string.
-