From 9eac32ec67cd3a1ee5058322125f1350414c64ba Mon Sep 17 00:00:00 2001 From: Lorenz Date: Wed, 7 Sep 2022 12:58:34 +0200 Subject: fixed bazaar api checking too often --- .../skyhanni/features/bazaar/BazaarDataGrabber.kt | 35 ++++++++++------------ 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni') diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataGrabber.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataGrabber.kt index 01f01015c..7318f1aa5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataGrabber.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataGrabber.kt @@ -13,9 +13,7 @@ internal class BazaarDataGrabber(private var bazaarMap: MutableMap() - private var lastData = "" var lastTime = 0L - var blockNoChange = false var currentlyUpdating = false } @@ -60,32 +58,21 @@ internal class BazaarDataGrabber(private var bazaarMap: MutableMap 9_000) { - blockNoChange = true - } else { - if (blockNoChange) { - return - } - } + if (System.currentTimeMillis() > lastTime + 10_000) { + currentlyUpdating = true + lastTime = System.currentTimeMillis() + updateBazaarData() + currentlyUpdating = false } - - currentlyUpdating = true - updateBazaarData() - currentlyUpdating = false } private fun updateBazaarData() { val bazaarData = APIUtil.getJSONResponse("https://api.hypixel.net/skyblock/bazaar") - if (bazaarData.toString() != lastData) { - lastData = bazaarData.toString() - lastTime = System.currentTimeMillis() - } val products = bazaarData["products"].asJsonObject for (entry in products.entrySet()) { - val apiName = entry.key + var apiName = entry.key //TODO use repo if (apiName == "ENCHANTED_CARROT_ON_A_STICK") continue @@ -108,6 +95,16 @@ internal class BazaarDataGrabber(private var bazaarMap: MutableMap