aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt16
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt5
3 files changed, 18 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
index 4a3568a9f..c688b1ff3 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
@@ -12,10 +12,14 @@ import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
import at.hannibal2.skyhanni.test.command.CopyErrorCommand
import at.hannibal2.skyhanni.utils.*
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
+import at.hannibal2.skyhanni.utils.ItemUtils.getItemNameOrNull
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList
+import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
+import at.hannibal2.skyhanni.utils.NEUItems.getItemStack
+import at.hannibal2.skyhanni.utils.NEUItems.getPrice
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.RenderUtils.drawString
import at.hannibal2.skyhanni.utils.RenderUtils.exactLocation
@@ -232,9 +236,9 @@ class GardenVisitorFeatures {
list.add("§7(§fAny§7)")
} else {
for (item in items) {
- val internalName = NEUItems.getInternalNameOrNull(item)
+ val internalName = NEUItems.getInternalNameOrNull_new(item)
if (internalName != null) {
- list.add(NEUItems.getItemStack(internalName))
+ list.add(internalName.getItemStack())
} else {
list.add(" '$item' ")
}
@@ -369,10 +373,10 @@ class GardenVisitorFeatures {
val formattedLine = line.substring(4)
val (itemName, amount) = ItemUtils.readItemAmount(formattedLine)
if (itemName != null) {
- var internalName = NEUItems.getInternalNameOrNull(itemName)
+ var internalName = NEUItems.getInternalNameOrNull_new(itemName)
if (internalName != null) {
- internalName = internalName.replace("◆_", "")
- price = NEUItems.getPrice(internalName) * amount
+ internalName = internalName.asString().replace("◆_", "").asInternalName()
+ price = internalName.getPrice() * amount
if (config.visitorShowPrice) {
val format = NumberUtil.format(price)
@@ -381,7 +385,7 @@ class GardenVisitorFeatures {
if (totalPrice == 0.0) {
totalPrice = price
val multiplier = NEUItems.getMultiplier(internalName)
- val rawName = NEUItems.getItemStackOrNull(multiplier.first)?.name?.removeColor() ?: continue
+ val rawName = multiplier.first.getItemNameOrNull()?.removeColor() ?: continue
getByNameOrNull(rawName)?.let {
val cropAmount = multiplier.second.toLong() * amount
val formattedAmount = LorenzUtils.formatInteger(cropAmount)
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
index 14bb25231..53e810483 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
@@ -227,5 +227,7 @@ object ItemUtils {
return pair
}
- fun NEUInternalName.getItemName() = getItemStack().name ?: error("No item name found for $this")
+ fun NEUInternalName.getItemNameOrNull() = getItemStack().name
+
+ fun NEUInternalName.getItemName() = getItemNameOrNull() ?: error("No item name found for $this")
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
index 446eeffc0..ad424d5d2 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
@@ -229,6 +229,11 @@ object NEUItems {
GlStateManager.popMatrix()
}
+ fun getMultiplier(internalName: NEUInternalName, tryCount: Int = 0): Pair<NEUInternalName, Int> {
+ val pair = getMultiplier(internalName.asString(), tryCount)
+ return Pair(pair.first.asInternalName(), pair.second)
+ }
+
fun getMultiplier(internalName: String, tryCount: Int = 0): Pair<String, Int> {
if (multiplierCache.contains(internalName)) {
return multiplierCache[internalName]!!