From bb0a6799a67e3bed3f78948b2dc5711c668e1c4f Mon Sep 17 00:00:00 2001 From: ingle Date: Mon, 10 Oct 2022 17:33:57 -0500 Subject: + add Arachne Boss Kill timer --- src/main/kotlin/dulkirmod/features/ArachneTimer.kt | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/main/kotlin/dulkirmod/features/ArachneTimer.kt (limited to 'src/main/kotlin/dulkirmod/features') diff --git a/src/main/kotlin/dulkirmod/features/ArachneTimer.kt b/src/main/kotlin/dulkirmod/features/ArachneTimer.kt new file mode 100644 index 0000000..7e0f144 --- /dev/null +++ b/src/main/kotlin/dulkirmod/features/ArachneTimer.kt @@ -0,0 +1,42 @@ +package dulkirmod.features + +import dulkirmod.DulkirMod +import dulkirmod.DulkirMod.Companion.mc +import dulkirmod.config.Config +import dulkirmod.utils.Utils +import net.minecraft.util.ChatComponentText +import net.minecraftforge.client.event.ClientChatReceivedEvent +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class ArachneTimer { + private var startmillis : Long = -1; + private var endmillis : Long = -1; + + @SubscribeEvent(receiveCanceled = true, priority = EventPriority.LOW) + fun onChat(event: ClientChatReceivedEvent) { + if (!Config.arachneKillTimer) return + + var killtime : Float = -1f; + + if (event.type == 2.toByte()) { + return + } + + val unformatted = Utils.stripColorCodes(event.message.unformattedText) + if (unformatted == "[BOSS] Arachne: You dare to call me, the queen of the dark, to you. I'll accept no excuses, you shall die!") { + startmillis = System.currentTimeMillis() + } + + if (unformatted == "[BOSS] Arachne: You are lucky this time that you only called out a portion of my power. If you dared to face me at my peak, you would not survive!") { + endmillis = System.currentTimeMillis() + if (startmillis > -1) { + killtime = (endmillis - startmillis).toFloat() / 1000 + + mc.thePlayer.addChatMessage( + ChatComponentText("${DulkirMod.CHAT_PREFIX} §6Arachne took §7$killtime §6seconds to kill.") + ) + } + } + } +} \ No newline at end of file -- cgit