From e68587ae9609128f2658a6bccd1a331792b326a9 Mon Sep 17 00:00:00 2001 From: Fix3dll Date: Sun, 3 Apr 2022 15:27:58 +0300 Subject: fix: Fire trial interaction with Fancybar, bazaar and lbin appearing at same time a cleaner look for bazaar without extra tooltip --- .../skyblocker/skyblock/FancyStatusBars.java | 2 +- .../skyblocker/skyblock/item/PriceInfoTooltip.java | 44 ++++++++++++---------- 2 files changed, 25 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/FancyStatusBars.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/FancyStatusBars.java index 75d232e9..5d3cf9c4 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/FancyStatusBars.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/FancyStatusBars.java @@ -17,7 +17,7 @@ public class FancyStatusBars extends DrawableHelper { private static final MinecraftClient client = MinecraftClient.getInstance(); private static final Identifier BARS = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/bars.png"); private static final Pattern ACTION_BAR_MANA = Pattern.compile("§b-\\d+ Mana \\(.*\\) +"); - private static final Pattern ACTION_BAR_STATUS = Pattern.compile("^§[6c](\\d+)/(\\d+)❤(\\+§c\\d+.)?(?: +§a(\\d+)§a❈ Defense)?(?: +(\\S+(?:\\s\\S+)*))??(?: +§b(\\d+)/(\\d+)✎ +(?:Mana|§3(\\d+)ʬ))?(?: +(§[27].*))?$"); + private static final Pattern ACTION_BAR_STATUS = Pattern.compile("^§[6c](\\d+)/(\\d+)❤(\\+§c\\d+.)? +(?:§a(\\d+)§a❈ Defense|([^✎]*?))?(?: +§b(\\d+)/(\\d+)✎ +(?:Mana|§3(\\d+)ʬ))?(?: +(§[27].*))?$"); private final Resource[] resources = new Resource[]{ // Health 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 290bd0ae..ddb290a7 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/PriceInfoTooltip.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/PriceInfoTooltip.java @@ -49,6 +49,7 @@ public class PriceInfoTooltip { 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) { if (npcPricesJson == null) { @@ -63,7 +64,28 @@ public class PriceInfoTooltip { } } - if (SkyblockerConfig.get().general.itemTooltip.enableLowestBIN) { + boolean bazaarExist = false; + if (SkyblockerConfig.get().general.itemTooltip.enableBazaarPrice + && !bazaarOpened) { + if (bazaarPricesJson == null) { + if (!nullMsgSend) { + client.player.sendMessage(new TranslatableText("skyblocker.itemTooltip.nullMessage"), false); + nullMsgSend = true; + } + } else if (bazaarPricesJson.has(name)) { + JsonObject getItem = bazaarPricesJson.getAsJsonObject(name); + lines.add(new LiteralText(String.format("%-18s", "Bazaar buy Price:")) + .formatted(Formatting.GOLD) + .append(getCoinsMessage(getItem.get("buyPrice").getAsDouble(), count))); + lines.add(new LiteralText(String.format("%-19s", "Bazaar sell Price:")) + .formatted(Formatting.GOLD) + .append(getCoinsMessage(getItem.get("sellPrice").getAsDouble(), count))); + bazaarExist = true; + } + } + + // bazaarOpened & bazaarExist check for lbin, because Skytils keeps some bazaar item data in lbin api + if (SkyblockerConfig.get().general.itemTooltip.enableLowestBIN && !bazaarOpened && !bazaarExist) { if (lowestPricesJson == null) { if (!nullMsgSend) { client.player.sendMessage(new TranslatableText("skyblocker.itemTooltip.nullMessage"), false); @@ -134,25 +156,7 @@ public class PriceInfoTooltip { } } - if (SkyblockerConfig.get().general.itemTooltip.enableBazaarPrice - && lines.stream().noneMatch(each -> each.getString().contains("Buy price:") || each.getString().contains("Sell price:"))) { - if (bazaarPricesJson == null) { - if (!nullMsgSend) { - client.player.sendMessage(new TranslatableText("skyblocker.itemTooltip.nullMessage"), false); - nullMsgSend = true; - } - } else if (bazaarPricesJson.has(name)) { - JsonObject getItem = bazaarPricesJson.getAsJsonObject(name); - lines.add(new LiteralText(String.format("%-18s", "Bazaar buy Price:")) - .formatted(Formatting.GOLD) - .append(getCoinsMessage(getItem.get("buyPrice").getAsDouble(), count))); - lines.add(new LiteralText(String.format("%-19s", "Bazaar sell Price:")) - .formatted(Formatting.GOLD) - .append(getCoinsMessage(getItem.get("sellPrice").getAsDouble(), count))); - } - } - - if (SkyblockerConfig.get().general.itemTooltip.enableMuseumDate) { + if (SkyblockerConfig.get().general.itemTooltip.enableMuseumDate && !bazaarOpened) { if (isMuseumJson == null) { if (!nullMsgSend) { client.player.sendMessage(new TranslatableText("skyblocker.itemTooltip.nullMessage"), false); -- cgit From 86dea997bdca5403cecc914be5fb9c06bfb41bf3 Mon Sep 17 00:00:00 2001 From: Fix3dll Date: Sun, 3 Apr 2022 16:35:07 +0300 Subject: add: if not on skyblock, dont get PriceInfoTooltip data --- .../me/xmrvizzy/skyblocker/skyblock/item/PriceInfoTooltip.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') 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 ddb290a7..28083944 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/PriceInfoTooltip.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/PriceInfoTooltip.java @@ -256,9 +256,16 @@ public class PriceInfoTooltip { } } - public static int minute = 0; + // If these options is true beforehand, the client will get first data of these options while loading. + // After then, it will only fetch the data if it is on Skyblock. + public static int minute = -1; public static void init() { skyblocker.scheduler.scheduleCyclic(() -> { + if (!Utils.isOnSkyblock && 0 < minute++) { + nullMsgSend = false; + return; + } + List> futureList = new ArrayList<>(); if ((SkyblockerConfig.get().general.itemTooltip.enableAvgBIN) && (oneDayAvgPricesJson == null || threeDayAvgPricesJson == null || minute % 5 == 0)) { SkyblockerConfig.Average type = SkyblockerConfig.get().general.itemTooltip.avg; -- cgit From 80da142db31d79625d6e57ab4c30bbd6ddc6469c Mon Sep 17 00:00:00 2001 From: Fix3d Date: Sat, 23 Apr 2022 21:32:28 +0300 Subject: fix: PriceInfoTooltip bazaar item price null check --- .../skyblocker/skyblock/item/PriceInfoTooltip.java | 39 ++++++++++------------ 1 file changed, 17 insertions(+), 22 deletions(-) (limited to 'src') 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 28083944..3a5980f0 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/PriceInfoTooltip.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/PriceInfoTooltip.java @@ -65,8 +65,7 @@ public class PriceInfoTooltip { } boolean bazaarExist = false; - if (SkyblockerConfig.get().general.itemTooltip.enableBazaarPrice - && !bazaarOpened) { + if (SkyblockerConfig.get().general.itemTooltip.enableBazaarPrice && !bazaarOpened) { if (bazaarPricesJson == null) { if (!nullMsgSend) { client.player.sendMessage(new TranslatableText("skyblocker.itemTooltip.nullMessage"), false); @@ -76,10 +75,14 @@ public class PriceInfoTooltip { JsonObject getItem = bazaarPricesJson.getAsJsonObject(name); lines.add(new LiteralText(String.format("%-18s", "Bazaar buy Price:")) .formatted(Formatting.GOLD) - .append(getCoinsMessage(getItem.get("buyPrice").getAsDouble(), count))); + .append(getItem.get("buyPrice").isJsonNull() + ? new LiteralText("No data").formatted(Formatting.RED) + : getCoinsMessage(getItem.get("buyPrice").getAsDouble(), count))); lines.add(new LiteralText(String.format("%-19s", "Bazaar sell Price:")) .formatted(Formatting.GOLD) - .append(getCoinsMessage(getItem.get("sellPrice").getAsDouble(), count))); + .append(getItem.get("sellPrice").isJsonNull() + ? new LiteralText("No data").formatted(Formatting.RED) + : getCoinsMessage(getItem.get("sellPrice").getAsDouble(), count))); bazaarExist = true; } } @@ -132,26 +135,18 @@ public class PriceInfoTooltip { // "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)) { - if (oneDayAvgPricesJson.get(name) != null) { - lines.add(new LiteralText(String.format("%-19s", "1 Day Avg. Price:")) - .formatted(Formatting.GOLD) - .append(getCoinsMessage(oneDayAvgPricesJson.get(name).getAsDouble(), count))); - } else { - lines.add(new LiteralText(String.format("%-19s", "1 Day Avg. Price:")) - .formatted(Formatting.GOLD) - .append(new LiteralText("No data").formatted(Formatting.RED))); - } + lines.add(new LiteralText(String.format("%-19s", "1 Day Avg. Price:")) + .formatted(Formatting.GOLD) + .append(oneDayAvgPricesJson.get(name) == null + ? new LiteralText("No data").formatted(Formatting.RED) + : getCoinsMessage(oneDayAvgPricesJson.get(name).getAsDouble(), count))); } if (!name.isEmpty() && (type == SkyblockerConfig.Average.THREE_DAY || type == SkyblockerConfig.Average.BOTH)) { - if (threeDayAvgPricesJson.get(name) != null) { - lines.add(new LiteralText(String.format("%-19s", "3 Day Avg. Price:")) - .formatted(Formatting.GOLD) - .append(getCoinsMessage(threeDayAvgPricesJson.get(name).getAsDouble(), count))); - } else { - lines.add(new LiteralText(String.format("%-19s", "3 Day Avg. Price:")) - .formatted(Formatting.GOLD) - .append(new LiteralText("No data").formatted(Formatting.RED))); - } + lines.add(new LiteralText(String.format("%-19s", "3 Day Avg. Price:")) + .formatted(Formatting.GOLD) + .append(threeDayAvgPricesJson.get(name) == null + ? new LiteralText("No data").formatted(Formatting.RED) + : getCoinsMessage(threeDayAvgPricesJson.get(name).getAsDouble(), count))); } } } -- cgit