From 224d21a6048d87d1318a5f7dfbd0e0dabb0944bb Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Fri, 21 Jan 2022 18:56:21 +0100 Subject: [PATCH] Chat class is now sealed and easier usage of special colors --- Core/src/main/java/fr/pandacube/lib/core/chat/Chat.java | 6 +++++- .../main/java/fr/pandacube/lib/core/chat/ChatUtil.java | 8 ++++---- .../fr/pandacube/lib/core/players/IPlayerManager.java | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Core/src/main/java/fr/pandacube/lib/core/chat/Chat.java b/Core/src/main/java/fr/pandacube/lib/core/chat/Chat.java index 897bf84..597c8ea 100644 --- a/Core/src/main/java/fr/pandacube/lib/core/chat/Chat.java +++ b/Core/src/main/java/fr/pandacube/lib/core/chat/Chat.java @@ -34,7 +34,7 @@ import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.BaseComponent; -public abstract class Chat extends ChatStatic implements HoverEventSource, ComponentLike { +public abstract sealed class Chat extends ChatStatic implements HoverEventSource, ComponentLike { protected ComponentBuilder builder; protected boolean console = false; @@ -244,6 +244,10 @@ public abstract class Chat extends ChatStatic implements HoverEventSource styleOp) { builder.style(styleOp); return this; } diff --git a/Core/src/main/java/fr/pandacube/lib/core/chat/ChatUtil.java b/Core/src/main/java/fr/pandacube/lib/core/chat/ChatUtil.java index 373f4df..da4b120 100644 --- a/Core/src/main/java/fr/pandacube/lib/core/chat/ChatUtil.java +++ b/Core/src/main/java/fr/pandacube/lib/core/chat/ChatUtil.java @@ -65,7 +65,7 @@ public class ChatUtil { String dispURL = (url.length() > 50) ? (url.substring(0, 48) + "...") : url; return (FormatableChat) chat() .clickURL(url) - .color(Chat.getConfig().urlColor) + .urlColor() .hover( hover != null ? hover : Chat.text(dispURL) ) @@ -89,7 +89,7 @@ public class ChatUtil { /* package */ static FormatableChat createCommandLink(Chat d, String commandWithSlash, Chat hoverText) { FormatableChat c = chat() .clickCommand(commandWithSlash) - .color(Chat.getConfig().commandColor); + .commandColor(); if (hoverText != null) c.hover(hoverText); return (FormatableChat) c.then(d); @@ -114,7 +114,7 @@ public class ChatUtil { /* package */ static FormatableChat createCommandSuggest(Chat d, String commandWithSlash, Chat hoverText) { FormatableChat c = chat() .clickSuggest(commandWithSlash) - .color(Chat.getConfig().commandColor); + .commandColor(); if (hoverText != null) c.hover(hoverText); return (FormatableChat) c.then(d); @@ -167,7 +167,7 @@ public class ChatUtil { FormatableChat pDisp = createCommandLink(Integer.toString(page), String.format(cmdFormat, page), "Aller à la page " + page); if (page == currentPage) { - pDisp.color(Chat.getConfig().highlightedCommandColor); + pDisp.highlightedCommandColor(); } d.then(pDisp); diff --git a/Core/src/main/java/fr/pandacube/lib/core/players/IPlayerManager.java b/Core/src/main/java/fr/pandacube/lib/core/players/IPlayerManager.java index c056734..2fdc074 100644 --- a/Core/src/main/java/fr/pandacube/lib/core/players/IPlayerManager.java +++ b/Core/src/main/java/fr/pandacube/lib/core/players/IPlayerManager.java @@ -125,7 +125,7 @@ public abstract class IPlayerManager