diff options
Diffstat (limited to 'src/main/kotlin/dulkirmod/features/chat')
-rw-r--r-- | src/main/kotlin/dulkirmod/features/chat/AbiphoneDND.kt | 34 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/features/chat/FakeMsg.kt | 4 |
2 files changed, 18 insertions, 20 deletions
diff --git a/src/main/kotlin/dulkirmod/features/chat/AbiphoneDND.kt b/src/main/kotlin/dulkirmod/features/chat/AbiphoneDND.kt index a6a0ab6..9b429cb 100644 --- a/src/main/kotlin/dulkirmod/features/chat/AbiphoneDND.kt +++ b/src/main/kotlin/dulkirmod/features/chat/AbiphoneDND.kt @@ -10,7 +10,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent private val abiphoneFormat = "✆ (\\w+) ✆ ".toRegex() private var lastRing: Long = 0 -class AbiphoneDND { +object AbiphoneDND { //BLOCK ABIPHONE SOUNDS @SubscribeEvent(receiveCanceled = false, priority = EventPriority.LOW) fun onSound(event: PlaySoundEvent) { @@ -22,24 +22,22 @@ class AbiphoneDND { } } - companion object { - fun handle(event: ClientChatReceivedEvent, unformatted: String) { - if (!Config.abiDND) return - if (unformatted matches abiphoneFormat) { - val matchResult = abiphoneFormat.find(unformatted) - event.isCanceled = true - lastRing = System.currentTimeMillis() - if (Config.abiCallerID) { - val blocked = if (Math.random() < .001) "Breefing" - else matchResult?.groups?.get(1)?.value - TextUtils.info("§6Call blocked from $blocked!") - } - } - if (unformatted.startsWith("✆ Ring...") && unformatted.endsWith("[PICK UP]") - && System.currentTimeMillis() - lastRing < 5000 - ) { - event.isCanceled = true + fun handle(event: ClientChatReceivedEvent, unformatted: String) { + if (!Config.abiDND) return + if (unformatted matches abiphoneFormat) { + val matchResult = abiphoneFormat.find(unformatted) + event.isCanceled = true + lastRing = System.currentTimeMillis() + if (Config.abiCallerID) { + val blocked = if (Math.random() < .001) "Breefing" + else matchResult?.groups?.get(1)?.value + TextUtils.info("§6Call blocked from $blocked!") } } + if (unformatted.startsWith("✆ Ring...") && unformatted.endsWith("[PICK UP]") + && System.currentTimeMillis() - lastRing < 5000 + ) { + event.isCanceled = true + } } }
\ No newline at end of file diff --git a/src/main/kotlin/dulkirmod/features/chat/FakeMsg.kt b/src/main/kotlin/dulkirmod/features/chat/FakeMsg.kt index 8e4d2dd..ca78dae 100644 --- a/src/main/kotlin/dulkirmod/features/chat/FakeMsg.kt +++ b/src/main/kotlin/dulkirmod/features/chat/FakeMsg.kt @@ -6,9 +6,9 @@ import net.minecraftforge.client.event.ClientChatReceivedEvent object FakeMsg { private val dulkirRegex = "^From \\[MVP(\\+|\\+\\+)] Dulkir: c:".toRegex() fun handle(event: ClientChatReceivedEvent, unformatted: String) { - if (dulkirRegex.matches(unformatted)) { + if (unformatted.contains(dulkirRegex)) { event.isCanceled = true - val message = unformatted.replace(dulkirRegex, "").replace("&", "§") + val message = unformatted.replace(dulkirRegex, "").replace("&", "§").trim() TextUtils.info(message, false) } } |