Skip to content

Commit

Permalink
legacy chat component reading: remove quotes around text + test
Browse files Browse the repository at this point in the history
  • Loading branch information
Bixilon committed Aug 6, 2024
1 parent 84e9c89 commit dddd0eb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 8 additions & 4 deletions src/test/java/de/bixilon/minosoft/data/text/ChatComponentTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,16 @@ internal class ChatComponentTest {
}

@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 chat = ChatComponent.of(string)

TODO()
val text = ChatComponent.of(string)

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) {
Expand Down

0 comments on commit dddd0eb

Please sign in to comment.