Additionnal methods in BukkitChatColorUtil for Adventure colors

This commit is contained in:
Marc Baloup 2021-07-18 22:55:44 +02:00
parent 88e1959229
commit 316894dbe0
Signed by: marcbal
GPG Key ID: BBC0FE3ABC30B893
1 changed files with 14 additions and 2 deletions

View File

@ -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());
}
}