diff --git a/MinecraftClient/ChatBot.cs b/MinecraftClient/ChatBot.cs
index 8a1d0ee6..c7f28ed8 100644
--- a/MinecraftClient/ChatBot.cs
+++ b/MinecraftClient/ChatBot.cs
@@ -501,11 +501,12 @@ namespace MinecraftClient
/// Disconnect from the server and restart the program
/// It will unload and reload all the bots and then reconnect to the server
///
- /// If connection fails, the client will make X extra attempts
- protected void ReconnectToTheServer(int ExtraAttempts = 3)
+ /// In case of failure, maximum extra attempts before aborting
+ /// Optional delay, in seconds, before restarting
+ protected void ReconnectToTheServer(int ExtraAttempts = 3, int delaySeconds = 0)
{
McTcpClient.ReconnectionAttemptsLeft = ExtraAttempts;
- Program.Restart();
+ Program.Restart(delaySeconds);
}
///
diff --git a/MinecraftClient/Program.cs b/MinecraftClient/Program.cs
index 61f699a8..f4763723 100644
--- a/MinecraftClient/Program.cs
+++ b/MinecraftClient/Program.cs
@@ -268,12 +268,18 @@ namespace MinecraftClient
///
/// Disconnect the current client from the server and restart it
///
- public static void Restart()
+ /// Optional delay, in seconds, before restarting
+ public static void Restart(int delaySeconds = 0)
{
new Thread(new ThreadStart(delegate
{
if (Client != null) { Client.Disconnect(); ConsoleIO.Reset(); }
if (offlinePrompt != null) { offlinePrompt.Abort(); offlinePrompt = null; ConsoleIO.Reset(); }
+ if (delaySeconds > 0)
+ {
+ Console.WriteLine("Waiting " + delaySeconds + " seconds before restarting...");
+ System.Threading.Thread.Sleep(delaySeconds * 1000);
+ }
Console.WriteLine("Restarting Minecraft Console Client...");
InitializeClient();
})).Start();