diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-08-09 11:49:50 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-08-09 11:49:50 +0200 |
commit | 3bcd5b3a8afa5b322d75af1b82681fd7b1e494e5 (patch) | |
tree | ba3fc5108a01423ed96ea576aa32cb9de091ba9b /src | |
parent | 8d12c5259ff12e25f74194db19731ecc10280e47 (diff) | |
download | skyhanni-3bcd5b3a8afa5b322d75af1b82681fd7b1e494e5.tar.gz skyhanni-3bcd5b3a8afa5b322d75af1b82681fd7b1e494e5.tar.bz2 skyhanni-3bcd5b3a8afa5b322d75af1b82681fd7b1e494e5.zip |
bringing the future of NEUInternalName a bit closer to reality
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataHolder.kt | 5 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt | 29 |
2 files changed, 14 insertions, 20 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataHolder.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataHolder.kt index 043e8c3ac..146f94c90 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataHolder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataHolder.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems +import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.StringUtils.removeColor import kotlinx.coroutines.launch import kotlin.concurrent.fixedRateTimer @@ -62,8 +63,8 @@ class BazaarDataHolder { return null } val displayName = stack.name!!.removeColor() - val sellPrice = NEUItems.getPrice(internalName, true) - val buyPrice = NEUItems.getPrice(internalName, false) + val sellPrice = internalName.getPrice(true) + val buyPrice = internalName.getPrice(false) val npcPrice = npcPrices[internalName].let { if (it == null) { if (!ignoreNoNpcPrice(internalName.asString())) { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt index 4509d512e..4c18c7f94 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt @@ -146,27 +146,22 @@ object NEUItems { return price } - fun getPrice(internalName: NEUInternalName): Double { - if (internalName.asString() == "WISP_POTION") { - return 20_000.0 - } - return getPrice(internalName, false) - } - - fun getPrice(internalName: String) = getPrice(NEUInternalName.from(internalName)) - fun transHypixelNameToInternalName(hypixelId: String): NEUInternalName { val name = manager.auctionManager.transformHypixelBazaarToNEUItemId(hypixelId) return NEUInternalName.from(name) } - fun getPrice(internalName: NEUInternalName, useSellingPrice: Boolean): Double { - val result = manager.auctionManager.getBazaarOrBin(internalName.asString(), useSellingPrice) + fun NEUInternalName.getPrice(useSellingPrice: Boolean = false): Double { + val string = asString() + if (string == "WISP_POTION") { + return 20_000.0 + } + val result = manager.auctionManager.getBazaarOrBin(string, useSellingPrice) if (result == -1.0) { - if (internalName.asString() == "JACK_O_LANTERN") { + if (string == "JACK_O_LANTERN") { return getPrice("PUMPKIN", useSellingPrice) + 1 } - if (internalName.asString() == "GOLDEN_CARROT") { + if (string == "GOLDEN_CARROT") { // 6.8 for some players return 7.0 // NPC price } @@ -174,9 +169,8 @@ object NEUItems { return result } - fun getPrice(internalName: String, useSellingPrice: Boolean): Double { - return getPrice(NEUInternalName.from(internalName), useSellingPrice) - } + fun getPrice(internalName: String, useSellingPrice: Boolean = false) = + NEUInternalName.from(internalName).getPrice(useSellingPrice) fun getItemStackOrNull(internalName: NEUInternalName) = ItemResolutionQuery(manager) .withKnownInternalName(internalName.asString()) @@ -189,8 +183,7 @@ object NEUItems { fun getItemStack(internalName: NEUInternalName, definite: Boolean = false): ItemStack = getItemStackOrNull(internalName) ?: run { - - if (getPrice(internalName) == -1.0) return@run fallbackItem + if (internalName.getPrice() == -1.0) return@run fallbackItem if (definite) { Utils.showOutdatedRepoNotification() |