Skip to content

Commit

Permalink
Fix BazaarPriceTooltip sack crash
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinthegreat1 committed Sep 22, 2024
1 parent f075ae0 commit c129224
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ public void addToTooltip(@Nullable Slot focusedSlot, ItemStack stack, List<Text>
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)));
}
}

Expand Down

0 comments on commit c129224

Please sign in to comment.