From f1c370d3f4a145c5bff28c5ece8a788156d4d05f Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:43:43 -0400 Subject: Fix: El Dorado Dupe (Again) (#2786) --- .../at/hannibal2/skyhanni/features/event/hoppity/HoppityAPI.kt | 10 ++++++++++ .../inventory/chocolatefactory/ChocolateFactoryStrayTracker.kt | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityAPI.kt index 8d3ac22c3..d6100acfe 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityAPI.kt @@ -24,15 +24,18 @@ import at.hannibal2.skyhanni.utils.ItemUtils.itemName import at.hannibal2.skyhanni.utils.LorenzRarity import at.hannibal2.skyhanni.utils.LorenzRarity.DIVINE import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RegexUtils.anyMatches import at.hannibal2.skyhanni.utils.RegexUtils.firstMatcher import at.hannibal2.skyhanni.utils.RegexUtils.groupOrNull import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matches +import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getMinecraftId import at.hannibal2.skyhanni.utils.SkyblockSeason import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.seconds @SkyHanniModule object HoppityAPI { @@ -45,6 +48,7 @@ object HoppityAPI { private var newRabbit = false private var lastMeal: HoppityEggType? = null private var lastDuplicateAmount: Long? = null + private var lastDoradoFire: SimpleTimeMark = SimpleTimeMark.farPast() val hoppityRarities by lazy { LorenzRarity.entries.filter { it <= DIVINE } } @@ -122,6 +126,11 @@ object HoppityAPI { } } ChocolateFactoryStrayTracker.strayDoradoPattern.matchMatcher(formLoreToSingleLine(it.stack.getLore())) { + // If the lore contains the escape pattern, we don't want to fire the event. + // There are also 3 separate messages that can match, which is why we need to check the time since the last fire. + val escaped = ChocolateFactoryStrayTracker.doradoEscapeStrayPattern.anyMatches(it.stack.getLore()) + if (escaped || lastDoradoFire.passedSince() <= 10.seconds) return@matchMatcher + // We don't need to do a handleStrayClicked here - the lore from El Dorado is already: // §6§lGolden Rabbit §d§lCAUGHT! // Which will trigger the above matcher. We only need to check name here to fire the found event for Dorado. @@ -130,6 +139,7 @@ object HoppityAPI { lastMeal = STRAY duplicate = it.stack.getLore().any { line -> duplicateDoradoStrayPattern.matches(line) } attemptFireRabbitFound() + lastDoradoFire = SimpleTimeMark.now() } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStrayTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStrayTracker.kt index 5c640893c..765f65627 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStrayTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStrayTracker.kt @@ -126,6 +126,15 @@ object ChocolateFactoryStrayTracker { "(?:§.)*already have captured him before.*", ) + /** + * REGEX-TEST: §7but he escaped and left behind + * REGEX-TEST: §7§6Legend of §6El Dorado §7grows! + */ + val doradoEscapeStrayPattern by ChocolateFactoryAPI.patternGroup.pattern( + "stray.doradoescape", + "(?:§.)*(?:but he escaped and left behind|Legend of (?:§.)*El Dorado (?:§.)*grows!)" + ) + private val tracker = SkyHanniTracker("Stray Tracker", { Data() }, { it.chocolateFactory.strayTracker }) { drawDisplay(it) } -- cgit