diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-26 12:32:42 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-26 12:32:42 +0100 |
commit | 13442c2fb2fe17bb7317cf154976f6e833c85c07 (patch) | |
tree | dfe7c396aa68871d7330f4633174c07108cf20eb /src/main/java/at/hannibal2/skyhanni | |
parent | 766fba1391153631cd9fb4420e0a761909b78be7 (diff) | |
download | skyhanni-13442c2fb2fe17bb7317cf154976f6e833c85c07.tar.gz skyhanni-13442c2fb2fe17bb7317cf154976f6e833c85c07.tar.bz2 skyhanni-13442c2fb2fe17bb7317cf154976f6e833c85c07.zip |
fixing MessageSendToServerEvent
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt index 618636f63..c426f9666 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt @@ -65,21 +65,23 @@ object ChatManager { @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) fun onActionBarPacket(event: PacketEvent.ReceiveEvent) { - val packet = event.packet - if (packet is S02PacketChat) { - val messageComponent = packet.chatComponent - - val message = LorenzUtils.stripVanillaMessage(messageComponent.formattedText) - if (packet.type.toInt() == 2) { - val actionBarEvent = LorenzActionBarEvent(message) - actionBarEvent.postAndCatch() - } - } + val packet = event.packet as? S02PacketChat ?: return - if (packet is C01PacketChatMessage) { - val message = packet.message - event.isCanceled = MessageSendToServerEvent(message).postAndCatch() + val messageComponent = packet.chatComponent + val message = LorenzUtils.stripVanillaMessage(messageComponent.formattedText) + if (packet.type.toInt() == 2) { + val actionBarEvent = LorenzActionBarEvent(message) + actionBarEvent.postAndCatch() } + + } + + @SubscribeEvent + fun onSendMessageToServerPacket(event: PacketEvent.SendEvent) { + val packet = event.packet as? C01PacketChatMessage ?: return + + val message = packet.message + event.isCanceled = MessageSendToServerEvent(message).postAndCatch() } @SubscribeEvent(receiveCanceled = true) |