diff options
5 files changed, 37 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 9b64ee1b5..ae24e155f 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -349,7 +349,6 @@ import at.hannibal2.skyhanni.utils.KeyboardManager import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.MinecraftConsoleFilter.Companion.initLogging import at.hannibal2.skyhanni.utils.NEUVersionCheck.checkIfNeuIsLoaded -import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils import at.hannibal2.skyhanni.utils.TabListData import at.hannibal2.skyhanni.utils.UtilsPatterns import at.hannibal2.skyhanni.utils.repopatterns.RepoPatternManager @@ -434,7 +433,6 @@ class SkyHanniMod { loadModule(BingoCardReader()) loadModule(GardenBestCropTime()) loadModule(TrackerManager) - loadModule(SkyBlockItemModifierUtils) loadModule(UtilsPatterns) // APIs 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 (?<level>\\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 (?<level>\\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<String, RepoPatternImpl>() 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 /** diff --git a/src/test/java/at/hannibal2/skyhanni/test/ItemModifierTest.kt b/src/test/java/at/hannibal2/skyhanni/test/ItemModifierTest.kt new file mode 100644 index 000000000..75fb59568 --- /dev/null +++ b/src/test/java/at/hannibal2/skyhanni/test/ItemModifierTest.kt @@ -0,0 +1,26 @@ +package at.hannibal2.skyhanni.test + +import at.hannibal2.skyhanni.utils.ItemUtils.isEnchanted +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEnchantments +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getHotPotatoCount +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getItemUuid +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getReforgeName +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.hasArtOfPeace +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.isRecombobulated +import org.junit.jupiter.api.Test + +class ItemModifierTest { + + @Test + fun testUpgradeLevelMasterStars() { + val itemStack = TestExportTools.getTestData(TestExportTools.Item, "10starnecronhead") + assert(!itemStack.isRecombobulated()) + assert(itemStack.getReforgeName() == "ancient") + assert(itemStack.getItemUuid() == "2810b7fe-33af-4dab-bb41-b4815f5847af") + assert(itemStack.isEnchanted()) + assert(itemStack.getHotPotatoCount() == 15) + assert(itemStack.getEnchantments()?.size == 11) + assert(itemStack.hasArtOfPeace()) +// assert(itemStack.getDungeonStarCount() == 10) + } +} |