use the adventure api

- migrate BungeeCord Chat API to Adventure API
- add some functions to literalText
- update some dependencies and plugins
This commit is contained in:
l4zs
2022-01-08 22:30:09 +01:00
parent 6bacddfdb5
commit 9c008dcba4
11 changed files with 156 additions and 84 deletions

View File

@@ -1,6 +1,9 @@
@file:Suppress("Unused")
package net.axay.kspigot.extensions
import net.axay.kspigot.main.PluginInstance
import net.kyori.adventure.text.Component.text
import org.bukkit.Bukkit
import org.bukkit.NamespacedKey
import org.bukkit.World
@@ -36,7 +39,7 @@ val pluginManager get() = Bukkit.getPluginManager()
* @return the number of recipients
* @see Bukkit.broadcastMessage
*/
fun broadcast(msg: String) = Bukkit.broadcastMessage(msg)
fun broadcast(msg: String) = Bukkit.getServer().broadcast(text(msg))
/**
* Shortcut to get the ConsoleSender.

View File

@@ -1,3 +1,5 @@
@file:Suppress("Unused")
package net.axay.kspigot.extensions.bukkit
import net.axay.kspigot.annotations.NMS_General
@@ -5,7 +7,6 @@ import net.axay.kspigot.chat.literalText
import net.axay.kspigot.extensions.onlinePlayers
import net.axay.kspigot.main.PluginInstance
import net.axay.kspigot.pluginmessages.PluginMessageConnect
import net.md_5.bungee.api.ChatMessageType
import org.bukkit.Location
import org.bukkit.Material
import org.bukkit.attribute.Attribute
@@ -146,7 +147,7 @@ fun Player.getHandItem(hand: EquipmentSlot?) = when (hand) {
* Sends the given [text] as an action bar message.
*/
fun Player.actionBar(text: String) {
spigot().sendMessage(ChatMessageType.ACTION_BAR, literalText { legacyText(text) })
sendActionBar(literalText { legacyText(text) })
}
/**

View File

@@ -1,11 +1,12 @@
package net.axay.kspigot.extensions.bukkit
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer
import org.bukkit.inventory.meta.BookMeta
val BookMeta.content
get() =
StringBuilder().apply {
for (it in pages) {
for (it in pages().map { LegacyComponentSerializer.legacy('§').serialize(it) }) {
if (isNotEmpty())
append('\n')
append(it)