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

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.events.BitsUpdateEvent
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.SoundUtils
import at.hannibal2.skyhanni.utils.SoundUtils.createSound
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.seconds

class NoBitsWarning {

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

    @SubscribeEvent
    fun onBitsGain(event: BitsUpdateEvent.BitsGain) {
        if (!isEnabled()) return
        if (event.bitsAvailable != 0) return

        ChatUtils.clickableChat(
            "§bNo Bits Available! §eClick to run /bz booster cookie.",
            "bz booster cookie"
        )
        LorenzUtils.sendTitle("§bNo Bits Available", 5.seconds)
        if (config.notificationSound) SoundUtils.repeatSound(100, 10, createSound("note.pling", 0.6f))
    }

    @SubscribeEvent
    fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
        event.move(35, "misc.noBitsWarning", "misc.noBitsWarning.enabled")
    }

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