diff --git a/MinecraftClient/McTcpClient.cs b/MinecraftClient/McTcpClient.cs
index 234bc579..3951e1c7 100644
--- a/MinecraftClient/McTcpClient.cs
+++ b/MinecraftClient/McTcpClient.cs
@@ -597,6 +597,21 @@ namespace MinecraftClient
}
}
+ ///
+ /// Get an online player by UUID
+ ///
+ /// Player UUID
+ /// The player, or NULL if not found
+ public PlayerInfo GetPlayer(Guid uuid)
+ {
+ lock (onlinePlayers)
+ {
+ if (onlinePlayers.ContainsKey(uuid))
+ return onlinePlayers[uuid];
+ return null;
+ }
+ }
+
///
/// Registers the given plugin channel for the given bot.
///
diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs
index 2c1ee364..6ce70dc0 100644
--- a/MinecraftClient/Protocol/Handlers/Protocol18.cs
+++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs
@@ -447,8 +447,17 @@ namespace MinecraftClient.Protocol.Handlers
readNextVarInt(packetData);
break;
case 0x03: //Update display name
- if (readNextBool(packetData))
- readNextString(packetData);
+ bool hasDisplayName = readNextBool(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;
case 0x04: //Player Leave
handler.OnPlayerLeave(uuid);
diff --git a/MinecraftClient/Protocol/IMinecraftComHandler.cs b/MinecraftClient/Protocol/IMinecraftComHandler.cs
index fd0f9e63..882c2d3f 100644
--- a/MinecraftClient/Protocol/IMinecraftComHandler.cs
+++ b/MinecraftClient/Protocol/IMinecraftComHandler.cs
@@ -23,6 +23,7 @@ namespace MinecraftClient.Protocol
string GetUserUUID();
string GetSessionID();
PlayerInfo[] GetOnlinePlayers();
+ PlayerInfo GetPlayer(Guid uuid);
Location GetCurrentLocation();
World GetWorld();
diff --git a/MinecraftClient/Protocol/PlayerInfo.cs b/MinecraftClient/Protocol/PlayerInfo.cs
index 86a506a3..eae0727d 100644
--- a/MinecraftClient/Protocol/PlayerInfo.cs
+++ b/MinecraftClient/Protocol/PlayerInfo.cs
@@ -8,15 +8,14 @@ namespace MinecraftClient.Protocol
///
/// Information about a player (player tab list item)
///
- public struct PlayerInfo : IComparable
+ public class PlayerInfo : IComparable
{
private Guid _uuid;
private string _name;
- private string _displayName;
public Guid UUID { get { return _uuid; } }
public string Name { get { return _name; } }
- public string DisplayName { get { return _displayName; } }
+ public string DisplayName { get; set; }
///
/// Create a new PlayerInfo structure
@@ -27,7 +26,7 @@ namespace MinecraftClient.Protocol
{
_uuid = uuid;
_name = name;
- _displayName = name;
+ DisplayName = name;
}
///
@@ -39,7 +38,7 @@ namespace MinecraftClient.Protocol
public PlayerInfo(Guid uuid, string name, string displayName)
: this(uuid, name)
{
- _displayName = displayName;
+ DisplayName = displayName;
}
///