From 5607930d95e526c529dac318d8e958b7b4de052b Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 9 Aug 2023 14:21:22 +0200 Subject: Using NEUInternalName in more classes --- src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt | 4 ++-- .../hannibal2/skyhanni/features/bazaar/BazaarDataHolder.kt | 12 ++++++------ .../skyhanni/features/slayer/SlayerItemProfitTracker.kt | 2 +- src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt | 13 ++++--------- src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt | 10 +++++----- 5 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt index 934e9bda0..62e151d2f 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt @@ -79,11 +79,11 @@ object SlayerAPI { return result } - fun getNameWithEnchantmentFor(internalName: NEUInternalName): String? { + fun getNameWithEnchantmentFor(internalName: NEUInternalName): String { if (internalName.asString() == "WISP_POTION") { return "§fWisp's Ice-Flavored Water" } - return internalName.getItemStack().nameWithEnchantment + return internalName.getItemStack().nameWithEnchantment ?: error("Could not find name for $internalName") } @SubscribeEvent 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 76e4b3f77..039b57540 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataHolder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataHolder.kt @@ -68,7 +68,7 @@ class BazaarDataHolder { val buyPrice = internalName.getPrice(false) val npcPrice = npcPrices[internalName].let { if (it == null) { - if (!ignoreNoNpcPrice(internalName.asString())) { + if (!ignoreNoNpcPrice(internalName)) { LorenzUtils.debug("NPC price not found for '$internalName'") } 0.0 @@ -80,12 +80,12 @@ class BazaarDataHolder { return data } - private fun ignoreNoNpcPrice(internalName: String): Boolean { + private fun ignoreNoNpcPrice(internalName: NEUInternalName): Boolean { if (internalName.startsWith("TURBO_")) return true - if (internalName == "PURPLE_CANDY") return true - if (internalName == "JACOBS_TICKET") return true - if (internalName == "RAW_SOULFLOW") return true - if (internalName == "DERELICT_ASHE") return true + if (internalName.equals("PURPLE_CANDY")) return true + if (internalName.equals("JACOBS_TICKET")) return true + if (internalName.equals("RAW_SOULFLOW")) return true + if (internalName.equals("DERELICT_ASHE")) return true if (internalName.contains(";")) return true diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt index 57a7a5621..e5f846252 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt @@ -180,7 +180,7 @@ object SlayerItemProfitTracker { val price = (getPrice(internalName) * amount).toLong() - val cleanName = SlayerAPI.getNameWithEnchantmentFor(internalName) ?: internalName.asString() + val cleanName = SlayerAPI.getNameWithEnchantmentFor(internalName) var name = cleanName val priceFormat = NumberUtil.format(price) val hidden = itemProfit.hidden diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index 314275fa8..8fe41bfb2 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -176,15 +176,10 @@ object ItemUtils { } val ItemStack.nameWithEnchantment: String? - get() { - val name = name - name?.let { - if (name.endsWith("Enchanted Book")) { - return getLore()[0] - } - } - - return name + get() = name?.let { + if (it.endsWith("Enchanted Book")) { + getLore()[0] + } else it } fun isSkyBlockMenuItem(stack: ItemStack?): Boolean = stack?.getInternalName_old() == "SKYBLOCK_MENU" diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt index 6aa6fa28c..f55277e0a 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt @@ -151,16 +151,15 @@ object NEUItems { manager.auctionManager.transformHypixelBazaarToNEUItemId(hypixelId).asInternalName() fun NEUInternalName.getPrice(useSellingPrice: Boolean = false): Double { - val string = asString() - if (string == "WISP_POTION") { + if (equals("WISP_POTION")) { return 20_000.0 } - val result = manager.auctionManager.getBazaarOrBin(string, useSellingPrice) + val result = manager.auctionManager.getBazaarOrBin(asString(), useSellingPrice) if (result == -1.0) { - if (string == "JACK_O_LANTERN") { + if (equals("JACK_O_LANTERN")) { return getPrice("PUMPKIN", useSellingPrice) + 1 } - if (string == "GOLDEN_CARROT") { + if (equals("GOLDEN_CARROT")) { // 6.8 for some players return 7.0 // NPC price } @@ -177,6 +176,7 @@ object NEUItems { fun getItemStackOrNull(internalName: String) = internalName.asInternalName().getItemStackOrNull() + // TODO remove fun getItemStack(internalName: String, definite: Boolean = false): ItemStack = internalName.asInternalName().getItemStack(definite) -- cgit