aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt24
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/composter/GardenComposterInventoryFeatures.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt51
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt11
7 files changed, 71 insertions, 55 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt
index 5bf03b7e3..aee2a93f4 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt
@@ -171,23 +171,19 @@ object ComposterOverlay {
return
}
if (organicMatterFactors.isEmpty()) {
- organicMatterDisplay =
- Collections.singletonList(
- listOf(
- "§cSkyHanni composter error:", "§cRepo data not loaded!",
- "§7(organicMatterFactors is empty)",
- ),
- )
+ organicMatterDisplay = listOf(
+ Collections.singletonList("§cSkyHanni composter error:"),
+ Collections.singletonList("§cRepo data not loaded!"),
+ Collections.singletonList("§7(organicMatterFactors is empty)"),
+ )
return
}
if (fuelFactors.isEmpty()) {
- organicMatterDisplay =
- Collections.singletonList(
- listOf(
- "§cSkyHanni composter error:", "§cRepo data not loaded!",
- "§7(fuelFactors is empty)",
- ),
- )
+ organicMatterDisplay = listOf(
+ Collections.singletonList("§cSkyHanni composter error:"),
+ Collections.singletonList("§cRepo data not loaded!"),
+ Collections.singletonList("§7(fuelFactors is empty)"),
+ )
return
}
if (currentOrganicMatterItem.let { it !in organicMatterFactors.keys && it != NONE }) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/GardenComposterInventoryFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/GardenComposterInventoryFeatures.kt
index eb6dc41e0..a4510af8b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/GardenComposterInventoryFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/GardenComposterInventoryFeatures.kt
@@ -57,14 +57,7 @@ object GardenComposterInventoryFeatures {
)
continue
}
- val internalName = NEUInternalName.fromItemNameOrNull(itemName) ?: run {
- ErrorManager.logErrorStateWithData(
- "Error reading internal name for item: $itemName",
- "could not find internal name for",
- "itemName" to itemName
- )
- continue
- }
+ val internalName = NEUInternalName.fromItemName(itemName)
val lowestBin = internalName.getPrice()
val price = lowestBin * amount
fullPrice += price
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt
index e55916f95..a587443e5 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt
@@ -13,7 +13,6 @@ import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.events.item.ItemHoverEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.test.command.ErrorManager
-import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList
import at.hannibal2.skyhanni.utils.ConditionalUtils
import at.hannibal2.skyhanni.utils.InventoryUtils
@@ -25,7 +24,6 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NEUInternalName
-import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
@@ -203,12 +201,6 @@ object EstimatedItemValue {
if (internalName.contains("UNIQUE_RUNE")) return listOf()
if (internalName.contains("WISP_POTION")) return listOf()
-
- if (internalName.getItemStackOrNull() == null) {
- ChatUtils.debug("Estimated Item Value is null for: '$internalName'")
- return listOf()
- }
-
val list = mutableListOf<String>()
list.add("§aEstimated Item Value:")
val pair = EstimatedItemValueCalculator.calculate(stack, list)
diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt
index 3e31faef0..d3df5da3e 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt
@@ -20,7 +20,6 @@ import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorColorNames
import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.getBazaarData
import at.hannibal2.skyhanni.features.mining.OreBlock
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
-import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.BlockUtils
import at.hannibal2.skyhanni.utils.BlockUtils.getBlockStateAt
import at.hannibal2.skyhanni.utils.ChatUtils
@@ -32,7 +31,6 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull
import at.hannibal2.skyhanni.utils.ItemUtils.getItemCategoryOrNull
import at.hannibal2.skyhanni.utils.ItemUtils.getItemRarityOrNull
import at.hannibal2.skyhanni.utils.ItemUtils.itemName
-import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LorenzColor
@@ -366,12 +364,9 @@ object SkyHanniDebugsAndTests {
return
}
- val internalName = hand.getInternalNameOrNull()
- ?: ErrorManager.skyHanniError("Internal name is null for item ${hand.name}")
-
- val rawInternalName = internalName.asString()
- OSUtils.copyToClipboard(rawInternalName)
- ChatUtils.chat("§eCopied internal name §7$rawInternalName §eto the clipboard!")
+ val internalName = hand.getInternalName().asString()
+ OSUtils.copyToClipboard(internalName)
+ ChatUtils.chat("§eCopied internal name §7$internalName §eto the clipboard!")
}
fun toggleRender() {
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
index 95dad660c..cd55107db 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
@@ -1,6 +1,8 @@
package at.hannibal2.skyhanni.utils
import at.hannibal2.skyhanni.data.PetAPI
+import at.hannibal2.skyhanni.events.DebugDataCollectEvent
+import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
@@ -14,7 +16,9 @@ import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEnchantments
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.isRecombobulated
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.StringUtils.removeResets
+import com.google.common.collect.Lists
import io.github.moulberry.notenoughupdates.recipes.NeuRecipe
+import io.github.moulberry.notenoughupdates.util.NotificationHandler
import net.minecraft.client.Minecraft
import net.minecraft.init.Items
import net.minecraft.item.ItemStack
@@ -22,14 +26,18 @@ import net.minecraft.nbt.NBTTagCompound
import net.minecraft.nbt.NBTTagList
import net.minecraft.nbt.NBTTagString
import net.minecraftforge.common.util.Constants
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.LinkedList
import java.util.regex.Matcher
import kotlin.time.Duration.Companion.seconds
+@SkyHanniModule
object ItemUtils {
private val itemNameCache = mutableMapOf<NEUInternalName, String>() // internal name -> item name
+ private val missingRepoItems = mutableSetOf<String>()
+
fun ItemStack.cleanName() = this.displayName.removeColor()
fun isSack(stack: ItemStack) = stack.getInternalName().endsWith("_SACK") && stack.cleanName().endsWith(" Sack")
@@ -264,7 +272,7 @@ object ItemUtils {
*/
var ItemStack.name: String
get() = this.displayName ?: ErrorManager.skyHanniError(
- "Could not get name if ItemStack",
+ "Could not get name of ItemStack",
"itemStack" to this,
"displayName" to displayName,
"internal name" to getInternalNameOrNull(),
@@ -360,7 +368,11 @@ object ItemUtils {
}
val itemStack = getItemStackOrNull()
- val name = itemStack?.name ?: error("Could not find item name for $this")
+ val name = itemStack?.name ?: run {
+ val name = toString()
+ addMissingRepoItem(name, "Could not find item name for $name")
+ return "§c$name"
+ }
// show enchanted book name
if (itemStack.getItemCategoryOrNull() == ItemCategory.ENCHANTED_BOOK) {
@@ -411,4 +423,39 @@ object ItemUtils {
it.key.getPrice(pastRecipes = pastRecipes) * it.value
}.sum()
+ @SubscribeEvent
+ fun onDebugDataCollect(event: DebugDataCollectEvent) {
+ event.title("Missing Repo Items")
+
+ if (missingRepoItems.isNotEmpty()) {
+ event.addData {
+ add("Detected ${missingRepoItems.size} missing items:")
+ for (itemName in missingRepoItems) {
+ add(" - $itemName")
+ }
+ }
+ } else {
+ event.addIrrelevant("No Repo Item fails detected.")
+ }
+ }
+
+ fun addMissingRepoItem(name: String, message: String) {
+ if (!missingRepoItems.add(name)) return
+ ChatUtils.debug(message)
+// showRepoWarning()
+ }
+
+ // Running NEU's function `Utils.showOutdatedRepoNotification()` caused a NoSuchMethodError in dev env.
+ // Therefore we run NotificationHandler.displayNotification directly
+ private fun showRepoWarning() {
+ NotificationHandler.displayNotification(
+ Lists.newArrayList(
+ "§c§lMissing repo data",
+ "§cData used for some SkyHanni features is not up to date, this should normally not be the case.",
+ "§cYou can try §l/neuresetrepo§r§c and restart your game to see if that fixes the issue.",
+ "§cIf the problem persists please join the SkyHanni Discord and message in §l#support§r§c to get support.",
+ ),
+ true, true,
+ )
+ }
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt
index 98f903468..18568869a 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt
@@ -1,7 +1,5 @@
package at.hannibal2.skyhanni.utils
-import at.hannibal2.skyhanni.test.command.ErrorManager
-
class NEUInternalName private constructor(private val internalName: String) {
companion object {
@@ -24,11 +22,11 @@ class NEUInternalName private constructor(private val internalName: String) {
fun fromItemNameOrNull(itemName: String): NEUInternalName? =
ItemNameResolver.getInternalNameOrNull(itemName.removeSuffix(" Pet"))
- fun fromItemName(itemName: String): NEUInternalName =
- fromItemNameOrNull(itemName) ?: ErrorManager.skyHanniError(
- "NEUInternalName is null for item name: '$itemName'",
- "inventoryName" to InventoryUtils.openInventoryName()
- )
+ fun fromItemName(itemName: String): NEUInternalName = fromItemNameOrNull(itemName) ?: run {
+ val name = "itemName:$itemName"
+ ItemUtils.addMissingRepoItem(name, "Could not find internal name for $name")
+ return NEUInternalName.MISSING_ITEM
+ }
}
fun asString() = internalName
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
index ae3863410..b7cf23eeb 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
@@ -197,14 +197,9 @@ object NEUItems {
getItemStackOrNull() ?: run {
getPriceOrNullNew() ?: return@run fallbackItem
if (ignoreItemsFilter.match(this.asString())) return@run fallbackItem
- ErrorManager.logErrorWithData(
- IllegalStateException("Something went wrong!"),
- "Encountered an error getting the item for §7$this§c. " +
- "This may be because your NEU repo is outdated. Please ask in the SkyHanni " +
- "Discord if this is the case.",
- "Item name" to this.asString(),
- "repo commit" to manager.latestRepoCommit,
- )
+
+ val name = this.toString()
+ ItemUtils.addMissingRepoItem(name, "Could not create item stack for $name")
fallbackItem
}