From b7b798821267c6b2365618bf2ca552f07f366dc1 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Sat, 4 May 2024 15:19:43 +0200 Subject: Fix: Reputation Helper wrong miniboss amount (#1633) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../dailyquest/DailyQuestHelper.kt | 11 +++++++++ .../reputationhelper/dailyquest/QuestLoader.kt | 28 ++++++++++++++++++++++ 2 files changed, 39 insertions(+) (limited to 'src') 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() 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(?\\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() + } } } -- cgit