Add support for legacyText

This commit is contained in:
Jakob K
2021-06-28 01:38:53 +02:00
parent 2ddd43a86b
commit 528d8abe3f

View File

@@ -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.