mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-14 14:45:27 +01:00
Remove usage of java.awt.Color (#4312)
This fixes issues on headless JREs which lack java.awt classes.
This commit is contained in:
parent
409210ccde
commit
7e25570344
@ -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()) {
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user