From 2a465d20b139c93064bd2032e0932f150756d8c5 Mon Sep 17 00:00:00 2001 From: Empa <42304516+ItsEmpa@users.noreply.github.com> Date: Wed, 12 Jun 2024 17:10:02 +0200 Subject: Fix: No MP Message (#2065) Co-authored-by: Luna --- src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt index 56e3cdf42..194664c94 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt @@ -57,6 +57,7 @@ object MaxwellAPI { storage?.maxwell?.favoritePowers = value } + private val NO_POWER by lazy { getPowerByNameOrNull("No Power") } private var powers = mutableListOf() private val patternGroup = RepoPattern.group("data.maxwell") @@ -258,23 +259,24 @@ object MaxwellAPI { var foundMagicalPower = false for (line in stack.getLore()) { redstoneCollectionRequirementPattern.matchMatcher(line) { + if (magicalPower == 0 && currentPower == NO_POWER) return ChatUtils.chat( "Seems like you don't have the Requirement for the Accessory Bag yet, " + "setting power to No Power and magical power to 0.", ) - currentPower = getPowerByNameOrNull("No Power") + currentPower = NO_POWER magicalPower = 0 + tunings = listOf() return } - if (noPowerSelectedPattern.matches(line)) currentPower = getPowerByNameOrNull("No Power") + if (noPowerSelectedPattern.matches(line)) currentPower = NO_POWER inventoryMPPattern.matchMatcher(line) { // MagicalPower is boosted in catacombs if (DungeonAPI.inDungeon()) return@matchMatcher - val mp = group("mp") - magicalPower = mp.formatInt() + magicalPower = group("mp").formatInt() foundMagicalPower = true } @@ -292,7 +294,10 @@ object MaxwellAPI { } // If Magical Power isn't in the lore - if (!foundMagicalPower) magicalPower = 0 + if (!foundMagicalPower) { + magicalPower = 0 + tunings = listOf() + } } fun getPowerByNameOrNull(name: String) = powers.find { it == name } -- cgit