aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
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/hannibal2/skyhanni/utils/ItemUtils.kt
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/hannibal2/skyhanni/utils/ItemUtils.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt17
1 files changed, 15 insertions, 2 deletions
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