mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
Return exit codes for specific failures when in non-interactive mode (#1120)
This commit is contained in:
parent
03388bf5a1
commit
9370064072
1 changed files with 16 additions and 3 deletions
|
|
@ -324,14 +324,14 @@ namespace MinecraftClient
|
|||
/// <summary>
|
||||
/// Disconnect the current client from the server and exit the app
|
||||
/// </summary>
|
||||
public static void Exit()
|
||||
public static void Exit(int exitcode = 0)
|
||||
{
|
||||
new Thread(new ThreadStart(delegate
|
||||
{
|
||||
if (client != null) { client.Disconnect(); ConsoleIO.Reset(); }
|
||||
if (offlinePrompt != null) { offlinePrompt.Abort(); offlinePrompt = null; ConsoleIO.Reset(); }
|
||||
if (Settings.playerHeadAsIcon) { ConsoleIcon.revertToMCCIcon(); }
|
||||
Environment.Exit(0);
|
||||
Environment.Exit(exitcode);
|
||||
})).Start();
|
||||
}
|
||||
|
||||
|
|
@ -421,7 +421,20 @@ namespace MinecraftClient
|
|||
offlinePrompt.Start();
|
||||
}
|
||||
}
|
||||
else Exit();
|
||||
else
|
||||
{
|
||||
// Not in interactive mode, just exit and let the calling script handle the failure
|
||||
if (disconnectReason.HasValue)
|
||||
{
|
||||
// Return distinct exit codes for known failures.
|
||||
if (disconnectReason.Value == ChatBot.DisconnectReason.UserLogout) Exit(1);
|
||||
if (disconnectReason.Value == ChatBot.DisconnectReason.InGameKick) Exit(2);
|
||||
if (disconnectReason.Value == ChatBot.DisconnectReason.ConnectionLost) Exit(3);
|
||||
if (disconnectReason.Value == ChatBot.DisconnectReason.LoginRejected) Exit(4);
|
||||
}
|
||||
Exit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue