aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-11-26 12:12:06 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-11-26 12:12:06 +0100
commitd0bef35f6d876d00673112d72415cbb0643d65ba (patch)
tree6466dfdac4b93d662e1ca73226bf3d016d0bcf82 /src/main/java/at/hannibal2/skyhanni/data
parenta7a952b657c3deacf55252d4adce39f4c05840ef (diff)
downloadskyhanni-d0bef35f6d876d00673112d72415cbb0643d65ba.tar.gz
skyhanni-d0bef35f6d876d00673112d72415cbb0643d65ba.tar.bz2
skyhanni-d0bef35f6d876d00673112d72415cbb0643d65ba.zip
Added MessageSendToServerEvent
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt
index c7ddf1777..618636f63 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt
@@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.data
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.LorenzActionBarEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.events.MessageSendToServerEvent
import at.hannibal2.skyhanni.events.PacketEvent
import at.hannibal2.skyhanni.features.chat.ChatFilterGui
import at.hannibal2.skyhanni.utils.IdentityCharacteristics
@@ -13,6 +14,7 @@ import net.minecraft.client.Minecraft
import net.minecraft.client.gui.ChatLine
import net.minecraft.client.gui.GuiNewChat
import net.minecraft.event.HoverEvent
+import net.minecraft.network.play.client.C01PacketChatMessage
import net.minecraft.network.play.server.S02PacketChat
import net.minecraft.util.EnumChatFormatting
import net.minecraft.util.IChatComponent
@@ -64,13 +66,19 @@ object ChatManager {
@SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
fun onActionBarPacket(event: PacketEvent.ReceiveEvent) {
val packet = event.packet
- if (packet !is S02PacketChat) return
- val messageComponent = packet.chatComponent
+ 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 message = LorenzUtils.stripVanillaMessage(messageComponent.formattedText)
+ if (packet.type.toInt() == 2) {
+ val actionBarEvent = LorenzActionBarEvent(message)
+ actionBarEvent.postAndCatch()
+ }
+ }
+
+ if (packet is C01PacketChatMessage) {
+ val message = packet.message
+ event.isCanceled = MessageSendToServerEvent(message).postAndCatch()
}
}
@@ -164,4 +172,4 @@ object ChatManager {
history.actionKind = ActionKind.RETRACTED
history.actionReason = reason.uppercase()
}
-} \ No newline at end of file
+}