legacy chat component reading: remove quotes around text + test

This commit is contained in:
Moritz Zwerger 2024-08-06 23:05:33 +02:00
parent 84e9c897aa
commit dddd0ebde4
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 9 additions and 5 deletions

View File

@ -121,7 +121,7 @@ interface ChatComponent {
} }
} }
return LegacyComponentReader.parse(parent, string, restricted).trim() ?: EmptyComponent return LegacyComponentReader.parse(parent, string.removeSurrounding("\""), restricted).trim() ?: EmptyComponent
} }
fun String.chat(): ChatComponent { fun String.chat(): ChatComponent {

View File

@ -319,12 +319,16 @@ internal class ChatComponentTest {
} }
@Test @Test
fun something() { // tree.ac fun `remove quotes around legacy text`() { // tree.ac
val string = """"§2Join the Other Server? Find it at §6Port 25566§2!"""" val string = """"§2Join the Other Server? Find it at §6Port 25566§2!""""
val chat = ChatComponent.of(string) val text = ChatComponent.of(string)
TODO()
val expected = BaseComponent(
TextComponent("Join the Other Server? Find it at ").color(ChatColors.DARK_GREEN),
TextComponent("Port 25566").color(ChatColors.GOLD),
TextComponent("!").color(ChatColors.DARK_GREEN),
)
assertEquals(text, expected)
} }
private fun assertEquals(expected: ChatComponent, actual: ChatComponent) { private fun assertEquals(expected: ChatComponent, actual: ChatComponent) {