Skip to content

Commit

Permalink
use minimessage instead of deprecated chatcolor
Browse files Browse the repository at this point in the history
  • Loading branch information
emmaboecker committed Apr 16, 2023
1 parent 194577d commit cb41d34
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/main/kotlin/de/nycode/slpf/SimpleLuckPermsFormatter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import io.papermc.paper.event.player.AsyncChatEvent
import net.kyori.adventure.text.Component
import net.kyori.adventure.text.JoinConfiguration
import net.kyori.adventure.text.format.NamedTextColor
import net.kyori.adventure.text.minimessage.MiniMessage
import net.luckperms.api.LuckPerms
import net.luckperms.api.event.group.GroupCreateEvent
import net.luckperms.api.event.group.GroupDataRecalculateEvent
import net.luckperms.api.event.group.GroupDeleteEvent
import net.luckperms.api.event.user.UserDataRecalculateEvent
import net.luckperms.api.model.group.Group
import org.bukkit.Bukkit
import org.bukkit.ChatColor
import org.bukkit.entity.Player
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
Expand All @@ -25,6 +25,8 @@ class SimpleLuckPermsFormatter : JavaPlugin(), Listener {
private lateinit var chatFormat: String
private var useColorInsteadOfPrefix: Boolean = true

private val miniMessage = MiniMessage.miniMessage()

override fun onEnable() {
luckPerms = loadLuckPerms() ?: error("Unable to load the LuckPerms API")
Bukkit.getPluginManager()
Expand Down Expand Up @@ -56,20 +58,10 @@ class SimpleLuckPermsFormatter : JavaPlugin(), Listener {
.forEachIndexed { index, group ->
val team = scoreboard.registerNewTeam(getFormattedWeight(group.weight.orElse(index)) + group.name)
team.prefix(
Component.text(
ChatColor
.translateAlternateColorCodes(
'&', group.cachedData.metaData.prefix ?: ""
)
)
miniMessage.deserialize(group.cachedData.metaData.prefix ?: "")
)
team.suffix(
Component.text(
ChatColor
.translateAlternateColorCodes(
'&', group.cachedData.metaData.suffix ?: ""
)
)
miniMessage.deserialize(group.cachedData.metaData.suffix ?: "")
)
team.color(
NamedTextColor.NAMES.value(group.cachedData.metaData.getMetaValue("color")?.lowercase() ?: "gray")
Expand Down

0 comments on commit cb41d34

Please sign in to comment.