From 2be48c7c308ebfcee49f49eeb0e8279e09a0778b Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 16 Apr 2024 20:32:48 +0100 Subject: [PATCH] maybe bold for html? --- .../mcutils/backend/common/ColorUtils.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main/java/xyz/mcutils/backend/common/ColorUtils.java b/src/main/java/xyz/mcutils/backend/common/ColorUtils.java index 75b10e0..bae4e05 100644 --- a/src/main/java/xyz/mcutils/backend/common/ColorUtils.java +++ b/src/main/java/xyz/mcutils/backend/common/ColorUtils.java @@ -46,10 +46,18 @@ public final class ColorUtils { return STRIP_COLOR_PATTERN.matcher(input).replaceAll(""); } + /** + * Convert the given input + * into HTML. + * + * @param input the input to convert + * @return the HTML converted input + */ @NonNull public static String toHTML(@NonNull String input) { StringBuilder builder = new StringBuilder(); boolean nextIsColor = false; // Is the next char a color code? + boolean isBold = false; // Is the text currently bold? // Get the leading spaces from the first line int leadingSpaces = 0; @@ -74,6 +82,19 @@ public final class ColorUtils { nextIsColor = false; continue; } + if (character == 'l') { // Start bold + isBold = true; + builder.append(""); + continue; + } + if (character == 'r') { // Reset formatting + if (isBold) { + builder.append(""); + isBold = false; + } + builder.append(""); + continue; + } if (character == ' ') { // Preserve space character builder.append(" "); } else { @@ -86,4 +107,5 @@ public final class ColorUtils { return builder.toString(); } + } \ No newline at end of file