diff --git a/MinecraftClient/Commands/List.cs b/MinecraftClient/Commands/List.cs index b6791f9c..b1a653d6 100644 --- a/MinecraftClient/Commands/List.cs +++ b/MinecraftClient/Commands/List.cs @@ -5,16 +5,16 @@ using System.Text; namespace MinecraftClient.Commands { - public class List : Command - { - public override string CMDName { get { return "list"; } } - public override string CMDDesc { get { return "list: get the player list."; } } + public class List : Command + { + public override string CMDName { get { return "list"; } } + public override string CMDDesc { get { return "list: get the player list."; } } - public override string Run(McTcpClient handler, string command) - { - handler.ListPlayers(); - return ""; - } - } + public override string Run(McTcpClient handler, string command) + { + handler.ListPlayers(); + return ""; + } + } } diff --git a/MinecraftClient/McTcpClient.cs b/MinecraftClient/McTcpClient.cs index 8a72a7de..47954ad5 100644 --- a/MinecraftClient/McTcpClient.cs +++ b/MinecraftClient/McTcpClient.cs @@ -33,7 +33,7 @@ namespace MinecraftClient private string uuid; private string sessionid; - public Dictionary players; + public Dictionary players; public int getServerPort() { return port; } public string getServerHost() { return host; } @@ -58,7 +58,7 @@ namespace MinecraftClient public McTcpClient(string username, string uuid, string sessionID, int protocolversion, string server_ip, ushort port) { StartClient(username, uuid, sessionID, server_ip, port, protocolversion, false, ""); - players = new Dictionary(); + players = new Dictionary(); } /// @@ -391,17 +391,18 @@ namespace MinecraftClient else return handler.SendChatMessage(text); } - /// - /// Display a list of players - /// - /// True if the players can be listed - public bool ListPlayers() - { - ConsoleIO.WriteLine ("Player List"); - foreach (string player in players.Values) - ConsoleIO.WriteLine (player); - return true; - } + /// + /// Display a list of players + /// + /// True if the players can be listed + + public bool ListPlayers() + { + ConsoleIO.WriteLine ("Player List"); + foreach (string player in players.Values) + ConsoleIO.WriteLine (player); + return true; + } /// /// Allow to respawn after death @@ -409,17 +410,17 @@ namespace MinecraftClient /// True if packet successfully sent public bool SendRespawnPacket() - { - return handler.SendRespawnPacket (); - } + { + return handler.SendRespawnPacket (); + } - public void addPlayer(string uuid, string name) { - players[uuid] = name; - } - public void removePlayer(string uuid){ - players.Remove (uuid); - } + public void addPlayer(string uuid, string name) { + players[uuid] = name; + } + public void removePlayer(string uuid){ + players.Remove (uuid); + } - public HashSet getPlayers() { return new HashSet(players.Values); } - } + public HashSet getPlayers() { return new HashSet(players.Values); } + } } diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index ce65540e..edac89b1 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -141,28 +141,28 @@ namespace MinecraftClient.Protocol.Handlers SendPacket(0x00, getVarInt(readNextVarInt(ref packetData))); break; case 0x02: - handler.OnTextReceived(ChatParser.ParseText(readNextString(ref packetData))); + handler.OnTextReceived(ChatParser.ParseText(readNextString(ref packetData))); + break; + case 0x0C: //Entity Look and Relative Move + //ConsoleIO.WriteLineFormatted("§8 0x0C entity:" + readNextVarInt(ref packetData) + " has come in to sight"); + break; + case 0x38: // update player list + int action = readNextVarInt (ref packetData); + int numActions = readNextVarInt (ref packetData); + string uuid = readNextUUID (ref packetData); + switch (action) { + case 0x00: + string name = readNextString (ref packetData); + handler.addPlayer (uuid, name); + break; + case 0x04: + handler.removePlayer (uuid); + break; + default: + //do nothing + break; + } break; - case 0x0C: //Entity Look and Relative Move - //ConsoleIO.WriteLineFormatted("§8 0x0C entity:" + readNextVarInt(ref packetData) + " has come in to sight"); - break; - case 0x38: // update player list - int action = readNextVarInt (ref packetData); - int numActions = readNextVarInt (ref packetData); - string uuid = readNextUUID (ref packetData); - switch (action) { - case 0x00: - string name = readNextString (ref packetData); - handler.addPlayer (uuid, name); - break; - case 0x04: - handler.removePlayer (uuid); - break; - default: - //do nothing - break; - } - break; case 0x3A: int autocomplete_count = readNextVarInt(ref packetData); string tab_list = ""; @@ -276,16 +276,16 @@ namespace MinecraftClient.Protocol.Handlers else return ""; } - /// - /// Read a uuid from a cache of bytes and remove it from the cache - /// - /// Cache of bytes to read from - /// The uuid as a string + /// + /// Read a uuid from a cache of bytes and remove it from the cache + /// + /// Cache of bytes to read from + /// The uuid as a string - private string readNextUUID(ref byte[] cache) - { - return BitConverter.ToString(readData (16, ref cache)).Replace ("-", string.Empty).ToLower(); - } + private string readNextUUID(ref byte[] cache) + { + return BitConverter.ToString(readData (16, ref cache)).Replace ("-", string.Empty).ToLower(); + } /// /// Read a byte array from a cache of bytes and remove it from the cache diff --git a/MinecraftClient/Protocol/IMinecraftComHandler.cs b/MinecraftClient/Protocol/IMinecraftComHandler.cs index 1fddceeb..79b4fe39 100644 --- a/MinecraftClient/Protocol/IMinecraftComHandler.cs +++ b/MinecraftClient/Protocol/IMinecraftComHandler.cs @@ -22,9 +22,9 @@ namespace MinecraftClient.Protocol string getUserUUID(); string getSessionID(); - void addPlayer(string uuid, string name); - void removePlayer(string uuid); - HashSet getPlayers(); + void addPlayer(string uuid, string name); + void removePlayer(string uuid); + HashSet getPlayers(); /// /// This method is called when the protocol handler receives a chat message