From 6ada0c11bfb7f79f39a94db061f158f46e89d8d2 Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Sun, 21 Jan 2024 22:38:20 +1100 Subject: fix tests and bring it back (#943) Bring back the deleted test and fix the issue causing it. #943 --- .../java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt | 5 +---- src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt | 4 ++++ .../at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt | 7 ++++++- 3 files changed, 11 insertions(+), 5 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/utils') diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt index 3614eb39d..ed7b94770 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt @@ -8,7 +8,6 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor -import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import com.google.gson.JsonObject import net.minecraft.item.Item import net.minecraft.item.ItemStack @@ -18,8 +17,6 @@ import java.util.Locale object SkyBlockItemModifierUtils { private val drillPartTypes = listOf("drill_part_upgrade_module", "drill_part_engine", "drill_part_fuel_tank") - private val petLevelPattern by RepoPattern.pattern("utils.item.petlevel", "(?:§f§f)?§7\\[Lvl (?\\d+)] .*") - fun ItemStack.getHotPotatoCount() = getAttributeInt("hot_potato_count") fun ItemStack.getFarmingForDummiesCount() = getAttributeInt("farming_for_dummies_count") @@ -95,7 +92,7 @@ object SkyBlockItemModifierUtils { inline val ItemStack.cachedData get() = (this as ItemStackCachedData).skyhanni_cachedData fun ItemStack.getPetLevel(): Int { - petLevelPattern.matchMatcher(this.displayName) { + UtilsPatterns.petLevelPattern.matchMatcher(this.displayName) { return group("level").toInt() } return 0 diff --git a/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt b/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt index fdaa65050..05bb4620b 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt @@ -35,4 +35,8 @@ object UtilsPatterns { "item.name.potion", ".*Potion" ) + val petLevelPattern by patternGroup.pattern( + "item.petlevel", + "(?:§f§f)?§7\\[Lvl (?\\d+)] .*" + ) } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt b/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt index 1aee38844..a0bc09da7 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt @@ -38,7 +38,12 @@ object RepoPatternManager { private var usedKeys = mutableMapOf() private var wasPreinitialized = false - private val isInDevEnv = Launch.blackboard["fml.deobfuscatedEnvironment"] as Boolean + private val isInDevEnv = try { + Launch.blackboard["fml.deobfuscatedEnvironment"] as Boolean + } catch (_: Exception) { + true + } + private val config get() = SkyHanniMod.feature.dev.repoPattern /** -- cgit