aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Cole <40234707+DavidArthurCole@users.noreply.github.com>2024-10-21 16:43:43 -0400
committerGitHub <noreply@github.com>2024-10-21 22:43:43 +0200
commitf1c370d3f4a145c5bff28c5ece8a788156d4d05f (patch)
tree9bcc5a3e7838b360501b88acf7d08b724aaf292c
parentc0d2a5855c1e90e502473ed80408d1ecc74e90a2 (diff)
downloadSkyHanni-f1c370d3f4a145c5bff28c5ece8a788156d4d05f.tar.gz
SkyHanni-f1c370d3f4a145c5bff28c5ece8a788156d4d05f.tar.bz2
SkyHanni-f1c370d3f4a145c5bff28c5ece8a788156d4d05f.zip
Fix: El Dorado Dupe (Again) (#2786)
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityAPI.kt10
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStrayTracker.kt9
2 files changed, 19 insertions, 0 deletions
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)
}