From a8973b851ad4d3edb0e6c605eb7aea29c6e66938 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Fri, 22 Mar 2024 18:04:45 +0100 Subject: Improvement: Load Trophy Fishing from NEU (#1123) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Co-authored-by: Cal Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> --- src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/main/java/at/hannibal2/skyhanni/utils') diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt index 67f01b531..467afe55f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt @@ -1,7 +1,9 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.config.ConfigManager +import at.hannibal2.skyhanni.data.jsonobjects.other.HypixelPlayerApiJson import at.hannibal2.skyhanni.data.jsonobjects.repo.MultiFilterJson +import at.hannibal2.skyhanni.events.NeuProfileDataLoadedEvent import at.hannibal2.skyhanni.events.NeuRepositoryReloadEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarDataHolder @@ -15,6 +17,7 @@ import com.google.gson.JsonPrimitive import io.github.moulberry.notenoughupdates.NEUManager import io.github.moulberry.notenoughupdates.NEUOverlay import io.github.moulberry.notenoughupdates.NotEnoughUpdates +import io.github.moulberry.notenoughupdates.events.ProfileDataLoadedEvent import io.github.moulberry.notenoughupdates.overlays.AuctionSearchOverlay import io.github.moulberry.notenoughupdates.overlays.BazaarSearchOverlay import io.github.moulberry.notenoughupdates.recipes.CraftingRecipe @@ -63,6 +66,21 @@ object NEUItems { allItemsCache = readAllNeuItems() } + @SubscribeEvent + fun onProfileDataLoaded(event: ProfileDataLoadedEvent) { + val apiData = event.data ?: return + try { + val playerData = ConfigManager.gson.fromJson(apiData) + NeuProfileDataLoadedEvent(playerData).postAndCatch() + + } catch (e: Exception) { + ErrorManager.logErrorWithData( + e, "Error reading hypixel player api data", + "data" to apiData + ) + } + } + @Deprecated("Use NEUInternalName rather than String", ReplaceWith("NEUInternalName.fromItemName(itemName)")) fun getRawInternalName(itemName: String): String = NEUInternalName.fromItemName(itemName).asString() -- cgit