aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
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
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')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt10
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/CollectionTracker.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt28
3 files changed, 21 insertions, 25 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt
index b0c08a4e8..b40bb81b2 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt
@@ -25,17 +25,15 @@ class BazaarApi {
NEUItems.getInternalNameOrNull(name)?.let { getBazaarDataByInternalName(it) }
fun getBazaarDataByInternalName(internalName: String) =
- getBazaarDataByInternalName_new(NEUInternalName.from(internalName))
+ NEUInternalName.from(internalName).getBazaarData()
- fun getBazaarDataByInternalName_new(internalName: NEUInternalName) = if (isBazaarItem(internalName)) {
- holder.getData(internalName)
+ fun NEUInternalName.getBazaarData() = if (isBazaarItem()) {
+ holder.getData(this)
} else null
fun isBazaarItem(stack: ItemStack) = isBazaarItem(stack.getInternalName())
- fun isBazaarItem(internalName: NEUInternalName): Boolean {
- return NEUItems.manager.auctionManager.getBazaarInfo(internalName.asString()) != null
- }
+ fun NEUInternalName.isBazaarItem() = NEUItems.manager.auctionManager.getBazaarInfo(asString()) != null
fun isBazaarItem(internalName: String): Boolean {
return NEUItems.manager.auctionManager.getBazaarInfo(internalName) != null
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionTracker.kt
index af01ca68b..741a1a089 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionTracker.kt
@@ -10,6 +10,8 @@ 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.getItemStack
+import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import net.minecraft.client.Minecraft
@@ -62,7 +64,7 @@ class CollectionTracker {
return
}
- val stack = NEUItems.getItemStackOrNull(foundInternalName)
+ val stack = foundInternalName.getItemStackOrNull()
if (stack == null) {
LorenzUtils.chat("§c[SkyHanni] Item '$rawName' does not exist!")
return
@@ -129,7 +131,7 @@ class CollectionTracker {
display = Collections.singletonList(buildList {
internalName?.let {
- add(NEUItems.getItemStack(it))
+ add(it.getItemStack())
}
add("$itemName collection: §e$format $gainText")
})
@@ -141,7 +143,7 @@ class CollectionTracker {
fun handleTabComplete(command: String): List<String>? {
if (command != "shtrackcollection") return null
- return CollectionAPI.collectionValue.keys.mapNotNull { NEUItems.getItemStackOrNull(it) }
+ return CollectionAPI.collectionValue.keys.mapNotNull { it.getItemStackOrNull() }
.map { it.displayName.removeColor().replace(" ", "_") }
}
}
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