diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-10-05 17:18:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-05 17:18:59 +0200 |
commit | 4b6789f6eb4bb40720bc0e445d701935d0cafdcb (patch) | |
tree | 1c238516da94843df0db3c4c39300faaf1a2d7aa /src/main/java/at | |
parent | 1c9fd3f55529461e32a341a71318b9b4664ef816 (diff) | |
download | skyhanni-4b6789f6eb4bb40720bc0e445d701935d0cafdcb.tar.gz skyhanni-4b6789f6eb4bb40720bc0e445d701935d0cafdcb.tar.bz2 skyhanni-4b6789f6eb4bb40720bc0e445d701935d0cafdcb.zip |
Backend: /shdebug + bz fetch (#2675)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/bazaar/HypixelBazaarFetcher.kt | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/bazaar/HypixelBazaarFetcher.kt b/src/main/java/at/hannibal2/skyhanni/data/bazaar/HypixelBazaarFetcher.kt index 13044b7c3..c1a7af289 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/bazaar/HypixelBazaarFetcher.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/bazaar/HypixelBazaarFetcher.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.data.bazaar import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigManager +import at.hannibal2.skyhanni.events.DebugDataCollectEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarData import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule @@ -29,11 +30,30 @@ object HypixelBazaarFetcher { private const val HIDDEN_FAILED_ATTEMPTS = 3 var latestProductInformation = mapOf<NEUInternalName, BazaarData>() + private var lastSuccessfulFetch = SimpleTimeMark.farPast() private var nextFetchTime = SimpleTimeMark.farPast() private var failedAttempts = 0 private var nextFetchIsManual = false @SubscribeEvent + fun onDebugDataCollect(event: DebugDataCollectEvent) { + event.title("Bazaar Fetching") + + val data = listOf( + "failedAttempts: $failedAttempts", + "nextFetchIsManual: $nextFetchIsManual", + "nextFetchTime: ${nextFetchTime.timeUntil()}", + "lastSuccessfulFetch: ${lastSuccessfulFetch.passedSince()}", + ) + + if (failedAttempts == 0) { + event.addIrrelevant(data) + } else { + event.addData(data) + } + } + + @SubscribeEvent fun onTick(event: LorenzTickEvent) { if (!canFetch()) return SkyHanniMod.coroutineScope.launch { @@ -51,6 +71,7 @@ object HypixelBazaarFetcher { if (response.success) { latestProductInformation = process(response.products) failedAttempts = 0 + lastSuccessfulFetch = SimpleTimeMark.now() } else { val rawResponse = jsonResponse.toString() onError(fetchType, Exception("success=false, cause=${response.cause}"), rawResponse) |