mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Store extended player info, list display names
- Add 1.10.1 and 1.10.2 in supported version list - Store both player name and player display names - List command will sort players by player name - List command will now display by display name - Ability to use /list raw to display by real name Suggestion by Johngreen123
This commit is contained in:
parent
a4cc36ce05
commit
9a98a9d46f
10 changed files with 156 additions and 85 deletions
|
|
@ -8,11 +8,18 @@ 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 override string CMDDesc { get { return "list [raw]: get the player list."; } }
|
||||
|
||||
public override string Run(McTcpClient handler, string command)
|
||||
{
|
||||
return "PlayerList: " + String.Join(", ", handler.GetOnlinePlayers());
|
||||
bool rawNames = getArg(command).ToLower() == "raw";
|
||||
return "PlayerList: "
|
||||
+ String.Join(", ",
|
||||
handler.GetOnlinePlayers()
|
||||
.OrderBy(player => player.Name)
|
||||
.Select(player => rawNames
|
||||
? player.Name
|
||||
: player.DisplayName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,31 +23,10 @@ namespace MinecraftClient
|
|||
|
||||
private static readonly List<string> cmd_names = new List<string>();
|
||||
private static readonly Dictionary<string, Command> cmds = new Dictionary<string, Command>();
|
||||
private readonly Dictionary<Guid, string> onlinePlayers = new Dictionary<Guid, string>();
|
||||
private readonly Dictionary<Guid, PlayerInfo> onlinePlayers = new Dictionary<Guid, PlayerInfo>();
|
||||
|
||||
private readonly List<ChatBot> bots = new List<ChatBot>();
|
||||
private static readonly List<ChatBots.Script> scripts_on_hold = new List<ChatBots.Script>();
|
||||
public void BotLoad(ChatBot b) {
|
||||
b.SetHandler(this);
|
||||
bots.Add(b);
|
||||
b.Initialize();
|
||||
if (this.handler != null)
|
||||
{
|
||||
b.AfterGameJoined();
|
||||
}
|
||||
Settings.SingleCommand = "";
|
||||
}
|
||||
public void BotUnLoad(ChatBot b) {
|
||||
bots.RemoveAll(item => object.ReferenceEquals(item, b));
|
||||
|
||||
// ToList is needed to avoid an InvalidOperationException from modfiying the list while it's being iterated upon.
|
||||
var botRegistrations = registeredBotPluginChannels.Where(entry => entry.Value.Contains(b)).ToList();
|
||||
foreach (var entry in botRegistrations)
|
||||
{
|
||||
UnregisterPluginChannel(entry.Key, b);
|
||||
}
|
||||
}
|
||||
public void BotClear() { bots.Clear(); }
|
||||
|
||||
private readonly Dictionary<string, List<ChatBot>> registeredBotPluginChannels = new Dictionary<string, List<ChatBot>>();
|
||||
private readonly List<string> registeredServerPluginChannels = new List<String>();
|
||||
|
|
@ -86,7 +65,6 @@ namespace MinecraftClient
|
|||
/// <param name="server_ip">The server IP</param>
|
||||
/// <param name="port">The server port to use</param>
|
||||
/// <param name="protocolversion">Minecraft protocol version to use</param>
|
||||
|
||||
public McTcpClient(string username, string uuid, string sessionID, int protocolversion, ForgeInfo forgeInfo, string server_ip, ushort port)
|
||||
{
|
||||
StartClient(username, uuid, sessionID, server_ip, port, protocolversion, forgeInfo, false, "");
|
||||
|
|
@ -102,7 +80,6 @@ namespace MinecraftClient
|
|||
/// <param name="port">The server port to use</param>
|
||||
/// <param name="protocolversion">Minecraft protocol version to use</param>
|
||||
/// <param name="command">The text or command to send.</param>
|
||||
|
||||
public McTcpClient(string username, string uuid, string sessionID, string server_ip, ushort port, int protocolversion, ForgeInfo forgeInfo, string command)
|
||||
{
|
||||
StartClient(username, uuid, sessionID, server_ip, port, protocolversion, forgeInfo, true, command);
|
||||
|
|
@ -119,7 +96,6 @@ namespace MinecraftClient
|
|||
/// <param name="uuid">The player's UUID for online-mode authentication</param>
|
||||
/// <param name="singlecommand">If set to true, the client will send a single command and then disconnect from the server</param>
|
||||
/// <param name="command">The text or command to send. Will only be sent if singlecommand is set to true.</param>
|
||||
|
||||
private void StartClient(string user, string uuid, string sessionID, string server_ip, ushort port, int protocolversion, ForgeInfo forgeInfo, bool singlecommand, string command)
|
||||
{
|
||||
bool retry = false;
|
||||
|
|
@ -209,7 +185,6 @@ namespace MinecraftClient
|
|||
/// <summary>
|
||||
/// Allows the user to send chat messages, commands, and to leave the server.
|
||||
/// </summary>
|
||||
|
||||
private void CommandPrompt()
|
||||
{
|
||||
try
|
||||
|
|
@ -267,7 +242,6 @@ namespace MinecraftClient
|
|||
/// <param name="interactive_mode">Set to true if command was sent by the user using the command prompt</param>
|
||||
/// <param name="response_msg">May contain a confirmation or error message after processing the command, or "" otherwise.</param>
|
||||
/// <returns>TRUE if the command was indeed an internal MCC command</returns>
|
||||
|
||||
public bool PerformInternalCommand(string command, ref string response_msg)
|
||||
{
|
||||
/* Load commands from the 'Commands' namespace */
|
||||
|
|
@ -330,7 +304,6 @@ namespace MinecraftClient
|
|||
/// <summary>
|
||||
/// Disconnect the client from the server
|
||||
/// </summary>
|
||||
|
||||
public void Disconnect()
|
||||
{
|
||||
foreach (ChatBot bot in bots)
|
||||
|
|
@ -352,10 +325,47 @@ namespace MinecraftClient
|
|||
client.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load a new bot
|
||||
/// </summary>
|
||||
public void BotLoad(ChatBot b)
|
||||
{
|
||||
b.SetHandler(this);
|
||||
bots.Add(b);
|
||||
b.Initialize();
|
||||
if (this.handler != null)
|
||||
{
|
||||
b.AfterGameJoined();
|
||||
}
|
||||
Settings.SingleCommand = "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unload a bot
|
||||
/// </summary>
|
||||
public void BotUnLoad(ChatBot b)
|
||||
{
|
||||
bots.RemoveAll(item => object.ReferenceEquals(item, b));
|
||||
|
||||
// ToList is needed to avoid an InvalidOperationException from modfiying the list while it's being iterated upon.
|
||||
var botRegistrations = registeredBotPluginChannels.Where(entry => entry.Value.Contains(b)).ToList();
|
||||
foreach (var entry in botRegistrations)
|
||||
{
|
||||
UnregisterPluginChannel(entry.Key, b);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear bots
|
||||
/// </summary>
|
||||
public void BotClear()
|
||||
{
|
||||
bots.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a server was successfully joined
|
||||
/// </summary>
|
||||
|
||||
public void OnGameJoined()
|
||||
{
|
||||
if (!String.IsNullOrWhiteSpace(Settings.BrandInfo))
|
||||
|
|
@ -370,7 +380,6 @@ namespace MinecraftClient
|
|||
/// </summary>
|
||||
/// <param name="location">The new location</param>
|
||||
/// <param name="relative">If true, the location is relative to the current location</param>
|
||||
|
||||
public void UpdateLocation(Location location, bool relative)
|
||||
{
|
||||
lock (locationLock)
|
||||
|
|
@ -390,7 +399,6 @@ namespace MinecraftClient
|
|||
/// </summary>
|
||||
/// <param name="location">The new location</param>
|
||||
/// <param name="relative">If true, the location is relative to the current location</param>
|
||||
|
||||
public void UpdateLocation(Location location)
|
||||
{
|
||||
UpdateLocation(location, false);
|
||||
|
|
@ -417,7 +425,6 @@ namespace MinecraftClient
|
|||
/// Received some text from the server
|
||||
/// </summary>
|
||||
/// <param name="text">Text received</param>
|
||||
|
||||
public void OnTextReceived(string text)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(text, false);
|
||||
|
|
@ -441,7 +448,6 @@ namespace MinecraftClient
|
|||
/// <summary>
|
||||
/// When connection has been lost
|
||||
/// </summary>
|
||||
|
||||
public void OnConnectionLost(ChatBot.DisconnectReason reason, string message)
|
||||
{
|
||||
bool will_restart = false;
|
||||
|
|
@ -474,7 +480,6 @@ namespace MinecraftClient
|
|||
/// <summary>
|
||||
/// Called ~10 times per second by the protocol handler
|
||||
/// </summary>
|
||||
|
||||
public void OnUpdate()
|
||||
{
|
||||
foreach (var bot in bots.ToArray())
|
||||
|
|
@ -516,7 +521,6 @@ namespace MinecraftClient
|
|||
/// </summary>
|
||||
/// <param name="text">Text to send to the server</param>
|
||||
/// <returns>True if the text was sent with no error</returns>
|
||||
|
||||
public bool SendText(string text)
|
||||
{
|
||||
if (text.Length > 100) //Message is too long?
|
||||
|
|
@ -547,7 +551,6 @@ namespace MinecraftClient
|
|||
/// Allow to respawn after death
|
||||
/// </summary>
|
||||
/// <returns>True if packet successfully sent</returns>
|
||||
|
||||
public bool SendRespawnPacket()
|
||||
{
|
||||
return handler.SendRespawnPacket();
|
||||
|
|
@ -557,17 +560,16 @@ namespace MinecraftClient
|
|||
/// Triggered when a new player joins the game
|
||||
/// </summary>
|
||||
/// <param name="uuid">UUID of the player</param>
|
||||
/// <param name="name">Name of the player</param>
|
||||
|
||||
public void OnPlayerJoin(Guid uuid, string name)
|
||||
/// <param name="info">Info about this player</param>
|
||||
public void OnPlayerJoin(PlayerInfo info)
|
||||
{
|
||||
//Ignore TabListPlus placeholders
|
||||
if (name.StartsWith("0000tab#"))
|
||||
if (info.Name.StartsWith("0000tab#"))
|
||||
return;
|
||||
|
||||
lock (onlinePlayers)
|
||||
{
|
||||
onlinePlayers[uuid] = name;
|
||||
onlinePlayers[info.UUID] = info;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -575,7 +577,6 @@ namespace MinecraftClient
|
|||
/// Triggered when a player has left the game
|
||||
/// </summary>
|
||||
/// <param name="uuid">UUID of the player</param>
|
||||
|
||||
public void OnPlayerLeave(Guid uuid)
|
||||
{
|
||||
lock (onlinePlayers)
|
||||
|
|
@ -588,8 +589,7 @@ namespace MinecraftClient
|
|||
/// Get a set of online player names
|
||||
/// </summary>
|
||||
/// <returns>Online player names</returns>
|
||||
|
||||
public string[] GetOnlinePlayers()
|
||||
public PlayerInfo[] GetOnlinePlayers()
|
||||
{
|
||||
lock (onlinePlayers)
|
||||
{
|
||||
|
|
@ -602,7 +602,6 @@ namespace MinecraftClient
|
|||
/// </summary>
|
||||
/// <param name="channel">The channel to register.</param>
|
||||
/// <param name="bot">The bot to register the channel for.</param>
|
||||
|
||||
public void RegisterPluginChannel(string channel, ChatBot bot)
|
||||
{
|
||||
if (registeredBotPluginChannels.ContainsKey(channel))
|
||||
|
|
@ -623,7 +622,6 @@ namespace MinecraftClient
|
|||
/// </summary>
|
||||
/// <param name="channel">The channel to unregister.</param>
|
||||
/// <param name="bot">The bot to unregister the channel for.</param>
|
||||
|
||||
public void UnregisterPluginChannel(string channel, ChatBot bot)
|
||||
{
|
||||
if (registeredBotPluginChannels.ContainsKey(channel))
|
||||
|
|
@ -646,7 +644,6 @@ namespace MinecraftClient
|
|||
/// <param name="data">The payload for the packet.</param>
|
||||
/// <param name="sendEvenIfNotRegistered">Whether the packet should be sent even if the server or the client hasn't registered it yet.</param>
|
||||
/// <returns>Whether the packet was sent: true if it was sent, false if there was a connection error or it wasn't registered.</returns>
|
||||
|
||||
public bool SendPluginChannelMessage(string channel, byte[] data, bool sendEvenIfNotRegistered = false)
|
||||
{
|
||||
if (!sendEvenIfNotRegistered)
|
||||
|
|
@ -668,7 +665,6 @@ namespace MinecraftClient
|
|||
/// </summary>
|
||||
/// <param name="channel">The channel the message was sent on</param>
|
||||
/// <param name="data">The data from the channel</param>
|
||||
|
||||
public void OnPluginChannelMessage(string channel, byte[] data)
|
||||
{
|
||||
if (channel == "REGISTER")
|
||||
|
|
|
|||
|
|
@ -148,6 +148,7 @@
|
|||
<Compile Include="Protocol\Handlers\Protocol16.cs" />
|
||||
<Compile Include="Protocol\IMinecraftCom.cs" />
|
||||
<Compile Include="Protocol\IMinecraftComHandler.cs" />
|
||||
<Compile Include="Protocol\PlayerInfo.cs" />
|
||||
<Compile Include="Protocol\ProtocolHandler.cs" />
|
||||
<Compile Include="Protocol\SessionCache\CacheType.cs" />
|
||||
<Compile Include="Protocol\SessionCache\SessionCache.cs" />
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ namespace MinecraftClient
|
|||
/// Allows to connect to any Minecraft server, send and receive text, automated scripts.
|
||||
/// This source code is released under the CDDL 1.0 License.
|
||||
/// </summary>
|
||||
|
||||
static class Program
|
||||
{
|
||||
private static McTcpClient Client;
|
||||
|
|
@ -23,7 +22,7 @@ namespace MinecraftClient
|
|||
|
||||
public const string Version = "1.10.0 DEV";
|
||||
public const string MCLowestVersion = "1.4.6";
|
||||
public const string MCHighestVersion = "1.10.0";
|
||||
public const string MCHighestVersion = "1.10.2";
|
||||
|
||||
private static Thread offlinePrompt = null;
|
||||
private static bool useMcVersionOnce = false;
|
||||
|
|
@ -31,7 +30,6 @@ namespace MinecraftClient
|
|||
/// <summary>
|
||||
/// The main entry point of Minecraft Console Client
|
||||
/// </summary>
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Console Client for MC {0} to {1} - v{2} - By ORelio & Contributors", MCLowestVersion, MCHighestVersion, Version);
|
||||
|
|
@ -129,7 +127,6 @@ namespace MinecraftClient
|
|||
/// <summary>
|
||||
/// Start a new Client
|
||||
/// </summary>
|
||||
|
||||
private static void InitializeClient()
|
||||
{
|
||||
SessionToken session = new SessionToken();
|
||||
|
|
@ -271,7 +268,6 @@ namespace MinecraftClient
|
|||
/// <summary>
|
||||
/// Disconnect the current client from the server and restart it
|
||||
/// </summary>
|
||||
|
||||
public static void Restart()
|
||||
{
|
||||
new Thread(new ThreadStart(delegate
|
||||
|
|
@ -286,7 +282,6 @@ namespace MinecraftClient
|
|||
/// <summary>
|
||||
/// Disconnect the current client from the server and exit the app
|
||||
/// </summary>
|
||||
|
||||
public static void Exit()
|
||||
{
|
||||
new Thread(new ThreadStart(delegate
|
||||
|
|
@ -305,7 +300,6 @@ namespace MinecraftClient
|
|||
/// <param name="errorMessage">Error message to display and optionally pass to AutoRelog bot</param>
|
||||
/// <param name="versionError">Specify if the error is related to an incompatible or unkown server version</param>
|
||||
/// <param name="disconnectReason">If set, the error message will be processed by the AutoRelog bot</param>
|
||||
|
||||
public static void HandleFailure(string errorMessage = null, bool versionError = false, ChatBots.AutoRelog.DisconnectReason? disconnectReason = null)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(errorMessage))
|
||||
|
|
@ -387,7 +381,6 @@ namespace MinecraftClient
|
|||
/// <summary>
|
||||
/// Detect if the user is running Minecraft Console Client through Mono
|
||||
/// </summary>
|
||||
|
||||
public static bool isUsingMono
|
||||
{
|
||||
get
|
||||
|
|
@ -402,7 +395,6 @@ namespace MinecraftClient
|
|||
/// <param name="nameSpace">Namespace to process</param>
|
||||
/// <param name="assembly">Assembly to use. Default is Assembly.GetExecutingAssembly()</param>
|
||||
/// <returns></returns>
|
||||
|
||||
public static Type[] GetTypesInNamespace(string nameSpace, Assembly assembly = null)
|
||||
{
|
||||
if (assembly == null) { assembly = Assembly.GetExecutingAssembly(); }
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
case 0xC9:
|
||||
string name = readNextString(); bool online = readNextByte() != 0x00; readData(2);
|
||||
Guid FakeUUID = new Guid(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(name)).Take(16).ToArray());
|
||||
if (online) { handler.OnPlayerJoin(FakeUUID, name); } else { handler.OnPlayerLeave(FakeUUID); }
|
||||
if (online) { handler.OnPlayerJoin(new PlayerInfo(FakeUUID, name)); } else { handler.OnPlayerLeave(FakeUUID); }
|
||||
break;
|
||||
case 0xCA: if (protocolversion >= 72) { readData(9); } else readData(3); break;
|
||||
case 0xCB: autocomplete_result = readNextString(); autocomplete_received = true; break;
|
||||
|
|
|
|||
|
|
@ -437,9 +437,10 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
}
|
||||
readNextVarInt(packetData);
|
||||
readNextVarInt(packetData);
|
||||
string displayName = name;
|
||||
if (readNextBool(packetData))
|
||||
readNextString(packetData);
|
||||
handler.OnPlayerJoin(uuid, name);
|
||||
displayName = readNextString(packetData);
|
||||
handler.OnPlayerJoin(new PlayerInfo(uuid, name, displayName));
|
||||
break;
|
||||
case 0x01: //Update gamemode
|
||||
case 0x02: //Update latency
|
||||
|
|
@ -465,7 +466,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
short ping = readNextShort(packetData);
|
||||
Guid FakeUUID = new Guid(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(name)).Take(16).ToArray());
|
||||
if (online)
|
||||
handler.OnPlayerJoin(FakeUUID, name);
|
||||
handler.OnPlayerJoin(new PlayerInfo(FakeUUID, name));
|
||||
else handler.OnPlayerLeave(FakeUUID);
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -22,55 +22,48 @@ namespace MinecraftClient.Protocol
|
|||
string GetUsername();
|
||||
string GetUserUUID();
|
||||
string GetSessionID();
|
||||
string[] GetOnlinePlayers();
|
||||
PlayerInfo[] GetOnlinePlayers();
|
||||
Location GetCurrentLocation();
|
||||
World GetWorld();
|
||||
|
||||
/// <summary>
|
||||
/// Called when a server was successfully joined
|
||||
/// </summary>
|
||||
|
||||
void OnGameJoined();
|
||||
|
||||
/// <summary>
|
||||
/// This method is called when the protocol handler receives a chat message
|
||||
/// </summary>
|
||||
|
||||
void OnTextReceived(string text);
|
||||
|
||||
/// <summary>
|
||||
/// This method is called when a new player joins the game
|
||||
/// </summary>
|
||||
/// <param name="uuid">UUID of the player</param>
|
||||
/// <param name="name">Name of the player</param>
|
||||
|
||||
void OnPlayerJoin(Guid uuid, string name);
|
||||
/// <param name="info">Info about this player</param>
|
||||
void OnPlayerJoin(PlayerInfo info);
|
||||
|
||||
/// <summary>
|
||||
/// This method is called when a player has left the game
|
||||
/// </summary>
|
||||
/// <param name="uuid">UUID of the player</param>
|
||||
|
||||
void OnPlayerLeave(Guid uuid);
|
||||
|
||||
/// <summary>
|
||||
/// Called when the server sets the new location for the player
|
||||
/// </summary>
|
||||
/// <param name="location">New location of the player</param>
|
||||
|
||||
void UpdateLocation(Location location);
|
||||
|
||||
/// <summary>
|
||||
/// This method is called when the connection has been lost
|
||||
/// </summary>
|
||||
|
||||
void OnConnectionLost(ChatBot.DisconnectReason reason, string message);
|
||||
|
||||
/// <summary>
|
||||
/// Called ~10 times per second (10 ticks per second)
|
||||
/// Useful for updating bots in other parts of the program
|
||||
/// </summary>
|
||||
|
||||
void OnUpdate();
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -78,7 +71,6 @@ namespace MinecraftClient.Protocol
|
|||
/// </summary>
|
||||
/// <param name="channel">The channel to register.</param>
|
||||
/// <param name="bot">The bot to register the channel for.</param>
|
||||
|
||||
void RegisterPluginChannel(string channel, ChatBot bot);
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -86,7 +78,6 @@ namespace MinecraftClient.Protocol
|
|||
/// </summary>
|
||||
/// <param name="channel">The channel to unregister.</param>
|
||||
/// <param name="bot">The bot to unregister the channel for.</param>
|
||||
|
||||
void UnregisterPluginChannel(string channel, ChatBot bot);
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -97,7 +88,6 @@ namespace MinecraftClient.Protocol
|
|||
/// <param name="data">The payload for the packet.</param>
|
||||
/// <param name="sendEvenIfNotRegistered">Whether the packet should be sent even if the server or the client hasn't registered it yet.</param>
|
||||
/// <returns>Whether the packet was sent: true if it was sent, false if there was a connection error or it wasn't registered.</returns>
|
||||
|
||||
bool SendPluginChannelMessage(string channel, byte[] data, bool sendEvenIfNotRegistered = false);
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -105,7 +95,6 @@ namespace MinecraftClient.Protocol
|
|||
/// </summary>
|
||||
/// <param name="channel">The channel the message was sent on</param>
|
||||
/// <param name="data">The data from the channel</param>
|
||||
|
||||
void OnPluginChannelMessage(string channel, byte[] data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
86
MinecraftClient/Protocol/PlayerInfo.cs
Normal file
86
MinecraftClient/Protocol/PlayerInfo.cs
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
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 struct PlayerInfo : IComparable<PlayerInfo>
|
||||
{
|
||||
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; } }
|
||||
|
||||
/// <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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -96,6 +96,7 @@ namespace MinecraftClient.Protocol
|
|||
return 60;
|
||||
case "1.5.2":
|
||||
return 61;
|
||||
case "1.6":
|
||||
case "1.6.0":
|
||||
return 72;
|
||||
case "1.6.1":
|
||||
|
|
@ -114,6 +115,7 @@ namespace MinecraftClient.Protocol
|
|||
case "1.7.9":
|
||||
case "1.7.10":
|
||||
return 5;
|
||||
case "1.8":
|
||||
case "1.8.0":
|
||||
case "1.8.1":
|
||||
case "1.8.2":
|
||||
|
|
@ -125,6 +127,7 @@ namespace MinecraftClient.Protocol
|
|||
case "1.8.8":
|
||||
case "1.8.9":
|
||||
return 47;
|
||||
case "1.9":
|
||||
case "1.9.0":
|
||||
return 107;
|
||||
case "1.9.1":
|
||||
|
|
@ -134,7 +137,10 @@ namespace MinecraftClient.Protocol
|
|||
case "1.9.3":
|
||||
case "1.9.4":
|
||||
return 110;
|
||||
case "1.10":
|
||||
case "1.10.0":
|
||||
case "1.10.1":
|
||||
case "1.10.2":
|
||||
return 210;
|
||||
default:
|
||||
return 0;
|
||||
|
|
@ -234,7 +240,6 @@ namespace MinecraftClient.Protocol
|
|||
/// <param name="accesstoken">Will contain the cached access token previously returned by Minecraft.net</param>
|
||||
/// <param name="clienttoken">Will contain the cached client token created on login</param>
|
||||
/// <returns>Returns the status of the token (Valid, Invalid, etc.)</returns>
|
||||
///
|
||||
public static LoginResult GetTokenValidation(SessionToken session)
|
||||
{
|
||||
try
|
||||
|
|
@ -269,7 +274,6 @@ namespace MinecraftClient.Protocol
|
|||
/// <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>
|
||||
/// <returns>Returns the status of the new token request (Success, Failure, etc.)</returns>
|
||||
///
|
||||
public static LoginResult GetNewToken(SessionToken currentsession, out SessionToken newsession)
|
||||
{
|
||||
newsession = new SessionToken();
|
||||
|
|
@ -319,7 +323,6 @@ namespace MinecraftClient.Protocol
|
|||
/// <param name="accesstoken">Session ID</param>
|
||||
/// <param name="serverhash">Server ID</param>
|
||||
/// <returns>TRUE if session was successfully checked</returns>
|
||||
|
||||
public static bool SessionCheck(string uuid, string accesstoken, string serverhash)
|
||||
{
|
||||
try
|
||||
|
|
@ -348,7 +351,6 @@ namespace MinecraftClient.Protocol
|
|||
/// <param name="cookies">Cookies for making the request</param>
|
||||
/// <param name="result">Request result</param>
|
||||
/// <returns>HTTP Status code</returns>
|
||||
|
||||
private static int doHTTPSGet(string host, string endpoint, string cookies, ref string result)
|
||||
{
|
||||
List<String> http_request = new List<string>();
|
||||
|
|
@ -372,7 +374,6 @@ namespace MinecraftClient.Protocol
|
|||
/// <param name="request">Request payload</param>
|
||||
/// <param name="result">Request result</param>
|
||||
/// <returns>HTTP Status code</returns>
|
||||
|
||||
private static int doHTTPSPost(string host, string endpoint, string request, ref string result)
|
||||
{
|
||||
List<String> http_request = new List<string>();
|
||||
|
|
@ -395,7 +396,6 @@ namespace MinecraftClient.Protocol
|
|||
/// <param name="host">Host to connect to</param>
|
||||
/// <param name="result">Request result</param>
|
||||
/// <returns>HTTP Status code</returns>
|
||||
|
||||
private static int doHTTPSRequest(List<string> headers, string host, ref string result)
|
||||
{
|
||||
string postResult = null;
|
||||
|
|
@ -425,7 +425,6 @@ namespace MinecraftClient.Protocol
|
|||
/// </summary>
|
||||
/// <param name="text">Source text</param>
|
||||
/// <returns>Encoded text</returns>
|
||||
|
||||
private static string jsonEncode(string text)
|
||||
{
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
- respawn : Use this to respawn if you are dead (like clicking "respawn" ingame)
|
||||
- log <text> : display some text in the console (useful for scripts)
|
||||
- list : list players logged in to the server (uses tab list info sent by server)
|
||||
- list [raw] : list players logged in to the server (raw = force show real names)
|
||||
- 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)
|
||||
- move : used for moving when terrain and movements feature is enabled
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue