diff options
author | Aaron <51387595+AzureAaron@users.noreply.github.com> | 2023-07-14 15:36:53 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-14 15:36:53 -0400 |
commit | d29e8df47677c3e9f05636eb8ebfd88ea1da612c (patch) | |
tree | 458283ba4b75909ce925b68b9ef58476e48a028b /src/main/java/me/xmrvizzy/skyblocker/skyblock | |
parent | 614a56303a468e65a0b965bacee822da936436c8 (diff) | |
parent | a22be409f7f9e62aa195387f61ae981eb75c7e8f (diff) | |
download | Skyblocker-d29e8df47677c3e9f05636eb8ebfd88ea1da612c.tar.gz Skyblocker-d29e8df47677c3e9f05636eb8ebfd88ea1da612c.tar.bz2 Skyblocker-d29e8df47677c3e9f05636eb8ebfd88ea1da612c.zip |
Merge pull request #200 from AzureAaron/dungeon-blessings-enhancements
Sort + Colourize Blessings
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker/skyblock')
-rw-r--r-- | src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/DungeonBuffWidget.java | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/DungeonBuffWidget.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/DungeonBuffWidget.java index 6ad5268e..d56d3522 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/DungeonBuffWidget.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/DungeonBuffWidget.java @@ -5,6 +5,9 @@ import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; +import java.util.Arrays; +import java.util.Comparator; + // this widget shows a list of obtained dungeon buffs // TODO: could be more pretty, can't be arsed atm @@ -31,14 +34,32 @@ public class DungeonBuffWidget extends Widget { return; } - for (int i = 1; i < lines.length; i++) { - if (lines[i].length() < 3) { // empty line is §s + //Filter out text unrelated to blessings + lines = Arrays.stream(lines).filter(s -> s.contains("Blessing")).toArray(String[]::new); + + //Alphabetically sort the blessings + Arrays.sort(lines, Comparator.comparing(String::toLowerCase)); + + for (String line : lines) { + if (line.length() < 3) { // empty line is §s break; } - this.addComponent(new PlainTextComponent(Text.of(lines[i]))); + int color = getBlessingColor(line); + this.addComponent(new PlainTextComponent(Text.literal(line).styled(style -> style.withColor(color)))); } this.pack(); } -} + @SuppressWarnings("DataFlowIssue") + public int getBlessingColor(String blessing) { + if (blessing.contains("Life")) return Formatting.LIGHT_PURPLE.getColorValue(); + if (blessing.contains("Power")) return Formatting.RED.getColorValue(); + if (blessing.contains("Stone")) return Formatting.GREEN.getColorValue(); + if (blessing.contains("Time")) return 0xafb8c1; + if (blessing.contains("Wisdom")) return Formatting.AQUA.getColorValue(); + + return 0xffffff; + } + +}
\ No newline at end of file |