From 7b68c0c45a34107a8c77ffcfb1e3d096db56f41e Mon Sep 17 00:00:00 2001 From: BruceChen Date: Sat, 3 Sep 2022 13:39:45 +0800 Subject: [PATCH] Setting the default type of chat --- MinecraftClient/Protocol/Handlers/Protocol18.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index 9ee4614b..13f0d57c 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -184,7 +184,6 @@ namespace MinecraftClient.Protocol.Handlers { 4, ChatParser.MessageType.TEAM_MSG_COMMAND_INCOMING }, { 5, ChatParser.MessageType.TEAM_MSG_COMMAND_OUTGOING }, { 6, ChatParser.MessageType.EMOTE_COMMAND }, - { 7, ChatParser.MessageType.RAW_MSG }, }; else if (this.protocolVersion == MC_1_19_Version) ChatParser.ChatId2Type = new() @@ -481,7 +480,8 @@ namespace MinecraftClient.Protocol.Handlers verifyResult = player == null ? false : player.VerifyMessage(signedChat, timestamp, salt, ref messageSignature); } - handler.OnTextReceived(new(signedChat, true, messageType, senderUUID, unsignedChatContent, senderDisplayName, senderTeamName, timestamp, messageSignature, verifyResult)); + ChatMessage chat = new(signedChat, true, messageType, senderUUID, unsignedChatContent, senderDisplayName, senderTeamName, timestamp, messageSignature, verifyResult); + handler.OnTextReceived(chat); } else // 1.19.1 + { @@ -518,7 +518,7 @@ namespace MinecraftClient.Protocol.Handlers Dictionary chatInfo = Json.ParseJson(chatName).Properties; string senderDisplayName = (chatInfo.ContainsKey("insertion") ? chatInfo["insertion"] : chatInfo["text"]).StringValue; string? senderTeamName = null; - ChatParser.MessageType messageTypeEnum = ChatParser.ChatId2Type![chatTypeId]; + ChatParser.MessageType messageTypeEnum = ChatParser.ChatId2Type!.GetValueOrDefault(chatTypeId, ChatParser.MessageType.CHAT); if (targetName != null && (messageTypeEnum == ChatParser.MessageType.TEAM_MSG_COMMAND_INCOMING || messageTypeEnum == ChatParser.MessageType.TEAM_MSG_COMMAND_OUTGOING)) senderTeamName = Json.ParseJson(targetName).Properties["with"].DataArray[0].Properties["text"].StringValue;