Compare commits
No commits in common. "5b43aed0b490b7f345d0f662d5f7cd528506adae" and "544abd218cf4c06d2ff5e46dac443f943fdb9a03" have entirely different histories.
5b43aed0b4
...
544abd218c
@ -1,69 +1,65 @@
|
|||||||
package fr.pandacube.lib.paper.util;
|
package fr.pandacube.lib.paper.util;
|
||||||
|
|
||||||
|
import org.bukkit.DyeColor;
|
||||||
|
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.format.TextColor;
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
import org.bukkit.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import org.bukkit.DyeColor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Utility class around chat coloring.
|
|
||||||
*/
|
|
||||||
public class BukkitChatColorUtil {
|
public class BukkitChatColorUtil {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link TextColor} that is visually the closest from the provided {@link DyeColor} when used on a sign.
|
* Returns the {@link ChatColor} that is visually the closest from the provided {@link DyeColor} when used on a sign.
|
||||||
|
*
|
||||||
|
* Multiple {@link DyeColor} may return the same
|
||||||
* @param dye the provided dye color
|
* @param dye the provided dye color
|
||||||
* @return the closest chat color from {@code dye}
|
* @return the closest chat color from {@code dye}
|
||||||
*/
|
*/
|
||||||
public static TextColor fromDyeToSignColor(DyeColor dye) {
|
public static ChatColor fromDyeToSignColor(DyeColor dye) {
|
||||||
//org.bukkit.Color col = dye.getColor();
|
//org.bukkit.Color col = dye.getColor();
|
||||||
//return ChatColor.of(new Color(col.asRGB()));
|
//return ChatColor.of(new Color(col.asRGB()));
|
||||||
// hmmm this is not that simple, of course
|
// hmmm this is not that simple, of course
|
||||||
|
|
||||||
// black
|
// black
|
||||||
return switch (dye) {
|
return switch (dye) {
|
||||||
case BLACK -> TextColor.fromHexString("#000000");
|
case BLACK -> ChatColor.of("#000000");
|
||||||
case RED -> TextColor.fromHexString("#650000");
|
case RED -> ChatColor.of("#650000");
|
||||||
case GREEN -> TextColor.fromHexString("#006500");
|
case GREEN -> ChatColor.of("#006500");
|
||||||
case BROWN -> TextColor.fromHexString("#361B07");
|
case BROWN -> ChatColor.of("#361B07");
|
||||||
case BLUE -> TextColor.fromHexString("#000065");
|
case BLUE -> ChatColor.of("#000065");
|
||||||
case PURPLE -> TextColor.fromHexString("#3F0C5F");
|
case PURPLE -> ChatColor.of("#3F0C5F");
|
||||||
case CYAN -> TextColor.fromHexString("#006565");
|
case CYAN -> ChatColor.of("#006565");
|
||||||
case LIGHT_GRAY -> TextColor.fromHexString("#535353");
|
case LIGHT_GRAY -> ChatColor.of("#535353");
|
||||||
case GRAY -> TextColor.fromHexString("#323232");
|
case GRAY -> ChatColor.of("#323232");
|
||||||
case PINK -> TextColor.fromHexString("#652947");
|
case PINK -> ChatColor.of("#652947");
|
||||||
case LIME -> TextColor.fromHexString("#4B6500");
|
case LIME -> ChatColor.of("#4B6500");
|
||||||
case YELLOW -> TextColor.fromHexString("#656500");
|
case YELLOW -> ChatColor.of("#656500");
|
||||||
case LIGHT_BLUE -> TextColor.fromHexString("#3C4B51");
|
case LIGHT_BLUE -> ChatColor.of("#3C4B51");
|
||||||
case MAGENTA -> TextColor.fromHexString("#650065");
|
case MAGENTA -> ChatColor.of("#650065");
|
||||||
case ORANGE -> TextColor.fromHexString("#65280C");
|
case ORANGE -> ChatColor.of("#65280C");
|
||||||
case WHITE -> TextColor.fromHexString("#656565");
|
case WHITE -> ChatColor.of("#656565");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static ChatColor toBukkit(net.md_5.bungee.api.ChatColor color) {
|
public static org.bukkit.ChatColor toBukkit(ChatColor color) {
|
||||||
return ChatColor.valueOf(color.getName().toUpperCase());
|
return org.bukkit.ChatColor.valueOf(color.getName().toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ChatColor toBukkit(TextColor color) {
|
public static org.bukkit.ChatColor toBukkit(TextColor color) {
|
||||||
return toBukkit(NamedTextColor.nearestTo(color));
|
return toBukkit(NamedTextColor.nearestTo(color));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ChatColor toBukkit(NamedTextColor color) {
|
public static org.bukkit.ChatColor toBukkit(NamedTextColor color) {
|
||||||
return ChatColor.valueOf(color.toString().toUpperCase());
|
return org.bukkit.ChatColor.valueOf(color.toString().toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NamedTextColor toAdventure(ChatColor color) {
|
public static NamedTextColor toAdventure(org.bukkit.ChatColor color) {
|
||||||
return NamedTextColor.NAMES.value(color.name().toLowerCase());
|
return NamedTextColor.NAMES.value(color.name().toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NamedTextColor toAdventure(net.md_5.bungee.api.ChatColor color) {
|
|
||||||
return NamedTextColor.NAMES.value(color.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -106,11 +106,6 @@ public abstract class AbstractClientWS implements AbstractWS {
|
|||||||
private void reconnectIfNecessary() {
|
private void reconnectIfNecessary() {
|
||||||
synchronized (socket) {
|
synchronized (socket) {
|
||||||
if (autoReconnect && !isConnecting && socket.get() == null) {
|
if (autoReconnect && !isConnecting && socket.get() == null) {
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
} catch (InterruptedException ignored) {
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
|
||||||
connect();
|
connect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user