aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/slayer
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-08-09 12:12:27 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-08-09 12:12:27 +0200
commit17ec026c19d1e203244217d599f72bd265d9aac8 (patch)
tree28c86ae9415e11ec316741ba752a7e807a10f74c /src/main/java/at/hannibal2/skyhanni/features/slayer
parent3bcd5b3a8afa5b322d75af1b82681fd7b1e494e5 (diff)
downloadskyhanni-17ec026c19d1e203244217d599f72bd265d9aac8.tar.gz
skyhanni-17ec026c19d1e203244217d599f72bd265d9aac8.tar.bz2
skyhanni-17ec026c19d1e203244217d599f72bd265d9aac8.zip
Using NEUInternalName in slayer profit tracker
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/slayer')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt28
1 files changed, 12 insertions, 16 deletions
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 581761831..d67390349 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt
@@ -6,15 +6,16 @@ import at.hannibal2.skyhanni.data.ProfileStorageData
import at.hannibal2.skyhanni.data.SlayerAPI
import at.hannibal2.skyhanni.data.TitleUtils
import at.hannibal2.skyhanni.events.*
-import at.hannibal2.skyhanni.features.bazaar.BazaarApi
+import at.hannibal2.skyhanni.features.bazaar.BazaarApi.Companion.getBazaarData
import at.hannibal2.skyhanni.features.bazaar.BazaarData
import at.hannibal2.skyhanni.test.PriceSource
import at.hannibal2.skyhanni.utils.*
-import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
+import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull_new
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList
import at.hannibal2.skyhanni.utils.LorenzUtils.addSelector
import at.hannibal2.skyhanni.utils.LorenzUtils.sortedDesc
+import at.hannibal2.skyhanni.utils.NEUItems.getPrice
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
@@ -80,7 +81,7 @@ object SlayerItemProfitTracker {
update()
}
- private fun addItemPickup(internalName: String, stackSize: Int) {
+ private fun addItemPickup(internalName: NEUInternalName, stackSize: Int) {
val itemLog = currentLog() ?: return
itemLog.modify {
@@ -134,8 +135,7 @@ object SlayerItemProfitTracker {
val itemStack = item.entityItem
val name = itemStack.name ?: return
if (SlayerAPI.ignoreSlayerDrop(name)) return
- val internalName = itemStack.getInternalName()
- if (internalName == "") return
+ val internalName = itemStack.getInternalNameOrNull_new() ?: return
val (itemName, price) = SlayerAPI.getItemNameAndPrice(itemStack)
addItemPickup(internalName, itemStack.stackSize)
@@ -180,7 +180,7 @@ object SlayerItemProfitTracker {
val price = (getPrice(internalName) * amount).toLong()
- val cleanName = SlayerAPI.getNameWithEnchantmentFor(internalName) ?: internalName
+ val cleanName = SlayerAPI.getNameWithEnchantmentFor(internalName) ?: internalName.asString()
var name = cleanName
val priceFormat = NumberUtil.format(price)
val hidden = itemProfit.hidden
@@ -298,18 +298,14 @@ object SlayerItemProfitTracker {
list.slayerCompletedCount = 0
}
- private fun getPrice(internalName: String): Double {
- val bazaarData = BazaarApi.getBazaarDataByInternalName(internalName)
- return bazaarData?.let { getPrice(it) } ?: NEUItems.getPrice(internalName)
- }
+ private fun getPrice(internalName: NEUInternalName) =
+ internalName.getBazaarData()?.let { getPrice(it) } ?: internalName.getPrice()
- private fun getPrice(bazaarData: BazaarData): Double {
- return when (config.priceFrom) {
- 0 -> bazaarData.sellPrice
- 1 -> bazaarData.buyPrice
+ private fun getPrice(bazaarData: BazaarData) = when (config.priceFrom) {
+ 0 -> bazaarData.sellPrice
+ 1 -> bazaarData.buyPrice
- else -> bazaarData.npcPrice
- }
+ else -> bazaarData.npcPrice
}
@SubscribeEvent