From 5dd4c58fea97d5df8f18c099701b7034ae8939f5 Mon Sep 17 00:00:00 2001 From: inglettronald Date: Wed, 21 Jun 2023 22:10:31 -0500 Subject: more work on Chat parsing and Sound handling --- .../com/dulkirfabric/features/chat/AbiPhoneDND.kt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/main/kotlin/com/dulkirfabric/features') diff --git a/src/main/kotlin/com/dulkirfabric/features/chat/AbiPhoneDND.kt b/src/main/kotlin/com/dulkirfabric/features/chat/AbiPhoneDND.kt index f3f83e2..8763741 100644 --- a/src/main/kotlin/com/dulkirfabric/features/chat/AbiPhoneDND.kt +++ b/src/main/kotlin/com/dulkirfabric/features/chat/AbiPhoneDND.kt @@ -2,22 +2,27 @@ package com.dulkirfabric.features.chat import com.dulkirfabric.config.DulkirConfig import com.dulkirfabric.events.ChatReceivedEvent +import com.dulkirfabric.events.OverlayReceivedEvent import com.dulkirfabric.events.PlaySoundEvent import com.dulkirfabric.util.TextUtils +import com.dulkirfabric.util.TextUtils.unformattedString import meteordevelopment.orbit.EventHandler +import net.minecraft.client.sound.Sound +import net.minecraft.text.Text object AbiPhoneDND { private val abiPhoneFormat = "✆ (\\w+) ✆ ".toRegex() - var lastRing = 0L + private var lastRing = 0L //BLOCK ABIPHONE SOUNDS @EventHandler fun onSound(event: PlaySoundEvent) { if (!DulkirConfig.configOptions.abiPhoneDND) return if (System.currentTimeMillis() - lastRing < 5000) { - if (event.sound.sound.identifier.path == "note.pling" && event.sound.volume == 0.69f && event.sound.pitch == 1.6666666f) { - event.isCancelled = true + // TODO: Make this not error out madge + if (event.sound.id.path == "block.note_block.pling" && event.sound.volume == 0.69f && event.sound.pitch == 1.6666666f) { + event.isCancelled = true } } } @@ -25,7 +30,8 @@ object AbiPhoneDND { @EventHandler fun handle(event: ChatReceivedEvent) { if (!DulkirConfig.configOptions.abiPhoneDND) return - val unformatted: String = TextUtils.stripColorCodes(event.message) + val unformatted: String = event.message.unformattedString + println(unformatted) if (unformatted matches abiPhoneFormat && !unformatted.contains("Elle") && !unformatted.contains("Dean")) { val matchResult = abiPhoneFormat.find(unformatted) event.isCancelled = true @@ -37,9 +43,8 @@ object AbiPhoneDND { } } if (unformatted.startsWith("✆ Ring...") && unformatted.endsWith("[PICK UP]") - && System.currentTimeMillis() - lastRing < 5000 - ) { - event.isCancelled + && System.currentTimeMillis() - lastRing < 5000) { + event.isCancelled = true } } } \ No newline at end of file -- cgit