ChatFilledLine can now add spaces on the right, if enabled in the builder.

This commit is contained in:
Marc Baloup 2023-10-20 23:07:25 +02:00
parent c7b33132a9
commit 0e016881d7
1 changed files with 12 additions and 1 deletions

View File

@ -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;
}