aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/dulkirmod/features/GardenVisitorAlert.kt
blob: 8bcd14521f31e80eba812e1364cb78f144bf638b (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package dulkirmod.features

import dulkirmod.DulkirMod
import dulkirmod.config.Config
import dulkirmod.utils.TabListUtils
import dulkirmod.utils.TitleUtils
import dulkirmod.utils.Utils

object GardenVisitorAlert {
    private var hasSentAlert = false
    private var lastAlert = 0

    fun alert() {
        if (!Config.notifyMaxVisitors) return
        if (!Utils.isInSkyblock()) return

        if (TabListUtils.area != "Garden") {
            hasSentAlert = false
        }

        if (TabListUtils.maxVisitors && !hasSentAlert) {
            val color = Utils.getColorString(Config.bestiaryNotifColor)
            TitleUtils.drawStringForTime("${color}Max Visitors", 5000)
            DulkirMod.mc.thePlayer.playSound("note.pling", 1f * Config.bestiaryNotifVol, .3f)
            DulkirMod.mc.thePlayer.playSound("note.pling", 1f * Config.bestiaryNotifVol, .6f)
            DulkirMod.mc.thePlayer.playSound("note.pling", 1f * Config.bestiaryNotifVol, .9f)
            hasSentAlert = true
            lastAlert = System.currentTimeMillis().toInt()
        } else if (!TabListUtils.maxVisitors) hasSentAlert = false

        val timeSinceLastAlert = System.currentTimeMillis().toInt() - lastAlert

        if (TabListUtils.maxVisitors && hasSentAlert && timeSinceLastAlert > 5000 && Config.persistentAlert) {
            lastAlert = System.currentTimeMillis().toInt()
            val color = Utils.getColorString(Config.bestiaryNotifColor)
            TitleUtils.drawStringForTime("${color}Max Visitors", 5000)
            DulkirMod.mc.thePlayer.playSound("note.pling", 1f * Config.bestiaryNotifVol, .3f)
            DulkirMod.mc.thePlayer.playSound("note.pling", 1f * Config.bestiaryNotifVol, .6f)
            DulkirMod.mc.thePlayer.playSound("note.pling", 1f * Config.bestiaryNotifVol, .9f)
        }
    }

}