From 1ea9026acb04504200892b67c81c60ee64723b12 Mon Sep 17 00:00:00 2001 From: Lorenz Date: Wed, 24 Aug 2022 16:26:54 +0200 Subject: formatting dungeon features --- .../skyhanni/features/dungeon/DungeonCleanEnd.kt | 6 +- .../features/dungeon/DungeonDeathCounter.kt | 4 +- .../features/dungeon/DungeonMilestoneDisplay.kt | 96 ---------------------- .../features/dungeon/DungeonMilestonesDisplay.kt | 96 ++++++++++++++++++++++ 4 files changed, 101 insertions(+), 101 deletions(-) delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestoneDisplay.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt (limited to 'src/main/java/at/hannibal2/skyhanni/features') diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt index 01950688a..6867e2171 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt @@ -25,7 +25,7 @@ class DungeonCleanEnd { @SubscribeEvent fun onChatMessage(event: LorenzChatEvent) { if (!LorenzUtils.inDungeons) return - if (!SkyHanniMod.feature.dungeon.cleanEnd) return + if (!SkyHanniMod.feature.dungeon.cleanEndToggle) return val message = event.message @@ -36,7 +36,7 @@ class DungeonCleanEnd { private fun shouldBlock(): Boolean { if (!LorenzUtils.inDungeons) return false - if (!SkyHanniMod.feature.dungeon.cleanEnd) return false + if (!SkyHanniMod.feature.dungeon.cleanEndToggle) return false if (!bossDone) return false @@ -63,7 +63,7 @@ class DungeonCleanEnd { @SubscribeEvent fun onHealthUpdatePacket(event: PacketEvent.ReceiveEvent) { if (!LorenzUtils.inDungeons) return - if (!SkyHanniMod.feature.dungeon.cleanEnd) return + if (!SkyHanniMod.feature.dungeon.cleanEndToggle) return if (bossDone) return if (lastBossId == -1) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonDeathCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonDeathCounter.kt index c59f5a3cb..129d9e3bd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonDeathCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonDeathCounter.kt @@ -88,10 +88,10 @@ class DungeonDeathCounter { fun renderOverlay(event: RenderGameOverlayEvent.Post) { if (!isEnabled()) return - SkyHanniMod.feature.dungeon.deathCounterPos.renderString(DungeonMilestoneDisplay.color + textToRender) + SkyHanniMod.feature.dungeon.deathCounterPos.renderString(DungeonMilestonesDisplay.color + textToRender) } private fun isEnabled(): Boolean { - return LorenzUtils.inDungeons && SkyHanniMod.feature.dungeon.deathCounter + return LorenzUtils.inDungeons && SkyHanniMod.feature.dungeon.deathCounterDisplay } } \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestoneDisplay.kt deleted file mode 100644 index cd8464730..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestoneDisplay.kt +++ /dev/null @@ -1,96 +0,0 @@ -package at.hannibal2.skyhanni.features.dungeon - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.events.DungeonEnterEvent -import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzUtils.matchRegex -import at.hannibal2.skyhanni.utils.RenderUtils.renderString -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 diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt new file mode 100644 index 000000000..12af1c7a4 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt @@ -0,0 +1,96 @@ +package at.hannibal2.skyhanni.features.dungeon + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.DungeonEnterEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.matchRegex +import at.hannibal2.skyhanni.utils.RenderUtils.renderString +import net.minecraftforge.client.event.RenderGameOverlayEvent +import net.minecraftforge.event.world.WorldEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.concurrent.fixedRateTimer + +class DungeonMilestonesDisplay { + + + 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.showMileStonesDisplayPos.renderString(color + textToRender) + } + + private fun isEnabled(): Boolean { + return LorenzUtils.inDungeons && SkyHanniMod.feature.dungeon.showMilestonesDisplay + } +} \ No newline at end of file -- cgit