aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-08-28 20:03:20 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-08-28 20:03:20 +0200
commit8106e9ceb246f4cbc8215705b88efe3be3465ab3 (patch)
tree51e24da491ea4cc2d0d45b34d09ebdfbb4bad356 /src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
parent9cb5096106171c5e5ce6750d8cafed51d0edac52 (diff)
downloadskyhanni-8106e9ceb246f4cbc8215705b88efe3be3465ab3.tar.gz
skyhanni-8106e9ceb246f4cbc8215705b88efe3be3465ab3.tar.bz2
skyhanni-8106e9ceb246f4cbc8215705b88efe3be3465ab3.zip
Fixed npc price detection
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt31
1 files changed, 12 insertions, 19 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
index bf97892bb..fac794a53 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
@@ -136,14 +136,7 @@ object NEUItems {
fun getInternalNameOrNull(nbt: NBTTagCompound) =
ItemResolutionQuery(manager).withItemNBT(nbt).resolveInternalName()?.asInternalName()
- fun NEUInternalName.getPriceOrNull(useSellingPrice: Boolean = false): Double? {
- val price = getPrice(useSellingPrice)
- if (price == -1.0) {
- getNpcPrice()
- return null
- }
- return price
- }
+ fun NEUInternalName.getPrice(useSellingPrice: Boolean = false) = getPriceOrNull(useSellingPrice) ?: -1.0
fun NEUInternalName.getNpcPrice() = getNpcPriceOrNull() ?: -1.0
@@ -152,21 +145,21 @@ object NEUItems {
fun transHypixelNameToInternalName(hypixelId: String) =
manager.auctionManager.transformHypixelBazaarToNEUItemId(hypixelId).asInternalName()
- fun NEUInternalName.getPrice(useSellingPrice: Boolean = false): Double {
+ fun NEUInternalName.getPriceOrNull(useSellingPrice: Boolean = false): Double? {
if (equals("WISP_POTION")) {
return 20_000.0
}
val result = manager.auctionManager.getBazaarOrBin(asString(), useSellingPrice)
- if (result == -1.0) {
- if (equals("JACK_O_LANTERN")) {
- return getPrice("PUMPKIN", useSellingPrice) + 1
- }
- if (equals("GOLDEN_CARROT")) {
- // 6.8 for some players
- return 7.0 // NPC price
- }
+ if (result != -1.0) return result
+
+ if (equals("JACK_O_LANTERN")) {
+ return getPrice("PUMPKIN", useSellingPrice) + 1
}
- return result
+ if (equals("GOLDEN_CARROT")) {
+ // 6.8 for some players
+ return 7.0 // NPC price
+ }
+ return getNpcPriceOrNull()
}
fun getPrice(internalName: String, useSellingPrice: Boolean = false) =
@@ -184,7 +177,7 @@ object NEUItems {
fun NEUInternalName.getItemStack(definite: Boolean = false): ItemStack =
getItemStackOrNull() ?: run {
- if (getPrice() == -1.0) return@run fallbackItem
+ if (getPriceOrNull() == null) return@run fallbackItem
if (definite) {
Utils.showOutdatedRepoNotification()