diff --git a/src/main/kotlin/net/axay/kspigot/chat/LiteralTextBuilder.kt b/src/main/kotlin/net/axay/kspigot/chat/LiteralTextBuilder.kt index 631ab222..a7888595 100644 --- a/src/main/kotlin/net/axay/kspigot/chat/LiteralTextBuilder.kt +++ b/src/main/kotlin/net/axay/kspigot/chat/LiteralTextBuilder.kt @@ -71,6 +71,23 @@ class LiteralTextBuilder(val internalText: BaseComponent, ) { siblingText.addExtra(LiteralTextBuilder(text).apply(builder).build()) } + /** + * Append the given legacy text to the parent. This + * allows you to use legacy color codes (e.g. `§c` for red). + * It is **not** recommended to use this. + * + * @param text the text instance + * @param builder the builder which can be used to set the style and add child text components + */ + inline fun legacyText( + text: String, + builder: LiteralTextBuilder.() -> Unit = { } + ) { + TextComponent.fromLegacyText(text).forEach { + siblingText.addExtra(LiteralTextBuilder(it).apply(builder).build()) + } + } + /** * Sets the text which should be displayed when hovering * over the text in the chat.