Skip to content

Commit

Permalink
add checkAndDownload option
Browse files Browse the repository at this point in the history
CMLauncher.CreateProcess
  • Loading branch information
AlphaBs committed Sep 4, 2021
1 parent a55745f commit 7e2b48e
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions CmlLib/Core/CMLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ public async Task CheckAndDownloadAsync(MVersion version)
}
}

// not stable
public Process CreateProcess(string mcversion, string forgeversion, MLaunchOption option)
{
CheckAndDownload(GetVersion(mcversion));
Expand All @@ -188,27 +189,35 @@ public Process CreateProcess(string mcversion, string forgeversion, MLaunchOptio
return CreateProcess(versionName, option);
}

public Process CreateProcess(string versionName, MLaunchOption option)
=> CreateProcess(GetVersion(versionName), option);
public Process CreateProcess(string versionName, MLaunchOption option, bool checkAndDownload=true)
=> CreateProcess(GetVersion(versionName), option, checkAndDownload);

[MethodTimer.Time]
public Process CreateProcess(MVersion version, MLaunchOption option)
public Process CreateProcess(MVersion version, MLaunchOption option, bool checkAndDownload=true)
{
option.StartVersion = version;
CheckAndDownload(option.StartVersion);

if (checkAndDownload)
CheckAndDownload(option.StartVersion);

return CreateProcess(option);
}

public async Task<Process> CreateProcessAsync(string versionName, MLaunchOption option)
public async Task<Process> CreateProcessAsync(string versionName, MLaunchOption option,
bool checkAndDownload=true)
{
var version = await GetVersionAsync(versionName).ConfigureAwait(false);
return await CreateProcessAsync(version, option).ConfigureAwait(false);
return await CreateProcessAsync(version, option, checkAndDownload).ConfigureAwait(false);
}

public async Task<Process> CreateProcessAsync(MVersion version, MLaunchOption option)
public async Task<Process> CreateProcessAsync(MVersion version, MLaunchOption option,
bool checkAndDownload=true)
{
option.StartVersion = version;
await CheckAndDownloadAsync(option.StartVersion).ConfigureAwait(false);

if (checkAndDownload)
await CheckAndDownloadAsync(option.StartVersion).ConfigureAwait(false);

return await CreateProcessAsync(option).ConfigureAwait(false);
}

Expand Down

0 comments on commit 7e2b48e

Please sign in to comment.