diff options
author | MTOnline69 <97001154+MTOnline69@users.noreply.github.com> | 2024-09-07 21:26:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-07 22:26:59 +0200 |
commit | 988807120f71bafe20d63b8beeb8fac244065219 (patch) | |
tree | 5f85acea1dbebf9b9c592c067435a24261181b56 /src/main/java/at/hannibal2/skyhanni/features/combat | |
parent | b0b2d42b999ebf8ebb41ad48a54f52ce1315d1dd (diff) | |
download | skyhanni-988807120f71bafe20d63b8beeb8fac244065219.tar.gz skyhanni-988807120f71bafe20d63b8beeb8fac244065219.tar.bz2 skyhanni-988807120f71bafe20d63b8beeb8fac244065219.zip |
Feature: Arachne kill timer (#1993)
Co-authored-by: Cal <cwolfson58@gmail.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/combat')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/combat/mobs/ArachneKillTimer.kt | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/ArachneKillTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/ArachneKillTimer.kt new file mode 100644 index 000000000..d4980ec50 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/ArachneKillTimer.kt @@ -0,0 +1,88 @@ +package at.hannibal2.skyhanni.features.combat.mobs + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.features.chat.ArachneChatMessageHider +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland +import at.hannibal2.skyhanni.utils.RegexUtils.matches +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.TimeUtils.format +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration + +@SkyHanniModule +object ArachneKillTimer { + + private val config get() = SkyHanniMod.feature.combat.mobs + + private val patternGroup = RepoPattern.group("chat.arachne") + + /** + * REGEX-TEST: §c[BOSS] Arachne§r§f: A befitting welcome! + */ + private val arachneCallingSpawnedPattern by patternGroup.pattern( + "calling.spawned", + "§c\\[BOSS] Arachne§r§f: A befitting welcome!" + ) + /** + * REGEX-TEST: §c[BOSS] Arachne§r§f: With your sacrifice. + */ + private val arachneCrystalSpawnedPattern by patternGroup.pattern( + "crystal.spawned", + "§c\\[BOSS] Arachne§r§f: With your sacrifice." + ) + /** + * REGEX-TEST: §f §r§6§lARACHNE DOWN! + */ + private val arachneDeathPattern by patternGroup.pattern( + "dead", + "§f.*§r§6§lARACHNE DOWN!" + ) + /** + * REGEX-TEST: §f §r§eYour Damage: §r§a1,155,000 §r§7(Position #1) + */ + private val arachneDamagePattern by patternGroup.pattern( + "damage", + "§f +§r§eYour Damage: §r§a[0-9,]+ §r§7\\(Position #[0-9,]+\\)" + ) + + private var arachneSpawnedTime = SimpleTimeMark.farPast() + private var arachneKillTime = Duration.ZERO + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (!isEnabled()) return + if (arachneCallingSpawnedPattern.matches(event.message) || arachneCrystalSpawnedPattern.matches(event.message)) { + arachneSpawnedTime = SimpleTimeMark.now() + } + + if (arachneDeathPattern.matches(event.message) && arachneSpawnedTime != SimpleTimeMark.farPast()) { + arachneKillTime = arachneSpawnedTime.passedSince() + } + + if (ArachneChatMessageHider.arachneCallingPattern.matches(event.message) || + ArachneChatMessageHider.arachneCrystalPattern.matches(event.message) + ) { + arachneSpawnedTime = SimpleTimeMark.farPast() + } + + if (arachneKillTime.isPositive() && arachneDamagePattern.matches(event.message)) { + val format = arachneKillTime.format(showMilliSeconds = true) + ChatUtils.chat(" §eArachne took §b$format§e seconds to kill.", prefix = false) + arachneKillTime = Duration.ZERO + arachneSpawnedTime = SimpleTimeMark.farPast() + } + } + + @SubscribeEvent + fun onWorldChange(event: LorenzWorldChangeEvent) { + arachneSpawnedTime = SimpleTimeMark.farPast() + } + + fun isEnabled() = IslandType.SPIDER_DEN.isInIsland() && config.arachneKillTimer +} |