aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-03-28 17:32:27 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-03-28 17:32:27 +0200
commitea0fa98cbd55f87c2f9ab5ab4032a9044feeb793 (patch)
treeda267dd3c4f428241b6a1989cfae65aacbc7d21a
parentf20726ed77f21aead51ec3da2e90411c57aaf5f5 (diff)
downloadskyhanni-ea0fa98cbd55f87c2f9ab5ab4032a9044feeb793.tar.gz
skyhanni-ea0fa98cbd55f87c2f9ab5ab4032a9044feeb793.tar.bz2
skyhanni-ea0fa98cbd55f87c2f9ab5ab4032a9044feeb793.zip
Fixed coins per copper display in SkyMall not showing when some items are not in the NEU Repo.
-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())