mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Implement tab list display name update
Packet 0x2D with action 0x03
This commit is contained in:
parent
461385d057
commit
b1d4f85b23
4 changed files with 31 additions and 7 deletions
|
|
@ -597,6 +597,21 @@ namespace MinecraftClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get an online player by UUID
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uuid">Player UUID</param>
|
||||||
|
/// <returns>The player, or NULL if not found</returns>
|
||||||
|
public PlayerInfo GetPlayer(Guid uuid)
|
||||||
|
{
|
||||||
|
lock (onlinePlayers)
|
||||||
|
{
|
||||||
|
if (onlinePlayers.ContainsKey(uuid))
|
||||||
|
return onlinePlayers[uuid];
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Registers the given plugin channel for the given bot.
|
/// Registers the given plugin channel for the given bot.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -447,8 +447,17 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
readNextVarInt(packetData);
|
readNextVarInt(packetData);
|
||||||
break;
|
break;
|
||||||
case 0x03: //Update display name
|
case 0x03: //Update display name
|
||||||
if (readNextBool(packetData))
|
bool hasDisplayName = readNextBool(packetData);
|
||||||
readNextString(packetData);
|
string newDisplayName = null;
|
||||||
|
if (hasDisplayName)
|
||||||
|
newDisplayName = readNextString(packetData);
|
||||||
|
PlayerInfo player = handler.GetPlayer(uuid);
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
if (hasDisplayName)
|
||||||
|
player.DisplayName = newDisplayName;
|
||||||
|
else player.DisplayName = player.Name;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 0x04: //Player Leave
|
case 0x04: //Player Leave
|
||||||
handler.OnPlayerLeave(uuid);
|
handler.OnPlayerLeave(uuid);
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ namespace MinecraftClient.Protocol
|
||||||
string GetUserUUID();
|
string GetUserUUID();
|
||||||
string GetSessionID();
|
string GetSessionID();
|
||||||
PlayerInfo[] GetOnlinePlayers();
|
PlayerInfo[] GetOnlinePlayers();
|
||||||
|
PlayerInfo GetPlayer(Guid uuid);
|
||||||
Location GetCurrentLocation();
|
Location GetCurrentLocation();
|
||||||
World GetWorld();
|
World GetWorld();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,14 @@ namespace MinecraftClient.Protocol
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Information about a player (player tab list item)
|
/// Information about a player (player tab list item)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public struct PlayerInfo : IComparable<PlayerInfo>
|
public class PlayerInfo : IComparable<PlayerInfo>
|
||||||
{
|
{
|
||||||
private Guid _uuid;
|
private Guid _uuid;
|
||||||
private string _name;
|
private string _name;
|
||||||
private string _displayName;
|
|
||||||
|
|
||||||
public Guid UUID { get { return _uuid; } }
|
public Guid UUID { get { return _uuid; } }
|
||||||
public string Name { get { return _name; } }
|
public string Name { get { return _name; } }
|
||||||
public string DisplayName { get { return _displayName; } }
|
public string DisplayName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new PlayerInfo structure
|
/// Create a new PlayerInfo structure
|
||||||
|
|
@ -27,7 +26,7 @@ namespace MinecraftClient.Protocol
|
||||||
{
|
{
|
||||||
_uuid = uuid;
|
_uuid = uuid;
|
||||||
_name = name;
|
_name = name;
|
||||||
_displayName = name;
|
DisplayName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -39,7 +38,7 @@ namespace MinecraftClient.Protocol
|
||||||
public PlayerInfo(Guid uuid, string name, string displayName)
|
public PlayerInfo(Guid uuid, string name, string displayName)
|
||||||
: this(uuid, name)
|
: this(uuid, name)
|
||||||
{
|
{
|
||||||
_displayName = displayName;
|
DisplayName = displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue