diff options
author | J10a1n15 <45315647+j10a1n15@users.noreply.github.com> | 2024-04-18 20:13:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-18 20:13:35 +0200 |
commit | 602940752c3a74473c8092b3d646926686b38522 (patch) | |
tree | 1489e71f5efde963741358bd0285c5b90d3afb8d /src | |
parent | 04ce843b12afe771fba6e03b3cd39a806a81cbd5 (diff) | |
download | skyhanni-602940752c3a74473c8092b3d646926686b38522.tar.gz skyhanni-602940752c3a74473c8092b3d646926686b38522.tar.bz2 skyhanni-602940752c3a74473c8092b3d646926686b38522.zip |
Feature: Bits Gained Chat Message (#1487)
Diffstat (limited to 'src')
7 files changed, 52 insertions, 30 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 62ee61fb6..d1ce70441 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -853,7 +853,7 @@ class SkyHanniMod { loadModule(CraftMaterialsFromBazaar()) loadModule(DungeonShadowAssassinNotification()) loadModule(PestProfitTracker) - loadModule(NoBitsWarning()) + loadModule(NoBitsWarning) loadModule(ColdOverlay()) loadModule(QuiverDisplay()) loadModule(QuiverWarning()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt index 77c732678..9f0b281ff 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt @@ -12,7 +12,7 @@ import com.google.gson.JsonPrimitive object ConfigUpdaterMigrator { val logger = LorenzLogger("ConfigMigration") - const val CONFIG_VERSION = 39 + const val CONFIG_VERSION = 40 fun JsonElement.at(chain: List<String>, init: Boolean): JsonElement? { if (chain.isEmpty()) return this if (this !is JsonObject) return null diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/BitsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/BitsConfig.java new file mode 100644 index 000000000..24b183ff5 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/BitsConfig.java @@ -0,0 +1,31 @@ +package at.hannibal2.skyhanni.config.features.misc; + +import at.hannibal2.skyhanni.config.FeatureToggle; +import com.google.gson.annotations.Expose; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider; +import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; + +public class BitsConfig { + @Expose + @ConfigOption(name = "Enable No Bits Warning", desc = "Alerts you when you have no bits available.") + @ConfigEditorBoolean + @FeatureToggle + public boolean enableWarning = true; + + @Expose + @ConfigOption(name = "Notification Sound", desc = "Plays a notification sound when you get a warning.") + @ConfigEditorBoolean + public boolean notificationSound = true; + + @Expose + @ConfigOption(name = "Bits Gain Chat Message", desc = "Shows a chat message when you gain bits.") + @ConfigEditorBoolean + @FeatureToggle + public boolean bitsGainChatMessage = true; + + @Expose + @ConfigOption(name = "Threshold", desc = "The amount of bits you need to have to not get a warning.") + @ConfigEditorSlider(minValue = 0, maxValue = 1000, minStep = 1) + public int threshold = 400; +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java index 8b21e3e85..d1fa39a86 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java @@ -98,9 +98,9 @@ public class MiscConfig { public PetCandyDisplayConfig petCandy = new PetCandyDisplayConfig(); @Expose - @ConfigOption(name = "No Bits Warning", desc = "") + @ConfigOption(name = "Bits Features", desc = "") @Accordion - public NoBitsWarningConfig noBitsWarning = new NoBitsWarningConfig(); + public BitsConfig bits = new BitsConfig(); @Expose @ConfigOption(name = "Patcher Coords Waypoints", desc = "") diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/NoBitsWarningConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/NoBitsWarningConfig.java deleted file mode 100644 index 2542d7728..000000000 --- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/NoBitsWarningConfig.java +++ /dev/null @@ -1,19 +0,0 @@ -package at.hannibal2.skyhanni.config.features.misc; - -import at.hannibal2.skyhanni.config.FeatureToggle; -import com.google.gson.annotations.Expose; -import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; -import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; - -public class NoBitsWarningConfig { - @Expose - @ConfigOption(name = "Enabled", desc = "Alerts you when you have no bits available.") - @ConfigEditorBoolean - @FeatureToggle - public boolean enabled = true; - - @Expose - @ConfigOption(name = "Notification Sound", desc = "Plays a notification sound when you get a warning.") - @ConfigEditorBoolean - public boolean notificationSound = true; -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt index 05109d4fb..d400959c0 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt @@ -7,8 +7,8 @@ import at.hannibal2.skyhanni.events.BitsUpdateEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.ScoreboardChangeEvent +import at.hannibal2.skyhanni.features.misc.NoBitsWarning.sendBitsGainChatMessage import at.hannibal2.skyhanni.test.command.ErrorManager -import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils @@ -154,7 +154,7 @@ object BitsAPI { if (amount > bits) { bitsAvailable -= amount - bits - ChatUtils.debug("You have gained §3${amount - bits} Bits §7according to the scoreboard!") + sendBitsGainChatMessage(amount - bits) bits = amount sendBitsGainEvent() } else { @@ -228,7 +228,7 @@ object BitsAPI { val difference = bits - bitsAvailable if (difference > 0) { - ChatUtils.debug("You have gained §3${difference} Bits §7according to the menu!") + sendBitsGainChatMessage(difference) bits += difference } } 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 } |