|
@@ -42,9 +42,9 @@ internal static class Downloader
|
|
|
if (DownloadJava)
|
|
|
{
|
|
|
Settings.logger.Debug("Getting required Java version.");
|
|
|
- if (versionJson.JavaVersion.MajorVersion != null)
|
|
|
+ string javaUrl = "";
|
|
|
+ if (versionJson.JavaVersion is not null && versionJson.JavaVersion.MajorVersion != null)
|
|
|
{
|
|
|
- string javaUrl = "";
|
|
|
switch (versionJson.JavaVersion.MajorVersion)
|
|
|
{
|
|
|
case 8:
|
|
@@ -78,26 +78,40 @@ internal static class Downloader
|
|
|
javaUrl = "https://files.veloe.link/launcher/java/18/linux64/java.zip";
|
|
|
|
|
|
break;
|
|
|
- }
|
|
|
- if (javaUrl != "")
|
|
|
- {
|
|
|
- Settings.logger.Debug("Downloading Java");
|
|
|
- DownloadingFileName("java.zip");
|
|
|
- webClient.DownloadFileAsync(new System.Uri(javaUrl), Settings.MinecraftForlderPath + "java.zip");
|
|
|
- waitWhileBisy(ref webClient);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- Settings.logger.Debug("Unpacking Java");
|
|
|
- DownloadingFileName("Unpacking java.zip");
|
|
|
- ZipFile.ExtractToDirectory($"{Settings.MinecraftForlderPath}java.zip", Settings.MinecraftForlderPath, true);
|
|
|
- File.Delete($"{Settings.MinecraftForlderPath}java.zip");
|
|
|
- }
|
|
|
- else
|
|
|
- Settings.logger.Debug("Required Java version don't found in json file."); //log that java was not downloaded;
|
|
|
+ if (versionJson.Assets == "legacy")
|
|
|
+ {
|
|
|
+ if (Environment.Is64BitOperatingSystem && OperatingSystem.IsWindows())
|
|
|
+ javaUrl = "https://files.veloe.link/launcher/java/8/windows64/java.zip";
|
|
|
+ if (!Environment.Is64BitOperatingSystem && OperatingSystem.IsWindows())
|
|
|
+ javaUrl = "https://files.veloe.link/launcher/java/8/windows32/java.zip";
|
|
|
+
|
|
|
+ if (Environment.Is64BitOperatingSystem && OperatingSystem.IsLinux())
|
|
|
+ javaUrl = "https://files.veloe.link/launcher/java/8/linux64/java.zip";
|
|
|
+ if (!Environment.Is64BitOperatingSystem && OperatingSystem.IsLinux())
|
|
|
+ javaUrl = "https://files.veloe.link/launcher/java/8/linux32/java.zip";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (javaUrl != "")
|
|
|
+ {
|
|
|
+ Settings.logger.Debug("Downloading Java");
|
|
|
+ DownloadingFileName("java.zip");
|
|
|
+ webClient.DownloadFileAsync(new System.Uri(javaUrl), Settings.minecraftForlderPath + "java.zip");
|
|
|
+ waitWhileBisy(ref webClient);
|
|
|
+
|
|
|
+ Settings.logger.Debug("Unpacking Java");
|
|
|
+ DownloadingFileName("Unpacking java.zip");
|
|
|
+ ZipFile.ExtractToDirectory($"{Settings.minecraftForlderPath}java.zip", Settings.minecraftForlderPath, true);
|
|
|
+ File.Delete($"{Settings.minecraftForlderPath}java.zip");
|
|
|
}
|
|
|
+ else
|
|
|
+ Settings.logger.Debug("Required Java version don't found in json file."); //log that java was not downloaded;
|
|
|
}
|
|
|
|
|
|
//download json
|
|
|
- var path = Settings.MinecraftForlderPath + "/versions/" + versionJson.Id;
|
|
|
+ var path = Settings.minecraftForlderPath + "/versions/" + versionJson.Id;
|
|
|
if (!Directory.Exists(path))
|
|
|
{
|
|
|
Settings.logger.Debug("Creating path: {0}", path);
|
|
@@ -141,64 +155,52 @@ internal static class Downloader
|
|
|
Settings.logger.Debug("Downloading libraries.");
|
|
|
foreach (var library in versionJson.Libraries)
|
|
|
{
|
|
|
- var libPath = Settings.MinecraftForlderPath + "libraries/";
|
|
|
- string[] libPathSplit = new[] { "" };
|
|
|
+ var libPath = Settings.minecraftForlderPath + "libraries/";
|
|
|
string libUrl = "";
|
|
|
string sha1 = String.Empty;
|
|
|
// getting path and url if universal lib
|
|
|
if (library.Natives is null)
|
|
|
{
|
|
|
- libPath = Settings.MinecraftForlderPath + "libraries/";
|
|
|
- libPathSplit = library.Downloads.Artifact.Path.Split('/');
|
|
|
+ libPath = Settings.minecraftForlderPath + "libraries/" + library.Downloads.Artifact.Path;
|
|
|
libUrl = library.Downloads.Artifact.Url;
|
|
|
sha1 = library.Downloads.Artifact.Sha1;
|
|
|
- for (int i = 0; i < libPathSplit.Length - 1; i++)
|
|
|
- {
|
|
|
- libPath += libPathSplit[i] + "/";
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
else
|
|
|
{ // getting path if native
|
|
|
- libPath = Settings.MinecraftForlderPath + "libraries/";
|
|
|
- libPathSplit = new[] { "" };
|
|
|
+ libPath = Settings.minecraftForlderPath + "libraries/";
|
|
|
libUrl = "";
|
|
|
-
|
|
|
- if (OperatingSystem.IsWindows() && library.Natives.Windows is not null)
|
|
|
+ if (library.Downloads.Classifiers is not null)
|
|
|
{
|
|
|
- if (library.Downloads.Classifiers.NativesWindows is not null)
|
|
|
- {
|
|
|
- libPathSplit = library.Downloads.Classifiers.NativesWindows.Path.Split('/');
|
|
|
- libUrl = library.Downloads.Classifiers.NativesWindows.Url;
|
|
|
- sha1 = library.Downloads.Classifiers.NativesWindows.Sha1;
|
|
|
- }
|
|
|
- else
|
|
|
+ if (OperatingSystem.IsWindows() && library.Natives.Windows is not null)
|
|
|
{
|
|
|
- if (Environment.Is64BitOperatingSystem)
|
|
|
+ if (library.Downloads.Classifiers.NativesWindows is not null)
|
|
|
{
|
|
|
- libPathSplit = library.Downloads.Classifiers.NativesWindows64.Path.Split('/');
|
|
|
- libUrl = library.Downloads.Classifiers.NativesWindows64.Url;
|
|
|
- sha1 = library.Downloads.Classifiers.NativesWindows64.Sha1;
|
|
|
+ libPath += library.Downloads.Classifiers.NativesWindows.Path;
|
|
|
+ libUrl = library.Downloads.Classifiers.NativesWindows.Url;
|
|
|
+ sha1 = library.Downloads.Classifiers.NativesWindows.Sha1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- libPathSplit = library.Downloads.Classifiers.NativesWindows32.Path.Split('/');
|
|
|
- libUrl = library.Downloads.Classifiers.NativesWindows32.Url;
|
|
|
- sha1 = library.Downloads.Classifiers.NativesWindows32.Sha1;
|
|
|
+ if (Environment.Is64BitOperatingSystem && library.Downloads.Classifiers.NativesWindows64 is not null)
|
|
|
+ {
|
|
|
+ libPath += library.Downloads.Classifiers.NativesWindows64.Path;
|
|
|
+ libUrl = library.Downloads.Classifiers.NativesWindows64.Url;
|
|
|
+ sha1 = library.Downloads.Classifiers.NativesWindows64.Sha1;
|
|
|
+ }
|
|
|
+ else if (library.Downloads.Classifiers.NativesWindows32 is not null)
|
|
|
+ {
|
|
|
+ libPath += library.Downloads.Classifiers.NativesWindows32.Path;
|
|
|
+ libUrl = library.Downloads.Classifiers.NativesWindows32.Url;
|
|
|
+ sha1 = library.Downloads.Classifiers.NativesWindows32.Sha1;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- if (OperatingSystem.IsLinux() && library.Natives.Linux is not null)
|
|
|
- {
|
|
|
- libPathSplit = library.Downloads.Classifiers.NativesLinux.Path.Split('/');
|
|
|
- libUrl = library.Downloads.Classifiers.NativesLinux.Url;
|
|
|
- sha1 = library.Downloads.Classifiers.NativesLinux.Url;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- for (int i = 0; i < libPathSplit.Length - 1; i++)
|
|
|
- {
|
|
|
- libPath += libPathSplit[i] + "/";
|
|
|
+ if (OperatingSystem.IsLinux() && library.Natives.Linux is not null && library.Downloads.Classifiers.NativesLinux is not null)
|
|
|
+ {
|
|
|
+ libPath += library.Downloads.Classifiers.NativesLinux.Path;
|
|
|
+ libUrl = library.Downloads.Classifiers.NativesLinux.Url;
|
|
|
+ sha1 = library.Downloads.Classifiers.NativesLinux.Url;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -206,21 +208,24 @@ internal static class Downloader
|
|
|
if (libUrl == String.Empty)
|
|
|
continue;
|
|
|
|
|
|
+ var libName = Path.GetFileName(libPath);
|
|
|
+ var libDir = Path.GetDirectoryName(libPath);
|
|
|
+
|
|
|
//checking rules
|
|
|
if (library.Rules == null)
|
|
|
- {
|
|
|
- if (!Directory.Exists(libPath))
|
|
|
+ {
|
|
|
+ if (!Directory.Exists(libDir))
|
|
|
{
|
|
|
Settings.logger.Debug("Creating path: {0}", path);
|
|
|
- Directory.CreateDirectory(libPath);
|
|
|
+ Directory.CreateDirectory(libDir);
|
|
|
}
|
|
|
|
|
|
chksum = String.Empty;
|
|
|
|
|
|
- if (File.Exists(libPath + "/" + libPathSplit.Last()))
|
|
|
+ if (File.Exists(libPath))
|
|
|
{
|
|
|
- DownloadingFileName($"Checking hash: {libPathSplit.Last()}");
|
|
|
- FileStream fop = File.OpenRead(libPath + "/" + libPathSplit.Last());
|
|
|
+ DownloadingFileName($"Checking hash: {libName}");
|
|
|
+ FileStream fop = File.OpenRead(libPath);
|
|
|
byte[] hash = System.Security.Cryptography.SHA1.Create().ComputeHash(fop);
|
|
|
chksum = BitConverter.ToString(hash).Replace("-", String.Empty).ToLower();
|
|
|
|
|
@@ -230,9 +235,9 @@ internal static class Downloader
|
|
|
|
|
|
if (chksum != sha1)
|
|
|
{
|
|
|
- Settings.logger.Debug("Downloading: {0}", libPathSplit.Last());
|
|
|
- DownloadingFileName(libPathSplit.Last());
|
|
|
- webClient.DownloadFileAsync(new System.Uri(libUrl), libPath + "/" + libPathSplit.Last());
|
|
|
+ Settings.logger.Debug("Downloading: {0}", libName);
|
|
|
+ DownloadingFileName(libName);
|
|
|
+ webClient.DownloadFileAsync(new System.Uri(libUrl), libDir + "/" + libName);
|
|
|
waitWhileBisy(ref webClient);
|
|
|
}
|
|
|
}
|
|
@@ -242,18 +247,18 @@ internal static class Downloader
|
|
|
{
|
|
|
if (rule.Action == "allow") // && rule.os is null
|
|
|
{
|
|
|
- if (!Directory.Exists(libPath))
|
|
|
+ if (!Directory.Exists(libDir))
|
|
|
{
|
|
|
Settings.logger.Debug("Creating path: {0}", path);
|
|
|
- Directory.CreateDirectory(libPath);
|
|
|
+ Directory.CreateDirectory(libDir);
|
|
|
}
|
|
|
|
|
|
chksum = String.Empty;
|
|
|
|
|
|
- if (File.Exists(libPath + "/" + libPathSplit.Last()) && sha1 != String.Empty)
|
|
|
+ if (File.Exists(libDir + "/" + libName) && sha1 != String.Empty)
|
|
|
{
|
|
|
- DownloadingFileName($"Checking hash: {libPathSplit.Last()}");
|
|
|
- FileStream fop = File.OpenRead(libPath + "/" + libPathSplit.Last());
|
|
|
+ DownloadingFileName($"Checking hash: {libName}");
|
|
|
+ FileStream fop = File.OpenRead(libDir + "/" + libName);
|
|
|
byte[] hash = System.Security.Cryptography.SHA1.Create().ComputeHash(fop);
|
|
|
chksum = BitConverter.ToString(hash).Replace("-", String.Empty).ToLower();
|
|
|
|
|
@@ -263,9 +268,9 @@ internal static class Downloader
|
|
|
|
|
|
if (chksum != sha1)
|
|
|
{
|
|
|
- Settings.logger.Debug("Downloading: {0}", libPathSplit.Last());
|
|
|
- DownloadingFileName(libPathSplit.Last());
|
|
|
- webClient.DownloadFileAsync(new System.Uri(libUrl), libPath + "/" + libPathSplit.Last());
|
|
|
+ Settings.logger.Debug("Downloading: {0}", libName);
|
|
|
+ DownloadingFileName(libName);
|
|
|
+ webClient.DownloadFileAsync(new System.Uri(libUrl), libDir + "/" + libName);
|
|
|
waitWhileBisy(ref webClient);
|
|
|
}
|
|
|
continue;
|
|
@@ -279,33 +284,33 @@ internal static class Downloader
|
|
|
Settings.logger.Debug("Creating path: {0}", path);
|
|
|
Directory.CreateDirectory(libPath);
|
|
|
}
|
|
|
- Settings.logger.Debug("Downloading: {0}", libPathSplit.Last());
|
|
|
- DownloadingFileName = libPathSplit.Last();
|
|
|
- webClient.DownloadFileAsync(new System.Uri(libUrl), libPath + "/" + libPathSplit.Last());
|
|
|
+ Settings.logger.Debug("Downloading: {0}", libName);
|
|
|
+ DownloadingFileName = libName;
|
|
|
+ webClient.DownloadFileAsync(new System.Uri(libUrl), libPath + "/" + libName);
|
|
|
waitWhileBisy(ref webClient);
|
|
|
}
|
|
|
*/
|
|
|
}
|
|
|
}
|
|
|
//unpacking native libs
|
|
|
- if (((library.Natives is not null || library.Downloads.Classifiers is not null) && File.Exists(libPath + "/" + libPathSplit.Last())) /*&& chksum != sha1*/)
|
|
|
+ if ((library.Natives is not null || library.Downloads.Classifiers is not null) && File.Exists(libPath)/*&& chksum != sha1*/)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- if (!((
|
|
|
+ if (!(library.Downloads.Classifiers is not null && (
|
|
|
library.Downloads.Classifiers.NativesWindows is not null ||
|
|
|
library.Downloads.Classifiers.NativesWindows64 is not null ||
|
|
|
- library.Downloads.Classifiers.NativesWindows32 is not null) && OperatingSystem.IsWindows() ||
|
|
|
- library.Downloads.Classifiers.NativesLinux is not null && OperatingSystem.IsLinux()))
|
|
|
+ (library.Downloads.Classifiers.NativesWindows32 is not null && OperatingSystem.IsWindows()) ||
|
|
|
+ (library.Downloads.Classifiers.NativesLinux is not null && OperatingSystem.IsLinux()))))
|
|
|
continue;
|
|
|
|
|
|
- if (!Directory.Exists(Settings.MinecraftForlderPath + "versions/" + versionJson.Id + "/natives/"))
|
|
|
+ if (!Directory.Exists(Settings.minecraftForlderPath + "versions/" + versionJson.Id + "/natives/"))
|
|
|
{
|
|
|
- Settings.logger.Debug("Creating path: {0}", Settings.MinecraftForlderPath + "versions/" + versionJson.Id + "/natives/");
|
|
|
- Directory.CreateDirectory(Settings.MinecraftForlderPath + "versions/" + versionJson.Id + "/natives/");
|
|
|
+ Settings.logger.Debug("Creating path: {0}", Settings.minecraftForlderPath + "versions/" + versionJson.Id + "/natives/");
|
|
|
+ Directory.CreateDirectory(Settings.minecraftForlderPath + "versions/" + versionJson.Id + "/natives/");
|
|
|
}
|
|
|
- Settings.logger.Debug("Extracting {0} to {1}", libPathSplit.Last(), Settings.MinecraftForlderPath + "versions/" + versionJson.Id + "/natives/");
|
|
|
- ZipFile.ExtractToDirectory(libPath + "/" + libPathSplit.Last(), Settings.MinecraftForlderPath + "versions/" + versionJson.Id + "/natives/", true);
|
|
|
+ Settings.logger.Debug("Extracting {0} to {1}", libName, Settings.minecraftForlderPath + "versions/" + versionJson.Id + "/natives/");
|
|
|
+ ZipFile.ExtractToDirectory(libDir + "/" + libName, Settings.minecraftForlderPath + "versions/" + versionJson.Id + "/natives/", true);
|
|
|
}
|
|
|
catch (IOException ex)
|
|
|
{
|
|
@@ -316,15 +321,15 @@ internal static class Downloader
|
|
|
}
|
|
|
|
|
|
var assetsJson = Downloader.DownloadAndDeserializeJsonData<AssetsManifest>(versionJson.AssetIndex.Url);
|
|
|
- var assetsPath = Settings.MinecraftForlderPath + "assets/" + versionJson.Assets + "/objects";
|
|
|
+ var assetsPath = Settings.minecraftForlderPath + "assets/" + versionJson.Assets + "/objects";
|
|
|
var assetsUrl = "https://resources.download.minecraft.net/";
|
|
|
|
|
|
//download assets json
|
|
|
Settings.logger.Debug("Downloading: {0}", versionJson.Assets + ".json");
|
|
|
|
|
|
- if (!Directory.Exists(Settings.MinecraftForlderPath + "/assets/" + versionJson.Assets + "/indexes/"))
|
|
|
- Directory.CreateDirectory(Settings.MinecraftForlderPath + "/assets/" + versionJson.Assets + "/indexes/");
|
|
|
- webClient.DownloadFileAsync(new System.Uri(versionJson.AssetIndex.Url), Settings.MinecraftForlderPath + "/assets/" + versionJson.Assets + "/indexes/" + versionJson.Assets + ".json");
|
|
|
+ if (!Directory.Exists(Settings.minecraftForlderPath + "/assets/" + versionJson.Assets + "/indexes/"))
|
|
|
+ Directory.CreateDirectory(Settings.minecraftForlderPath + "/assets/" + versionJson.Assets + "/indexes/");
|
|
|
+ webClient.DownloadFileAsync(new System.Uri(versionJson.AssetIndex.Url), Settings.minecraftForlderPath + "/assets/" + versionJson.Assets + "/indexes/" + versionJson.Assets + ".json");
|
|
|
waitWhileBisy(ref webClient);
|
|
|
|
|
|
//download assets
|
|
@@ -361,27 +366,27 @@ internal static class Downloader
|
|
|
var forgePath = $"Forge{versionJson.Id}";
|
|
|
var forgeUrl = $"https://files.veloe.link/launcher/forge/Forge{versionJson.Id}/";
|
|
|
|
|
|
- if (!Directory.Exists($"{Settings.MinecraftForlderPath}versions/Forge{versionJson.Id}"))
|
|
|
+ if (!Directory.Exists($"{Settings.minecraftForlderPath}versions/Forge{versionJson.Id}"))
|
|
|
{
|
|
|
- Settings.logger.Debug("Creating path: {0}", $"{Settings.MinecraftForlderPath}versions/" + forgePath);
|
|
|
- Directory.CreateDirectory($"{Settings.MinecraftForlderPath}versions/" + forgePath);
|
|
|
+ Settings.logger.Debug("Creating path: {0}", $"{Settings.minecraftForlderPath}versions/" + forgePath);
|
|
|
+ Directory.CreateDirectory($"{Settings.minecraftForlderPath}versions/" + forgePath);
|
|
|
}
|
|
|
waitWhileBisy(ref webClient);
|
|
|
|
|
|
Settings.logger.Debug("Downloading: {0}", $"Forge{versionJson.Id}.json");
|
|
|
DownloadingFileName($"Forge{versionJson.Id}.json");
|
|
|
- webClient.DownloadFileAsync(new System.Uri($"{forgeUrl}Forge{versionJson.Id}.json"), Settings.MinecraftForlderPath + "versions/" + forgePath + "/" + forgePath + ".json");
|
|
|
+ webClient.DownloadFileAsync(new System.Uri($"{forgeUrl}Forge{versionJson.Id}.json"), Settings.minecraftForlderPath + "versions/" + forgePath + "/" + forgePath + ".json");
|
|
|
waitWhileBisy(ref webClient);
|
|
|
|
|
|
Settings.logger.Debug("Downloading: {0}", "libraries.zip");
|
|
|
DownloadingFileName("libraries.zip");
|
|
|
- webClient.DownloadFileAsync(new System.Uri(forgeUrl + "libraries.zip"), Settings.MinecraftForlderPath + "versions/" + forgePath + "/libraries.zip");
|
|
|
+ webClient.DownloadFileAsync(new System.Uri(forgeUrl + "libraries.zip"), Settings.minecraftForlderPath + "versions/" + forgePath + "/libraries.zip");
|
|
|
waitWhileBisy(ref webClient);
|
|
|
|
|
|
Settings.logger.Debug("Extracting: {0}", "libraries.zip");
|
|
|
DownloadingFileName("Unpacking libraries.zip");
|
|
|
- ZipFile.ExtractToDirectory($"{Settings.MinecraftForlderPath}versions/Forge{versionJson.Id}/libraries.zip", Settings.MinecraftForlderPath, true);
|
|
|
- File.Delete($"{Settings.MinecraftForlderPath}versions/Forge{versionJson.Id}/libraries.zip");
|
|
|
+ ZipFile.ExtractToDirectory($"{Settings.minecraftForlderPath}versions/Forge{versionJson.Id}/libraries.zip", Settings.minecraftForlderPath, true);
|
|
|
+ File.Delete($"{Settings.minecraftForlderPath}versions/Forge{versionJson.Id}/libraries.zip");
|
|
|
}
|
|
|
|
|
|
if (InstallOptifine)
|
|
@@ -389,45 +394,45 @@ internal static class Downloader
|
|
|
var optifinePath = $"Optifine{versionJson.Id}";
|
|
|
var optifineUrl = $"https://files.veloe.link/launcher/optifine/Optifine{versionJson.Id}/";
|
|
|
|
|
|
- if (!Directory.Exists($"{Settings.MinecraftForlderPath}versions/Optifine{versionJson.Id}"))
|
|
|
+ if (!Directory.Exists($"{Settings.minecraftForlderPath}versions/Optifine{versionJson.Id}"))
|
|
|
{
|
|
|
- Settings.logger.Debug("Creating path: {0}", $"{Settings.MinecraftForlderPath}Optifine/" + optifinePath);
|
|
|
- Directory.CreateDirectory($"{Settings.MinecraftForlderPath}Optifine/" + optifinePath);
|
|
|
+ Settings.logger.Debug("Creating path: {0}", $"{Settings.minecraftForlderPath}Optifine/" + optifinePath);
|
|
|
+ Directory.CreateDirectory($"{Settings.minecraftForlderPath}Optifine/" + optifinePath);
|
|
|
}
|
|
|
|
|
|
Settings.logger.Debug("Downloading: {0}", $"Optifine{versionJson.Id}.json");
|
|
|
DownloadingFileName($"Optifine{versionJson.Id}.json");
|
|
|
- webClient.DownloadFileAsync(new System.Uri($"{optifineUrl}Optifine{versionJson.Id}.json"), Settings.MinecraftForlderPath + "versions/" + optifinePath + "/" + optifinePath + ".json");
|
|
|
+ webClient.DownloadFileAsync(new System.Uri($"{optifineUrl}Optifine{versionJson.Id}.json"), Settings.minecraftForlderPath + "versions/" + optifinePath + "/" + optifinePath + ".json");
|
|
|
waitWhileBisy(ref webClient);
|
|
|
|
|
|
Settings.logger.Debug("Downloading: {0}", $"Optifine{versionJson.Id}.jar");
|
|
|
DownloadingFileName($"Optifine{versionJson.Id}.json");
|
|
|
- webClient.DownloadFileAsync(new System.Uri($"{optifineUrl}Optifine{versionJson.Id}.jar"), Settings.MinecraftForlderPath + "versions/" + optifinePath + "/" + optifinePath + ".jar");
|
|
|
+ webClient.DownloadFileAsync(new System.Uri($"{optifineUrl}Optifine{versionJson.Id}.jar"), Settings.minecraftForlderPath + "versions/" + optifinePath + "/" + optifinePath + ".jar");
|
|
|
waitWhileBisy(ref webClient);
|
|
|
|
|
|
Settings.logger.Debug("Downloading: {0}", "libraries.zip");
|
|
|
DownloadingFileName("libraries.zip");
|
|
|
- webClient.DownloadFileAsync(new System.Uri(optifineUrl + "libraries.zip"), Settings.MinecraftForlderPath + "versions/" + optifinePath + "/libraries.zip");
|
|
|
+ webClient.DownloadFileAsync(new System.Uri(optifineUrl + "libraries.zip"), Settings.minecraftForlderPath + "versions/" + optifinePath + "/libraries.zip");
|
|
|
waitWhileBisy(ref webClient);
|
|
|
|
|
|
Settings.logger.Debug("Extracting: {0}", "libraries.zip");
|
|
|
DownloadingFileName("Unpacking libraries.zip");
|
|
|
- ZipFile.ExtractToDirectory($"{Settings.MinecraftForlderPath}versions/Optifine{versionJson.Id}/libraries.zip", Settings.MinecraftForlderPath, true);
|
|
|
- File.Delete($"{Settings.MinecraftForlderPath}versions/Optifine{versionJson.Id}/libraries.zip");
|
|
|
+ ZipFile.ExtractToDirectory($"{Settings.minecraftForlderPath}versions/Optifine{versionJson.Id}/libraries.zip", Settings.minecraftForlderPath, true);
|
|
|
+ File.Delete($"{Settings.minecraftForlderPath}versions/Optifine{versionJson.Id}/libraries.zip");
|
|
|
}
|
|
|
|
|
|
if (InstallForgeOptifine)
|
|
|
{
|
|
|
- if (!Directory.Exists($"{Settings.MinecraftForlderPath}versions/Forge{versionJson.Id}/mods"))
|
|
|
+ if (!Directory.Exists($"{Settings.minecraftForlderPath}versions/Forge{versionJson.Id}/mods"))
|
|
|
{
|
|
|
- Settings.logger.Debug("Creating path: {0}", $"{Settings.MinecraftForlderPath}versions/Forge" + versionJson.Id + "/mods");
|
|
|
- Directory.CreateDirectory($"{Settings.MinecraftForlderPath}versions/Forge" + versionJson.Id + "/mods");
|
|
|
+ Settings.logger.Debug("Creating path: {0}", $"{Settings.minecraftForlderPath}versions/Forge" + versionJson.Id + "/mods");
|
|
|
+ Directory.CreateDirectory($"{Settings.minecraftForlderPath}versions/Forge" + versionJson.Id + "/mods");
|
|
|
}
|
|
|
|
|
|
Settings.logger.Debug("Downloading: {0}", $"Optifine{versionJson.Id}.jar");
|
|
|
DownloadingFileName($"Optifine{versionJson.Id}.jar");
|
|
|
webClient.DownloadFileAsync(new System.Uri(@$"https://files.veloe.link/launcher/forge/Forge{versionJson.Id}/Optifine{versionJson.Id}.jar"),
|
|
|
- Settings.MinecraftForlderPath + "versions/Forge" + versionJson.Id + "/mods/" + "Optifine" + versionJson.Id + ".jar");
|
|
|
+ Settings.minecraftForlderPath + "versions/Forge" + versionJson.Id + "/mods/" + "Optifine" + versionJson.Id + ".jar");
|
|
|
waitWhileBisy(ref webClient);
|
|
|
}
|
|
|
|
|
@@ -444,7 +449,8 @@ internal static class Downloader
|
|
|
IsControlsEnabled(true);
|
|
|
DownloadingFileName($"Error occured while downloading {versionJson.Id}.");
|
|
|
Settings.logger.Error(ex.Message);
|
|
|
- Settings.logger.Error(ex.StackTrace);
|
|
|
+ if (ex.StackTrace is not null)
|
|
|
+ Settings.logger.Error(ex.StackTrace);
|
|
|
return TaskStatus.Faulted;
|
|
|
}
|
|
|
return TaskStatus.RanToCompletion;
|
|
@@ -478,7 +484,7 @@ internal static class Downloader
|
|
|
|
|
|
Settings.logger.Debug("Downloading {0}.json", FilteredVersion.Id);
|
|
|
DownloadingFileName($"{FilteredVersion.Id}.json");
|
|
|
- var versionJson = Downloader.DownloadAndDeserializeJsonData<Entity.Version.Version>(FilteredVersion.Url, Settings.MinecraftForlderPath + "versions/" + FilteredVersion.Id + "/", FilteredVersion.Id + ".json");
|
|
|
+ var versionJson = Downloader.DownloadAndDeserializeJsonData<Entity.Version.Version>(FilteredVersion.Url, Settings.minecraftForlderPath + "versions/" + FilteredVersion.Id + "/", FilteredVersion.Id + ".json");
|
|
|
|
|
|
await Downloader.StartDownload(
|
|
|
DownloadingFileName,
|
|
@@ -494,17 +500,17 @@ internal static class Downloader
|
|
|
|
|
|
IsControlsEnabled(false);
|
|
|
|
|
|
- string modpackUrl = null;
|
|
|
+ string modpackUrl = string.Empty;
|
|
|
|
|
|
if (SelectedModpack.Url is not null)
|
|
|
modpackUrl = SelectedModpack.Url;
|
|
|
else
|
|
|
modpackUrl = $"https://files.veloe.link/launcher/modpacks/{SelectedModpack.Name}.zip";
|
|
|
|
|
|
- if (!Directory.Exists($"{Settings.MinecraftForlderPath}versions/{SelectedModpack.Name}"))
|
|
|
+ if (!Directory.Exists($"{Settings.minecraftForlderPath}versions/{SelectedModpack.Name}"))
|
|
|
{
|
|
|
- Settings.logger.Debug("Creating path: {0}", $"{Settings.MinecraftForlderPath}versions/{SelectedModpack.Name}");
|
|
|
- Directory.CreateDirectory($"{Settings.MinecraftForlderPath}versions/{SelectedModpack.Name}");
|
|
|
+ Settings.logger.Debug("Creating path: {0}", $"{Settings.minecraftForlderPath}versions/{SelectedModpack.Name}");
|
|
|
+ Directory.CreateDirectory($"{Settings.minecraftForlderPath}versions/{SelectedModpack.Name}");
|
|
|
}
|
|
|
|
|
|
WebClient webClient = new WebClient();
|
|
@@ -513,13 +519,13 @@ internal static class Downloader
|
|
|
|
|
|
Settings.logger.Debug("Downloading: {0}", $"{SelectedModpack.Name}.zip");
|
|
|
DownloadingFileName($"{SelectedModpack.Name}.zip");
|
|
|
- webClient.DownloadFileAsync(new System.Uri(modpackUrl), Settings.MinecraftForlderPath + $"versions/{SelectedModpack.Name}.zip");
|
|
|
+ webClient.DownloadFileAsync(new System.Uri(modpackUrl), Settings.minecraftForlderPath + $"versions/{SelectedModpack.Name}.zip");
|
|
|
waitWhileBisy(ref webClient);
|
|
|
|
|
|
Settings.logger.Debug("Extracting: {0}", $"{SelectedModpack.Name}.zip");
|
|
|
DownloadingFileName($"Unpacking {SelectedModpack.Name}.zip");
|
|
|
- ZipFile.ExtractToDirectory($"{Settings.MinecraftForlderPath}versions/{SelectedModpack.Name}.zip", Settings.MinecraftForlderPath + $"versions/{SelectedModpack.Name}", true);
|
|
|
- File.Delete($"{Settings.MinecraftForlderPath}versions/{SelectedModpack.Name}.zip");
|
|
|
+ ZipFile.ExtractToDirectory($"{Settings.minecraftForlderPath}versions/{SelectedModpack.Name}.zip", Settings.minecraftForlderPath + $"versions/{SelectedModpack.Name}", true);
|
|
|
+ File.Delete($"{Settings.minecraftForlderPath}versions/{SelectedModpack.Name}.zip");
|
|
|
|
|
|
RemoveProgressBar(webClient);
|
|
|
|
|
@@ -537,20 +543,23 @@ internal static class Downloader
|
|
|
var message = ex.Message;
|
|
|
var stackTrace = ex.StackTrace;
|
|
|
Settings.logger.Error(ex.Message);
|
|
|
- Settings.logger.Error(ex.StackTrace);
|
|
|
- Exception innerException = ex.InnerException;
|
|
|
+ if (ex.StackTrace is not null)
|
|
|
+ Settings.logger.Error(ex.StackTrace);
|
|
|
+ Exception? innerException = ex.InnerException;
|
|
|
while (innerException is not null)
|
|
|
{
|
|
|
message += "\n" + innerException.Message;
|
|
|
stackTrace += "\n" + innerException.StackTrace;
|
|
|
Settings.logger.Error(innerException.Message);
|
|
|
- Settings.logger.Error(innerException.StackTrace);
|
|
|
+ if (innerException.StackTrace is not null)
|
|
|
+ Settings.logger.Error(innerException.StackTrace);
|
|
|
innerException = innerException.InnerException;
|
|
|
}
|
|
|
|
|
|
+#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
|
|
Dispatcher.UIThread.InvokeAsync(() =>
|
|
|
{
|
|
|
- if (Avalonia.Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
|
|
+ if (Avalonia.Application.Current is not null && Avalonia.Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
|
|
{
|
|
|
Dispatcher.UIThread.InvokeAsync(() =>
|
|
|
{
|
|
@@ -563,6 +572,7 @@ internal static class Downloader
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
+#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
|
|
return TaskStatus.Faulted;
|
|
|
}
|
|
|
return TaskStatus.RanToCompletion;
|
|
@@ -608,20 +618,22 @@ internal static class Downloader
|
|
|
var message = ex.Message;
|
|
|
var stackTrace = ex.StackTrace;
|
|
|
Settings.logger.Error(ex.Message);
|
|
|
- Settings.logger.Error(ex.StackTrace);
|
|
|
- Exception innerException = ex.InnerException;
|
|
|
+ if (ex.StackTrace is not null)
|
|
|
+ Settings.logger.Error(ex.StackTrace);
|
|
|
+ Exception? innerException = ex.InnerException;
|
|
|
while (innerException is not null)
|
|
|
{
|
|
|
message += "\n" + innerException.Message;
|
|
|
stackTrace += "\n" + innerException.StackTrace;
|
|
|
Settings.logger.Error(innerException.Message);
|
|
|
- Settings.logger.Error(innerException.StackTrace);
|
|
|
+ if (innerException.StackTrace is not null)
|
|
|
+ Settings.logger.Error(innerException.StackTrace);
|
|
|
innerException = innerException.InnerException;
|
|
|
}
|
|
|
|
|
|
Dispatcher.UIThread.InvokeAsync(() =>
|
|
|
{
|
|
|
- if (Avalonia.Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
|
|
+ if (Avalonia.Application.Current is not null && Avalonia.Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
|
|
{
|
|
|
Dispatcher.UIThread.InvokeAsync(() =>
|
|
|
{
|