Class MiniMessageConverter

java.lang.Object
net.blockhost.commons.message.MiniMessageConverter

public final class MiniMessageConverter extends Object

Utility class for converting legacy Minecraft color codes to MiniMessage format.

This converter handles both section sign (§) and ampersand (&) color codes, including standard colors, formatting codes, and hex colors in various formats.

Supported Formats

Format Example Description
Standard colors &a, §c Legacy color codes 0-9 and a-f
Formatting &l, §o Bold, italic, underline, etc.
Hex (short) &#FF0000, §#FF0000 6-digit hex colors
Hex (ugly) &x&F&F&0&0&0&0 Spigot-style hex format

Example Usage

// Convert legacy colors to MiniMessage
String legacy = "&aHello &lWorld!";
String miniMessage = MiniMessageConverter.convert(legacy);
// Result: "<reset><green>Hello <bold>World!"

// Then parse with MiniMessage
Component component = MessageService.parse(miniMessage);
See Also:
  • Method Details

    • convert

      public static String convert(String str)

      Converts a string containing legacy color codes to MiniMessage format.

      This method handles both ampersand (&) and section sign (§) color codes, converting them to their MiniMessage tag equivalents.

      Parameters:
      str - the string containing legacy color codes
      Returns:
      the string with legacy codes converted to MiniMessage tags