aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/PriceInfoTooltip.java
diff options
context:
space:
mode:
authorFix3d <serhanduzce@gmail.com>2023-04-15 00:33:36 +0300
committerFix3d <serhanduzce@gmail.com>2023-04-15 00:33:36 +0300
commitd7a62f213b0bddae9b1cc925b7626b8f4cb25823 (patch)
treeac3a988088dbf67fd4eb881d70e99d0e8ee85fde /src/main/java/me/xmrvizzy/skyblocker/skyblock/item/PriceInfoTooltip.java
parentab518948c923b3242fe5f48a0bb5d2e873878108 (diff)
downloadSkyblocker-d7a62f213b0bddae9b1cc925b7626b8f4cb25823.tar.gz
Skyblocker-d7a62f213b0bddae9b1cc925b7626b8f4cb25823.tar.bz2
Skyblocker-d7a62f213b0bddae9b1cc925b7626b8f4cb25823.zip
fix average price on pets
and some cleanup for timestamp
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker/skyblock/item/PriceInfoTooltip.java')
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/item/PriceInfoTooltip.java92
1 files changed, 49 insertions, 43 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/PriceInfoTooltip.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/PriceInfoTooltip.java
index 608122ad..e0cb97aa 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/PriceInfoTooltip.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/PriceInfoTooltip.java
@@ -51,7 +51,6 @@ public class PriceInfoTooltip {
if (name == null) return;
int count = stack.getCount();
- String timestamp = getTimestamp(stack);
boolean bazaarOpened = lines.stream().anyMatch(each -> each.getString().contains("Buy price:") || each.getString().contains("Sell price:"));
if (SkyblockerConfig.get().general.itemTooltip.enableNPCPrice) {
@@ -102,46 +101,50 @@ public class PriceInfoTooltip {
if (threeDayAvgPricesJson == null || oneDayAvgPricesJson == null) {
nullWarning();
}
- else if (threeDayAvgPricesJson.has(name) || oneDayAvgPricesJson.has(name)) {
+ else {
/*
- We are skipping check average prices for potions and runes
- because there is no data for their in API.
+ We are skipping check average prices for potions, runes
+ and enchanted books because there is no data for their in API.
*/
if (name.contains("PET-")) {
name = name.replace("PET-", "")
- .replace("COMMON", "0")
.replace("UNCOMMON", "1")
+ .replace("COMMON", "0")
.replace("RARE", "2")
.replace("EPIC", "3")
.replace("LEGENDARY", "4")
.replace("MYTHIC", "5")
.replace("-", ";");
- } else if (name.contains("ENCHANTED_BOOK-")) {
- name = name.replace("ENCHANTED_BOOK-", "").replace("-", ";");
- } else if (name.contains("POTION-")) {
- name = "";
- } else if (name.contains("RUNE-")) {
+ } else if (name.contains("POTION-") || name.contains("RUNE-") || name.contains("ENCHANTED_BOOK-")) {
name = "";
} else {
name = name.replace(":", "-");
}
- SkyblockerConfig.Average type = SkyblockerConfig.get().general.itemTooltip.avg;
-
- // "No data" line because of API not keeping old data, it causes NullPointerException
- if (!name.isEmpty() && (type == SkyblockerConfig.Average.ONE_DAY || type == SkyblockerConfig.Average.BOTH)) {
- lines.add(Text.literal(String.format("%-19s", "1 Day Avg. Price:"))
- .formatted(Formatting.GOLD)
- .append(oneDayAvgPricesJson.get(name) == null
- ? Text.literal("No data").formatted(Formatting.RED)
- : getCoinsMessage(oneDayAvgPricesJson.get(name).getAsDouble(), count)));
- }
- if (!name.isEmpty() && (type == SkyblockerConfig.Average.THREE_DAY || type == SkyblockerConfig.Average.BOTH)) {
- lines.add(Text.literal(String.format("%-19s", "3 Day Avg. Price:"))
- .formatted(Formatting.GOLD)
- .append(threeDayAvgPricesJson.get(name) == null
- ? Text.literal("No data").formatted(Formatting.RED)
- : getCoinsMessage(threeDayAvgPricesJson.get(name).getAsDouble(), count)));
+ if (!name.isEmpty() && (threeDayAvgPricesJson.has(name) || oneDayAvgPricesJson.has(name))) {
+ SkyblockerConfig.Average type = SkyblockerConfig.get().general.itemTooltip.avg;
+
+ // "No data" line because of API not keeping old data, it causes NullPointerException
+ if (type == SkyblockerConfig.Average.ONE_DAY || type == SkyblockerConfig.Average.BOTH) {
+ lines.add(
+ Text.literal(String.format("%-19s", "1 Day Avg. Price:"))
+ .formatted(Formatting.GOLD)
+ .append(oneDayAvgPricesJson.get(name) == null
+ ? Text.literal("No data").formatted(Formatting.RED)
+ : getCoinsMessage(oneDayAvgPricesJson.get(name).getAsDouble(), count)
+ )
+ );
+ }
+ if (type == SkyblockerConfig.Average.THREE_DAY || type == SkyblockerConfig.Average.BOTH) {
+ lines.add(
+ Text.literal(String.format("%-19s", "3 Day Avg. Price:"))
+ .formatted(Formatting.GOLD)
+ .append(threeDayAvgPricesJson.get(name) == null
+ ? Text.literal("No data").formatted(Formatting.RED)
+ : getCoinsMessage(threeDayAvgPricesJson.get(name).getAsDouble(), count)
+ )
+ );
+ }
}
}
}
@@ -149,22 +152,25 @@ public class PriceInfoTooltip {
if (SkyblockerConfig.get().general.itemTooltip.enableMuseumDate && !bazaarOpened) {
if (isMuseumJson == null) {
nullWarning();
- }
- else if (isMuseumJson.has(name)) {
- String itemCategory = isMuseumJson.get(name).toString().replaceAll("\"", "");
- String format = switch (itemCategory) {
- case "Weapons" -> "%-18s";
- case "Armor" -> "%-19s";
- default -> "%-20s";
- };
- lines.add(Text.literal(String.format(format, "Museum: (" + itemCategory + ")"))
- .formatted(Formatting.LIGHT_PURPLE)
- .append(Text.literal(timestamp != null ? timestamp : "").formatted(Formatting.RED)));
- }
- else if (timestamp != null) {
- lines.add(Text.literal(String.format("%-21s", "Obtained: "))
- .formatted(Formatting.LIGHT_PURPLE)
- .append(Text.literal(timestamp).formatted(Formatting.RED)));
+ }
+ else {
+ String timestamp = getTimestamp(stack);
+
+ if (isMuseumJson.has(name)) {
+ String itemCategory = isMuseumJson.get(name).toString().replaceAll("\"", "");
+ String format = switch (itemCategory) {
+ case "Weapons" -> "%-18s";
+ case "Armor" -> "%-19s";
+ default -> "%-20s";
+ };
+ lines.add(Text.literal(String.format(format, "Museum: (" + itemCategory + ")"))
+ .formatted(Formatting.LIGHT_PURPLE)
+ .append(Text.literal(timestamp).formatted(Formatting.RED)));
+ } else if (!timestamp.isEmpty()) {
+ lines.add(Text.literal(String.format("%-21s", "Obtained: "))
+ .formatted(Formatting.LIGHT_PURPLE)
+ .append(Text.literal(timestamp).formatted(Formatting.RED)));
+ }
}
}
}
@@ -214,7 +220,7 @@ public class PriceInfoTooltip {
}
}
- return null;
+ return "";
}
public static String getInternalNameFromNBT(ItemStack stack) {