Chat class is now sealed and easier usage of special colors
This commit is contained in:
parent
6a2f14ae39
commit
224d21a604
@ -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<Component>, ComponentLike {
|
||||
public abstract sealed class Chat extends ChatStatic implements HoverEventSource<Component>, ComponentLike {
|
||||
|
||||
protected ComponentBuilder<?, ?> builder;
|
||||
protected boolean console = false;
|
||||
@ -244,6 +244,10 @@ public abstract class Chat extends ChatStatic implements HoverEventSource<Compon
|
||||
public FormatableChat infoColor() { return color(config.infoColor); }
|
||||
public FormatableChat dataColor() { return color(config.dataColor); }
|
||||
public FormatableChat decorationColor() { return color(config.decorationColor); }
|
||||
public FormatableChat urlColor() { return color(config.urlColor); }
|
||||
public FormatableChat commandColor() { return color(config.commandColor); }
|
||||
public FormatableChat highlightedCommandColor() { return color(config.highlightedCommandColor); }
|
||||
public FormatableChat broadcastColor() { return color(config.broadcastColor); }
|
||||
|
||||
private FormatableChat setStyle(Consumer<Style.Builder> styleOp) { builder.style(styleOp); return this; }
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -125,7 +125,7 @@ public abstract class IPlayerManager<OP extends IOnlinePlayer, OF extends IOffPl
|
||||
|
||||
public static Chat prefixedAndColored(Chat message) {
|
||||
return Chat.chat()
|
||||
.color(Chat.getConfig().broadcastColor)
|
||||
.broadcastColor()
|
||||
.then(Chat.getConfig().prefix.get())
|
||||
.then(message);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user