Skip to content

Commit

Permalink
meow
Browse files Browse the repository at this point in the history
  • Loading branch information
Thunderblade73 committed Jul 13, 2024
1 parent ecb0e3e commit 959c7fd
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
33 changes: 33 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/features/chat/SoundResponse.kt
Original file line number Diff line number Diff line change
@@ -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()
}
}
}
7 changes: 6 additions & 1 deletion src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) }

Expand All @@ -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) {
Expand Down Expand Up @@ -73,6 +74,10 @@ object SoundUtils {
plingSound.playSound()
}

fun playMeowSound() {
meowSound.playSound()
}

fun command(args: Array<String>) {
if (args.isEmpty()) {
ChatUtils.userError("Specify a sound effect to test")
Expand Down

0 comments on commit 959c7fd

Please sign in to comment.