mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Fix 1.19.3 message signature issue
This commit is contained in:
parent
8cdd32a52a
commit
3735cab9dd
5 changed files with 52 additions and 16 deletions
|
|
@ -2417,6 +2417,11 @@ namespace MinecraftClient
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void OnGameJoined(bool isOnlineMode)
|
public void OnGameJoined(bool isOnlineMode)
|
||||||
{
|
{
|
||||||
|
if (protocolversion < Protocol18Handler.MC_1_19_3_Version || playerKeyPair == null || !isOnlineMode)
|
||||||
|
SetCanSendMessage(true);
|
||||||
|
else
|
||||||
|
SetCanSendMessage(false);
|
||||||
|
|
||||||
string? bandString = Config.Main.Advanced.BrandInfo.ToBrandString();
|
string? bandString = Config.Main.Advanced.BrandInfo.ToBrandString();
|
||||||
if (!String.IsNullOrWhiteSpace(bandString))
|
if (!String.IsNullOrWhiteSpace(bandString))
|
||||||
handler.SendBrandInfo(bandString.Trim());
|
handler.SendBrandInfo(bandString.Trim());
|
||||||
|
|
@ -2435,9 +2440,6 @@ namespace MinecraftClient
|
||||||
&& playerKeyPair != null && isOnlineMode)
|
&& playerKeyPair != null && isOnlineMode)
|
||||||
handler.SendPlayerSession(playerKeyPair);
|
handler.SendPlayerSession(playerKeyPair);
|
||||||
|
|
||||||
if (protocolversion < Protocol18Handler.MC_1_19_3_Version)
|
|
||||||
CanSendMessage = true;
|
|
||||||
|
|
||||||
if (inventoryHandlingRequested)
|
if (inventoryHandlingRequested)
|
||||||
{
|
{
|
||||||
inventoryHandlingRequested = false;
|
inventoryHandlingRequested = false;
|
||||||
|
|
@ -3482,9 +3484,10 @@ namespace MinecraftClient
|
||||||
ConsoleIO.OnAutoCompleteDone(transactionId, result);
|
ConsoleIO.OnAutoCompleteDone(transactionId, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnDeclareCommands()
|
public void SetCanSendMessage(bool canSendMessage)
|
||||||
{
|
{
|
||||||
CanSendMessage = true;
|
CanSendMessage = canSendMessage;
|
||||||
|
Log.Debug("CanSendMessage = " + canSendMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -75,8 +75,9 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
private readonly BlockingCollection<Tuple<int, Queue<byte>>> packetQueue = new();
|
private readonly BlockingCollection<Tuple<int, Queue<byte>>> packetQueue = new();
|
||||||
private float LastYaw, LastPitch;
|
private float LastYaw, LastPitch;
|
||||||
|
|
||||||
|
private bool receiveDeclareCommands = false, receivePlayerInfo = false;
|
||||||
private object MessageSigningLock = new();
|
private object MessageSigningLock = new();
|
||||||
private Guid chatUuid = Guid.Empty;
|
private Guid chatUuid = Guid.NewGuid();
|
||||||
private int pendingAcknowledgments = 0, messageIndex = 0;
|
private int pendingAcknowledgments = 0, messageIndex = 0;
|
||||||
private LastSeenMessagesCollector lastSeenMessagesCollector;
|
private LastSeenMessagesCollector lastSeenMessagesCollector;
|
||||||
private LastSeenMessageList.AcknowledgedMessage? lastReceivedMessage = null;
|
private LastSeenMessageList.AcknowledgedMessage? lastReceivedMessage = null;
|
||||||
|
|
@ -367,7 +368,19 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
SendPacket(PacketTypesOut.Pong, packetData);
|
SendPacket(PacketTypesOut.Pong, packetData);
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.JoinGame:
|
case PacketTypesIn.JoinGame:
|
||||||
|
{ // Temporary fix
|
||||||
|
log.Debug("Receive JoinGame");
|
||||||
|
|
||||||
|
receiveDeclareCommands = receivePlayerInfo = false;
|
||||||
|
|
||||||
|
messageIndex = 0;
|
||||||
|
pendingAcknowledgments = 0;
|
||||||
|
|
||||||
|
lastReceivedMessage = null;
|
||||||
|
lastSeenMessagesCollector = protocolVersion >= MC_1_19_3_Version ? new(20) : new(5);
|
||||||
|
}
|
||||||
handler.OnGameJoined(isOnlineMode);
|
handler.OnGameJoined(isOnlineMode);
|
||||||
|
|
||||||
int playerEntityID = dataTypes.ReadNextInt(packetData);
|
int playerEntityID = dataTypes.ReadNextInt(packetData);
|
||||||
handler.OnReceivePlayerEntityID(playerEntityID);
|
handler.OnReceivePlayerEntityID(playerEntityID);
|
||||||
|
|
||||||
|
|
@ -467,8 +480,11 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
case PacketTypesIn.DeclareCommands:
|
case PacketTypesIn.DeclareCommands:
|
||||||
if (protocolVersion >= MC_1_19_Version)
|
if (protocolVersion >= MC_1_19_Version)
|
||||||
{
|
{
|
||||||
|
log.Debug("Receive DeclareCommands");
|
||||||
DeclareCommands.Read(dataTypes, packetData, protocolVersion);
|
DeclareCommands.Read(dataTypes, packetData, protocolVersion);
|
||||||
handler.OnDeclareCommands();
|
receiveDeclareCommands = true;
|
||||||
|
if (receivePlayerInfo)
|
||||||
|
handler.SetCanSendMessage(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.ChatMessage:
|
case PacketTypesIn.ChatMessage:
|
||||||
|
|
@ -1404,10 +1420,28 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
byte[] encodedPublicKey = dataTypes.ReadNextByteArray(packetData);
|
byte[] encodedPublicKey = dataTypes.ReadNextByteArray(packetData);
|
||||||
byte[] publicKeySignature = dataTypes.ReadNextByteArray(packetData);
|
byte[] publicKeySignature = dataTypes.ReadNextByteArray(packetData);
|
||||||
player.SetPublicKey(chatUuid, publicKeyExpiryTime, encodedPublicKey, publicKeySignature);
|
player.SetPublicKey(chatUuid, publicKeyExpiryTime, encodedPublicKey, publicKeySignature);
|
||||||
|
|
||||||
|
if (playerUuid == handler.GetUserUuid())
|
||||||
|
{
|
||||||
|
log.Debug("Receive ChatUuid = " + chatUuid);
|
||||||
|
this.chatUuid = chatUuid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
player.ClearPublicKey();
|
player.ClearPublicKey();
|
||||||
|
|
||||||
|
if (playerUuid == handler.GetUserUuid())
|
||||||
|
{
|
||||||
|
log.Debug("Receive ChatUuid = Empty");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (playerUuid == handler.GetUserUuid())
|
||||||
|
{
|
||||||
|
receivePlayerInfo = true;
|
||||||
|
if (receiveDeclareCommands)
|
||||||
|
handler.SetCanSendMessage(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((actionBitset & 1 << 2) > 0) // Actions bit 2: update gamemode
|
if ((actionBitset & 1 << 2) > 0) // Actions bit 2: update gamemode
|
||||||
|
|
@ -3392,7 +3426,6 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
{
|
{
|
||||||
List<byte> packet = new();
|
List<byte> packet = new();
|
||||||
|
|
||||||
chatUuid = Guid.NewGuid();
|
|
||||||
packet.AddRange(DataTypes.GetUUID(chatUuid));
|
packet.AddRange(DataTypes.GetUUID(chatUuid));
|
||||||
packet.AddRange(DataTypes.GetLong(playerKeyPair.GetExpirationMilliseconds()));
|
packet.AddRange(DataTypes.GetLong(playerKeyPair.GetExpirationMilliseconds()));
|
||||||
packet.AddRange(DataTypes.GetVarInt(playerKeyPair.PublicKey.Key.Length));
|
packet.AddRange(DataTypes.GetVarInt(playerKeyPair.PublicKey.Key.Length));
|
||||||
|
|
@ -3400,6 +3433,8 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
packet.AddRange(DataTypes.GetVarInt(playerKeyPair.PublicKey.SignatureV2!.Length));
|
packet.AddRange(DataTypes.GetVarInt(playerKeyPair.PublicKey.SignatureV2!.Length));
|
||||||
packet.AddRange(playerKeyPair.PublicKey.SignatureV2);
|
packet.AddRange(playerKeyPair.PublicKey.SignatureV2);
|
||||||
|
|
||||||
|
log.Debug($"SendPlayerSession MessageUUID = {chatUuid.ToString()}, len(PublicKey) = {playerKeyPair.PublicKey.Key.Length}, len(SignatureV2) = {playerKeyPair.PublicKey.SignatureV2!.Length}");
|
||||||
|
|
||||||
SendPacket(PacketTypesOut.PlayerSession, packet);
|
SendPacket(PacketTypesOut.PlayerSession, packet);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -466,7 +466,7 @@ namespace MinecraftClient.Protocol
|
||||||
/// <param name="result">All commands.</param>
|
/// <param name="result">All commands.</param>
|
||||||
public void OnAutoCompleteDone(int transactionId, string[] result);
|
public void OnAutoCompleteDone(int transactionId, string[] result);
|
||||||
|
|
||||||
public void OnDeclareCommands();
|
public void SetCanSendMessage(bool canSendMessage);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Send a click container button packet to the server.
|
/// Send a click container button packet to the server.
|
||||||
|
|
|
||||||
|
|
@ -302,11 +302,9 @@ namespace MinecraftClient.Protocol.Message
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
ConsoleIO.WriteLineFormatted("§8" + Translations.chat_fail, acceptnewlines: true);
|
ConsoleIO.WriteLineFormatted("§8" + Translations.chat_fail, acceptnewlines: true);
|
||||||
if (Config.Logging.DebugMessages)
|
ConsoleIO.WriteLine(e.Message);
|
||||||
{
|
if (Config.Logging.DebugMessages && !string.IsNullOrEmpty(e.StackTrace))
|
||||||
ConsoleIO.WriteLine(e.Message);
|
ConsoleIO.WriteLine(e.StackTrace);
|
||||||
ConsoleIO.WriteLine(e.StackTrace ?? "");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -705,7 +705,7 @@ namespace MinecraftClient
|
||||||
public bool SignMessageInCommand = true;
|
public bool SignMessageInCommand = true;
|
||||||
|
|
||||||
[TomlInlineComment("$Signature.MarkLegallySignedMsg$")]
|
[TomlInlineComment("$Signature.MarkLegallySignedMsg$")]
|
||||||
public bool MarkLegallySignedMsg = false;
|
public bool MarkLegallySignedMsg = true;
|
||||||
|
|
||||||
[TomlInlineComment("$Signature.MarkModifiedMsg$")]
|
[TomlInlineComment("$Signature.MarkModifiedMsg$")]
|
||||||
public bool MarkModifiedMsg = true;
|
public bool MarkModifiedMsg = true;
|
||||||
|
|
@ -714,7 +714,7 @@ namespace MinecraftClient
|
||||||
public bool MarkIllegallySignedMsg = true;
|
public bool MarkIllegallySignedMsg = true;
|
||||||
|
|
||||||
[TomlInlineComment("$Signature.MarkSystemMessage$")]
|
[TomlInlineComment("$Signature.MarkSystemMessage$")]
|
||||||
public bool MarkSystemMessage = false;
|
public bool MarkSystemMessage = true;
|
||||||
|
|
||||||
[TomlInlineComment("$Signature.ShowModifiedChat$")]
|
[TomlInlineComment("$Signature.ShowModifiedChat$")]
|
||||||
public bool ShowModifiedChat = true;
|
public bool ShowModifiedChat = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue