MiniMessageParser

public final class MiniMessageParser

A self-contained MiniMessage parser that emits BungeeCord BaseComponents — the component API already on the Spigot classpath and already used by Logger/SpigotMessage. No Kyori Adventure dependency.

Why BungeeCord components

BungeeCord's net.md_5.bungee.api.chat package is itself a full component tree: colours, hex, decorations, hover, click, insertion, font, keybind and translatable components are all representable, so the interactive half of MiniMessage is just a matter of wiring the parser to the right component setters rather than a reason to shade Adventure.

Outputs

  • parse → rich BaseComponent[] for message/title sinks (full hover/click/font/keybind fidelity).
  • toLegacy → a legacy §-coded string for name sinks (setDisplayName/setCustomName); colours/gradients/decorations survive, interactive events drop (names can't carry them anyway).

Backwards compatibility

Both entry points first run applyLegacy, which rewrites legacy &/§ colour and format codes (including &#rrggbb and the BungeeCord &x&r&r… hex form) into MiniMessage tags. A legacy colour code resets decorations, matching how the vanilla client renders § strings, so existing config text keeps its exact appearance. The historical MagmaCore tags (<gradient>, <rainbow>, <#hex>) and their short aliases (<g:…>, <r>) are accepted too.

Lenient parsing

Unrecognised or malformed <…> (e.g. a literal role name like <Quest Giver>), stray closing tags and \< are left verbatim; unclosed tags auto-close at end of input.

Coverage

Implemented: named colours, <#rrggbb>, <color:…>, decorations + negation, reset, gradient (with per-segment nested-colour overrides), rainbow, transition, pride, newline, hover (show_text / show_item / show_entity), click (all actions), insert/insertion, font, key, lang/translatable (with arguments). Recognised but with their effect dropped (server-rendered or too new for the BungeeCord component API), consumed rather than printed literally: <nbt>, <score>, <selector>, <sprite>, <head> emit nothing, while <shadow> still renders its inner text (only the shadow colour is ignored).

Functions

Link copied to clipboard
public static Array<BaseComponent> parse(String input)
Parses MiniMessage (and legacy & codes) into rich BungeeCord components.
Link copied to clipboard
public static String toLegacy(String input)
Parses MiniMessage and serialises down to a legacy §-coded string (hex-aware).