diff options
| author | inglettronald <inglettronald@gmail.com> | 2023-06-21 22:10:31 -0500 |
|---|---|---|
| committer | inglettronald <inglettronald@gmail.com> | 2023-06-21 22:10:31 -0500 |
| commit | 5dd4c58fea97d5df8f18c099701b7034ae8939f5 (patch) | |
| tree | 3ef3b740b4942a5786b428b402b68edb672aef0f /src/main/kotlin/com/dulkirfabric/features/chat | |
| parent | b56cf5d2a1aa1864b43acae69aedde676afafd57 (diff) | |
| download | DulkirMod-Fabric-5dd4c58fea97d5df8f18c099701b7034ae8939f5.tar.gz DulkirMod-Fabric-5dd4c58fea97d5df8f18c099701b7034ae8939f5.tar.bz2 DulkirMod-Fabric-5dd4c58fea97d5df8f18c099701b7034ae8939f5.zip | |
more work on Chat parsing and Sound handling
Diffstat (limited to 'src/main/kotlin/com/dulkirfabric/features/chat')
| -rw-r--r-- | src/main/kotlin/com/dulkirfabric/features/chat/AbiPhoneDND.kt | 19 |
1 files changed, 12 insertions, 7 deletions
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 |
