aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/dulkirfabric/features/slayer/BossTimer.kt
blob: c08ed97563a7f5d106f1921fc7cc079d2e05d657 (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
package com.dulkirfabric.features.slayer

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 (lastType != event.type) return
        val bossTime: Float = (event.timestamp - lastSpawnTime) / 1000f
        TextUtils.info("§6Slayer Boss took ${"%.2f".format(bossTime)}s to kill.")
    }
}