From ab43b1989ebb75d5ca3ddd59a71e6a8879f040b0 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Mon, 5 Feb 2024 22:41:23 +0100 Subject: Add outgoing chat log to /shchathistory (#863) Added outgoing chat log to /shchathistory. #863 --- src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt index 34e4354dd..08bef76ff 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt @@ -17,6 +17,7 @@ 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.ChatComponentText import net.minecraft.util.EnumChatFormatting import net.minecraft.util.IChatComponent import net.minecraftforge.client.event.ClientChatReceivedEvent @@ -46,6 +47,8 @@ object ChatManager { RETRACTED(EnumChatFormatting.DARK_PURPLE.toString() + EnumChatFormatting.BOLD), MODIFIED(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD), ALLOWED(EnumChatFormatting.GREEN), + OUTGOING(EnumChatFormatting.BLUE), + OUTGOING_BLOCKED(EnumChatFormatting.BLUE.toString() + EnumChatFormatting.BOLD), ; val renderedString = "$format$name" @@ -82,7 +85,14 @@ object ChatManager { val packet = event.packet as? C01PacketChatMessage ?: return val message = packet.message - event.isCanceled = MessageSendToServerEvent(message).postAndCatch() + val component = ChatComponentText(message) + messageHistory[IdentityCharacteristics(component)] = + MessageFilteringResult(component, ActionKind.OUTGOING, null, null) + if (MessageSendToServerEvent(message).postAndCatch()) { + event.isCanceled = true + messageHistory[IdentityCharacteristics(component)] = + MessageFilteringResult(component, ActionKind.OUTGOING_BLOCKED, null, null) + } } @SubscribeEvent(receiveCanceled = true) -- cgit