From 3d25b39a8c4d269a11a8982dbc9d4bee14164544 Mon Sep 17 00:00:00 2001 From: bluefireoly Date: Sat, 3 Oct 2020 23:12:47 +0200 Subject: [PATCH] Added legacyText support to component builder --- src/main/kotlin/net/axay/kspigot/chat/KSpigotChat.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/kotlin/net/axay/kspigot/chat/KSpigotChat.kt b/src/main/kotlin/net/axay/kspigot/chat/KSpigotChat.kt index af3da58c..2dcb3e1a 100644 --- a/src/main/kotlin/net/axay/kspigot/chat/KSpigotChat.kt +++ b/src/main/kotlin/net/axay/kspigot/chat/KSpigotChat.kt @@ -16,6 +16,8 @@ class KSpigotComponentBuilder { private val components = ArrayList() + // COMPONENTS + inline fun text(text: String, builder: TextComponent.() -> Unit = { }) { this += TextComponent(text).apply(builder) } @@ -39,6 +41,12 @@ class KSpigotComponentBuilder { this += TranslatableComponent(translatable, with).apply(builder) } + // SPECIAL + + fun legacyText(text: String, color: ChatColor = ChatColor.WHITE) { + this += TextComponent.fromLegacyText(text, color) + } + operator fun plusAssign(baseComponent: BaseComponent) { components += baseComponent } operator fun plusAssign(baseComponents: Array) { components += baseComponents }