aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/misc/ThunderBottleNotification.kt
blob: 681f1a0dde9d1ecf83ff4bc8a1095d9f9fd661c4 (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
package at.hannibal2.skyhanni.features.misc

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.seconds

@SkyHanniModule
object ThunderBottleNotification {

    private val config get() = SkyHanniMod.feature.misc

    private val thunderBottleChargedPattern by RepoPattern.pattern(
        "thunderbottle.charged",
        "§e> Your bottle of thunder has fully charged!",
    )

    @SubscribeEvent
    fun onChat(event: LorenzChatEvent) {
        if (!isEnabled()) return

        if (thunderBottleChargedPattern.matches(event.message)) {
            LorenzUtils.sendTitle("§eThunder Bottle Charged!", 3.seconds)
        }
    }

    private fun isEnabled() = LorenzUtils.inSkyBlock && config.thunderBottleNotification
}