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 (char == '>') {
inTag = false
if (currentComponent.isNotEmpty())
when (currentComponent.toString()) {
"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()}")
else -> components[components.lastIndex] = "${components[components.lastIndex]}<${currentComponent}>"
}
currentComponent.clear()
} else
currentComponent.append(char)
} else
@ -80,11 +83,17 @@ abstract class TwoCycleFormatterImpl: TwoCycleFormatter() {
currentComponent.append(char)
} else
inTag = true
if (currentComponent.isNotEmpty())
components.add("TEXT:${currentComponent}")
currentComponent.clear()
}
else -> currentComponent.append(char)
}
if (currentComponent.isNotEmpty())
components.add("TEXT:${currentComponent}")
return components.toTypedArray()
}
}