aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data/FixedRateTimerManager.kt
blob: a0125d35ee1a742584bb8856fa1f8f8440eb0629 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package at.hannibal2.skyhanni.data

import at.hannibal2.skyhanni.events.SecondPassedEvent
import at.hannibal2.skyhanni.utils.LorenzUtils
import net.minecraft.client.Minecraft
import kotlin.concurrent.fixedRateTimer

class FixedRateTimerManager {
    private var totalSeconds = 0

    init {
        fixedRateTimer(name = "skyhanni-fixed-rate-timer-manager", period = 1000L) {
            Minecraft.getMinecraft().addScheduledTask {
                if (!LorenzUtils.onHypixel) return@addScheduledTask
                SecondPassedEvent(totalSeconds).postAndCatch()
                totalSeconds++
            }
        }
    }
}