From 1ea9026acb04504200892b67c81c60ee64723b12 Mon Sep 17 00:00:00 2001 From: Lorenz Date: Wed, 24 Aug 2022 16:26:54 +0200 Subject: formatting dungeon features --- .../java/at/hannibal2/skyhanni/SkyHanniMod.java | 2 +- .../at/hannibal2/skyhanni/config/Features.java | 4 +- .../skyhanni/config/features/Dungeon.java | 39 ++++++--- .../skyhanni/features/dungeon/DungeonCleanEnd.kt | 6 +- .../features/dungeon/DungeonDeathCounter.kt | 4 +- .../features/dungeon/DungeonMilestoneDisplay.kt | 96 ---------------------- .../features/dungeon/DungeonMilestonesDisplay.kt | 96 ++++++++++++++++++++++ 7 files changed, 132 insertions(+), 115 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') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 49eca4470..48b568a9f 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -78,7 +78,7 @@ public class SkyHanniMod { registerEvent(new ExpBottleOnGroundHider()); registerEvent(new DamageIndicatorManager()); registerEvent(new ItemAbilityCooldown()); - registerEvent(new DungeonMilestoneDisplay()); + registerEvent(new DungeonMilestonesDisplay()); registerEvent(new DungeonDeathCounter()); registerEvent(new DungeonCleanEnd()); registerEvent(new DungeonBossMessages()); diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java index 56a78c3c8..ba3b49129 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Features.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java @@ -37,8 +37,8 @@ public class Features { return; } - if (runnableId.equals("dungeonMilestoneDisplay")) { - editOverlay(activeConfigCategory, 200, 16, dungeon.milestoneDisplayPos); + if (runnableId.equals("dungeonMilestonesDisplay")) { + editOverlay(activeConfigCategory, 200, 16, dungeon.showMileStonesDisplayPos); return; } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Dungeon.java b/src/main/java/at/hannibal2/skyhanni/config/features/Dungeon.java index 7be3f6902..74d2a076c 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Dungeon.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Dungeon.java @@ -1,9 +1,7 @@ package at.hannibal2.skyhanni.config.features; import at.hannibal2.skyhanni.config.gui.core.config.Position; -import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigEditorBoolean; -import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigEditorButton; -import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigOption; +import at.hannibal2.skyhanni.config.gui.core.config.annotations.*; import com.google.gson.annotations.Expose; public class Dungeon { @@ -13,33 +11,52 @@ public class Dungeon { @ConfigEditorBoolean public boolean highlightClickedBlocks = false; + @ConfigOption(name = "Milestones", desc = "") + @ConfigEditorAccordion(id = 0) + public boolean showMilestone = false; + @Expose - @ConfigOption(name = "Milestone Display", desc = "Show the current milestone inside Dungeons.") + @ConfigOption(name = "Milestones Display", desc = "Show the current milestone inside Dungeons.") @ConfigEditorBoolean - public boolean showMilestoneDisplay = false; + @ConfigAccordionId(id = 0) + public boolean showMilestonesDisplay = false; @Expose @ConfigOption(name = "Milestone Display Position", desc = "") - @ConfigEditorButton(runnableId = "dungeonMilestoneDisplay", buttonText = "Edit") - public Position milestoneDisplayPos = new Position(10, 10, false, true); + @ConfigEditorButton(runnableId = "dungeonMilestonesDisplay", buttonText = "Edit") + @ConfigAccordionId(id = 0) + public Position showMileStonesDisplayPos = new Position(10, 10, false, true); + + @ConfigOption(name = "Death Counter", desc = "") + @ConfigEditorAccordion(id = 1) + public boolean deathCounter = false; @Expose - @ConfigOption(name = "Death Counter", desc = "Display the total amount of deaths in the current dungeon.") + @ConfigOption(name = "Death Counter Display", desc = "Display the total amount of deaths in the current dungeon.") @ConfigEditorBoolean - public boolean deathCounter = false; + @ConfigAccordionId(id = 1) + public boolean deathCounterDisplay = false; @Expose @ConfigOption(name = "Death Counter Position", desc = "") @ConfigEditorButton(runnableId = "dungeonDeathCounter", buttonText = "Edit") + @ConfigAccordionId(id = 1) public Position deathCounterPos = new Position(10, 10, false, true); + @ConfigOption(name = "Clean End", desc = "") + @ConfigEditorAccordion(id = 2) + public boolean cleanEnd = false; + @Expose @ConfigOption(name = "Clean End", desc = "Hide entities and particles after the boss in Floor 1 - 6 has died.") @ConfigEditorBoolean - public boolean cleanEnd = false; + @ConfigAccordionId(id = 2) + public boolean cleanEndToggle = false; @Expose - @ConfigOption(name = "Ignore Guardians", desc = "Ignore F3 and M3 guardians from the clean end feature when sneaking. Makes it easier to kill them after the boss died already. Thanks hypixel.") + @ConfigOption(name = "Ignore Guardians", desc = "Ignore F3 and M3 guardians from the clean end feature when " + + "sneaking. Makes it easier to kill them after the boss died already. Thanks hypixel.") @ConfigEditorBoolean + @ConfigAccordionId(id = 2) public boolean cleanEndF3IgnoreGuardians = false; } \ No newline at end of file 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