From f3dd77b530bc3fb0866b16eea334fdbe3b5642de Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Mon, 19 Jun 2023 23:30:58 -0400 Subject: Improve documentation and trim trailing space --- .../skyblocker/skyblock/tabhud/util/PlayerListMgr.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/main/java/me/xmrvizzy/skyblocker') diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerListMgr.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerListMgr.java index 665fc981..82a4ae01 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerListMgr.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerListMgr.java @@ -119,16 +119,22 @@ public class PlayerListMgr { return null; } - //Rebuild the text object to remove beginning space thats in all faction quest stuff - MutableText newTxt = Text.empty(); + //Rebuild the text object to remove leading space thats in all faction quest stuff (also removes trailing space just in case) + MutableText newText = Text.empty(); + int size = txt.getSiblings().size(); - for(int i = 0; i < txt.getSiblings().size(); i++) { + for(int i = 0; i < size; i++) { Text current = txt.getSiblings().get(i); String textToAppend = current.getString(); - newTxt.append(Text.literal((i == 0) ? StringUtils.removeStart(textToAppend, " ") : textToAppend ).setStyle(current.getStyle())); + + //Trim leading & trailing space - this can only be done at the start and end otherwise it'll produce malformed results + if(i == 0) textToAppend = StringUtils.removeStart(textToAppend, " "); + if(i == size - 1) textToAppend = StringUtils.removeEnd(textToAppend, " "); + + newText.append(Text.literal(textToAppend).setStyle(current.getStyle())); } - return newTxt; + return newText; } /** -- cgit