aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorappable <enzospiacitelli@gmail.com>2024-05-18 02:19:48 -0700
committerGitHub <noreply@github.com>2024-05-18 11:19:48 +0200
commitf378737cd5536acce4b956b86a27878d3c7df9ef (patch)
tree76e418400ef691c1de383cc6b8fa4c380793c488 /src/main/java
parentae88647c121f0349bf0eb1455224d1ef1e95f7c7 (diff)
downloadskyhanni-f378737cd5536acce4b956b86a27878d3c7df9ef.tar.gz
skyhanni-f378737cd5536acce4b956b86a27878d3c7df9ef.tar.bz2
skyhanni-f378737cd5536acce4b956b86a27878d3c7df9ef.zip
Fix: Bestiary Display when in search results (#1828)
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt
index c80573e32..22f60e1ff 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt
@@ -25,9 +25,11 @@ import at.hannibal2.skyhanni.utils.NumberUtil.toRoman
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.renderables.Renderable
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
+import net.minecraft.init.Items
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -36,6 +38,25 @@ object BestiaryData {
private val config get() = SkyHanniMod.feature.combat.bestiary
private val patternGroup = RepoPattern.group("combat.bestiary.data")
+
+ /**
+ * REGEX-TEST: §7Progress to Tier 14: §b26%
+ * REGEX-TEST: §7Progress to Tier XV: §b57.1%
+ */
+ private val tierProgressPattern by patternGroup.pattern(
+ "tierprogress",
+ "§7Progress to Tier [\\dIVXC]+: §b[\\d.]+%"
+ )
+
+ /**
+ * REGEX-TEST: §7Overall Progress: §b55.2%
+ * REGEX-TEST: §7Overall Progress: §b100% §7(§c§lMAX!§7)
+ */
+ private val overallProgressPattern by patternGroup.pattern(
+ "overallprogress",
+ "§7Overall Progress: §b[\\d.]+%(?: §7\\(§c§lMAX!§7\\))?"
+ )
+
private val progressPattern by patternGroup.pattern(
"progress",
"(?<current>[0-9kKmMbB,.]+)/(?<needed>[0-9kKmMbB,.]+\$)"
@@ -97,7 +118,7 @@ object BestiaryData {
isCategory = inventoryName == "Bestiary ➜ Fishing" || inventoryName == "Bestiary"
stackList.putAll(items)
inInventory = true
- overallProgressEnabled = items[52]?.getLore()?.any { it == "§7Overall Progress: §aSHOWN" } ?: false
+ overallProgressEnabled = isOverallProgressEnabled(items)
update()
}
@@ -384,6 +405,21 @@ object BestiaryData {
}
}
+ private fun isOverallProgressEnabled(inventoryItems: Map<Int, ItemStack>): Boolean {
+ if (inventoryItems[52]?.item == Items.ender_eye) {
+ return inventoryItems[52]?.getLore()?.any { it == "§7Overall Progress: §aSHOWN" } == true
+ }
+
+ indexes.forEach { index ->
+ val item = inventoryItems[index] ?: return true
+ val hasTierProgress = item.getLore().any { tierProgressPattern.matches(it) }
+ val hasOverallProgress = item.getLore().any { overallProgressPattern.matches(it) }
+ if (hasTierProgress && !hasOverallProgress) return false
+ }
+
+ return true
+ }
+
private fun isBestiaryGui(stack: ItemStack?, name: String): Boolean {
if (stack == null) return false
val bestiaryGuiTitleMatcher = titlePattern.matcher(name)