aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorKevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>2024-09-22 14:37:54 -0400
committerKevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>2024-09-22 14:37:54 -0400
commitc1292243286f61aac88fa1421456408b2f1aeebe (patch)
treea4274344ef0fe9d63b46b626c89257e7b5909c93 /src/main/java
parentf075ae0abb2dbb2a14512702ddaaabaf65eb8753 (diff)
downloadSkyblocker-c1292243286f61aac88fa1421456408b2f1aeebe.tar.gz
Skyblocker-c1292243286f61aac88fa1421456408b2f1aeebe.tar.bz2
Skyblocker-c1292243286f61aac88fa1421456408b2f1aeebe.zip
Fix BazaarPriceTooltip sack crash
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/BazaarPriceTooltip.java14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/BazaarPriceTooltip.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/BazaarPriceTooltip.java
index 6d7d26c5..4e1c0dc3 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/BazaarPriceTooltip.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/BazaarPriceTooltip.java
@@ -23,26 +23,26 @@ public class BazaarPriceTooltip extends SimpleTooltipAdder {
String skyblockApiId = stack.getSkyblockApiId();
if (TooltipInfoType.BAZAAR.hasOrNullWarning(skyblockApiId)) {
- int amount;
- if (lines.get(1).getString().endsWith("Sack")) {
- //The amount is in the 2nd sibling of the 3rd line of the lore. here V
+ int count;
+ if (lines.size() >= 4 && lines.get(3).getSiblings().size() >= 2 && lines.get(1).getString().endsWith("Sack")) {
+ //The count is in the 2nd sibling of the 3rd line of the lore. here V
//Example line: empty[style={color=dark_purple,!italic}, siblings=[literal{Stored: }[style={color=gray}], literal{0}[style={color=dark_gray}], literal{/20k}[style={color=gray}]]
String line = lines.get(3).getSiblings().get(1).getString().replace(",", "");
- amount = NumberUtils.isParsable(line) && !line.equals("0") ? Integer.parseInt(line) : stack.getCount();
+ count = NumberUtils.isParsable(line) && !line.equals("0") ? Integer.parseInt(line) : stack.getCount();
} else {
- amount = stack.getCount();
+ count = stack.getCount();
}
BazaarProduct product = TooltipInfoType.BAZAAR.getData().get(skyblockApiId);
lines.add(Text.literal(String.format("%-18s", "Bazaar buy Price:"))
.formatted(Formatting.GOLD)
.append(product.buyPrice().isEmpty()
? Text.literal("No data").formatted(Formatting.RED)
- : ItemTooltip.getCoinsMessage(product.buyPrice().getAsDouble(), amount)));
+ : ItemTooltip.getCoinsMessage(product.buyPrice().getAsDouble(), count)));
lines.add(Text.literal(String.format("%-19s", "Bazaar sell Price:"))
.formatted(Formatting.GOLD)
.append(product.sellPrice().isEmpty()
? Text.literal("No data").formatted(Formatting.RED)
- : ItemTooltip.getCoinsMessage(product.sellPrice().getAsDouble(), amount)));
+ : ItemTooltip.getCoinsMessage(product.sellPrice().getAsDouble(), count)));
}
}