aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/dulkirfabric/features/slayer/BossTimer.kt
blob: 563a6609ac8d10f90ff225928c79ca6683a0fe8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package com.dulkirfabric.features.slayer

import com.dulkirfabric.config.DulkirConfig
import com.dulkirfabric.events.SlayerBossEvents
import com.dulkirfabric.util.TextUtils
import meteordevelopment.orbit.EventHandler

object BossTimer {

    private var lastSpawnTime: Long = 0
    private var lastType = ""

    @EventHandler
    fun onSlayerStart(event: SlayerBossEvents.Spawn) {
        lastType = event.type
        lastSpawnTime = event.timestamp
    }

    @EventHandler
    fun onSlayerKill(event: SlayerBossEvents.Kill) {
        if (!DulkirConfig.configOptions.slayerKillTime) return
        if (lastType != event.type) return
        val bossTime: Float = (event.timestamp - lastSpawnTime) / 1000f
        TextUtils.info("§6Slayer Boss took ${"%.2f".format(bossTime)}s to kill.")
    }
}