diff options
| author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-05-13 12:40:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-13 12:40:21 +0200 |
| commit | 4e98f4a176fb8bfe2b9c9afcdb4b941d5b721704 (patch) | |
| tree | 2fa38db1c75150d3a5f69b14f4654796cbed577b /src/main/java/at/hannibal2/skyhanni/data | |
| parent | 253d92a20b93a46d308cc94b73130e87e82f2da1 (diff) | |
| download | skyhanni-4e98f4a176fb8bfe2b9c9afcdb4b941d5b721704.tar.gz skyhanni-4e98f4a176fb8bfe2b9c9afcdb4b941d5b721704.tar.bz2 skyhanni-4e98f4a176fb8bfe2b9c9afcdb4b941d5b721704.zip | |
Improvement: performance in various ways (#1782)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/EventCounter.kt | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/EventCounter.kt b/src/main/java/at/hannibal2/skyhanni/data/EventCounter.kt index f7a730a65..28f1e254b 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/EventCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/EventCounter.kt @@ -1,10 +1,12 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.SimpleTimeMark +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds object EventCounter { @@ -14,8 +16,15 @@ object EventCounter { private var map = mutableMapOf<String, Int>() private var lastUpdate = SimpleTimeMark.farPast() + private var enabled = false + + @SubscribeEvent + fun onSecondPassed(event: SecondPassedEvent) { + enabled = LorenzUtils.onHypixel && config.eventCounter + } + fun count(eventName: String) { - if (!isEnabled()) return + if (!enabled) return map.addOrPut(eventName, 1) @@ -42,6 +51,4 @@ object EventCounter { println("") println("total: ${total.addSeparators()}") } - - private fun isEnabled() = LorenzUtils.onHypixel && config.eventCounter } |
