Fixed a crash

Fixed a crash when a chat message was received on a server that uses protocol lib and viaversion.
This commit is contained in:
Anon 2024-01-28 21:43:21 +01:00 committed by GitHub
commit 3bfe5aa855
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -484,6 +484,7 @@ namespace MinecraftClient.Protocol.Handlers
private bool HandlePlayPackets(int packetId, Queue<byte> packetData)
{
try{
switch (packetPalette.GetIncommingTypeById(packetId))
{
case PacketTypesIn.KeepAlive: // Keep Alive (Play)
@ -797,7 +798,7 @@ namespace MinecraftClient.Protocol.Handlers
var chatInfo = Json.ParseJson(chatName).Properties;
var senderDisplayName =
(chatInfo.ContainsKey("insertion") ? chatInfo["insertion"] : chatInfo["text"])
(chatInfo.ContainsKey("insertion") ? chatInfo["insertion"] : (chatInfo.ContainsKey("text") ? chatInfo["text"] : ""))
.StringValue;
string? senderTeamName = null;
var messageTypeEnum =
@ -909,7 +910,7 @@ namespace MinecraftClient.Protocol.Handlers
var chatInfo =
Json.ParseJson(targetName ?? chatName).Properties;
var senderDisplayName =
(chatInfo.ContainsKey("insertion") ? chatInfo["insertion"] : chatInfo["text"])
(chatInfo.ContainsKey("insertion") ? chatInfo["insertion"] : (chatInfo.ContainsKey("text") ? chatInfo["text"] : ""))
.StringValue;
string? senderTeamName = null;
if (targetName != null &&
@ -2570,6 +2571,9 @@ namespace MinecraftClient.Protocol.Handlers
}
return true; //Packet processed
}catch(Exception exception){
exception.printStackTrace();
}
}
/// <summary>