PandaLib/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatConfig.java

162 lines
6.1 KiB
Java
Raw Normal View History

2022-07-30 13:58:16 +02:00
package fr.pandacube.lib.chat;
import java.util.function.Supplier;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextColor;
/**
* Class holding static configuration values for chat component rendering.
*/
@SuppressWarnings("CanBeFinal")
2022-07-30 13:58:16 +02:00
public class ChatConfig {
/**
* The color used for decoration.
*/
public static TextColor decorationColor = PandaTheme.CHAT_GREEN_1_NORMAL;
2022-07-30 13:58:16 +02:00
/**
* The character used as a pattern for decoration.
*/
public static char decorationChar = '-';
2022-07-30 13:58:16 +02:00
/**
* The number of decoration character to put between the text and the border of
* the line for left and right aligned text.
2022-07-30 13:58:16 +02:00
*/
public static int nbCharMargin = 1;
2022-07-30 13:58:16 +02:00
/**
* The color used for successful messages.
*/
public static TextColor successColor = PandaTheme.CHAT_GREEN_MAX_SAT;
2022-07-30 13:58:16 +02:00
/**
* The color used for error/failure messages.
*/
public static TextColor failureColor = PandaTheme.CHAT_RED_FAILURE;
2022-07-30 13:58:16 +02:00
/**
* the color used for informational messages.
*/
public static TextColor infoColor = PandaTheme.CHAT_GREEN_4;
2022-07-30 13:58:16 +02:00
/**
* The color used for warning messages.
*/
public static TextColor warningColor = PandaTheme.CHAT_BROWN_2_SAT;
2022-07-30 13:58:16 +02:00
/**
* The color used to display data in a message.
*/
2024-02-14 20:29:49 +01:00
public static TextColor dataColor = NamedTextColor.GRAY;
2022-07-30 13:58:16 +02:00
/**
* The color used for displayed URLs and clickable URLs.
*/
public static TextColor urlColor = PandaTheme.CHAT_GREEN_1_NORMAL;
2022-07-30 13:58:16 +02:00
/**
* The color used for displayed commands and clickable commands.
*/
public static TextColor commandColor = PandaTheme.CHAT_GRAY_MID;
2022-07-30 13:58:16 +02:00
/**
* The color sued to display a command that is highlighted. For example, the current page in a pagination.
*/
public static TextColor highlightedCommandColor = NamedTextColor.WHITE;
2022-07-30 13:58:16 +02:00
/**
* The color used for broadcast messages.
2022-07-30 13:58:16 +02:00
* It is often used in combination with {@link #prefix}.
*/
public static TextColor broadcastColor = NamedTextColor.YELLOW;
2022-07-30 13:58:16 +02:00
/**
* The prefix used for prefixed messages.
* It can be a stylized name of the server, like {@code "[Pandacube] "}.
2022-07-30 13:58:16 +02:00
* It is often used in combination with {@link #broadcastColor}.
*/
public static Supplier<Chat> prefix = PandaTheme::CHAT_MESSAGE_PREFIX;
2022-07-30 13:58:16 +02:00
/**
* Gets the width of the configured {@link #prefix}.
* @param console if the width has to be calculated for the console or not.
* @return the width of the configured {@link #prefix}.
*/
public static int getPrefixWidth(boolean console) {
Chat c;
return prefix == null ? 0 : (c = prefix.get()) == null ? 0 : ChatUtil.componentWidth(c.getAdv(), console);
}
2023-02-22 16:40:08 +01:00
/**
* A set of predefined colors.
*/
public static class PandaTheme {
2023-02-22 16:40:08 +01:00
/** Green 1 color. */
public static final TextColor CHAT_GREEN_1_NORMAL = TextColor.fromHexString("#3db849"); // h=126 s=50 l=48
2023-02-22 16:40:08 +01:00
/** Green 2 color. */
public static final TextColor CHAT_GREEN_2 = TextColor.fromHexString("#5ec969"); // h=126 s=50 l=58
2023-02-22 16:40:08 +01:00
/** Green 3 color. */
public static final TextColor CHAT_GREEN_3 = TextColor.fromHexString("#85d68d"); // h=126 s=50 l=68
2023-02-22 16:40:08 +01:00
/** Green 4 color. */
public static final TextColor CHAT_GREEN_4 = TextColor.fromHexString("#abe3b0"); // h=126 s=50 l=78
2023-02-22 16:40:08 +01:00
/** Green max saturation color. */
public static final TextColor CHAT_GREEN_MAX_SAT = TextColor.fromHexString("#00ff19"); // h=126 s=100 l=50
2023-02-22 16:40:08 +01:00
/** Green 1 saturated color. */
public static final TextColor CHAT_GREEN_1_SAT = TextColor.fromHexString("#20d532"); // h=126 s=50 l=48
2023-02-22 16:40:08 +01:00
/** Green 2 saturated color. */
public static final TextColor CHAT_GREEN_2_SAT = TextColor.fromHexString("#45e354"); // h=126 s=50 l=58
2023-02-22 16:40:08 +01:00
/** Green 3 saturated color. */
public static final TextColor CHAT_GREEN_3_SAT = TextColor.fromHexString("#71ea7d"); // h=126 s=50 l=68
2023-02-22 16:40:08 +01:00
/** Green 4 saturated color. */
public static final TextColor CHAT_GREEN_4_SAT = TextColor.fromHexString("#9df0a6"); // h=126 s=50 l=78
2023-02-22 16:40:08 +01:00
/** Brown 1 color. */
public static final TextColor CHAT_BROWN_1 = TextColor.fromHexString("#b26d3a"); // h=26 s=51 l=46
2023-02-22 16:40:08 +01:00
/** Brown 2 color. */
public static final TextColor CHAT_BROWN_2 = TextColor.fromHexString("#cd9265"); // h=26 s=51 l=60
2023-02-22 16:40:08 +01:00
/** Brown 3 color. */
public static final TextColor CHAT_BROWN_3 = TextColor.fromHexString("#e0bb9f"); // h=26 s=51 l=75
2023-02-22 16:40:08 +01:00
/** Brown 1 saturated color. */
public static final TextColor CHAT_BROWN_1_SAT = TextColor.fromHexString("#b35c19"); // h=26 s=75 l=40
2023-02-22 16:40:08 +01:00
/** Brown 2 saturated color. */
public static final TextColor CHAT_BROWN_2_SAT = TextColor.fromHexString("#e28136"); // h=26 s=51 l=55
2023-02-22 16:40:08 +01:00
/** Brown 3 saturated color. */
public static final TextColor CHAT_BROWN_3_SAT = TextColor.fromHexString("#ecab79"); // h=26 s=51 l=70
2023-02-22 16:40:08 +01:00
/** Gray medium color. */
public static final TextColor CHAT_GRAY_MID = TextColor.fromHexString("#888888");
2023-02-22 16:40:08 +01:00
/** Red failure color. */
public static final TextColor CHAT_RED_FAILURE = TextColor.fromHexString("#ff3333");
2023-02-22 16:40:08 +01:00
/** Color used for private message prefix decoration. */
public static final TextColor CHAT_PM_PREFIX_DECORATION = CHAT_BROWN_2_SAT;
2023-02-22 16:40:08 +01:00
/** Color used for sent message text. */
public static final TextColor CHAT_PM_SELF_MESSAGE = CHAT_GREEN_2;
2023-02-22 16:40:08 +01:00
/** Color used for received message text. */
public static final TextColor CHAT_PM_OTHER_MESSAGE = CHAT_GREEN_4;
2023-02-22 16:40:08 +01:00
/** Discord color. */
public static final TextColor CHAT_DISCORD_LINK_COLOR = TextColor.fromHexString("#00aff4");
2023-02-22 16:40:08 +01:00
/**
* Generate a prefix for broadcast message.
* @return a prefix for broadcast message.
*/
public static Chat CHAT_MESSAGE_PREFIX() {
return Chat.text("[")
.broadcastColor()
.thenDecoration("Serveur")
.thenText("] ");
}
}
2022-07-30 13:58:16 +02:00
}