aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt28
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)