Rename McTcpClient to McClient for clarity

+ Fix compile error in #1071
This commit is contained in:
ORelio 2020-06-20 15:01:16 +02:00
parent b52435f0ce
commit 2add4030f4
25 changed files with 36 additions and 36 deletions

View file

@ -32,15 +32,15 @@ namespace MinecraftClient
public enum DisconnectReason { InGameKick, LoginRejected, ConnectionLost, UserLogout }; public enum DisconnectReason { InGameKick, LoginRejected, ConnectionLost, UserLogout };
//Handler will be automatically set on bot loading, don't worry about this //Handler will be automatically set on bot loading, don't worry about this
public void SetHandler(McTcpClient handler) { this._handler = handler; } public void SetHandler(McClient handler) { this._handler = handler; }
protected void SetMaster(ChatBot master) { this.master = master; } protected void SetMaster(ChatBot master) { this.master = master; }
protected void LoadBot(ChatBot bot) { Handler.BotUnLoad(bot); Handler.BotLoad(bot); } protected void LoadBot(ChatBot bot) { Handler.BotUnLoad(bot); Handler.BotLoad(bot); }
private McTcpClient _handler = null; private McClient _handler = null;
private ChatBot master = null; private ChatBot master = null;
private List<string> registeredPluginChannels = new List<String>(); private List<string> registeredPluginChannels = new List<String>();
private Queue<string> chatQueue = new Queue<string>(); private Queue<string> chatQueue = new Queue<string>();
private DateTime lastMessageSentTime = DateTime.MinValue; private DateTime lastMessageSentTime = DateTime.MinValue;
private McTcpClient Handler private McClient Handler
{ {
get get
{ {
@ -657,7 +657,7 @@ namespace MinecraftClient
{ {
if (Settings.DebugMessages) if (Settings.DebugMessages)
ConsoleIO.WriteLogLine(String.Format("[{0}] Disconnecting and Reconnecting to the Server", this.GetType().Name)); ConsoleIO.WriteLogLine(String.Format("[{0}] Disconnecting and Reconnecting to the Server", this.GetType().Name));
McTcpClient.ReconnectionAttemptsLeft = ExtraAttempts; McClient.ReconnectionAttemptsLeft = ExtraAttempts;
Program.Restart(delaySeconds); Program.Restart(delaySeconds);
} }

View file

@ -23,7 +23,7 @@ namespace MinecraftClient.ChatBots
{ {
attempts = retries; attempts = retries;
if (attempts == -1) { attempts = int.MaxValue; } if (attempts == -1) { attempts = int.MaxValue; }
McTcpClient.ReconnectionAttemptsLeft = attempts; McClient.ReconnectionAttemptsLeft = attempts;
delay = DelayBeforeRelog; delay = DelayBeforeRelog;
if (delay < 1) { delay = 1; } if (delay < 1) { delay = 1; }
if (Settings.DebugMessages) if (Settings.DebugMessages)
@ -32,7 +32,7 @@ namespace MinecraftClient.ChatBots
public override void Initialize() public override void Initialize()
{ {
McTcpClient.ReconnectionAttemptsLeft = attempts; McClient.ReconnectionAttemptsLeft = attempts;
if (Settings.AutoRelog_IgnoreKickMessage) if (Settings.AutoRelog_IgnoreKickMessage)
{ {
if (Settings.DebugMessages) if (Settings.DebugMessages)
@ -96,7 +96,7 @@ namespace MinecraftClient.ChatBots
LogToConsole("Waiting " + delay + " seconds before reconnecting..."); LogToConsole("Waiting " + delay + " seconds before reconnecting...");
System.Threading.Thread.Sleep(delay * 1000); System.Threading.Thread.Sleep(delay * 1000);
McTcpClient.ReconnectionAttemptsLeft = attempts; McClient.ReconnectionAttemptsLeft = attempts;
ReconnectToTheServer(); ReconnectToTheServer();
return true; return true;
} }

View file

@ -29,7 +29,7 @@ namespace MinecraftClient
/// <param name="command">The full command, eg: 'mycommand arg1 arg2'</param> /// <param name="command">The full command, eg: 'mycommand arg1 arg2'</param>
/// <param name="localVars">Local variables passed along with the command (may be null)</param> /// <param name="localVars">Local variables passed along with the command (may be null)</param>
/// <returns>A confirmation/error message, or "" if no message</returns> /// <returns>A confirmation/error message, or "" if no message</returns>
public abstract string Run(McTcpClient handler, string command, Dictionary<string, object> localVars); public abstract string Run(McClient handler, string command, Dictionary<string, object> localVars);
/// <summary> /// <summary>
/// Return a list of aliases for this command. /// Return a list of aliases for this command.

View file

@ -10,7 +10,7 @@ namespace MinecraftClient.Commands
public override string CMDName { get { return "animation"; } } public override string CMDName { get { return "animation"; } }
public override string CMDDesc { get { return "animation <mainhand|offhand>"; } } public override string CMDDesc { get { return "animation <mainhand|offhand>"; } }
public override string Run(McTcpClient handler, string command, Dictionary<string, object> localVars) public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
{ {
if (hasArg(command)) if (hasArg(command))
{ {

View file

@ -10,7 +10,7 @@ namespace MinecraftClient.Commands
public override string CMDName { get { return "changeslot"; } } public override string CMDName { get { return "changeslot"; } }
public override string CMDDesc { get { return "changeslot <1-9>: Change hotbar"; } } public override string CMDDesc { get { return "changeslot <1-9>: Change hotbar"; } }
public override string Run(McTcpClient handler, string command, Dictionary<string, object> localVars) public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
{ {
if (!handler.GetInventoryEnabled()) return "Please enable InventoryHandling in the config file first."; if (!handler.GetInventoryEnabled()) return "Please enable InventoryHandling in the config file first.";
if (hasArg(command)) if (hasArg(command))

View file

@ -10,7 +10,7 @@ namespace MinecraftClient.Commands
public override string CMDName { get { return "connect"; } } public override string CMDName { get { return "connect"; } }
public override string CMDDesc { get { return "connect <server> [account]: connect to the specified server."; } } public override string CMDDesc { get { return "connect <server> [account]: connect to the specified server."; } }
public override string Run(McTcpClient handler, string command, Dictionary<string, object> localVars) public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
{ {
if (hasArg(command)) if (hasArg(command))
{ {

View file

@ -10,7 +10,7 @@ namespace MinecraftClient.Commands
public override string CMDName { get { return "debug"; } } public override string CMDName { get { return "debug"; } }
public override string CMDDesc { get { return "debug [on|off]: toggle debug messages."; } } public override string CMDDesc { get { return "debug [on|off]: toggle debug messages."; } }
public override string Run(McTcpClient handler, string command, Dictionary<string, object> localVars) public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
{ {
if (hasArg(command)) if (hasArg(command))
{ {

View file

@ -10,7 +10,7 @@ namespace MinecraftClient.Commands
public override string CMDName { get { return "exit"; } } public override string CMDName { get { return "exit"; } }
public override string CMDDesc { get { return "exit: disconnect from the server."; } } public override string CMDDesc { get { return "exit: disconnect from the server."; } }
public override string Run(McTcpClient handler, string command, Dictionary<string, object> localVars) public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
{ {
Program.Exit(); Program.Exit();
return ""; return "";

View file

@ -10,7 +10,7 @@ namespace MinecraftClient.Commands
public override string CMDName { get { return "health"; } } public override string CMDName { get { return "health"; } }
public override string CMDDesc { get { return "health: Display Health and Food saturation."; } } public override string CMDDesc { get { return "health: Display Health and Food saturation."; } }
public override string Run(McTcpClient handler, string command, Dictionary<string, object> localVars) public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
{ {
return "Health: " + handler.GetHealth() + ", Saturation: " + handler.GetSaturation() + ", Level: " + handler.GetLevel() + ", TotalExperience: " + handler.GetTotalExperience(); return "Health: " + handler.GetHealth() + ", Saturation: " + handler.GetSaturation() + ", Level: " + handler.GetLevel() + ", TotalExperience: " + handler.GetTotalExperience();
} }

View file

@ -11,7 +11,7 @@ namespace MinecraftClient.Commands
public override string CMDName { get { return "inventory"; } } public override string CMDName { get { return "inventory"; } }
public override string CMDDesc { get { return "inventory <<id>|player|container> <list|close|drop <slot> <1|all>|click <slot> <left|right|middle>> | inventory creativegive <slot> <itemtype> <count>: Interact with inventories"; } } public override string CMDDesc { get { return "inventory <<id>|player|container> <list|close|drop <slot> <1|all>|click <slot> <left|right|middle>> | inventory creativegive <slot> <itemtype> <count>: Interact with inventories"; } }
public override string Run(McTcpClient handler, string command, Dictionary<string, object> localVars) public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
{ {
if (handler.GetInventoryEnabled()) if (handler.GetInventoryEnabled())
{ {

View file

@ -10,7 +10,7 @@ namespace MinecraftClient.Commands
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, Dictionary<string, object> localVars) public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
{ {
return "PlayerList: " + String.Join(", ", handler.GetOnlinePlayers()); return "PlayerList: " + String.Join(", ", handler.GetOnlinePlayers());
} }

View file

@ -10,7 +10,7 @@ namespace MinecraftClient.Commands
public override string CMDName { get { return "log"; } } public override string CMDName { get { return "log"; } }
public override string CMDDesc { get { return "log <text>: log some text to the console."; } } public override string CMDDesc { get { return "log <text>: log some text to the console."; } }
public override string Run(McTcpClient handler, string command, Dictionary<string, object> localVars) public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
{ {
if (hasArg(command)) if (hasArg(command))
{ {

View file

@ -11,7 +11,7 @@ namespace MinecraftClient.Commands
public override string CMDName { get { return "look"; } } public override string CMDName { get { return "look"; } }
public override string CMDDesc { get { return "look <x y z|yaw pitch|up|down|east|west|north|south>: look at direction or coordinates."; } } public override string CMDDesc { get { return "look <x y z|yaw pitch|up|down|east|west|north|south>: look at direction or coordinates."; } }
public override string Run(McTcpClient handler, string command, Dictionary<string, object> localVars) public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
{ {
if (handler.GetTerrainEnabled()) if (handler.GetTerrainEnabled())
{ {

View file

@ -11,7 +11,7 @@ namespace MinecraftClient.Commands
public override string CMDName { get { return "move"; } } public override string CMDName { get { return "move"; } }
public override string CMDDesc { get { return "move <on|off|get|up|down|east|west|north|south|x y z>: walk or start walking."; } } public override string CMDDesc { get { return "move <on|off|get|up|down|east|west|north|south|x y z>: walk or start walking."; } }
public override string Run(McTcpClient handler, string command, Dictionary<string, object> localVars) public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
{ {
string[] args = getArgs(command); string[] args = getArgs(command);
string argStr = getArg(command).Trim().ToLower(); string argStr = getArg(command).Trim().ToLower();

View file

@ -10,7 +10,7 @@ namespace MinecraftClient.Commands
public override string CMDName { get { return "reco"; } } public override string CMDName { get { return "reco"; } }
public override string CMDDesc { get { return "reco [account]: restart and reconnect to the server."; } } public override string CMDDesc { get { return "reco [account]: restart and reconnect to the server."; } }
public override string Run(McTcpClient handler, string command, Dictionary<string, object> localVars) public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
{ {
string[] args = getArgs(command); string[] args = getArgs(command);
if (args.Length > 0) if (args.Length > 0)

View file

@ -10,7 +10,7 @@ namespace MinecraftClient.Commands
public override string CMDName { get { return "respawn"; } } public override string CMDName { get { return "respawn"; } }
public override string CMDDesc { get { return "respawn: Use this to respawn if you are dead."; } } public override string CMDDesc { get { return "respawn: Use this to respawn if you are dead."; } }
public override string Run(McTcpClient handler, string command, Dictionary<string, object> localVars) public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
{ {
handler.SendRespawnPacket(); handler.SendRespawnPacket();
return "You have respawned."; return "You have respawned.";

View file

@ -10,7 +10,7 @@ namespace MinecraftClient.Commands
public override string CMDName { get { return "script"; } } public override string CMDName { get { return "script"; } }
public override string CMDDesc { get { return "script <scriptname>: run a script file."; } } public override string CMDDesc { get { return "script <scriptname>: run a script file."; } }
public override string Run(McTcpClient handler, string command, Dictionary<string, object> localVars) public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
{ {
if (hasArg(command)) if (hasArg(command))
{ {

View file

@ -10,7 +10,7 @@ namespace MinecraftClient.Commands
public override string CMDName { get { return "send"; } } public override string CMDName { get { return "send"; } }
public override string CMDDesc { get { return "send <text>: send a chat message or command."; } } public override string CMDDesc { get { return "send <text>: send a chat message or command."; } }
public override string Run(McTcpClient handler, string command, Dictionary<string, object> localVars) public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
{ {
if (hasArg(command)) if (hasArg(command))
{ {

View file

@ -10,7 +10,7 @@ namespace MinecraftClient.Commands
public override string CMDName { get { return "set"; } } public override string CMDName { get { return "set"; } }
public override string CMDDesc { get { return "set varname=value: set a custom %variable%."; } } public override string CMDDesc { get { return "set varname=value: set a custom %variable%."; } }
public override string Run(McTcpClient handler, string command, Dictionary<string, object> localVars) public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
{ {
if (hasArg(command)) if (hasArg(command))
{ {

View file

@ -11,7 +11,7 @@ namespace MinecraftClient.Commands
public override string CMDName { get { return "Sneak"; } } public override string CMDName { get { return "Sneak"; } }
public override string CMDDesc { get { return "Sneak: Toggles sneaking"; } } public override string CMDDesc { get { return "Sneak: Toggles sneaking"; } }
public override string Run(McTcpClient handler, string command, Dictionary<string, object> localVars) public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
{ {
if (sneaking) if (sneaking)
{ {

View file

@ -10,7 +10,7 @@ namespace MinecraftClient.Commands
public override string CMDName { get { return "useitem"; } } public override string CMDName { get { return "useitem"; } }
public override string CMDDesc { get { return "useitem: Use (left click) an item on the hand"; } } public override string CMDDesc { get { return "useitem: Use (left click) an item on the hand"; } }
public override string Run(McTcpClient handler, string command, Dictionary<string, object> localVars) public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
{ {
if (handler.GetInventoryEnabled()) if (handler.GetInventoryEnabled())
{ {

View file

@ -11,7 +11,7 @@ namespace MinecraftClient.Commands
public override string CMDName { get { return "useblock"; } } public override string CMDName { get { return "useblock"; } }
public override string CMDDesc { get { return "useblock <x> <y> <z>: use block"; } } public override string CMDDesc { get { return "useblock <x> <y> <z>: use block"; } }
public override string Run(McTcpClient handler, string command, Dictionary<string, object> localVars) public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
{ {
if (!handler.GetTerrainEnabled()) return "Please enable TerrainHandling in the config file first."; if (!handler.GetTerrainEnabled()) return "Please enable TerrainHandling in the config file first.";
if (hasArg(command)) if (hasArg(command))

View file

@ -18,7 +18,7 @@ namespace MinecraftClient
/// <summary> /// <summary>
/// The main client class, used to connect to a Minecraft server. /// The main client class, used to connect to a Minecraft server.
/// </summary> /// </summary>
public class McTcpClient : IMinecraftComHandler public class McClient : IMinecraftComHandler
{ {
public static int ReconnectionAttemptsLeft = 0; public static int ReconnectionAttemptsLeft = 0;
@ -111,7 +111,7 @@ namespace MinecraftClient
/// <param name="server_ip">The server IP</param> /// <param name="server_ip">The server IP</param>
/// <param name="port">The server port to use</param> /// <param name="port">The server port to use</param>
/// <param name="protocolversion">Minecraft protocol version 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) public McClient(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, ""); StartClient(username, uuid, sessionID, server_ip, port, protocolversion, forgeInfo, false, "");
} }
@ -126,7 +126,7 @@ namespace MinecraftClient
/// <param name="port">The server port to use</param> /// <param name="port">The server port to use</param>
/// <param name="protocolversion">Minecraft protocol version to use</param> /// <param name="protocolversion">Minecraft protocol version to use</param>
/// <param name="command">The text or command to send.</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) public McClient(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); StartClient(username, uuid, sessionID, server_ip, port, protocolversion, forgeInfo, true, command);
} }
@ -1302,7 +1302,7 @@ namespace MinecraftClient
} }
catch (Exception e) catch (Exception e)
{ {
if (!(e2 is ThreadAbortException)) if (!(e is ThreadAbortException))
{ {
ConsoleIO.WriteLogLine("OnEntityEquipment: Got error from " + bot.ToString() + ": " + e.ToString()); ConsoleIO.WriteLogLine("OnEntityEquipment: Got error from " + bot.ToString() + ": " + e.ToString());
} }

View file

@ -255,7 +255,7 @@
<Compile Include="Crypto\IAesStream.cs" /> <Compile Include="Crypto\IAesStream.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="McTcpClient.cs" /> <Compile Include="McClient.cs" />
<Compile Include="Protocol\Handlers\Compression\ZlibStream.cs" /> <Compile Include="Protocol\Handlers\Compression\ZlibStream.cs" />
<Compile Include="Protocol\Handlers\Protocol18.cs" /> <Compile Include="Protocol\Handlers\Protocol18.cs" />
<Compile Include="Protocol\Handlers\Protocol16.cs" /> <Compile Include="Protocol\Handlers\Protocol16.cs" />
@ -314,4 +314,4 @@
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </Target>
--> -->
</Project> </Project>

View file

@ -27,7 +27,7 @@ namespace MinecraftClient
/// </remarks> /// </remarks>
static class Program static class Program
{ {
private static McTcpClient Client; private static McClient Client;
public static string[] startupargs; public static string[] startupargs;
public const string Version = MCHighestVersion; public const string Version = MCHighestVersion;
@ -264,9 +264,9 @@ namespace MinecraftClient
//Start the main TCP client //Start the main TCP client
if (Settings.SingleCommand != "") if (Settings.SingleCommand != "")
{ {
Client = new McTcpClient(session.PlayerName, session.PlayerID, session.ID, Settings.ServerIP, Settings.ServerPort, protocolversion, forgeInfo, Settings.SingleCommand); Client = new McClient(session.PlayerName, session.PlayerID, session.ID, Settings.ServerIP, Settings.ServerPort, protocolversion, forgeInfo, Settings.SingleCommand);
} }
else Client = new McTcpClient(session.PlayerName, session.PlayerID, session.ID, protocolversion, forgeInfo, Settings.ServerIP, Settings.ServerPort); else Client = new McClient(session.PlayerName, session.PlayerID, session.ID, protocolversion, forgeInfo, Settings.ServerIP, Settings.ServerPort);
//Update console title //Update console title
if (Settings.ConsoleTitle != "") if (Settings.ConsoleTitle != "")