Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Arachne kill timer #1993

Merged
merged 12 commits into from
Sep 7, 2024
2 changes: 1 addition & 1 deletion src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ class SkyHanniMod {
loadModule(SlayerItemsOnGround())
loadModule(RestorePieceOfWizardPortalLore())
loadModule(QuickModMenuSwitch)
loadModule(ArachneChatMessageHider())
loadModule(ArachneChatMessageHider)
loadModule(ShowItemUuid())
loadModule(FrozenTreasureTracker)
loadModule(MiningEventDisplay)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ public class MobsConfig {
@FeatureToggle
public boolean showArachneSpawnTimer = true;

@Expose
@ConfigOption(
name = "Arachne Kill Timer", desc = "Shows how long it took to kill Arachne after the fight ends. " +
"§cDoes not show if you were not in the Sanctuary when it spawned."
)
@ConfigEditorBoolean
@FeatureToggle
public boolean showArachneKillTimer = true;

@Expose
@ConfigOption(name = "Enderman TP Hider", desc = "Stops the Enderman Teleportation animation.")
@ConfigEditorBoolean
Expand Down
MTOnline69 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

class ArachneChatMessageHider {
object ArachneChatMessageHider {

private val config get() = SkyHanniMod.feature.chat
private var hideArachneDeadMessage = false

private val patternGroup = RepoPattern.group("chat.arachne")
private val arachneCallingPattern by patternGroup.pattern(
val arachneCallingPattern by patternGroup.pattern(
"calling",
"§4☄ §r.* §r§eplaced an §r§9Arachne's Calling§r§e!.*"
)
private val arachneCrystalPattern by patternGroup.pattern(
val arachneCrystalPattern by patternGroup.pattern(
"crystal",
"§4☄ §r.* §r§eplaced an Arachne Crystal! Something is awakening!"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
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")
private val arachneCallingSpawnedPattern by patternGroup.pattern(
"calling.spawned",
"§c\\[BOSS] Arachne§r§f: A befitting welcome!"
)
private val arachneCrystalSpawnedPattern by patternGroup.pattern(
"crystal.spawned",
"§c\\[BOSS] Arachne§r§f: With your sacrifice."
)
private val arachneDeathPattern by patternGroup.pattern(
"dead",
"§f.*§r§6§lARACHNE DOWN!"
)

private val arachneDamagePattern by patternGroup.pattern(
"damage",
"§f +§r§eYour Damage: §r§a[0-9,]+ §r§7\\(Position #[0-9,]+\\)"
MTOnline69 marked this conversation as resolved.
Show resolved Hide resolved
)

private var arachneSpawnedTime = SimpleTimeMark.farPast()
private var arachneKillTime = Duration.ZERO
private var arachneCallingPattern = ArachneChatMessageHider.arachneCallingPattern
private var arachneCrystalPattern = ArachneChatMessageHider.arachneCrystalPattern

@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()) {
val time = SimpleTimeMark.now()
arachneKillTime = time - arachneSpawnedTime
}

if (arachneCallingPattern.matches(event.message) || arachneCrystalPattern.matches(event.message)) {
arachneSpawnedTime = SimpleTimeMark.farPast()
}

if (arachneKillTime.isPositive() && arachneDamagePattern.matches(event.message)) {
val format = arachneKillTime.format(showMilliSeconds = true)
ChatUtils.chat(" §eArachne took §7$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.showArachneKillTimer
}
Loading