diff options
Diffstat (limited to 'src/main/kotlin')
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") } |