mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Add /list support in Protocol17
Fake UUID using md5(username) since protocol17 does not have UUID in player list item packet
This commit is contained in:
parent
f82041288d
commit
8d16f1ec89
1 changed files with 50 additions and 0 deletions
|
|
@ -6,6 +6,7 @@ using System.Net.Sockets;
|
|||
using System.Threading;
|
||||
using MinecraftClient.Crypto;
|
||||
using MinecraftClient.Proxy;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace MinecraftClient.Protocol.Handlers
|
||||
{
|
||||
|
|
@ -96,6 +97,17 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
case 0x02:
|
||||
handler.OnTextReceived(ChatParser.ParseText(readNextString()));
|
||||
break;
|
||||
case 0x38:
|
||||
string name = readNextString();
|
||||
bool online = readNextBool();
|
||||
short ping = readNextShort();
|
||||
Guid FakeUUID = new Guid(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(name)).Take(16).ToArray());
|
||||
if (online)
|
||||
{
|
||||
handler.OnPlayerJoin(FakeUUID, name);
|
||||
}
|
||||
else handler.OnPlayerLeave(FakeUUID);
|
||||
break;
|
||||
case 0x3A:
|
||||
int autocomplete_count = readNextVarInt();
|
||||
string tab_list = "";
|
||||
|
|
@ -186,6 +198,44 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
else return "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read a uuid from the network
|
||||
/// </summary>
|
||||
/// <param name="cache">Cache of bytes to read from</param>
|
||||
/// <returns>The uuid</returns>
|
||||
|
||||
private Guid readNextUUID()
|
||||
{
|
||||
byte[] cache = new byte[16];
|
||||
Receive(cache, 0, 16, SocketFlags.None);
|
||||
return new Guid(cache);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read a short from the network
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
|
||||
private short readNextShort()
|
||||
{
|
||||
byte[] tmp = new byte[2];
|
||||
Receive(tmp, 0, 2, SocketFlags.None);
|
||||
Array.Reverse(tmp);
|
||||
return BitConverter.ToInt16(tmp, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read a boolean from the network
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
|
||||
private bool readNextBool()
|
||||
{
|
||||
byte[] tmp = new byte[1];
|
||||
Receive(tmp, 0, 1, SocketFlags.None);
|
||||
return tmp[0] != 0x00;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read a byte array from the network
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue