Interface Formatter<T>
- Type Parameters:
T- formatter result type
PrismaticAPI.legacy() and PrismaticAPI.adventure()
facades.
Both facades use the same Prismatic parsing pipeline and only differ in the type they emit:
legacy output returns strings, while Adventure output returns
components.
- Since:
- 1.4.0
-
Method Summary
Modifier and TypeMethodDescriptionapplyColor(Color color, String string, boolean legacy) Applies a single color to the beginning of a string.applyGradient(String string, Color start, Color end, boolean legacy) Applies a per-character gradient between two colors.applyRainbow(String string, float saturation, boolean legacy) Applies a per-character rainbow effect.default TParses and colorizes a string without player context.Parses and colorizes a string using the full Prismatic pipeline for a specific player context.default net.md_5.bungee.api.ChatColorfromString(String string) Parses a color token into a chat color.net.md_5.bungee.api.ChatColorfromString(String string, boolean legacy) Converts a bare six-digit hexadecimal RGB value into a chat color.@Nullable StringgetEndColor(String string) Returns the last color code found in the formatted representation of a string.@Nullable StringgetStartColor(String string) Returns the first color code found in the formatted representation of a string.booleanstartsWithColor(String string) Determines whether the formatted representation of a string starts with a color code.Removes Bukkit colors, Bukkit special formatting, MiniMessage tags and Prismatic RGB syntax from a string.stripBukkit(String string) Removes standard Bukkit color codes from a string.stripMiniMessage(String string) Removes MiniMessage formatting tags from a string.Removes Prismatic RGB, gradient and rainbow syntax from a string while leaving legacy Bukkit codes untouched.stripSpecial(String string) Removes Bukkit special formatting codes from a string.
-
Method Details
-
fromString
Converts a bare six-digit hexadecimal RGB value into a chat color.When
legacyisfalse, the exact RGB value is preserved. Whenlegacyistrue, the result is downsampled to the nearest legacy Bukkit color.- Parameters:
string- six-digit hexadecimal RGB value without a leading#legacy- whether to downsample the resulting color to the legacy palette- Returns:
- the parsed chat color
- Throws:
NumberFormatException- ifstringis not a valid six-digit hexadecimal RGB value
-
fromString
Parses a color token into a chat color.This overload accepts plain legacy codes such as
a, prefixed legacy codes such as&aor§a, exact RGB values such asff8800, and compact hex tokens such as&xff8800. Blank input falls back toChatColor.WHITE.- Parameters:
string- color token to parse- Returns:
- the parsed chat color, or white when the input is blank or unrecognized
-
applyColor
Applies a single color to the beginning of a string.- Parameters:
color- color to prependstring- text to receive the colorlegacy- whether to use the nearest legacy Bukkit color instead of exact RGB- Returns:
- the colorized output
-
applyGradient
Applies a per-character gradient between two colors.- Parameters:
string- text to colorizestart- gradient start colorend- gradient end colorlegacy- whether to downsample each generated step to the legacy Bukkit palette- Returns:
- the gradient-colored output
-
applyRainbow
Applies a per-character rainbow effect.- Parameters:
string- text to colorizesaturation- rainbow saturation/brightness factor used to generate the palettelegacy- whether to downsample each generated step to the legacy Bukkit palette- Returns:
- the rainbow-colored output
-
colorize
Parses and colorizes a string using the full Prismatic pipeline for a specific player context.If the player supports hex colors, RGB output is preserved. Otherwise the result is downsampled to legacy-safe colors.
- Parameters:
player- player used to resolve runtime color capabilities, ornullto force the conservative legacy fallbackstring- text to parse and colorize- Returns:
- the formatted output
-
colorize
Parses and colorizes a string without player context.This delegates to
colorize(Player, String)with anullplayer, which means the formatting pipeline uses the conservative legacy fallback because no player capability information is available.- Parameters:
string- text to parse and colorize- Returns:
- the formatted output
-
stripBukkit
Removes standard Bukkit color codes from a string.- Parameters:
string- text to clean- Returns:
- the string without standard Bukkit color codes
-
stripSpecial
Removes Bukkit special formatting codes from a string.- Parameters:
string- text to clean- Returns:
- the string without Bukkit special formatting codes
-
stripRGB
Removes Prismatic RGB, gradient and rainbow syntax from a string while leaving legacy Bukkit codes untouched.- Parameters:
string- text to clean- Returns:
- the string without Prismatic RGB syntax
-
stripMiniMessage
Removes MiniMessage formatting tags from a string.- Parameters:
string- text to clean- Returns:
- the string without MiniMessage tags
-
stripAll
Removes Bukkit colors, Bukkit special formatting, MiniMessage tags and Prismatic RGB syntax from a string.- Parameters:
string- text to clean- Returns:
- the fully stripped plain-text string
-
startsWithColor
Determines whether the formatted representation of a string starts with a color code.- Parameters:
string- text to inspect- Returns:
trueif the formatted output begins with a color code
-
getStartColor
Returns the first color code found in the formatted representation of a string.- Parameters:
string- text to inspect- Returns:
- the first detected color code, or
nullif none is present
-
getEndColor
Returns the last color code found in the formatted representation of a string.- Parameters:
string- text to inspect- Returns:
- the last detected color code, or
nullif none is present
-