aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/dungeon/DungeonMilestoneDisplay.kt
diff options
context:
space:
mode:
authorLorenz <lo.scherf@gmail.com>2022-08-17 03:05:34 +0200
committerLorenz <lo.scherf@gmail.com>2022-08-17 03:05:34 +0200
commitef58a94bf31868c4b53218474f0be04c1cd93d97 (patch)
treecb56d5969f8bebf586298475a61c521229663fda /src/main/java/at/hannibal2/skyhanni/dungeon/DungeonMilestoneDisplay.kt
parent5669dbf6f68e7cacb2df6a4e37d703df8635353e (diff)
downloadskyhanni-ef58a94bf31868c4b53218474f0be04c1cd93d97.tar.gz
skyhanni-ef58a94bf31868c4b53218474f0be04c1cd93d97.tar.bz2
skyhanni-ef58a94bf31868c4b53218474f0be04c1cd93d97.zip
moving packets around
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/dungeon/DungeonMilestoneDisplay.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/dungeon/DungeonMilestoneDisplay.kt96
1 files changed, 0 insertions, 96 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/dungeon/DungeonMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/dungeon/DungeonMilestoneDisplay.kt
deleted file mode 100644
index 96bfba678..000000000
--- a/src/main/java/at/hannibal2/skyhanni/dungeon/DungeonMilestoneDisplay.kt
+++ /dev/null
@@ -1,96 +0,0 @@
-package at.hannibal2.skyhanni.dungeon
-
-import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.events.DungeonEnterEvent
-import at.hannibal2.skyhanni.events.LorenzChatEvent
-import at.hannibal2.skyhanni.utils.GuiRender.renderString
-import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.matchRegex
-import net.minecraftforge.client.event.RenderGameOverlayEvent
-import net.minecraftforge.event.world.WorldEvent
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import kotlin.concurrent.fixedRateTimer
-
-class DungeonMilestoneDisplay {
-
-
- companion object {
- private var textToRender = ""
- var color = ""
- var currentMilestone = 0
- var timeReached = 0L
-
- fun isMilestoneMessage(message: String): Boolean = when {
- message.matchRegex("§e§l(.*) Milestone §r§e.§r§7: You have dealt §r§c(.*)§r§7 Total Damage so far! §r§a(.*)") -> true
- message.matchRegex("§e§lArcher Milestone §r§e.§r§7: You have dealt §r§c(.*)§r§7 Ranged Damage so far! §r§a(.*)") -> true
- message.matchRegex("§e§lHealer Milestone §r§e.§r§7: You have healed §r§a(.*)§r§7 Damage so far! §r§a(.*)") -> true
- message.matchRegex("§e§lTank Milestone §r§e.§r§7: You have tanked and dealt §r§c(.*)§r§7 Total Damage so far! §r§a(.*)s") -> true
-
- else -> false
- }
- }
-
- init {
- fixedRateTimer(name = "dungeon-milestone-display", period = 200) {
- if (!isEnabled()) return@fixedRateTimer
- checkVisibility()
- }
- }
-
- private fun checkVisibility() {
- if (currentMilestone >= 3) {
- if (System.currentTimeMillis() > timeReached + 3_000)
- if (textToRender != "") {
- textToRender = textToRender.substring(1)
- }
- }
- }
-
- @SubscribeEvent(receiveCanceled = true)
- fun onChatPacket(event: LorenzChatEvent) {
- if (!isEnabled()) return
-
- if (isMilestoneMessage(event.message)) {
- event.blockedReason = "dungeon_milestone"
- currentMilestone++
- update()
- }
- }
-
- private fun update() {
- if (currentMilestone > 3) return
- if (currentMilestone == 3) {
- timeReached = System.currentTimeMillis()
- }
-
- color = when (currentMilestone) {
- 0, 1 -> "§c"
- 2 -> "§e"
- else -> "§a"
- }
- textToRender = "Current Milestone: $currentMilestone"
- }
-
- @SubscribeEvent
- fun onWorldChange(event: WorldEvent.Load) {
- textToRender = ""
- currentMilestone = 0
- }
-
- @SubscribeEvent
- fun onDungeonStart(event: DungeonEnterEvent) {
- currentMilestone = 0
- update()
- }
-
- @SubscribeEvent
- fun renderOverlay(event: RenderGameOverlayEvent.Post) {
- if (!isEnabled()) return
-
- SkyHanniMod.feature.dungeon.milestoneDisplayPos.renderString(color + textToRender)
- }
-
- private fun isEnabled(): Boolean {
- return LorenzUtils.inDungeons && SkyHanniMod.feature.dungeon.showMilestoneDisplay
- }
-} \ No newline at end of file