aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorThunderblade73 <85900443+Thunderblade73@users.noreply.github.com>2024-08-23 11:12:56 +0200
committerGitHub <noreply@github.com>2024-08-23 11:12:56 +0200
commit67060aeab991ebb18c3bba19adfa66c09e1acdcd (patch)
tree72a91bbd4c19a5c793fb6826f432dd04ed5f6ffc /src/main/java/at
parentc4e2893426a3e4ebe94d26199d1e23935fed9d73 (diff)
downloadskyhanni-67060aeab991ebb18c3bba19adfa66c09e1acdcd.tar.gz
skyhanni-67060aeab991ebb18c3bba19adfa66c09e1acdcd.tar.bz2
skyhanni-67060aeab991ebb18c3bba19adfa66c09e1acdcd.zip
Fix: ItemCategory error spam (#2392)
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt16
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt17
2 files changed, 26 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt
index fbb163caa..df3d85267 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt
@@ -74,10 +74,12 @@ object ErrorManager {
errorMessages[errorId]
}
val name = if (fullErrorMessage) "Full error" else "Error"
- ChatUtils.chat(errorMessage?.let {
- OSUtils.copyToClipboard(it)
- "$name copied into the clipboard, please report it on the SkyHanni discord!"
- } ?: "Error id not found!")
+ ChatUtils.chat(
+ errorMessage?.let {
+ OSUtils.copyToClipboard(it)
+ "$name copied into the clipboard, please report it on the SkyHanni discord!"
+ } ?: "Error id not found!",
+ )
}
fun logErrorStateWithData(
@@ -87,6 +89,7 @@ object ErrorManager {
ignoreErrorCache: Boolean = false,
noStackTrace: Boolean = false,
betaOnly: Boolean = false,
+ condition: () -> Boolean = { true },
) {
logError(
IllegalStateException(internalMessage),
@@ -95,6 +98,7 @@ object ErrorManager {
noStackTrace,
*extraData,
betaOnly = betaOnly,
+ condition = condition,
)
}
@@ -116,6 +120,7 @@ object ErrorManager {
noStackTrace: Boolean,
vararg extraData: Pair<String, Any?>,
betaOnly: Boolean = false,
+ condition: () -> Boolean = { true },
) {
if (betaOnly && !LorenzUtils.isBetaVersion()) return
if (!ignoreErrorCache) {
@@ -125,6 +130,7 @@ object ErrorManager {
if (pair in cache) return
cache.add(pair)
}
+ if (!condition()) return
Error(message, throwable).printStackTrace()
Minecraft.getMinecraft().thePlayer ?: return
@@ -152,7 +158,7 @@ object ErrorManager {
"§c[SkyHanni-${SkyHanniMod.version}]: $message§c. Click here to copy the error into the clipboard.",
onClick = { copyError(randomId) },
"§eClick to copy!",
- prefix = false
+ prefix = false,
)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
index 09f77ebce..8b6203aaa 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
@@ -18,6 +18,7 @@ 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 at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import com.google.common.collect.Lists
import io.github.moulberry.notenoughupdates.recipes.NeuRecipe
import io.github.moulberry.notenoughupdates.util.NotificationHandler
@@ -179,6 +180,15 @@ object ItemUtils {
fun ItemStack.getItemRarityOrCommon() = getItemRarityOrNull() ?: LorenzRarity.COMMON
+ private val itemCategoryRepoCheckPattern by RepoPattern.pattern(
+ "itemcategory.repocheck",
+ ItemCategory.entries.joinToString(separator = "|") { it.name },
+ )
+ private val rarityCategoryRepoCheckPattern by RepoPattern.pattern(
+ "rarity.repocheck",
+ LorenzRarity.entries.joinToString(separator = "|") { it.name },
+ )
+
private fun ItemStack.readItemCategoryAndRarity(): Pair<LorenzRarity?, ItemCategory?> {
val cleanName = this.cleanName()
@@ -204,6 +214,8 @@ object ItemUtils {
"inventory name" to InventoryUtils.openInventoryName(),
"pattern result" to category,
"lore" to getLore(),
+ betaOnly = true,
+ condition = { !itemCategoryRepoCheckPattern.matches(category) },
)
}
if (itemRarity == null) {
@@ -213,7 +225,10 @@ object ItemUtils {
"internal name" to getInternalName(),
"item name" to name,
"inventory name" to InventoryUtils.openInventoryName(),
+ "pattern result" to rarity,
"lore" to getLore(),
+ betaOnly = true,
+ condition = { !rarityCategoryRepoCheckPattern.matches(rarity) },
)
}
@@ -352,14 +367,12 @@ object ItemUtils {
return getInternalName().itemName
}
-
fun ItemStack.getAttributeFromShard(): Pair<String, Int>? {
if (getInternalName().asString() != "ATTRIBUTE_SHARD") return null
val attributes = getAttributes() ?: return null
return attributes.firstOrNull()
}
-
val ItemStack.itemNameWithoutColor: String get() = itemName.removeColor()
// use when showing the item name to the user (in guis, chat message, etc.), not for comparing