diff --git a/src/main/kotlin/net/axay/kspigot/chat/KSpigotChat.kt b/src/main/kotlin/net/axay/kspigot/chat/KSpigotChat.kt index d5f7d3cd..80fcb0eb 100644 --- a/src/main/kotlin/net/axay/kspigot/chat/KSpigotChat.kt +++ b/src/main/kotlin/net/axay/kspigot/chat/KSpigotChat.kt @@ -1,4 +1,4 @@ -@file:Suppress("MemberVisibilityCanBePrivate") +@file:Suppress("MemberVisibilityCanBePrivate", "DEPRECATION") package net.axay.kspigot.chat @@ -9,21 +9,48 @@ import net.md_5.bungee.api.chat.hover.content.Item import net.md_5.bungee.api.chat.hover.content.Text import java.awt.Color +@Deprecated( + "Outdated api, use literalText instead", + ReplaceWith("literalText { builder.invoke() }", "net.axay.kspigot.chat.literalText") +) inline fun chatComponent(builder: KSpigotComponentBuilder.() -> Unit): Array { return KSpigotComponentBuilder().apply(builder).create() } +@Deprecated( + "Outdated api, use literalText instead", + ReplaceWith("LiteralTextBuilder", "net.axay.kspigot.chat.LiteralTextBuilder") +) class KSpigotComponentBuilder { private val components = ArrayList() + + @Deprecated( + "Outdated api, use literalText instead", + ReplaceWith("text(text, builder)", "net.axay.kspigot.chat.LiteralTextBuilder.text") + ) inline fun text(text: String, builder: TextComponent.() -> Unit = { }) { this += TextComponent(text).apply(builder) } + @Deprecated( + "Outdated api, use literalText instead", + ReplaceWith( + "text(KeybindComponent(keybind)) { builder.invoke() }", + "net.axay.kspigot.chat.LiteralTextBuilder.text", "net.md_5.bungee.api.chat.KeybindComponent" + ) + ) inline fun keybind(keybind: String, builder: KeybindComponent.() -> Unit = { }) { this += KeybindComponent(keybind).apply(builder) } + @Deprecated( + "Outdated api, use literalText instead", + ReplaceWith( + "text(ScoreComponent(name, objective, value)) { builder.invoke() }", + "net.axay.kspigot.chat.LiteralTextBuilder.text", "net.md_5.bungee.api.chat.ScoreComponent" + ) + ) inline fun score(name: String, objective: String, value: String?, builder: ScoreComponent.() -> Unit = { }) { if (value != null) this += ScoreComponent(name, objective, value).apply(builder) @@ -31,10 +58,24 @@ class KSpigotComponentBuilder { this += ScoreComponent(name, objective).apply(builder) } + @Deprecated( + "Outdated api, use literalText instead", + ReplaceWith( + "text(SelectorComponent(selector)) { builder.invoke() }", + "net.axay.kspigot.chat.LiteralTextBuilder.text", "net.md_5.bungee.api.chat.SelectorComponent" + ) + ) inline fun selector(selector: String, builder: SelectorComponent.() -> Unit = { }) { this += SelectorComponent(selector).apply(builder) } + @Deprecated( + "Outdated api, use literalText instead", + ReplaceWith( + "text(TranslatableComponent(translatable, with)) { builder.invoke() }", + "net.axay.kspigot.chat.LiteralTextBuilder.text", "net.md_5.bungee.api.chat.TranslatableComponent" + ) + ) inline fun translatable( translatable: String, with: Array, @@ -43,14 +84,32 @@ class KSpigotComponentBuilder { this += TranslatableComponent(translatable, with).apply(builder) } + @Deprecated( + "Outdated api, use literalText instead", + ReplaceWith("legacyText(text) { builder.invoke(); this.color = color }", "net.axay.kspigot.chat.LiteralTextBuilder.legacyText") + ) fun legacyText(text: String, color: ChatColor = ChatColor.WHITE, builder: BaseComponent.() -> Unit = { }) { this += TextComponent.fromLegacyText(text, color).onEach { it.apply(builder) } } + @Deprecated( + "Outdated api, use literalText instead", + ReplaceWith( + "text(baseComponent)", + "net.axay.kspigot.chat.LiteralTextBuilder.text", "net.md_5.bungee.api.chat.BaseComponent" + ) + ) operator fun plusAssign(baseComponent: BaseComponent) { components += baseComponent } + @Deprecated( + "Outdated api, use literalText instead", + ReplaceWith( + "text(baseComponents)", + "net.axay.kspigot.chat.LiteralTextBuilder.text", "net.md_5.bungee.api.chat.BaseComponent" + ) + ) operator fun plusAssign(baseComponents: Array) { components += baseComponents }