finally support section signs i guess

This commit is contained in:
Chayapak 2023-05-06 16:52:04 +07:00
parent 24639b4043
commit 0a493b4466

View file

@ -175,8 +175,21 @@ public class ComponentUtilities {
public static Output stringifyPartially (TextComponent message, boolean motd, boolean ansi, String lastColor) {
if (motd || ansi) {
final String color = getColor(message.color(), motd, ansi);
String replacedContent = message.content();
// seems very mabe mabe
if (ansi) {
// is try-catch a great idea?
try {
replacedContent = Pattern
.compile("(\u00a7.)")
.matcher(message.content())
.replaceAll(m -> ansiMap.get(m.group(0).substring(1)));
} catch (Exception ignored) {}
}
// messy af
return new Output((lastColor != null ? lastColor : "") + (color != null ? color : "") + message.content() + (ansi ? ansiMap.get("r") : ""), color);
return new Output((lastColor != null ? lastColor : "") + (color != null ? color : "") + replacedContent + (ansi ? ansiMap.get("r") : ""), color);
}
return new Output(message.content(), null);