diff --git a/Essentials/src/main/java/com/earth2me/essentials/utils/FormatUtil.java b/Essentials/src/main/java/com/earth2me/essentials/utils/FormatUtil.java index 6ce0b7f29..55731454b 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/utils/FormatUtil.java +++ b/Essentials/src/main/java/com/earth2me/essentials/utils/FormatUtil.java @@ -2,8 +2,8 @@ package com.earth2me.essentials.utils; import net.ess3.api.IUser; import org.bukkit.ChatColor; +import org.bukkit.Color; -import java.awt.Color; import java.util.EnumSet; import java.util.Locale; import java.util.Set; @@ -129,7 +129,9 @@ public final class FormatUtil { if (hexColor.length() != 6) { throw new NumberFormatException("Invalid hex length"); } - Color.decode("#" + hexColor); + + //noinspection ResultOfMethodCallIgnored + Color.fromRGB(Integer.decode("#" + hexColor)); final StringBuilder assembledColorCode = new StringBuilder(); assembledColorCode.append(ChatColor.COLOR_CHAR + "x"); for (final char curChar : hexColor.toCharArray()) { diff --git a/EssentialsDiscord/src/main/java/net/essentialsx/discord/util/DiscordUtil.java b/EssentialsDiscord/src/main/java/net/essentialsx/discord/util/DiscordUtil.java index 45ccd551a..3de1e1f21 100644 --- a/EssentialsDiscord/src/main/java/net/essentialsx/discord/util/DiscordUtil.java +++ b/EssentialsDiscord/src/main/java/net/essentialsx/discord/util/DiscordUtil.java @@ -19,7 +19,6 @@ import net.essentialsx.discord.JDADiscordService; import okhttp3.OkHttpClient; import org.bukkit.Bukkit; -import java.awt.Color; import java.util.List; import java.util.UUID; import java.util.concurrent.CompletableFuture; @@ -129,17 +128,17 @@ public final class DiscordUtil { * @return The bukkit color code or blank string. */ public static String getRoleColorFormat(Member member) { - final Color color = member.getColor(); + final int rawColor = member.getColorRaw(); - if (color == null) { + if (rawColor == Role.DEFAULT_COLOR_RAW) { return ""; } if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_16_1_R01)) { // Essentials' FormatUtil allows us to not have to use bungee's chatcolor since bukkit's own one doesn't support rgb - return FormatUtil.replaceFormat("&#" + Integer.toHexString(color.getRGB()).substring(2)); + return FormatUtil.replaceFormat("&#" + Integer.toHexString(rawColor).substring(2)); } - return FormatUtil.replaceFormat("&" + DownsampleUtil.nearestTo(color.getRGB())); + return FormatUtil.replaceFormat("&" + DownsampleUtil.nearestTo(rawColor)); } /**