diff options
| author | Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> | 2024-08-26 12:43:36 +0800 |
|---|---|---|
| committer | Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> | 2024-08-26 12:43:36 +0800 |
| commit | 23fd52d0a8ce68bd4b908353e8b2c792dc02d5ef (patch) | |
| tree | 15661a30fff89f4f4c2705c7de5598f2aebf2780 /src/main/java | |
| parent | 4ba73931e36c67fbdde51fa52df5a3d67d216444 (diff) | |
| download | Skyblocker-23fd52d0a8ce68bd4b908353e8b2c792dc02d5ef.tar.gz Skyblocker-23fd52d0a8ce68bd4b908353e8b2c792dc02d5ef.tar.bz2 Skyblocker-23fd52d0a8ce68bd4b908353e8b2c792dc02d5ef.zip | |
Clean up collections cache
Diffstat (limited to 'src/main/java')
| -rw-r--r-- | src/main/java/de/hysky/skyblocker/skyblock/profileviewer/ProfileViewerScreen.java | 16 | ||||
| -rw-r--r-- | src/main/java/de/hysky/skyblocker/skyblock/profileviewer/collections/GenericCategory.java | 8 |
2 files changed, 13 insertions, 11 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/profileviewer/ProfileViewerScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/profileviewer/ProfileViewerScreen.java index ad6987c7..1939e0f6 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/profileviewer/ProfileViewerScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/profileviewer/ProfileViewerScreen.java @@ -18,7 +18,6 @@ import de.hysky.skyblocker.utils.ProfileUtils; import de.hysky.skyblocker.utils.scheduler.Scheduler; import it.unimi.dsi.fastutil.ints.IntImmutableList; import it.unimi.dsi.fastutil.ints.IntList; -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; @@ -48,10 +47,11 @@ public class ProfileViewerScreen extends Screen { public static final Logger LOGGER = LoggerFactory.getLogger(ProfileViewerScreen.class); private static final Text TITLE = Text.of("Skyblocker Profile Viewer"); private static final String HYPIXEL_COLLECTIONS = "https://api.hypixel.net/v2/resources/skyblock/collections"; - private static final Object2ObjectOpenHashMap<String, Map<String, ?>> COLLECTIONS_CACHE = new Object2ObjectOpenHashMap<>(); private static final Identifier TEXTURE = Identifier.of(SkyblockerMod.NAMESPACE, "textures/gui/profile_viewer/base_plate.png"); private static final int GUI_WIDTH = 322; private static final int GUI_HEIGHT = 180; + private static Map<String, String[]> COLLECTIONS; + private static Map<String, IntList> TIER_REQUIREMENTS; private String playerName; private JsonObject hypixelProfile; @@ -231,8 +231,8 @@ public class ProfileViewerScreen extends Screen { tierRequirementsMap.put(itemEntry.getKey(), tierReqs); }); }); - COLLECTIONS_CACHE.put("COLLECTIONS", collectionsMap); - COLLECTIONS_CACHE.put("TIER_REQS", tierRequirementsMap); + COLLECTIONS = collectionsMap; + TIER_REQUIREMENTS = tierRequirementsMap; } } catch (Exception e) { LOGGER.error("[Skyblocker Profile Viewer] Failed to fetch collections data", e); @@ -240,8 +240,12 @@ public class ProfileViewerScreen extends Screen { }); } - public static Map<String, Map<String, ?>> getCollectionsData() { - return COLLECTIONS_CACHE; + public static Map<String, String[]> getCollections() { + return COLLECTIONS; + } + + public static Map<String, IntList> getTierRequirements() { + return TIER_REQUIREMENTS; } /** diff --git a/src/main/java/de/hysky/skyblocker/skyblock/profileviewer/collections/GenericCategory.java b/src/main/java/de/hysky/skyblocker/skyblock/profileviewer/collections/GenericCategory.java index ec8fcd6d..b2e0e702 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/profileviewer/collections/GenericCategory.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/profileviewer/collections/GenericCategory.java @@ -4,6 +4,7 @@ import com.google.gson.JsonObject; import de.hysky.skyblocker.SkyblockerMod; import de.hysky.skyblocker.skyblock.itemlist.ItemRepository; import de.hysky.skyblocker.skyblock.profileviewer.ProfileViewerPage; +import de.hysky.skyblocker.skyblock.profileviewer.ProfileViewerScreen; import de.hysky.skyblocker.skyblock.tabhud.util.Ico; import it.unimi.dsi.fastutil.ints.IntList; import net.minecraft.client.MinecraftClient; @@ -26,7 +27,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import static de.hysky.skyblocker.skyblock.profileviewer.ProfileViewerScreen.getCollectionsData; import static de.hysky.skyblocker.skyblock.profileviewer.utils.ProfileViewerUtils.COMMA_FORMATTER; public class GenericCategory implements ProfileViewerPage { @@ -44,11 +44,9 @@ public class GenericCategory implements ProfileViewerPage { Map.entry("MUSHROOM_COLLECTION", "RED_MUSHROOM")); private final String[] ROMAN_NUMERALS = {"-", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII", "XIII", "XIV", "XV", "XVI", "XVII", "XVIII", "XIX", "XX"}; - @SuppressWarnings("unchecked") public GenericCategory(JsonObject hProfile, JsonObject pProfile, String collection) { - Map<String, Map<String, ?>> fetchedData = getCollectionsData(); - collectionsMap = (Map<String, String[]>) fetchedData.get("COLLECTIONS"); - tierRequirementsMap = (Map<String, IntList>) fetchedData.get("TIER_REQS"); + collectionsMap = ProfileViewerScreen.getCollections(); + tierRequirementsMap = ProfileViewerScreen.getTierRequirements(); this.category = collection; setupItemStacks(hProfile, pProfile); } |
