aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/dulkirfabric/features
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/com/dulkirfabric/features')
-rw-r--r--src/main/kotlin/com/dulkirfabric/features/chat/AbiPhoneDND.kt19
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