diff --git a/MinecraftClient/Commands/Upgrade.cs b/MinecraftClient/Commands/Upgrade.cs index 35ae3783..c244d80c 100644 --- a/MinecraftClient/Commands/Upgrade.cs +++ b/MinecraftClient/Commands/Upgrade.cs @@ -57,6 +57,7 @@ namespace MinecraftClient.Commands private static int DownloadUpdate(CmdResult r, bool force) { + Program.SetUpgradeCommandUsed(); if (UpgradeHelper.DownloadLatestBuild(force)) return r.SetAndReturn(CmdResult.Status.Done, Translations.mcc_update_start); else diff --git a/MinecraftClient/Program.cs b/MinecraftClient/Program.cs index 3bb3fbe5..99e1edbd 100644 --- a/MinecraftClient/Program.cs +++ b/MinecraftClient/Program.cs @@ -53,6 +53,7 @@ namespace MinecraftClient private static IDisposable? _sentrySdk = null; private static bool useMcVersionOnce = false; private static string settingsIniPath = "MinecraftClient.ini"; + private static bool upgradeCommandUsed = false; // [SENTRY] // Setting this string to an empty string will disable Sentry @@ -708,12 +709,21 @@ namespace MinecraftClient ConsoleIO.WriteLine(string.Format(Translations.config_load, settingsIniPath)); } + /// + /// Prevents the settings file from being saved. Called when the /upgrade command is used. + /// + public static void SetUpgradeCommandUsed() + { + upgradeCommandUsed = true; + } + /// /// Write-back settings /// public static void WriteBackSettings(bool enableBackup = true) { - Settings.WriteToFile(settingsIniPath, enableBackup); + if (!upgradeCommandUsed) + Settings.WriteToFile(settingsIniPath, enableBackup); } /// @@ -743,7 +753,8 @@ namespace MinecraftClient { WriteBackSettings(); ConsoleInteractive.ConsoleSuggestion.ClearSuggestions(); - ConsoleIO.WriteLineFormatted("§a" + string.Format(Translations.config_saving, settingsIniPath)); + if (!upgradeCommandUsed) + ConsoleIO.WriteLineFormatted("§a" + string.Format(Translations.config_saving, settingsIniPath)); if (client is not null) { client.Disconnect(); ConsoleIO.Reset(); } if (offlinePrompt is not null) { offlinePrompt.Item2.Cancel(); offlinePrompt.Item1.Join(); offlinePrompt = null; ConsoleIO.Reset(); }