ChatBot: Allow delay in ReconnectToTheServer()

See #252
This commit is contained in:
ORelio 2017-03-13 21:15:36 +01:00
parent a254a282cd
commit 59b12ff900
2 changed files with 11 additions and 4 deletions

View file

@ -268,12 +268,18 @@ namespace MinecraftClient
/// <summary>
/// Disconnect the current client from the server and restart it
/// </summary>
public static void Restart()
/// <param name="delay">Optional delay, in seconds, before restarting</param>
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();