From 959c7fd76d3e862ad5d9bd181ce7658f849f4563 Mon Sep 17 00:00:00 2001 From: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Date: Sat, 13 Jul 2024 17:29:56 +0200 Subject: [PATCH] meow --- .../config/features/chat/ChatConfig.java | 5 +++ .../skyhanni/features/chat/SoundResponse.kt | 33 +++++++++++++++++++ .../at/hannibal2/skyhanni/utils/SoundUtils.kt | 7 +++- 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/chat/SoundResponse.kt diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/chat/ChatConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/chat/ChatConfig.java index f9e64f1e07d4..1e3b2dbad415 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/chat/ChatConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/chat/ChatConfig.java @@ -142,4 +142,9 @@ public String toString() { @ConfigEditorBoolean @FeatureToggle public boolean petRarityDropMessage = true; + + @Expose + @ConfigOption(name = "Meow", desc = "Play a meow any time a meow appears in chat.") + @ConfigEditorBoolean + public boolean meow = false; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/SoundResponse.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/SoundResponse.kt new file mode 100644 index 000000000000..f4ae8d710b7a --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/SoundResponse.kt @@ -0,0 +1,33 @@ +package at.hannibal2.skyhanni.features.chat + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.RegexUtils.matches +import at.hannibal2.skyhanni.utils.SoundUtils +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@SkyHanniModule +object SoundResponse { + + private val config get() = SkyHanniMod.feature.chat + + private val repoGroup = RepoPattern.group("chat.sound.response") + + /** REGEX-TEST: meow + REGEX-TEST: meow + REGEX-TEST: meow + REGEX-TEST: MEow + REGEX-TEST: §ameow + REGEX-TEST: hello §ameow + * */ + private val meow by repoGroup.pattern("meow", "(?:^|^.* )(?: |§.)*(?i)meow(?: |§.)*(?:\$| .*\$)") + + @SubscribeEvent + fun onLorenzChat(event: LorenzChatEvent) { + if (config.meow && meow.matches(event.message)) { + SoundUtils.playMeowSound() + } + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt index 70e6242c621c..0de3f3d4e441 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt @@ -15,6 +15,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) } + private val meowSound by lazy { createSound("mob.cat.meow", 1f) } val plingSound by lazy { createSound("note.pling", 1f) } val centuryActiveTimerAlert by lazy { createSound("skyhanni:centurytimer.active", 1f) } @@ -38,7 +39,7 @@ object SoundUtils { } ErrorManager.logErrorWithData( e, "Failed to play a sound", - "soundLocation" to this.soundLocation + "soundLocation" to this.soundLocation, ) } finally { if (!SkyHanniMod.feature.misc.maintainGameVolume) { @@ -73,6 +74,10 @@ object SoundUtils { plingSound.playSound() } + fun playMeowSound() { + meowSound.playSound() + } + fun command(args: Array) { if (args.isEmpty()) { ChatUtils.userError("Specify a sound effect to test")