aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/dulkirfabric
diff options
context:
space:
mode:
authoringlettronald <inglettronald@gmail.com>2023-06-21 22:10:31 -0500
committeringlettronald <inglettronald@gmail.com>2023-06-21 22:10:31 -0500
commit5dd4c58fea97d5df8f18c099701b7034ae8939f5 (patch)
tree3ef3b740b4942a5786b428b402b68edb672aef0f /src/main/kotlin/com/dulkirfabric
parentb56cf5d2a1aa1864b43acae69aedde676afafd57 (diff)
downloadDulkirMod-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')
-rw-r--r--src/main/kotlin/com/dulkirfabric/DulkirModFabric.kt2
-rw-r--r--src/main/kotlin/com/dulkirfabric/Registrations.kt2
-rw-r--r--src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt2
-rw-r--r--src/main/kotlin/com/dulkirfabric/events/ChatReceivedEvent.kt3
-rw-r--r--src/main/kotlin/com/dulkirfabric/features/chat/AbiPhoneDND.kt19
-rw-r--r--src/main/kotlin/com/dulkirfabric/util/TextUtils.kt3
6 files changed, 19 insertions, 12 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/DulkirModFabric.kt b/src/main/kotlin/com/dulkirfabric/DulkirModFabric.kt
index 8748f20..80f4dc2 100644
--- a/src/main/kotlin/com/dulkirfabric/DulkirModFabric.kt
+++ b/src/main/kotlin/com/dulkirfabric/DulkirModFabric.kt
@@ -48,6 +48,4 @@ object DulkirModFabric : ModInitializer {
DulkirConfig.loadConfig()
}
- //!this.client.options.getPerspective().isFirstPerson(), this.client.options.getPerspective().isFrontView()
-
} \ No newline at end of file
diff --git a/src/main/kotlin/com/dulkirfabric/Registrations.kt b/src/main/kotlin/com/dulkirfabric/Registrations.kt
index d15be19..55b301a 100644
--- a/src/main/kotlin/com/dulkirfabric/Registrations.kt
+++ b/src/main/kotlin/com/dulkirfabric/Registrations.kt
@@ -61,7 +61,7 @@ object Registrations {
ClientReceiveMessageEvents.ALLOW_GAME.register(
ClientReceiveMessageEvents.AllowGame { message, overlay ->
if (overlay) !OverlayReceivedEvent(message.toString()).post()
- else !ChatReceivedEvent(message.toString()).post()
+ else !ChatReceivedEvent(message).post()
}
)
WorldRenderEvents.END.register(
diff --git a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt
index 832fae6..7ebe742 100644
--- a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt
+++ b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt
@@ -44,7 +44,7 @@ class DulkirConfig {
val builder = ConfigBuilder.create().setTitle(buttonText)
builder.setDefaultBackgroundTexture(Identifier("minecraft:textures/block/oak_planks.png"))
builder.setGlobalized(true)
- builder.setGlobalizedExpanded(true)
+ builder.setGlobalizedExpanded(false)
builder.setParentScreen(mc.currentScreen)
builder.setSavingRunnable(::saveConfig)
val entryBuilder = builder.entryBuilder()
diff --git a/src/main/kotlin/com/dulkirfabric/events/ChatReceivedEvent.kt b/src/main/kotlin/com/dulkirfabric/events/ChatReceivedEvent.kt
index 892baf1..9f8430d 100644
--- a/src/main/kotlin/com/dulkirfabric/events/ChatReceivedEvent.kt
+++ b/src/main/kotlin/com/dulkirfabric/events/ChatReceivedEvent.kt
@@ -1,6 +1,7 @@
package com.dulkirfabric.events
import com.dulkirfabric.events.base.CancellableEvent
+import net.minecraft.text.Text
data class
-ChatReceivedEvent(val message: String): CancellableEvent() \ No newline at end of file
+ChatReceivedEvent(val message: Text): CancellableEvent() \ No newline at end of file
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
diff --git a/src/main/kotlin/com/dulkirfabric/util/TextUtils.kt b/src/main/kotlin/com/dulkirfabric/util/TextUtils.kt
index c239ba0..c3baa9e 100644
--- a/src/main/kotlin/com/dulkirfabric/util/TextUtils.kt
+++ b/src/main/kotlin/com/dulkirfabric/util/TextUtils.kt
@@ -17,6 +17,9 @@ object TextUtils {
info("§9Toggled $message §8[$stateText§8]§r")
}
+ val Text.unformattedString
+ get() = string.replace("§.".toRegex(), "")
+
fun sendPartyChatMessage(message: String) {
this.sendCommand("/pc $message")
}