Remove tab display name experiment (not working)

- Tab display names should hold display name but...
 - Server sends <UUID, name, null> x Player count
 - TabListPlus sends <SlotID, ???tab#01, SlotText> x Slot Count
 - So we don't have player display names, only worthless slots
 - So the whole feature was useless, reverting to name only.
This commit is contained in:
ORelio 2016-08-27 15:46:34 +02:00
parent 61ce935c63
commit 2a07fbbae6
9 changed files with 18 additions and 141 deletions

View file

@ -8,18 +8,11 @@ namespace MinecraftClient.Commands
public class List : Command public class List : Command
{ {
public override string CMDName { get { return "list"; } } public override string CMDName { get { return "list"; } }
public override string CMDDesc { get { return "list [raw]: get the player list."; } } public override string CMDDesc { get { return "list: get the player list."; } }
public override string Run(McTcpClient handler, string command) public override string Run(McTcpClient handler, string command)
{ {
bool rawNames = getArg(command).ToLower() == "raw"; return "PlayerList: " + String.Join(", ", handler.GetOnlinePlayers());
return "PlayerList: "
+ String.Join(", ",
handler.GetOnlinePlayers()
.OrderBy(player => player.Name)
.Select(player => rawNames
? player.Name
: player.DisplayName));
} }
} }
} }

View file

@ -23,7 +23,7 @@ namespace MinecraftClient
private static readonly List<string> cmd_names = new List<string>(); private static readonly List<string> cmd_names = new List<string>();
private static readonly Dictionary<string, Command> cmds = new Dictionary<string, Command>(); private static readonly Dictionary<string, Command> cmds = new Dictionary<string, Command>();
private readonly Dictionary<Guid, PlayerInfo> onlinePlayers = new Dictionary<Guid, PlayerInfo>(); private readonly Dictionary<Guid, string> onlinePlayers = new Dictionary<Guid, string>();
private readonly List<ChatBot> bots = new List<ChatBot>(); private readonly List<ChatBot> bots = new List<ChatBot>();
private static readonly List<ChatBots.Script> scripts_on_hold = new List<ChatBots.Script>(); private static readonly List<ChatBots.Script> scripts_on_hold = new List<ChatBots.Script>();
@ -569,16 +569,16 @@ namespace MinecraftClient
/// Triggered when a new player joins the game /// Triggered when a new player joins the game
/// </summary> /// </summary>
/// <param name="uuid">UUID of the player</param> /// <param name="uuid">UUID of the player</param>
/// <param name="info">Info about this player</param> /// <param name="name">Name of the player</param>
public void OnPlayerJoin(PlayerInfo info) public void OnPlayerJoin(Guid uuid, string name)
{ {
//Ignore placeholders eg 0000tab# from TabListPlus //Ignore placeholders eg 0000tab# from TabListPlus
if (!ChatBot.IsValidName(info.Name)) if (!ChatBot.IsValidName(name))
return; return;
lock (onlinePlayers) lock (onlinePlayers)
{ {
onlinePlayers[info.UUID] = info; onlinePlayers[uuid] = name;
} }
} }
@ -598,7 +598,7 @@ namespace MinecraftClient
/// Get a set of online player names /// Get a set of online player names
/// </summary> /// </summary>
/// <returns>Online player names</returns> /// <returns>Online player names</returns>
public PlayerInfo[] GetOnlinePlayers() public string[] GetOnlinePlayers()
{ {
lock (onlinePlayers) lock (onlinePlayers)
{ {
@ -606,21 +606,6 @@ 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>

View file

@ -148,7 +148,6 @@
<Compile Include="Protocol\Handlers\Protocol16.cs" /> <Compile Include="Protocol\Handlers\Protocol16.cs" />
<Compile Include="Protocol\IMinecraftCom.cs" /> <Compile Include="Protocol\IMinecraftCom.cs" />
<Compile Include="Protocol\IMinecraftComHandler.cs" /> <Compile Include="Protocol\IMinecraftComHandler.cs" />
<Compile Include="Protocol\PlayerInfo.cs" />
<Compile Include="Protocol\ProtocolHandler.cs" /> <Compile Include="Protocol\ProtocolHandler.cs" />
<Compile Include="Protocol\SessionCache\CacheType.cs" /> <Compile Include="Protocol\SessionCache\CacheType.cs" />
<Compile Include="Protocol\SessionCache\SessionCache.cs" /> <Compile Include="Protocol\SessionCache\SessionCache.cs" />

View file

@ -160,7 +160,7 @@ namespace MinecraftClient.Protocol.Handlers
case 0xC9: case 0xC9:
string name = readNextString(); bool online = readNextByte() != 0x00; readData(2); string name = readNextString(); bool online = readNextByte() != 0x00; readData(2);
Guid FakeUUID = new Guid(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(name)).Take(16).ToArray()); Guid FakeUUID = new Guid(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(name)).Take(16).ToArray());
if (online) { handler.OnPlayerJoin(new PlayerInfo(FakeUUID, name)); } else { handler.OnPlayerLeave(FakeUUID); } if (online) { handler.OnPlayerJoin(FakeUUID, name); } else { handler.OnPlayerLeave(FakeUUID); }
break; break;
case 0xCA: if (protocolversion >= 72) { readData(9); } else readData(3); break; case 0xCA: if (protocolversion >= 72) { readData(9); } else readData(3); break;
case 0xCB: autocomplete_result = readNextString(); autocomplete_received = true; break; case 0xCB: autocomplete_result = readNextString(); autocomplete_received = true; break;

View file

@ -437,27 +437,17 @@ namespace MinecraftClient.Protocol.Handlers
} }
readNextVarInt(packetData); readNextVarInt(packetData);
readNextVarInt(packetData); readNextVarInt(packetData);
string displayName = name;
if (readNextBool(packetData)) if (readNextBool(packetData))
displayName = readNextString(packetData); readNextString(packetData);
handler.OnPlayerJoin(new PlayerInfo(uuid, name, displayName)); handler.OnPlayerJoin(uuid, name);
break; break;
case 0x01: //Update gamemode case 0x01: //Update gamemode
case 0x02: //Update latency case 0x02: //Update latency
readNextVarInt(packetData); readNextVarInt(packetData);
break; break;
case 0x03: //Update display name case 0x03: //Update display name
bool hasDisplayName = readNextBool(packetData); if (readNextBool(packetData))
string newDisplayName = null; readNextString(packetData);
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);
@ -475,7 +465,7 @@ namespace MinecraftClient.Protocol.Handlers
short ping = readNextShort(packetData); short ping = readNextShort(packetData);
Guid FakeUUID = new Guid(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(name)).Take(16).ToArray()); Guid FakeUUID = new Guid(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(name)).Take(16).ToArray());
if (online) if (online)
handler.OnPlayerJoin(new PlayerInfo(FakeUUID, name)); handler.OnPlayerJoin(FakeUUID, name);
else handler.OnPlayerLeave(FakeUUID); else handler.OnPlayerLeave(FakeUUID);
} }
break; break;

View file

@ -22,8 +22,7 @@ namespace MinecraftClient.Protocol
string GetUsername(); string GetUsername();
string GetUserUUID(); string GetUserUUID();
string GetSessionID(); string GetSessionID();
PlayerInfo[] GetOnlinePlayers(); string[] GetOnlinePlayers();
PlayerInfo GetPlayer(Guid uuid);
Location GetCurrentLocation(); Location GetCurrentLocation();
World GetWorld(); World GetWorld();
@ -41,8 +40,8 @@ namespace MinecraftClient.Protocol
/// This method is called when a new player joins the game /// This method is called when a new player joins the game
/// </summary> /// </summary>
/// <param name="uuid">UUID of the player</param> /// <param name="uuid">UUID of the player</param>
/// <param name="info">Info about this player</param> /// <param name="name">Name of the player</param>
void OnPlayerJoin(PlayerInfo info); void OnPlayerJoin(Guid uuid, string name);
/// <summary> /// <summary>
/// This method is called when a player has left the game /// This method is called when a player has left the game

View file

@ -1,85 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MinecraftClient.Protocol
{
/// <summary>
/// Information about a player (player tab list item)
/// </summary>
public class PlayerInfo : IComparable<PlayerInfo>
{
private Guid _uuid;
private string _name;
public Guid UUID { get { return _uuid; } }
public string Name { get { return _name; } }
public string DisplayName { get; set; }
/// <summary>
/// Create a new PlayerInfo structure
/// </summary>
/// <param name="uuid">Player Id</param>
/// <param name="name">Player Name</param>
public PlayerInfo(Guid uuid, string name)
{
_uuid = uuid;
_name = name;
DisplayName = name;
}
/// <summary>
/// Create a new PlayerInfo structure
/// </summary>
/// <param name="uuid">Player Id</param>
/// <param name="name">Player Name</param>
/// <param name="displayName">Player Display Name</param>
public PlayerInfo(Guid uuid, string name, string displayName)
: this(uuid, name)
{
DisplayName = displayName;
}
/// <summary>
/// String representation of the player
/// </summary>
/// <returns>Player display name</returns>
public override string ToString()
{
return DisplayName;
}
/// <summary>
/// Compare a player to another player
/// </summary>
/// <param name="obj">Other player</param>
/// <returns>TRUE if same player Id</returns>
public override bool Equals(object obj)
{
if (obj is PlayerInfo)
return UUID.Equals(((PlayerInfo)obj).UUID);
return base.Equals(obj);
}
/// <summary>
/// Basic hash function for player, from Player Id
/// </summary>
/// <returns>Interger hash</returns>
/// <remarks>Required when overriding Equals()</remarks>
public override int GetHashCode()
{
return UUID.GetHashCode();
}
/// <summary>
/// Allows sorting players by name
/// </summary>
/// <param name="obj">Other player to compare to</param>
/// <returns>Comparition with the player's name</returns>
int IComparable<PlayerInfo>.CompareTo(PlayerInfo obj)
{
return Name.CompareTo(obj.Name);
}
}
}

View file

@ -24,7 +24,6 @@ namespace MinecraftClient.Protocol
/// <param name="serverPort">Server Port to ping</param> /// <param name="serverPort">Server Port to ping</param>
/// <param name="protocolversion">Will contain protocol version, if ping successful</param> /// <param name="protocolversion">Will contain protocol version, if ping successful</param>
/// <returns>TRUE if ping was successful</returns> /// <returns>TRUE if ping was successful</returns>
public static bool GetServerInfo(string serverIP, ushort serverPort, ref int protocolversion, ref ForgeInfo forgeInfo) public static bool GetServerInfo(string serverIP, ushort serverPort, ref int protocolversion, ref ForgeInfo forgeInfo)
{ {
bool success = false; bool success = false;
@ -65,7 +64,6 @@ namespace MinecraftClient.Protocol
/// <param name="ProtocolVersion">Protocol version to handle</param> /// <param name="ProtocolVersion">Protocol version to handle</param>
/// <param name="Handler">Handler with the appropriate callbacks</param> /// <param name="Handler">Handler with the appropriate callbacks</param>
/// <returns></returns> /// <returns></returns>
public static IMinecraftCom getProtocolHandler(TcpClient Client, int ProtocolVersion, ForgeInfo forgeInfo, IMinecraftComHandler Handler) public static IMinecraftCom getProtocolHandler(TcpClient Client, int ProtocolVersion, ForgeInfo forgeInfo, IMinecraftComHandler Handler)
{ {
int[] supportedVersions_Protocol16 = { 51, 60, 61, 72, 73, 74, 78 }; int[] supportedVersions_Protocol16 = { 51, 60, 61, 72, 73, 74, 78 };
@ -82,7 +80,6 @@ namespace MinecraftClient.Protocol
/// </summary> /// </summary>
/// <param name="MCVersion">The Minecraft version number</param> /// <param name="MCVersion">The Minecraft version number</param>
/// <returns>The protocol version number or 0 if could not determine protocol version: error, unknown, not supported</returns> /// <returns>The protocol version number or 0 if could not determine protocol version: error, unknown, not supported</returns>
public static int MCVer2ProtocolVersion(string MCVersion) public static int MCVer2ProtocolVersion(string MCVersion)
{ {
if (MCVersion.Contains('.')) if (MCVersion.Contains('.'))
@ -170,7 +167,6 @@ namespace MinecraftClient.Protocol
/// <param name="clienttoken">Will contain the client token generated before sending to Minecraft.net</param> /// <param name="clienttoken">Will contain the client token generated before sending to Minecraft.net</param>
/// <param name="uuid">Will contain the player's PlayerID, needed for multiplayer</param> /// <param name="uuid">Will contain the player's PlayerID, needed for multiplayer</param>
/// <returns>Returns the status of the login (Success, Failure, etc.)</returns> /// <returns>Returns the status of the login (Success, Failure, etc.)</returns>
public static LoginResult GetLogin(string user, string pass, out SessionToken session) public static LoginResult GetLogin(string user, string pass, out SessionToken session)
{ {
session = new SessionToken() { ClientID = Guid.NewGuid().ToString().Replace("-", "") }; session = new SessionToken() { ClientID = Guid.NewGuid().ToString().Replace("-", "") };

View file

@ -63,7 +63,7 @@ In scripts and remote control, no slash is needed to perform the command.
- send <text> : send a message or a command to the server - send <text> : send a message or a command to the server
- respawn : Use this to respawn if you are dead (like clicking "respawn" ingame) - respawn : Use this to respawn if you are dead (like clicking "respawn" ingame)
- log <text> : display some text in the console (useful for scripts) - log <text> : display some text in the console (useful for scripts)
- list [raw] : list players logged in to the server (raw = force show real names) - list : list players logged in to the server (uses tab list info sent by server)
- set varname=value : set a value which can be used as %varname% in further commands - set varname=value : set a value which can be used as %varname% in further commands
- wait <time> : wait X ticks (10 ticks = ~1 second. Only for scripts) - wait <time> : wait X ticks (10 ticks = ~1 second. Only for scripts)
- move : used for moving when terrain and movements feature is enabled - move : used for moving when terrain and movements feature is enabled