diff options
| author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2024-04-02 06:07:46 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-01 21:07:46 +0200 |
| commit | 8b28b68d6956ae406c0b13abece629a197670edf (patch) | |
| tree | 49ad7909383eecca20cad544535d935177e6feaf /src/main/java/at/hannibal2/skyhanni/features/dungeon | |
| parent | 60c5f9c351a7f59622a09cc10a5047c5dca279fa (diff) | |
| download | skyhanni-8b28b68d6956ae406c0b13abece629a197670edf.tar.gz skyhanni-8b28b68d6956ae406c0b13abece629a197670edf.tar.bz2 skyhanni-8b28b68d6956ae406c0b13abece629a197670edf.zip | |
Backend: Less fixed rate timer (#1264)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/dungeon')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt index 3547a4827..dfaf5b02f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt @@ -4,12 +4,12 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.DungeonStartEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.StringUtils.matches import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import kotlin.concurrent.fixedRateTimer class DungeonMilestonesDisplay { @@ -33,22 +33,16 @@ class DungeonMilestonesDisplay { fun isMilestoneMessage(message: String): Boolean = milestonePatternList.any { it.matches(message) } } - init { - fixedRateTimer(name = "skyhanni-dungeon-milestone-display", period = 200) { - if (isEnabled()) { - checkVisibility() - } - } - } - - private fun checkVisibility() { + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!event.isMod(5)) return if (currentMilestone >= 3 && System.currentTimeMillis() > timeReached + 3_000 && display != "") { display = display.substring(1) } } @SubscribeEvent(receiveCanceled = true) - fun onChatPacket(event: LorenzChatEvent) { + fun onChat(event: LorenzChatEvent) { if (!isEnabled()) return if (isMilestoneMessage(event.message)) { |
