diff --git a/MinecraftClient/Bots.cs b/MinecraftClient/Bots.cs index dea680f3..e4b392a7 100644 --- a/MinecraftClient/Bots.cs +++ b/MinecraftClient/Bots.cs @@ -931,6 +931,13 @@ namespace MinecraftClient case "exit": //Exit bot & stay connected to the server UnloadBot(); break; + case "connect": + if (instruction_line.Length >= 9) + { + Settings.ServerIP = instruction_line.Substring(8); + ReconnectToTheServer(); + } + break; default: sleepticks = 0; Update(); //Unknown command : process next line immediately break; diff --git a/MinecraftClient/MinecraftCom.cs b/MinecraftClient/MinecraftCom.cs index 26598bf9..a275be79 100644 --- a/MinecraftClient/MinecraftCom.cs +++ b/MinecraftClient/MinecraftCom.cs @@ -15,7 +15,7 @@ namespace MinecraftClient { #region Login to Minecraft.net and get a new session ID - public enum LoginResult { OtherError, SSLError, Success, WrongPassword, Blocked, AccountMigrated, NotPremium }; + public enum LoginResult { OtherError, ServiceUnavailable, SSLError, Success, WrongPassword, Blocked, AccountMigrated, NotPremium }; /// /// Allows to login to a premium Minecraft account using the Yggdrasil authentication scheme. @@ -66,6 +66,10 @@ namespace MinecraftClient else return LoginResult.WrongPassword; } } + else if ((int)response.StatusCode == 503) + { + return LoginResult.ServiceUnavailable; + } else return LoginResult.Blocked; } else if (e.Status == WebExceptionStatus.SendFailure) @@ -110,6 +114,11 @@ namespace MinecraftClient bool encrypted = false; int protocolversion; + public MinecraftCom() + { + foreach (ChatBot bot in scripts_on_hold) { bots.Add(bot); } + scripts_on_hold.Clear(); + } public bool Update() { for (int i = 0; i < bots.Count; i++) { bots[i].Update(); } @@ -586,9 +595,14 @@ namespace MinecraftClient catch (System.IO.IOException) { } catch (NullReferenceException) { } catch (ObjectDisposedException) { } + + foreach (ChatBot bot in bots) + if (bot is Bots.Scripting) + scripts_on_hold.Add((Bots.Scripting)bot); } private List bots = new List(); + private static List scripts_on_hold = new List(); public void BotLoad(ChatBot b) { b.SetHandler(this); bots.Add(b); b.Initialize(); Settings.SingleCommand = ""; } public void BotUnLoad(ChatBot b) { bots.RemoveAll(item => object.ReferenceEquals(item, b)); } public void BotClear() { bots.Clear(); } diff --git a/MinecraftClient/Program.cs b/MinecraftClient/Program.cs index 55eaf496..80c36c2c 100644 --- a/MinecraftClient/Program.cs +++ b/MinecraftClient/Program.cs @@ -162,7 +162,7 @@ namespace MinecraftClient if (Settings.ChatLog_Enabled) { handler.BotLoad(new Bots.ChatLog(Settings.ChatLog_File, Settings.ChatLog_Filter, Settings.ChatLog_DateTime)); } if (Settings.PlayerLog_Enabled) { handler.BotLoad(new Bots.PlayerListLogger(Settings.PlayerLog_Delay, Settings.PlayerLog_File)); } if (Settings.AutoRelog_Enabled) { handler.BotLoad(new Bots.AutoRelog(Settings.AutoRelog_Delay, Settings.AutoRelog_Retries)); } - if (Settings.Scripting_Enabled) { handler.BotLoad(new Bots.Scripting(Settings.Scripting_ScriptFile)); } + if (Settings.StartupScript_Enabled) { handler.BotLoad(new Bots.Scripting(Settings.StartupScript_ScriptFile)); Settings.StartupScript_Enabled = false; } if (Settings.RemoteCtrl_Enabled){ handler.BotLoad(new Bots.RemoteControl()); } //Start the main TCP client @@ -192,6 +192,7 @@ namespace MinecraftClient { case MinecraftCom.LoginResult.AccountMigrated: Console.WriteLine("Account migrated, use e-mail as username."); break; case MinecraftCom.LoginResult.Blocked: Console.WriteLine("Too many failed logins. Please try again later."); break; + case MinecraftCom.LoginResult.ServiceUnavailable: Console.WriteLine("Login servers are unavailable. Please try again later."); break; case MinecraftCom.LoginResult.WrongPassword: Console.WriteLine("Incorrect password."); break; case MinecraftCom.LoginResult.NotPremium: Console.WriteLine("User not premium."); break; case MinecraftCom.LoginResult.OtherError: Console.WriteLine("Network error."); break; diff --git a/MinecraftClient/Settings.cs b/MinecraftClient/Settings.cs index dad3ecb5..e693f330 100644 --- a/MinecraftClient/Settings.cs +++ b/MinecraftClient/Settings.cs @@ -64,9 +64,9 @@ namespace MinecraftClient public static int AutoRelog_Retries = 3; public static string AutoRelog_KickMessagesFile = "kickmessages.txt"; - //Scripting Settings - public static bool Scripting_Enabled = false; - public static string Scripting_ScriptFile = "script.txt"; + //Startup Script Settings + public static bool StartupScript_Enabled = false; + public static string StartupScript_ScriptFile = "script.txt"; //Remote Control public static bool RemoteCtrl_Enabled = false; @@ -101,7 +101,7 @@ namespace MinecraftClient case "chatlog": pMode = ParseMode.ChatLog; break; case "hangman": pMode = ParseMode.Hangman; break; case "main": pMode = ParseMode.Main; break; - case "scripting": pMode = ParseMode.Scripting; break; + case "startupscript": pMode = ParseMode.Scripting; break; case "remotecontrol": pMode = ParseMode.RemoteControl; break; default: pMode = ParseMode.Default; break; } @@ -183,8 +183,8 @@ namespace MinecraftClient case ParseMode.Scripting: switch (argName.ToLower()) { - case "enabled": Scripting_Enabled = str2bool(argValue); break; - case "scriptfile": Scripting_ScriptFile = argValue; break; + case "enabled": StartupScript_Enabled = str2bool(argValue); break; + case "scriptfile": StartupScript_ScriptFile = argValue; break; } break; @@ -259,7 +259,7 @@ namespace MinecraftClient + "wordsfile=hangman-en.txt\r\n" + "fichiermots=hangman-fr.txt\r\n" + "\r\n" - + "[Scripting]\r\n" + + "[StartupScript]\r\n" + "enabled=false\r\n" + "scriptfile=testscript.txt\r\n" + "\r\n"