mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Fixed a crash on chat parsing.
Returned the commended try catch block.
This commit is contained in:
parent
b2ef5cb23b
commit
13de67b6f8
2 changed files with 54 additions and 47 deletions
|
|
@ -365,8 +365,8 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
/// <returns>TRUE if the packet was processed, FALSE if ignored or unknown</returns>
|
/// <returns>TRUE if the packet was processed, FALSE if ignored or unknown</returns>
|
||||||
internal bool HandlePacket(int packetId, Queue<byte> packetData)
|
internal bool HandlePacket(int packetId, Queue<byte> packetData)
|
||||||
{
|
{
|
||||||
//try
|
try
|
||||||
//{
|
{
|
||||||
switch (currentState)
|
switch (currentState)
|
||||||
{
|
{
|
||||||
// https://wiki.vg/Protocol#Login
|
// https://wiki.vg/Protocol#Login
|
||||||
|
|
@ -449,23 +449,23 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//}
|
}
|
||||||
//catch (Exception innerException)
|
catch (Exception innerException)
|
||||||
//{
|
{
|
||||||
// //throw;
|
//throw;
|
||||||
// if (innerException is ThreadAbortException || innerException is SocketException ||
|
if (innerException is ThreadAbortException || innerException is SocketException ||
|
||||||
// innerException.InnerException is SocketException)
|
innerException.InnerException is SocketException)
|
||||||
// throw; //Thread abort or Connection lost rather than invalid data
|
throw; //Thread abort or Connection lost rather than invalid data
|
||||||
|
|
||||||
// throw new System.IO.InvalidDataException(
|
throw new System.IO.InvalidDataException(
|
||||||
// string.Format(Translations.exception_packet_process,
|
string.Format(Translations.exception_packet_process,
|
||||||
// packetPalette.GetIncomingTypeById(packetId),
|
packetPalette.GetIncomingTypeById(packetId),
|
||||||
// packetId,
|
packetId,
|
||||||
// protocolVersion,
|
protocolVersion,
|
||||||
// currentState == CurrentState.Login,
|
currentState == CurrentState.Login,
|
||||||
// innerException.GetType()),
|
innerException.GetType()),
|
||||||
// innerException);
|
innerException);
|
||||||
//}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -493,7 +493,8 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//Send back "accepted" and "successfully loaded" responses for plugins or server config making use of resource pack mandatory
|
//Send back "accepted" and "successfully loaded" responses for plugins or server config making use of resource pack mandatory
|
||||||
var responseHeader = protocolVersion < MC_1_10_Version // After 1.10, the MC does not include resource pack hash in responses
|
var responseHeader =
|
||||||
|
protocolVersion < MC_1_10_Version // After 1.10, the MC does not include resource pack hash in responses
|
||||||
? dataTypes.ConcatBytes(DataTypes.GetVarInt(hash.Length), Encoding.UTF8.GetBytes(hash))
|
? dataTypes.ConcatBytes(DataTypes.GetVarInt(hash.Length), Encoding.UTF8.GetBytes(hash))
|
||||||
: Array.Empty<byte>();
|
: Array.Empty<byte>();
|
||||||
|
|
||||||
|
|
@ -507,7 +508,8 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
if (currentState == CurrentState.Configuration)
|
if (currentState == CurrentState.Configuration)
|
||||||
{
|
{
|
||||||
SendPacket(ConfigurationPacketTypesOut.ResourcePackResponse, acceptedResourcePackData); // Accepted
|
SendPacket(ConfigurationPacketTypesOut.ResourcePackResponse, acceptedResourcePackData); // Accepted
|
||||||
SendPacket(ConfigurationPacketTypesOut.ResourcePackResponse, loadedResourcePackData); // Successfully loaded
|
SendPacket(ConfigurationPacketTypesOut.ResourcePackResponse,
|
||||||
|
loadedResourcePackData); // Successfully loaded
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -2567,7 +2569,8 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
objectiveValue2 = dataTypes.ReadNextVarInt(packetData); // Value
|
objectiveValue2 = dataTypes.ReadNextVarInt(packetData); // Value
|
||||||
|
|
||||||
if (dataTypes.ReadNextBool(packetData)) // Has Display Name
|
if (dataTypes.ReadNextBool(packetData)) // Has Display Name
|
||||||
objectiveDisplayName3 = ChatParser.ParseText(dataTypes.ReadNextString(packetData)); // Has Display Name
|
objectiveDisplayName3 =
|
||||||
|
ChatParser.ParseText(dataTypes.ReadNextString(packetData)); // Has Display Name
|
||||||
|
|
||||||
if (dataTypes.ReadNextBool(packetData)) // Has Number Format
|
if (dataTypes.ReadNextBool(packetData)) // Has Number Format
|
||||||
numberFormat2 = dataTypes.ReadNextVarInt(packetData); // Number Format
|
numberFormat2 = dataTypes.ReadNextVarInt(packetData); // Number Format
|
||||||
|
|
@ -2585,7 +2588,8 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
objectiveValue2 = dataTypes.ReadNextVarInt(packetData);
|
objectiveValue2 = dataTypes.ReadNextVarInt(packetData);
|
||||||
}
|
}
|
||||||
|
|
||||||
handler.OnUpdateScore(entityName, action3, objectiveName3, objectiveDisplayName3, objectiveValue2, numberFormat2);
|
handler.OnUpdateScore(entityName, action3, objectiveName3, objectiveDisplayName3, objectiveValue2,
|
||||||
|
numberFormat2);
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.BlockChangedAck:
|
case PacketTypesIn.BlockChangedAck:
|
||||||
handler.OnBlockChangeAck(dataTypes.ReadNextVarInt(packetData));
|
handler.OnBlockChangeAck(dataTypes.ReadNextVarInt(packetData));
|
||||||
|
|
|
||||||
|
|
@ -471,7 +471,10 @@ namespace MinecraftClient.Protocol.Message
|
||||||
var withs = (object[])withComponent;
|
var withs = (object[])withComponent;
|
||||||
for (int i = 0; i < withs.Length; i++)
|
for (int i = 0; i < withs.Length; i++)
|
||||||
{
|
{
|
||||||
var withDict = (Dictionary<string, object>)withs[i];
|
var withDict = withs[i] is string
|
||||||
|
? new Dictionary<string, object>() { { "text", (string)withs[i] } }
|
||||||
|
: (Dictionary<string, object>)withs[i];
|
||||||
|
|
||||||
translateString.Add(NbtToString(withDict));
|
translateString.Add(NbtToString(withDict));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue