From 0e016881d76021af9e410fe74ba33128dd9354b0 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Fri, 20 Oct 2023 23:07:25 +0200 Subject: [PATCH] ChatFilledLine can now add spaces on the right, if enabled in the builder. --- .../java/fr/pandacube/lib/chat/ChatFilledLine.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatFilledLine.java b/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatFilledLine.java index 0ba9700..6517f8f 100644 --- a/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatFilledLine.java +++ b/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatFilledLine.java @@ -59,6 +59,7 @@ public class ChatFilledLine implements ComponentLike { private boolean decorationBold = false; private int nbSide = ChatConfig.nbCharMargin; private boolean spacesAroundText = false; + private boolean spacesDecorationRightSide = false; private boolean console = false; private Integer maxWidth = null; @@ -116,6 +117,16 @@ public class ChatFilledLine implements ComponentLike { return this; } + /** + * If the {@link #decoChar(char)} is set to space, also add spaces at the right of the text + * to reach the desired width. + * @return this. + */ + public ChatFilledLine spacesDecorationRightSide() { + spacesDecorationRightSide = true; + return this; + } + /** * Configure if the line will be rendered on console or not. * @param console true for console, false for game UI. @@ -184,7 +195,7 @@ public class ChatFilledLine implements ComponentLike { Chat d = Chat.chat() .then(Chat.text(ChatUtil.repeatedChar(decorationChar, nbCharLeft)).color(decorationColor).bold(decorationBold)) .then(text); - if (decorationChar != ' ') + if (decorationChar != ' ' || spacesDecorationRightSide) d.then(Chat.text(ChatUtil.repeatedChar(decorationChar, nbCharRight)).color(decorationColor).bold(decorationBold)); return (FormatableChat) d; }