mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Support downloading updates via command.
This commit is contained in:
parent
3713fa2dbe
commit
28827b720a
10 changed files with 2463 additions and 1974 deletions
50
MinecraftClient/Commands/Upgrade.cs
Normal file
50
MinecraftClient/Commands/Upgrade.cs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
class Upgrade : Command
|
||||
{
|
||||
public override string CmdName { get { return "upgrade"; } }
|
||||
public override string CmdUsage { get { return "upgrade [-f|check|cancel|download]"; } }
|
||||
public override string CmdDesc { get { return string.Empty; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
if (HasArg(command))
|
||||
{
|
||||
string[] args = GetArgs(command);
|
||||
return args[0] switch
|
||||
{
|
||||
"-f" => DownloadUpdate(force: true),
|
||||
"-force" => DownloadUpdate(force: true),
|
||||
"cancel" => CancelDownloadUpdate(),
|
||||
"check" => CheckUpdate(),
|
||||
"download" => DownloadUpdate(force: args.Length > 1 && (args[1] == "-f" || args[1] == "-force")),
|
||||
_ => GetCmdDescTranslated(),
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return DownloadUpdate(force: false);
|
||||
}
|
||||
}
|
||||
|
||||
private static string DownloadUpdate(bool force)
|
||||
{
|
||||
UpgradeHelper.DownloadLatestBuild(force);
|
||||
return Translations.mcc_update_start;
|
||||
}
|
||||
|
||||
private static string CancelDownloadUpdate()
|
||||
{
|
||||
UpgradeHelper.CancelDownloadUpdate();
|
||||
return Translations.mcc_update_cancel;
|
||||
}
|
||||
|
||||
private static string CheckUpdate()
|
||||
{
|
||||
UpgradeHelper.CheckUpdate(forceUpdate: true);
|
||||
return Translations.mcc_update_start;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue