From 6d9aa9f33e91294c5e5733982ffd6c77ebb1a674 Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Sat, 17 Feb 2024 21:17:49 -0500 Subject: [PATCH 1/2] Refactor search overlay bazaar data source --- .../skyblock/searchOverlay/SearchOverManager.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/searchOverlay/SearchOverManager.java b/src/main/java/de/hysky/skyblocker/skyblock/searchOverlay/SearchOverManager.java index b2a453a922..68f279c7b7 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/searchOverlay/SearchOverManager.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/searchOverlay/SearchOverManager.java @@ -96,13 +96,15 @@ private static void loadItems() { HashMap namesToId = new HashMap<>(); //get bazaar items - try (Http.ApiResponse response = Http.sendHypixelRequest("skyblock/bazaar", "")) { - JsonObject products = JsonParser.parseString(response.content()).getAsJsonObject().get("products").getAsJsonObject(); + try { + if (TooltipInfoType.BAZAAR.getData() == null) TooltipInfoType.BAZAAR.run(); + + JsonObject products = TooltipInfoType.BAZAAR.getData(); for (Map.Entry entry : products.entrySet()) { if (entry.getValue().isJsonObject()) { JsonObject product = entry.getValue().getAsJsonObject(); - String id = product.get("product_id").getAsString(); - int sellVolume = product.get("quick_status").getAsJsonObject().get("sellVolume").getAsInt(); + String id = product.get("id").getAsString(); + int sellVolume = product.get("sellVolume").getAsInt(); if (sellVolume == 0) continue; //do not add items that do not sell e.g. they are not actual in the bazaar Matcher matcher = BAZAAR_ENCHANTMENT_PATTERN.matcher(id); From 39cf82e4976f70bf8b8d27216a0284e30d9ae5e4 Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Sat, 17 Feb 2024 21:32:15 -0500 Subject: [PATCH 2/2] Rename search overlay package to match Java conventions --- src/main/java/de/hysky/skyblocker/SkyblockerMod.java | 2 +- .../de/hysky/skyblocker/mixin/ClientPlayerEntityMixin.java | 4 ++-- .../{searchOverlay => searchoverlay}/OverlayScreen.java | 2 +- .../{searchOverlay => searchoverlay}/SearchOverManager.java | 4 ++-- .../{searchOverlay => searchoverlay}/SplitStringTest.java | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) rename src/main/java/de/hysky/skyblocker/skyblock/{searchOverlay => searchoverlay}/OverlayScreen.java (99%) rename src/main/java/de/hysky/skyblocker/skyblock/{searchOverlay => searchoverlay}/SearchOverManager.java (99%) rename src/test/java/de/hysky/skyblocker/skyblock/{searchOverlay => searchoverlay}/SplitStringTest.java (95%) diff --git a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java index 1aa975263d..b8722fc6b3 100644 --- a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java +++ b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java @@ -26,7 +26,7 @@ import de.hysky.skyblocker.skyblock.itemlist.ItemRepository; import de.hysky.skyblocker.skyblock.quicknav.QuickNav; import de.hysky.skyblocker.skyblock.rift.TheRift; -import de.hysky.skyblocker.skyblock.searchOverlay.SearchOverManager; +import de.hysky.skyblocker.skyblock.searchoverlay.SearchOverManager; import de.hysky.skyblocker.skyblock.shortcut.Shortcuts; import de.hysky.skyblocker.skyblock.special.SpecialEffects; import de.hysky.skyblocker.skyblock.tabhud.TabHud; diff --git a/src/main/java/de/hysky/skyblocker/mixin/ClientPlayerEntityMixin.java b/src/main/java/de/hysky/skyblocker/mixin/ClientPlayerEntityMixin.java index 2a4c38a7c6..ceda9ed4db 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/ClientPlayerEntityMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixin/ClientPlayerEntityMixin.java @@ -6,8 +6,8 @@ import de.hysky.skyblocker.skyblock.item.HotbarSlotLock; import de.hysky.skyblocker.skyblock.item.ItemProtection; import de.hysky.skyblocker.skyblock.rift.HealingMelonIndicator; -import de.hysky.skyblocker.skyblock.searchOverlay.OverlayScreen; -import de.hysky.skyblocker.skyblock.searchOverlay.SearchOverManager; +import de.hysky.skyblocker.skyblock.searchoverlay.OverlayScreen; +import de.hysky.skyblocker.skyblock.searchoverlay.SearchOverManager; import de.hysky.skyblocker.utils.Utils; import net.minecraft.block.entity.SignBlockEntity; import net.minecraft.client.MinecraftClient; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/searchOverlay/OverlayScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/searchoverlay/OverlayScreen.java similarity index 99% rename from src/main/java/de/hysky/skyblocker/skyblock/searchOverlay/OverlayScreen.java rename to src/main/java/de/hysky/skyblocker/skyblock/searchoverlay/OverlayScreen.java index e1545c6c98..b8907e274f 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/searchOverlay/OverlayScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/searchoverlay/OverlayScreen.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.skyblock.searchOverlay; +package de.hysky.skyblocker.skyblock.searchoverlay; import de.hysky.skyblocker.config.SkyblockerConfigManager; import net.minecraft.client.gui.DrawContext; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/searchOverlay/SearchOverManager.java b/src/main/java/de/hysky/skyblocker/skyblock/searchoverlay/SearchOverManager.java similarity index 99% rename from src/main/java/de/hysky/skyblocker/skyblock/searchOverlay/SearchOverManager.java rename to src/main/java/de/hysky/skyblocker/skyblock/searchoverlay/SearchOverManager.java index 68f279c7b7..1d740601d0 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/searchOverlay/SearchOverManager.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/searchoverlay/SearchOverManager.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.skyblock.searchOverlay; +package de.hysky.skyblocker.skyblock.searchoverlay; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -336,7 +336,7 @@ private static void pushSign() { } } - static Pair splitString(String s) { + public static Pair splitString(String s) { if (s.length() <= 15) { return Pair.of(s, ""); } diff --git a/src/test/java/de/hysky/skyblocker/skyblock/searchOverlay/SplitStringTest.java b/src/test/java/de/hysky/skyblocker/skyblock/searchoverlay/SplitStringTest.java similarity index 95% rename from src/test/java/de/hysky/skyblocker/skyblock/searchOverlay/SplitStringTest.java rename to src/test/java/de/hysky/skyblocker/skyblock/searchoverlay/SplitStringTest.java index c397b5a47c..a9fd541f78 100644 --- a/src/test/java/de/hysky/skyblocker/skyblock/searchOverlay/SplitStringTest.java +++ b/src/test/java/de/hysky/skyblocker/skyblock/searchoverlay/SplitStringTest.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.skyblock.searchOverlay; +package de.hysky.skyblocker.skyblock.searchoverlay; import it.unimi.dsi.fastutil.Pair; import org.junit.jupiter.api.Assertions;