From 766e67b5a00af83bfbc25a1c0fa0a302225102bc Mon Sep 17 00:00:00 2001 From: ingle Date: Sat, 24 Sep 2022 02:08:54 -0500 Subject: Some more things work now --- src/main/kotlin/dulkirmod/events/ChatEvent.kt | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/main/kotlin/dulkirmod/events/ChatEvent.kt (limited to 'src/main/kotlin/dulkirmod/events/ChatEvent.kt') diff --git a/src/main/kotlin/dulkirmod/events/ChatEvent.kt b/src/main/kotlin/dulkirmod/events/ChatEvent.kt new file mode 100644 index 0000000..898e2e7 --- /dev/null +++ b/src/main/kotlin/dulkirmod/events/ChatEvent.kt @@ -0,0 +1,23 @@ +package dulkirmod.events + +import dulkirmod.DulkirMod +import net.minecraftforge.client.event.ClientChatReceivedEvent +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class ChatEvent { + @SubscribeEvent(receiveCanceled = true, priority = EventPriority.LOW) + fun onChat(event: ClientChatReceivedEvent) { + if (event.type == 2.toByte()) { + return + } + val unformatted = stripColorCodes(event.message.unformattedText) + if (unformatted == "Warping you to your SkyBlock island..." && DulkirMod.config.throttleNotifier) { + event.isCanceled = true; + DulkirMod.mc.thePlayer.sendChatMessage("/pc " + DulkirMod.config.customMessage) + } + } + private fun stripColorCodes(string: String): String { + return string.replace("ยง.".toRegex(), "") + } +} \ No newline at end of file -- cgit