mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
fixed whitespace to fit with code style
This commit is contained in:
parent
b0988a8960
commit
7fa2e0d02e
4 changed files with 68 additions and 67 deletions
|
|
@ -5,16 +5,16 @@ using System.Text;
|
||||||
|
|
||||||
namespace MinecraftClient.Commands
|
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: 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)
|
||||||
{
|
{
|
||||||
handler.ListPlayers();
|
handler.ListPlayers();
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ namespace MinecraftClient
|
||||||
private string uuid;
|
private string uuid;
|
||||||
private string sessionid;
|
private string sessionid;
|
||||||
|
|
||||||
public Dictionary<string, string> players;
|
public Dictionary<string, string> players;
|
||||||
|
|
||||||
public int getServerPort() { return port; }
|
public int getServerPort() { return port; }
|
||||||
public string getServerHost() { return host; }
|
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)
|
public McTcpClient(string username, string uuid, string sessionID, int protocolversion, string server_ip, ushort port)
|
||||||
{
|
{
|
||||||
StartClient(username, uuid, sessionID, server_ip, port, protocolversion, false, "");
|
StartClient(username, uuid, sessionID, server_ip, port, protocolversion, false, "");
|
||||||
players = new Dictionary<string, string>();
|
players = new Dictionary<string, string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -391,17 +391,18 @@ namespace MinecraftClient
|
||||||
else return handler.SendChatMessage(text);
|
else return handler.SendChatMessage(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Display a list of players
|
/// Display a list of players
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>True if the players can be listed</returns>
|
/// <returns>True if the players can be listed</returns>
|
||||||
public bool ListPlayers()
|
|
||||||
{
|
public bool ListPlayers()
|
||||||
ConsoleIO.WriteLine ("Player List");
|
{
|
||||||
foreach (string player in players.Values)
|
ConsoleIO.WriteLine ("Player List");
|
||||||
ConsoleIO.WriteLine (player);
|
foreach (string player in players.Values)
|
||||||
return true;
|
ConsoleIO.WriteLine (player);
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Allow to respawn after death
|
/// Allow to respawn after death
|
||||||
|
|
@ -409,17 +410,17 @@ namespace MinecraftClient
|
||||||
/// <returns>True if packet successfully sent</returns>
|
/// <returns>True if packet successfully sent</returns>
|
||||||
|
|
||||||
public bool SendRespawnPacket()
|
public bool SendRespawnPacket()
|
||||||
{
|
{
|
||||||
return handler.SendRespawnPacket ();
|
return handler.SendRespawnPacket ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayer(string uuid, string name) {
|
public void addPlayer(string uuid, string name) {
|
||||||
players[uuid] = name;
|
players[uuid] = name;
|
||||||
}
|
}
|
||||||
public void removePlayer(string uuid){
|
public void removePlayer(string uuid){
|
||||||
players.Remove (uuid);
|
players.Remove (uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashSet<string> getPlayers() { return new HashSet<string>(players.Values); }
|
public HashSet<string> getPlayers() { return new HashSet<string>(players.Values); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -141,28 +141,28 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
SendPacket(0x00, getVarInt(readNextVarInt(ref packetData)));
|
SendPacket(0x00, getVarInt(readNextVarInt(ref packetData)));
|
||||||
break;
|
break;
|
||||||
case 0x02:
|
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;
|
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:
|
case 0x3A:
|
||||||
int autocomplete_count = readNextVarInt(ref packetData);
|
int autocomplete_count = readNextVarInt(ref packetData);
|
||||||
string tab_list = "";
|
string tab_list = "";
|
||||||
|
|
@ -276,16 +276,16 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
else return "";
|
else return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Read a uuid from a cache of bytes and remove it from the cache
|
/// Read a uuid from a cache of bytes and remove it from the cache
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cache">Cache of bytes to read from</param>
|
/// <param name="cache">Cache of bytes to read from</param>
|
||||||
/// <returns>The uuid as a string</returns>
|
/// <returns>The uuid as a string</returns>
|
||||||
|
|
||||||
private string readNextUUID(ref byte[] cache)
|
private string readNextUUID(ref byte[] cache)
|
||||||
{
|
{
|
||||||
return BitConverter.ToString(readData (16, ref cache)).Replace ("-", string.Empty).ToLower();
|
return BitConverter.ToString(readData (16, ref cache)).Replace ("-", string.Empty).ToLower();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Read a byte array from a cache of bytes and remove it from the cache
|
/// Read a byte array from a cache of bytes and remove it from the cache
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,9 @@ namespace MinecraftClient.Protocol
|
||||||
string getUserUUID();
|
string getUserUUID();
|
||||||
string getSessionID();
|
string getSessionID();
|
||||||
|
|
||||||
void addPlayer(string uuid, string name);
|
void addPlayer(string uuid, string name);
|
||||||
void removePlayer(string uuid);
|
void removePlayer(string uuid);
|
||||||
HashSet<string> getPlayers();
|
HashSet<string> getPlayers();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when the protocol handler receives a chat message
|
/// This method is called when the protocol handler receives a chat message
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue