diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-05-02 16:01:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-02 16:01:39 +0200 |
commit | 6c8fc0df08331da7e49796985a1df5f14e6d7ac3 (patch) | |
tree | 3fb6f00ae187e3197d98de37d72168a860ee4d71 /src/main/java/at/hannibal2/skyhanni/utils | |
parent | 4353efaa3d18a61f49f79273bea63303afcab7e1 (diff) | |
download | skyhanni-6c8fc0df08331da7e49796985a1df5f14e6d7ac3.tar.gz skyhanni-6c8fc0df08331da7e49796985a1df5f14e6d7ac3.tar.bz2 skyhanni-6c8fc0df08331da7e49796985a1df5f14e6d7ac3.zip |
Backend: Bazaar Fetcher (#1597)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Co-authored-by: Cal <cwolfson58@gmail.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt | 5 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt | 2 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt | 11 |
3 files changed, 16 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt index bd1077be4..46a0d7b57 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt @@ -43,6 +43,11 @@ object APIUtil { ) .useSystemProperties() + /** + * TODO + * make suspend + * use withContext(Dispatchers.IO) { APIUtil.getJSONResponse(url) }.asJsonObject + */ fun getJSONResponse(urlString: String, silentError: Boolean = false) = getJSONResponseAsElement(urlString, silentError) as JsonObject diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 664eb86b9..63c2e4c67 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -85,6 +85,8 @@ object LorenzUtils { return result } + val debug: Boolean = onHypixel && SkyHanniMod.feature.dev.debug.enabled + private var previousApril = false fun SimpleDateFormat.formatCurrentTime(): String = this.format(System.currentTimeMillis()) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt index a5ffc6e14..430edc971 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt @@ -7,6 +7,7 @@ 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.BazaarApi.Companion.getBazaarData import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarDataHolder import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ItemBlink.checkBlinkItem @@ -149,6 +150,7 @@ object NEUItems { fun getInternalNameOrNull(nbt: NBTTagCompound): NEUInternalName? = ItemResolutionQuery(manager).withItemNBT(nbt).resolveInternalName()?.asInternalName() + fun NEUInternalName.getPrice(useSellingPrice: Boolean = false) = getPriceOrNull(useSellingPrice) ?: -1.0 fun NEUInternalName.getNpcPrice() = getNpcPriceOrNull() ?: -1.0 @@ -167,8 +169,13 @@ object NEUItems { if (this == NEUInternalName.WISP_POTION) { return 20_000.0 } - val result = manager.auctionManager.getBazaarOrBin(asString(), useSellingPrice) - if (result != -1.0) return result + + getBazaarData()?.let { + return if (useSellingPrice) it.sellOfferPrice else it.instantBuyPrice + } + + val result = manager.auctionManager.getLowestBin(asString()) + if (result != -1L) return result.toDouble() if (equals("JACK_O_LANTERN")) { return "PUMPKIN".asInternalName().getPrice(useSellingPrice) + 1 |