aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt15
2 files changed, 16 insertions, 8 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt
index 790a7020f..4de998443 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt
@@ -53,7 +53,9 @@ class SkyMartBestProfit {
name = "§9Sunder I"
}
- iconMap[name] = NEUItems.getItemStack(internalName)
+ NEUItems.getItemStackOrNull(internalName)?.let {
+ iconMap[name] = it
+ }
val advancedStats = if (config.skyMartCopperPriceAdvancedStats) {
" §7(§6$priceFormat §7/ §c$amountFormat Copper§7)"
@@ -80,12 +82,13 @@ class SkyMartBestProfit {
val longest = keys.map { it.first }.maxOfOrNull { renderer.getStringWidth(it.removeColor()) } ?: 0
for ((name, second) in keys) {
- val itemStack = iconMap[name]!!
var displayName = "$name§f:"
while (renderer.getStringWidth(displayName.removeColor()) < longest) {
displayName += " "
}
- newList.add(listOf(itemStack, "$displayName $second"))
+ iconMap[name]?.let {
+ newList.add(listOf(it, "$displayName $second"))
+ }
}
return newList
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
index 568ccbb87..8633dcadd 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
@@ -55,21 +55,26 @@ object NEUItems {
return result
}
- fun getItemStack(internalName: String): ItemStack {
+ fun getItemStackOrNull(internalName: String): ItemStack? {
if (itemCache.contains(internalName)) {
return itemCache[internalName]!!.copy()
}
val itemStack = ItemResolutionQuery(manager)
.withKnownInternalName(internalName)
- .resolveToItemStack()
- if (itemStack == null) {
+ .resolveToItemStack() ?: return null
+ itemCache[internalName] = itemStack
+ return itemStack.copy()
+ }
+
+ fun getItemStack(internalName: String): ItemStack {
+ val stack = getItemStackOrNull(internalName)
+ if (stack == null) {
val error = "ItemResolutionQuery returns null for internalName $internalName"
LorenzUtils.error(error)
throw RuntimeException(error)
}
- itemCache[internalName] = itemStack
- return itemStack.copy()
+ return stack
}
fun isVanillaItem(item: ItemStack) = manager.auctionManager.isVanillaItem(item.getInternalName())