Fix TwoCycleFormatterImpl parsing

This commit is contained in:
JeremyStar™ 2024-12-20 21:46:46 +01:00
parent 048ae6b074
commit 01c91244aa
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -57,6 +57,7 @@ abstract class TwoCycleFormatterImpl: TwoCycleFormatter() {
if (inTag) { if (inTag) {
if (char == '>') { if (char == '>') {
inTag = false inTag = false
if (currentComponent.isNotEmpty()) if (currentComponent.isNotEmpty())
when (currentComponent.toString()) { when (currentComponent.toString()) {
"reset" -> components.add("RESET") "reset" -> components.add("RESET")
@ -64,6 +65,8 @@ abstract class TwoCycleFormatterImpl: TwoCycleFormatter() {
"white", "black", "gray", "yellow", "green", "cyan", "light_blue", "blue", "purple", "magenta", "pink", "red", "orange" -> components.add("COLOR:${currentComponent.toString().uppercase()}") "white", "black", "gray", "yellow", "green", "cyan", "light_blue", "blue", "purple", "magenta", "pink", "red", "orange" -> components.add("COLOR:${currentComponent.toString().uppercase()}")
else -> components[components.lastIndex] = "${components[components.lastIndex]}<${currentComponent}>" else -> components[components.lastIndex] = "${components[components.lastIndex]}<${currentComponent}>"
} }
currentComponent.clear()
} else } else
currentComponent.append(char) currentComponent.append(char)
} else } else
@ -80,11 +83,17 @@ abstract class TwoCycleFormatterImpl: TwoCycleFormatter() {
currentComponent.append(char) currentComponent.append(char)
} else } else
inTag = true inTag = true
if (currentComponent.isNotEmpty())
components.add("TEXT:${currentComponent}")
currentComponent.clear() currentComponent.clear()
} }
else -> currentComponent.append(char) else -> currentComponent.append(char)
} }
if (currentComponent.isNotEmpty())
components.add("TEXT:${currentComponent}")
return components.toTypedArray() return components.toTypedArray()
} }
} }