aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-02-05 22:41:23 +0100
committerGitHub <noreply@github.com>2024-02-05 22:41:23 +0100
commitab43b1989ebb75d5ca3ddd59a71e6a8879f040b0 (patch)
treef89365e3e83badc015af47f4a5d9ede3d7d401c9 /src/main/java/at
parent8fd64fdf87da0b8e0f789847336890ceefdea975 (diff)
downloadskyhanni-ab43b1989ebb75d5ca3ddd59a71e6a8879f040b0.tar.gz
skyhanni-ab43b1989ebb75d5ca3ddd59a71e6a8879f040b0.tar.bz2
skyhanni-ab43b1989ebb75d5ca3ddd59a71e6a8879f040b0.zip
Add outgoing chat log to /shchathistory (#863)
Added outgoing chat log to /shchathistory. #863
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt12
1 files changed, 11 insertions, 1 deletions
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)