aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/dulkirfabric/features/VisitorAlert.kt
blob: 9f75d8320eb106c3b7a6968edc9a1f0f9ab53427 (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
44
45
package com.dulkirfabric.features

import com.dulkirfabric.config.DulkirConfig
import com.dulkirfabric.events.AreaChangeEvent
import com.dulkirfabric.events.HudRenderEvent
import com.dulkirfabric.events.LongUpdateEvent
import com.dulkirfabric.util.TablistUtils
import com.dulkirfabric.util.render.HudRenderUtil
import meteordevelopment.orbit.EventHandler
import net.minecraft.text.Style
import net.minecraft.text.Text
import net.minecraft.util.Formatting
import java.time.Duration

object VisitorAlert {

    private var canAlert = true
    private var prevVisitorState = ""

    @EventHandler
    private fun onAreaChange(event: AreaChangeEvent) {
        canAlert = true
    }

    @EventHandler
    private fun onLong(event: LongUpdateEvent) {
        if (TablistUtils.persistentInfo.area != "Garden") return
        if (TablistUtils.persistentInfo.nextVisitorTime == "Queue Full!") {
            if (DulkirConfig.configOptions.persistentVisitorAlert) {
                HudRenderUtil.drawTitle(
                    Text.literal("Max Visitors").setStyle(Style.EMPTY.withColor(Formatting.GOLD)),
                    Duration.ofSeconds(5)
                )
            } else if (canAlert) {
                HudRenderUtil.drawTitle(
                    Text.literal("Max Visitors").setStyle(Style.EMPTY.withColor(Formatting.GOLD)),
                    Duration.ofSeconds(5)
                )
                canAlert = false
            }
        }

        prevVisitorState = TablistUtils.persistentInfo.nextVisitorTime
    }
}