diff options
4 files changed, 49 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index c7e544839..9cc394cad 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -217,6 +217,7 @@ import at.hannibal2.skyhanni.features.inventory.ItemDisplayOverlayFeatures import at.hannibal2.skyhanni.features.inventory.ItemStars import at.hannibal2.skyhanni.features.inventory.PowerStoneGuideFeatures import at.hannibal2.skyhanni.features.inventory.QuickCraftFeatures +import at.hannibal2.skyhanni.features.inventory.QuiverNotification import at.hannibal2.skyhanni.features.inventory.RngMeterInventory import at.hannibal2.skyhanni.features.inventory.SackDisplay import at.hannibal2.skyhanni.features.inventory.ShiftClickBrewing @@ -746,6 +747,7 @@ class SkyHanniMod { loadModule(SulphurSkitterBox()) loadModule(HighlightInquisitors()) loadModule(VerminTracker) + loadModule(QuiverNotification) init() diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java index ce60c05ff..2c9813bcc 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java @@ -205,4 +205,11 @@ public class InventoryConfig { @ConfigEditorBoolean @FeatureToggle public boolean shiftClickBrewing = false; + + @Expose + @ConfigOption(name = "Low Quiver Alert", desc = "Notifies you when your Quiver runs out of arrows.") + @ConfigEditorBoolean + @FeatureToggle + public boolean quiverAlert = false; + } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/QuiverNotification.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/QuiverNotification.kt new file mode 100644 index 000000000..40e51c226 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/QuiverNotification.kt @@ -0,0 +1,23 @@ +package at.hannibal2.skyhanni.features.inventory + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.TitleManager +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.utils.SoundUtils +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.seconds + +object QuiverNotification { + private val quiverChatPattern by RepoPattern.pattern("inventory.quiver.chat.low", "§cYou only have (?<arrowsLeft>.*) arrows left in your Quiver!") + @SubscribeEvent + fun onChatMessage(event: LorenzChatEvent) { + if (!SkyHanniMod.configManager.features.inventory.quiverAlert) return + quiverChatPattern.matchMatcher(event.message) { + TitleManager.sendTitle("§c${group("arrowsLeft")} arrows left!", 3.seconds, 3.6, 7f) + SoundUtils.repeatSound(100, 30, SoundUtils.plingSound) + } + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt index 42ca4ee00..f9a330f20 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt @@ -1,5 +1,8 @@ package at.hannibal2.skyhanni.utils +import at.hannibal2.skyhanni.SkyHanniMod +import kotlinx.coroutines.delay +import kotlinx.coroutines.launch import net.minecraft.client.Minecraft import net.minecraft.client.audio.ISound import net.minecraft.client.audio.PositionedSound @@ -11,6 +14,7 @@ object SoundUtils { private val beepSound by lazy { createSound("random.orb", 1f) } private val clickSound by lazy { createSound("gui.button.press", 1f) } private val errorSound by lazy { createSound("mob.endermen.portal", 0f) } + val plingSound by lazy { createSound("note.pling", 1f) } val centuryActiveTimerAlert by lazy { createSound("skyhanni:centurytimer.active", 1f) } fun ISound.playSound() { @@ -57,6 +61,10 @@ object SoundUtils { clickSound.playSound() } + fun playPlingSound() { + plingSound.playSound() + } + fun command(args: Array<String>) { if (args.isEmpty()) { ChatUtils.userError("Specify a sound effect to test") @@ -73,4 +81,13 @@ object SoundUtils { fun playErrorSound() { errorSound.playSound() } + + fun repeatSound(delay: Long, repeat: Int, sound: ISound) { + SkyHanniMod.coroutineScope.launch { + repeat(repeat) { + sound.playSound() + delay(delay) + } + } + } } |