aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/xmrvizzy/skyblocker
diff options
context:
space:
mode:
authorAaron <51387595+AzureAaron@users.noreply.github.com>2023-06-19 23:30:58 -0400
committerAaron <51387595+AzureAaron@users.noreply.github.com>2023-06-19 23:30:58 -0400
commitf3dd77b530bc3fb0866b16eea334fdbe3b5642de (patch)
treedbababa9c156c3d58a69a3ef4c4e88049b22f16d /src/main/java/me/xmrvizzy/skyblocker
parent3c2ec1e9dc7dbcfff9f030619b0f088460841f21 (diff)
downloadSkyblocker-f3dd77b530bc3fb0866b16eea334fdbe3b5642de.tar.gz
Skyblocker-f3dd77b530bc3fb0866b16eea334fdbe3b5642de.tar.bz2
Skyblocker-f3dd77b530bc3fb0866b16eea334fdbe3b5642de.zip
Improve documentation and trim trailing space
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker')
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerListMgr.java16
1 files changed, 11 insertions, 5 deletions
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;
}
/**