From 602940752c3a74473c8092b3d646926686b38522 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Thu, 18 Apr 2024 20:13:35 +0200 Subject: Feature: Bits Gained Chat Message (#1487) --- .../hannibal2/skyhanni/features/misc/NoBitsWarning.kt | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features/misc') diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/NoBitsWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/NoBitsWarning.kt index 2529c026b..350e95384 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/NoBitsWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/NoBitsWarning.kt @@ -5,18 +5,25 @@ 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.NumberUtil.addSeparators 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 { +object NoBitsWarning { - private val config get() = SkyHanniMod.feature.misc.noBitsWarning + private val config get() = SkyHanniMod.feature.misc.bits + + fun sendBitsGainChatMessage(bits: Int) { + if (!isChatMessageEnabled()) return + if (bits < config.threshold) return + ChatUtils.chat("You have gained §b${bits.addSeparators()} §eBits.") + } @SubscribeEvent fun onBitsGain(event: BitsUpdateEvent.BitsGain) { - if (!isEnabled()) return + if (!isWarningEnabled()) return if (event.bitsAvailable != 0) return ChatUtils.clickableChat( @@ -30,7 +37,10 @@ class NoBitsWarning { @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { event.move(35, "misc.noBitsWarning", "misc.noBitsWarning.enabled") + event.move(40, "misc.noBitsWarning.enabled", "misc.bits.enableWarning") + event.move(40, "misc.noBitsWarning.notificationSound", "misc.bits.notificationSound") } - private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled + private fun isChatMessageEnabled() = LorenzUtils.inSkyBlock && config.bitsGainChatMessage + private fun isWarningEnabled() = LorenzUtils.inSkyBlock && config.enableWarning } -- cgit