From 316894dbe06bf10554443f3706481df83a20e8cf Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Sun, 18 Jul 2021 22:55:44 +0200 Subject: [PATCH] Additionnal methods in BukkitChatColorUtil for Adventure colors --- .../lib/paper/util/BukkitChatColorUtil.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Paper/src/main/java/fr/pandacube/lib/paper/util/BukkitChatColorUtil.java b/Paper/src/main/java/fr/pandacube/lib/paper/util/BukkitChatColorUtil.java index faa4b85..215be61 100644 --- a/Paper/src/main/java/fr/pandacube/lib/paper/util/BukkitChatColorUtil.java +++ b/Paper/src/main/java/fr/pandacube/lib/paper/util/BukkitChatColorUtil.java @@ -2,6 +2,8 @@ package fr.pandacube.lib.paper.util; import org.bukkit.DyeColor; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextColor; import net.md_5.bungee.api.ChatColor; public class BukkitChatColorUtil { @@ -59,12 +61,22 @@ public class BukkitChatColorUtil { throw new IllegalArgumentException("Unknown DyeColor: " + dye); } + - - public static org.bukkit.ChatColor fromBungeeToBukkit(ChatColor color) { + public static org.bukkit.ChatColor toBukkit(ChatColor color) { return org.bukkit.ChatColor.valueOf(color.getName().toUpperCase()); } + public static org.bukkit.ChatColor toBukkit(TextColor color) { + return toBukkit(NamedTextColor.nearestTo(color)); + } + public static org.bukkit.ChatColor toBukkit(NamedTextColor color) { + return org.bukkit.ChatColor.valueOf(color.toString()); + } + + public static NamedTextColor toAdventure(org.bukkit.ChatColor color) { + return NamedTextColor.NAMES.value(color.name()); + } }