Add an extension function for the new text builder

This commit is contained in:
Jakob K
2021-06-28 01:49:07 +02:00
parent 2b77e6ab15
commit 7b1487b563

View File

@@ -9,6 +9,22 @@ fun CommandSender.sendMessage(vararg components: BaseComponent) {
this.spigot().sendMessage(*components)
}
/**
* Opens a [LiteralTextBuilder].
*
* @param baseText the text you want to begin with, it is okay to let this empty
* @param builder the builder which can be used to set the style and add child text components
*/
inline fun CommandSender.sendText(
baseText: String = "",
crossinline builder: LiteralTextBuilder.() -> Unit = { }
) = this.spigot().sendMessage(literalText(baseText, builder))
@Suppress("DEPRECATION")
@Deprecated(
"Outdated api, use literalText instead",
ReplaceWith("sendText { builder.invoke() }", "net.axay.kspigot.chat.sendText")
)
fun CommandSender.sendMessage(builder: KSpigotComponentBuilder.() -> Unit) {
this.spigot().sendMessage(*KSpigotComponentBuilder().apply(builder).create())
}