diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-05-04 15:19:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-04 15:19:43 +0200 |
commit | b7b798821267c6b2365618bf2ca552f07f366dc1 (patch) | |
tree | 22d6e74362a435e7546f938caf99989f425cdd3a /src | |
parent | 61697f51e88361125ac555507cfa08fc00b126fc (diff) | |
download | skyhanni-b7b798821267c6b2365618bf2ca552f07f366dc1.tar.gz skyhanni-b7b798821267c6b2365618bf2ca552f07f366dc1.tar.bz2 skyhanni-b7b798821267c6b2365618bf2ca552f07f366dc1.zip |
Fix: Reputation Helper wrong miniboss amount (#1633)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src')
2 files changed, 39 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt index c656cc726..72b1e76a2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt @@ -41,6 +41,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.StringUtils.removeWordsAtEnd +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.inventory.ContainerChest import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -54,6 +55,16 @@ class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) { val quests = mutableListOf<Quest>() var greatSpook = false + /** + * REGEX-TEST: §7Kill the §cAshfang §7miniboss §a2 §7times! + * REGEX-TEST: §7Kill the §cMage Outlaw §7miniboss §a1 §7time! + * REGEX-TEST: §7miniboss §a1 §7time! + */ + val minibossAmountPattern by RepoPattern.pattern( + "crimson.reputationhelper.quest.minibossamount", + "(?:§7Kill the §c.+ §7|.*)miniboss §a(?<amount>\\d) §7times?!" + ) + private val config get() = SkyHanniMod.feature.crimsonIsle.reputationHelper @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt index e6753ffc5..3910eb9de 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt @@ -15,10 +15,13 @@ import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest.T import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest.UnknownQuest import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.TabListData +import net.minecraft.item.ItemStack class QuestLoader(private val dailyQuestHelper: DailyQuestHelper) { @@ -167,6 +170,31 @@ class QuestLoader(private val dailyQuestHelper: DailyQuestHelper) { quest.state = QuestState.ACCEPTED dailyQuestHelper.update() } + if (name == "Miniboss") { + fixMinibossAmount(quest, stack) + } + } + } + + // TODO remove this workaround once hypixel fixes the bug that amount is not in tab list for minibosses + private fun fixMinibossAmount(quest: Quest, stack: ItemStack) { + if (quest !is MiniBossQuest) return + val storedAmount = quest.needAmount + if (storedAmount != 1) return + for (line in stack.getLore()) { + val realAmount = dailyQuestHelper.minibossAmountPattern.matchMatcher(line) { + group("amount").toInt() + } ?: continue + if (storedAmount == realAmount) continue + + ChatUtils.debug("Wrong amount detected! realAmount: $realAmount, storedAmount: $storedAmount") + val newQuest = MiniBossQuest(quest.miniBoss, quest.state, realAmount) + DelayedRun.runNextTick { + dailyQuestHelper.quests.remove(quest) + dailyQuestHelper.quests.add(newQuest) + ChatUtils.chat("Fixed wrong miniboss amount from tab list.") + dailyQuestHelper.update() + } } } |