From 2add4030f4cf722cde0eda3ffa085020af53ce0c Mon Sep 17 00:00:00 2001 From: ORelio Date: Sat, 20 Jun 2020 15:01:16 +0200 Subject: [PATCH] Rename McTcpClient to McClient for clarity + Fix compile error in #1071 --- MinecraftClient/ChatBot.cs | 8 ++++---- MinecraftClient/ChatBots/AutoRelog.cs | 6 +++--- MinecraftClient/Command.cs | 2 +- MinecraftClient/Commands/Animation.cs | 2 +- MinecraftClient/Commands/ChangeSlot.cs | 2 +- MinecraftClient/Commands/Connect.cs | 2 +- MinecraftClient/Commands/Debug.cs | 2 +- MinecraftClient/Commands/Exit.cs | 2 +- MinecraftClient/Commands/Health.cs | 2 +- MinecraftClient/Commands/Inventory.cs | 2 +- MinecraftClient/Commands/List.cs | 2 +- MinecraftClient/Commands/Log.cs | 2 +- MinecraftClient/Commands/Look.cs | 2 +- MinecraftClient/Commands/Move.cs | 2 +- MinecraftClient/Commands/Reco.cs | 2 +- MinecraftClient/Commands/Respawn.cs | 2 +- MinecraftClient/Commands/Script.cs | 2 +- MinecraftClient/Commands/Send.cs | 2 +- MinecraftClient/Commands/Set.cs | 2 +- MinecraftClient/Commands/Sneak.cs | 2 +- MinecraftClient/Commands/UseItem.cs | 2 +- MinecraftClient/Commands/Useblock.cs | 2 +- MinecraftClient/{McTcpClient.cs => McClient.cs} | 8 ++++---- MinecraftClient/MinecraftClient.csproj | 4 ++-- MinecraftClient/Program.cs | 6 +++--- 25 files changed, 36 insertions(+), 36 deletions(-) rename MinecraftClient/{McTcpClient.cs => McClient.cs} (96%) diff --git a/MinecraftClient/ChatBot.cs b/MinecraftClient/ChatBot.cs index 8ddd2b0b..7092c413 100644 --- a/MinecraftClient/ChatBot.cs +++ b/MinecraftClient/ChatBot.cs @@ -32,15 +32,15 @@ namespace MinecraftClient public enum DisconnectReason { InGameKick, LoginRejected, ConnectionLost, UserLogout }; //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 LoadBot(ChatBot bot) { Handler.BotUnLoad(bot); Handler.BotLoad(bot); } - private McTcpClient _handler = null; + private McClient _handler = null; private ChatBot master = null; private List registeredPluginChannels = new List(); private Queue chatQueue = new Queue(); private DateTime lastMessageSentTime = DateTime.MinValue; - private McTcpClient Handler + private McClient Handler { get { @@ -657,7 +657,7 @@ namespace MinecraftClient { if (Settings.DebugMessages) ConsoleIO.WriteLogLine(String.Format("[{0}] Disconnecting and Reconnecting to the Server", this.GetType().Name)); - McTcpClient.ReconnectionAttemptsLeft = ExtraAttempts; + McClient.ReconnectionAttemptsLeft = ExtraAttempts; Program.Restart(delaySeconds); } diff --git a/MinecraftClient/ChatBots/AutoRelog.cs b/MinecraftClient/ChatBots/AutoRelog.cs index ac788357..496f6be9 100644 --- a/MinecraftClient/ChatBots/AutoRelog.cs +++ b/MinecraftClient/ChatBots/AutoRelog.cs @@ -23,7 +23,7 @@ namespace MinecraftClient.ChatBots { attempts = retries; if (attempts == -1) { attempts = int.MaxValue; } - McTcpClient.ReconnectionAttemptsLeft = attempts; + McClient.ReconnectionAttemptsLeft = attempts; delay = DelayBeforeRelog; if (delay < 1) { delay = 1; } if (Settings.DebugMessages) @@ -32,7 +32,7 @@ namespace MinecraftClient.ChatBots public override void Initialize() { - McTcpClient.ReconnectionAttemptsLeft = attempts; + McClient.ReconnectionAttemptsLeft = attempts; if (Settings.AutoRelog_IgnoreKickMessage) { if (Settings.DebugMessages) @@ -96,7 +96,7 @@ namespace MinecraftClient.ChatBots LogToConsole("Waiting " + delay + " seconds before reconnecting..."); System.Threading.Thread.Sleep(delay * 1000); - McTcpClient.ReconnectionAttemptsLeft = attempts; + McClient.ReconnectionAttemptsLeft = attempts; ReconnectToTheServer(); return true; } diff --git a/MinecraftClient/Command.cs b/MinecraftClient/Command.cs index 025bd6d4..0049f602 100644 --- a/MinecraftClient/Command.cs +++ b/MinecraftClient/Command.cs @@ -29,7 +29,7 @@ namespace MinecraftClient /// The full command, eg: 'mycommand arg1 arg2' /// Local variables passed along with the command (may be null) /// A confirmation/error message, or "" if no message - public abstract string Run(McTcpClient handler, string command, Dictionary localVars); + public abstract string Run(McClient handler, string command, Dictionary localVars); /// /// Return a list of aliases for this command. diff --git a/MinecraftClient/Commands/Animation.cs b/MinecraftClient/Commands/Animation.cs index ab777f01..50a8286d 100644 --- a/MinecraftClient/Commands/Animation.cs +++ b/MinecraftClient/Commands/Animation.cs @@ -10,7 +10,7 @@ namespace MinecraftClient.Commands public override string CMDName { get { return "animation"; } } public override string CMDDesc { get { return "animation "; } } - public override string Run(McTcpClient handler, string command, Dictionary localVars) + public override string Run(McClient handler, string command, Dictionary localVars) { if (hasArg(command)) { diff --git a/MinecraftClient/Commands/ChangeSlot.cs b/MinecraftClient/Commands/ChangeSlot.cs index 78b8b3dc..e012bbd7 100644 --- a/MinecraftClient/Commands/ChangeSlot.cs +++ b/MinecraftClient/Commands/ChangeSlot.cs @@ -10,7 +10,7 @@ namespace MinecraftClient.Commands public override string CMDName { get { return "changeslot"; } } public override string CMDDesc { get { return "changeslot <1-9>: Change hotbar"; } } - public override string Run(McTcpClient handler, string command, Dictionary localVars) + public override string Run(McClient handler, string command, Dictionary localVars) { if (!handler.GetInventoryEnabled()) return "Please enable InventoryHandling in the config file first."; if (hasArg(command)) diff --git a/MinecraftClient/Commands/Connect.cs b/MinecraftClient/Commands/Connect.cs index f8ce4ac8..21fdd045 100644 --- a/MinecraftClient/Commands/Connect.cs +++ b/MinecraftClient/Commands/Connect.cs @@ -10,7 +10,7 @@ namespace MinecraftClient.Commands public override string CMDName { get { return "connect"; } } public override string CMDDesc { get { return "connect [account]: connect to the specified server."; } } - public override string Run(McTcpClient handler, string command, Dictionary localVars) + public override string Run(McClient handler, string command, Dictionary localVars) { if (hasArg(command)) { diff --git a/MinecraftClient/Commands/Debug.cs b/MinecraftClient/Commands/Debug.cs index f7daaab9..15086687 100644 --- a/MinecraftClient/Commands/Debug.cs +++ b/MinecraftClient/Commands/Debug.cs @@ -10,7 +10,7 @@ namespace MinecraftClient.Commands public override string CMDName { get { return "debug"; } } public override string CMDDesc { get { return "debug [on|off]: toggle debug messages."; } } - public override string Run(McTcpClient handler, string command, Dictionary localVars) + public override string Run(McClient handler, string command, Dictionary localVars) { if (hasArg(command)) { diff --git a/MinecraftClient/Commands/Exit.cs b/MinecraftClient/Commands/Exit.cs index d55d1043..7afc373b 100644 --- a/MinecraftClient/Commands/Exit.cs +++ b/MinecraftClient/Commands/Exit.cs @@ -10,7 +10,7 @@ namespace MinecraftClient.Commands public override string CMDName { get { return "exit"; } } public override string CMDDesc { get { return "exit: disconnect from the server."; } } - public override string Run(McTcpClient handler, string command, Dictionary localVars) + public override string Run(McClient handler, string command, Dictionary localVars) { Program.Exit(); return ""; diff --git a/MinecraftClient/Commands/Health.cs b/MinecraftClient/Commands/Health.cs index 42bb9a3e..3711e277 100644 --- a/MinecraftClient/Commands/Health.cs +++ b/MinecraftClient/Commands/Health.cs @@ -10,7 +10,7 @@ namespace MinecraftClient.Commands public override string CMDName { get { return "health"; } } public override string CMDDesc { get { return "health: Display Health and Food saturation."; } } - public override string Run(McTcpClient handler, string command, Dictionary localVars) + public override string Run(McClient handler, string command, Dictionary localVars) { return "Health: " + handler.GetHealth() + ", Saturation: " + handler.GetSaturation() + ", Level: " + handler.GetLevel() + ", TotalExperience: " + handler.GetTotalExperience(); } diff --git a/MinecraftClient/Commands/Inventory.cs b/MinecraftClient/Commands/Inventory.cs index 91cdbd41..50e0396a 100644 --- a/MinecraftClient/Commands/Inventory.cs +++ b/MinecraftClient/Commands/Inventory.cs @@ -11,7 +11,7 @@ namespace MinecraftClient.Commands public override string CMDName { get { return "inventory"; } } public override string CMDDesc { get { return "inventory <|player|container> <1|all>|click > | inventory creativegive : Interact with inventories"; } } - public override string Run(McTcpClient handler, string command, Dictionary localVars) + public override string Run(McClient handler, string command, Dictionary localVars) { if (handler.GetInventoryEnabled()) { diff --git a/MinecraftClient/Commands/List.cs b/MinecraftClient/Commands/List.cs index 9e9b47cf..e4e488fe 100644 --- a/MinecraftClient/Commands/List.cs +++ b/MinecraftClient/Commands/List.cs @@ -10,7 +10,7 @@ namespace MinecraftClient.Commands 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, Dictionary localVars) + public override string Run(McClient handler, string command, Dictionary localVars) { return "PlayerList: " + String.Join(", ", handler.GetOnlinePlayers()); } diff --git a/MinecraftClient/Commands/Log.cs b/MinecraftClient/Commands/Log.cs index d04fef16..dcc39a97 100644 --- a/MinecraftClient/Commands/Log.cs +++ b/MinecraftClient/Commands/Log.cs @@ -10,7 +10,7 @@ namespace MinecraftClient.Commands public override string CMDName { get { return "log"; } } public override string CMDDesc { get { return "log : log some text to the console."; } } - public override string Run(McTcpClient handler, string command, Dictionary localVars) + public override string Run(McClient handler, string command, Dictionary localVars) { if (hasArg(command)) { diff --git a/MinecraftClient/Commands/Look.cs b/MinecraftClient/Commands/Look.cs index 0ff5cf8e..30173db5 100644 --- a/MinecraftClient/Commands/Look.cs +++ b/MinecraftClient/Commands/Look.cs @@ -11,7 +11,7 @@ namespace MinecraftClient.Commands public override string CMDName { get { return "look"; } } public override string CMDDesc { get { return "look : look at direction or coordinates."; } } - public override string Run(McTcpClient handler, string command, Dictionary localVars) + public override string Run(McClient handler, string command, Dictionary localVars) { if (handler.GetTerrainEnabled()) { diff --git a/MinecraftClient/Commands/Move.cs b/MinecraftClient/Commands/Move.cs index 918b1295..31010123 100644 --- a/MinecraftClient/Commands/Move.cs +++ b/MinecraftClient/Commands/Move.cs @@ -11,7 +11,7 @@ namespace MinecraftClient.Commands public override string CMDName { get { return "move"; } } public override string CMDDesc { get { return "move : walk or start walking."; } } - public override string Run(McTcpClient handler, string command, Dictionary localVars) + public override string Run(McClient handler, string command, Dictionary localVars) { string[] args = getArgs(command); string argStr = getArg(command).Trim().ToLower(); diff --git a/MinecraftClient/Commands/Reco.cs b/MinecraftClient/Commands/Reco.cs index fce08711..a5ee220a 100644 --- a/MinecraftClient/Commands/Reco.cs +++ b/MinecraftClient/Commands/Reco.cs @@ -10,7 +10,7 @@ namespace MinecraftClient.Commands public override string CMDName { get { return "reco"; } } public override string CMDDesc { get { return "reco [account]: restart and reconnect to the server."; } } - public override string Run(McTcpClient handler, string command, Dictionary localVars) + public override string Run(McClient handler, string command, Dictionary localVars) { string[] args = getArgs(command); if (args.Length > 0) diff --git a/MinecraftClient/Commands/Respawn.cs b/MinecraftClient/Commands/Respawn.cs index 24788568..b490b14d 100644 --- a/MinecraftClient/Commands/Respawn.cs +++ b/MinecraftClient/Commands/Respawn.cs @@ -10,7 +10,7 @@ namespace MinecraftClient.Commands 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 Run(McTcpClient handler, string command, Dictionary localVars) + public override string Run(McClient handler, string command, Dictionary localVars) { handler.SendRespawnPacket(); return "You have respawned."; diff --git a/MinecraftClient/Commands/Script.cs b/MinecraftClient/Commands/Script.cs index dc573e4f..727c6870 100644 --- a/MinecraftClient/Commands/Script.cs +++ b/MinecraftClient/Commands/Script.cs @@ -10,7 +10,7 @@ namespace MinecraftClient.Commands public override string CMDName { get { return "script"; } } public override string CMDDesc { get { return "script : run a script file."; } } - public override string Run(McTcpClient handler, string command, Dictionary localVars) + public override string Run(McClient handler, string command, Dictionary localVars) { if (hasArg(command)) { diff --git a/MinecraftClient/Commands/Send.cs b/MinecraftClient/Commands/Send.cs index 42ccd50c..1b78d2d2 100644 --- a/MinecraftClient/Commands/Send.cs +++ b/MinecraftClient/Commands/Send.cs @@ -10,7 +10,7 @@ namespace MinecraftClient.Commands public override string CMDName { get { return "send"; } } public override string CMDDesc { get { return "send : send a chat message or command."; } } - public override string Run(McTcpClient handler, string command, Dictionary localVars) + public override string Run(McClient handler, string command, Dictionary localVars) { if (hasArg(command)) { diff --git a/MinecraftClient/Commands/Set.cs b/MinecraftClient/Commands/Set.cs index 7216cf2e..4861c894 100644 --- a/MinecraftClient/Commands/Set.cs +++ b/MinecraftClient/Commands/Set.cs @@ -10,7 +10,7 @@ namespace MinecraftClient.Commands public override string CMDName { get { return "set"; } } public override string CMDDesc { get { return "set varname=value: set a custom %variable%."; } } - public override string Run(McTcpClient handler, string command, Dictionary localVars) + public override string Run(McClient handler, string command, Dictionary localVars) { if (hasArg(command)) { diff --git a/MinecraftClient/Commands/Sneak.cs b/MinecraftClient/Commands/Sneak.cs index b4e65421..d3dc3604 100644 --- a/MinecraftClient/Commands/Sneak.cs +++ b/MinecraftClient/Commands/Sneak.cs @@ -11,7 +11,7 @@ namespace MinecraftClient.Commands public override string CMDName { get { return "Sneak"; } } public override string CMDDesc { get { return "Sneak: Toggles sneaking"; } } - public override string Run(McTcpClient handler, string command, Dictionary localVars) + public override string Run(McClient handler, string command, Dictionary localVars) { if (sneaking) { diff --git a/MinecraftClient/Commands/UseItem.cs b/MinecraftClient/Commands/UseItem.cs index a6e3fbc9..1901f8c3 100644 --- a/MinecraftClient/Commands/UseItem.cs +++ b/MinecraftClient/Commands/UseItem.cs @@ -10,7 +10,7 @@ namespace MinecraftClient.Commands 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 Run(McTcpClient handler, string command, Dictionary localVars) + public override string Run(McClient handler, string command, Dictionary localVars) { if (handler.GetInventoryEnabled()) { diff --git a/MinecraftClient/Commands/Useblock.cs b/MinecraftClient/Commands/Useblock.cs index 98850cf0..a97b07a5 100644 --- a/MinecraftClient/Commands/Useblock.cs +++ b/MinecraftClient/Commands/Useblock.cs @@ -11,7 +11,7 @@ namespace MinecraftClient.Commands public override string CMDName { get { return "useblock"; } } public override string CMDDesc { get { return "useblock : use block"; } } - public override string Run(McTcpClient handler, string command, Dictionary localVars) + public override string Run(McClient handler, string command, Dictionary localVars) { if (!handler.GetTerrainEnabled()) return "Please enable TerrainHandling in the config file first."; if (hasArg(command)) diff --git a/MinecraftClient/McTcpClient.cs b/MinecraftClient/McClient.cs similarity index 96% rename from MinecraftClient/McTcpClient.cs rename to MinecraftClient/McClient.cs index fecee32b..4adc1630 100644 --- a/MinecraftClient/McTcpClient.cs +++ b/MinecraftClient/McClient.cs @@ -18,7 +18,7 @@ namespace MinecraftClient /// /// The main client class, used to connect to a Minecraft server. /// - public class McTcpClient : IMinecraftComHandler + public class McClient : IMinecraftComHandler { public static int ReconnectionAttemptsLeft = 0; @@ -111,7 +111,7 @@ namespace MinecraftClient /// The server IP /// The server port to use /// Minecraft protocol version to use - 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, ""); } @@ -126,7 +126,7 @@ namespace MinecraftClient /// The server port to use /// Minecraft protocol version to use /// The text or command to send. - 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); } @@ -1302,7 +1302,7 @@ namespace MinecraftClient } catch (Exception e) { - if (!(e2 is ThreadAbortException)) + if (!(e is ThreadAbortException)) { ConsoleIO.WriteLogLine("OnEntityEquipment: Got error from " + bot.ToString() + ": " + e.ToString()); } diff --git a/MinecraftClient/MinecraftClient.csproj b/MinecraftClient/MinecraftClient.csproj index 84f3d1f6..7d0ef066 100644 --- a/MinecraftClient/MinecraftClient.csproj +++ b/MinecraftClient/MinecraftClient.csproj @@ -255,7 +255,7 @@ - + @@ -314,4 +314,4 @@ --> - + \ No newline at end of file diff --git a/MinecraftClient/Program.cs b/MinecraftClient/Program.cs index 710f2ecc..b2ef0c6c 100644 --- a/MinecraftClient/Program.cs +++ b/MinecraftClient/Program.cs @@ -27,7 +27,7 @@ namespace MinecraftClient /// static class Program { - private static McTcpClient Client; + private static McClient Client; public static string[] startupargs; public const string Version = MCHighestVersion; @@ -264,9 +264,9 @@ namespace MinecraftClient //Start the main TCP client 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 if (Settings.ConsoleTitle != "")