its downloading!!!
This commit is contained in:
@@ -11,10 +11,10 @@ public class GameVersionDescriptor
|
||||
[JsonRequired] public string type { get; set; } = "";
|
||||
[JsonRequired] public string mainClass { get; set; } = "";
|
||||
[JsonRequired] public Downloads downloads { get; set; } = null!;
|
||||
[JsonRequired] public JavaVersion javaVersion { get; set; } = null!;
|
||||
[JsonRequired] public List<Library> libraries { get; set; } = null!;
|
||||
[JsonRequired] public AssetIndexProperties assetIndex { get; set; } = null!;
|
||||
[JsonRequired] public string assets { get; set; } = "";
|
||||
public JavaVersion javaVersion { get; set; } = new() { component = "jre-legacy", majorVersion = 8 };
|
||||
public string? minecraftArguments { get; set; }
|
||||
public ArgumentsNew? arguments { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Млаумчерб.Клиент.классы;
|
||||
|
||||
public class GameVersionProps
|
||||
public class GameVersionProps : IComparable<GameVersionProps>, IEquatable<GameVersionProps>
|
||||
{
|
||||
public string Name { get; }
|
||||
public IOPath LocalDescriptorPath { get; }
|
||||
@@ -31,4 +31,33 @@ public class GameVersionProps
|
||||
this(name, url, Пути.GetVersionDescriptorPath(name)) { }
|
||||
|
||||
public override string ToString() => Name;
|
||||
|
||||
public override int GetHashCode() => Name.GetHashCode();
|
||||
|
||||
public int CompareTo(GameVersionProps? other)
|
||||
{
|
||||
if (ReferenceEquals(this, other)) return 0;
|
||||
if (other is null) return 1;
|
||||
|
||||
if (Version.TryParse(Name, out var version1) && Version.TryParse(other.Name, out var version2))
|
||||
{
|
||||
return version1.CompareTo(version2);
|
||||
}
|
||||
|
||||
return String.Compare(Name, other.Name, StringComparison.InvariantCulture);
|
||||
}
|
||||
|
||||
public bool Equals(GameVersionProps? other)
|
||||
{
|
||||
if (other is null) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
return Name == other.Name;
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj is GameVersionProps other) return Equals(other);
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,77 @@
|
||||
namespace Млаумчерб.Клиент.классы;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Млаумчерб.Клиент.классы;
|
||||
|
||||
public class JavaVersionCatalog
|
||||
{
|
||||
|
||||
[JsonProperty("linux")]
|
||||
public Dictionary<string, JavaVersionProps[]>? linux_x86 { get; set; }
|
||||
[JsonProperty("linux-i386")]
|
||||
public Dictionary<string, JavaVersionProps[]>? linux_x64 { get; set; }
|
||||
[JsonProperty("mac-os")]
|
||||
public Dictionary<string, JavaVersionProps[]>? osx_x64 { get; set; }
|
||||
[JsonProperty("mac-os-arm64")]
|
||||
public Dictionary<string, JavaVersionProps[]>? osx_arm64 { get; set; }
|
||||
[JsonProperty("windows-arm64")]
|
||||
public Dictionary<string, JavaVersionProps[]>? windows_arm64 { get; set; }
|
||||
[JsonProperty("windows-x64")]
|
||||
public Dictionary<string, JavaVersionProps[]>? windows_x64 { get; set; }
|
||||
[JsonProperty("windows-x86")]
|
||||
public Dictionary<string, JavaVersionProps[]>? windows_x86 { get; set; }
|
||||
|
||||
public JavaVersionProps GetVersionProps(JavaVersion version)
|
||||
{
|
||||
var arch = RuntimeInformation.OSArchitecture;
|
||||
Dictionary<string, JavaVersionProps[]>? propsDict = null;
|
||||
switch (arch)
|
||||
{
|
||||
case Architecture.X86:
|
||||
if (OperatingSystem.IsWindows())
|
||||
propsDict = windows_x86;
|
||||
else if (OperatingSystem.IsLinux())
|
||||
propsDict = linux_x86;
|
||||
break;
|
||||
case Architecture.X64:
|
||||
if (OperatingSystem.IsWindows())
|
||||
propsDict = windows_x64;
|
||||
else if (OperatingSystem.IsLinux())
|
||||
propsDict = linux_x64;
|
||||
else if (OperatingSystem.IsMacOS())
|
||||
propsDict = osx_x64;
|
||||
break;
|
||||
case Architecture.Arm64:
|
||||
if (OperatingSystem.IsWindows())
|
||||
propsDict = windows_arm64;
|
||||
else if (OperatingSystem.IsMacOS())
|
||||
propsDict = osx_arm64;
|
||||
break;
|
||||
}
|
||||
|
||||
if (propsDict != null && propsDict.TryGetValue(version.component, out var props_array))
|
||||
{
|
||||
if (props_array.Length != 0)
|
||||
return props_array[0];
|
||||
}
|
||||
|
||||
throw new PlatformNotSupportedException($"Can't download java {version.majorVersion} for your operating system. " +
|
||||
$"Download it manually to directory {Пути.GetJavaRuntimeDir(version.component)}");
|
||||
}
|
||||
}
|
||||
|
||||
public class JavaVersionProps
|
||||
{
|
||||
[JsonRequired] public Artifact manifest { get; set; }
|
||||
/// url of JavaDistributiveManifest
|
||||
[JsonRequired] public Artifact manifest { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class JavaVersionManifest
|
||||
public class JavaDistributiveManifest
|
||||
{
|
||||
[JsonRequired] public Dictionary<string, JavaDistributiveElementProps> manifest { get; set; }
|
||||
[JsonRequired] public Dictionary<string, JavaDistributiveElementProps> files { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class JavaDistributiveElementProps
|
||||
{
|
||||
// "directory" / "file"
|
||||
/// "directory" / "file"
|
||||
[JsonRequired] public string type { get; set; } = "";
|
||||
public bool? executable { get; set; }
|
||||
public JavaCompressedArtifact? downloads { get; set; }
|
||||
@@ -26,5 +80,5 @@ public class JavaDistributiveElementProps
|
||||
public class JavaCompressedArtifact
|
||||
{
|
||||
public Artifact? lzma { get; set; }
|
||||
public Artifact raw { get; set; } = null!;
|
||||
[JsonRequired] public Artifact raw { get; set; } = null!;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using DTLib.Extensions;
|
||||
using System.Runtime.InteropServices;
|
||||
using DTLib.Extensions;
|
||||
|
||||
namespace Млаумчерб.Клиент.классы;
|
||||
|
||||
@@ -35,6 +36,23 @@ public class Libraries
|
||||
if(nativesKey is null)
|
||||
throw new Exception($"nativesKey for '{l.name}' is null");
|
||||
|
||||
// example: "natives-windows-${arch}"
|
||||
if (nativesKey.Contains('$'))
|
||||
{
|
||||
var span = nativesKey.AsSpan();
|
||||
nativesKey = span.After("${").Before('}') switch
|
||||
{
|
||||
"arch" => RuntimeInformation.OSArchitecture switch
|
||||
{
|
||||
Architecture.X64 => span.Before("${").ToString() + "64",
|
||||
Architecture.X86 => span.Before("${").ToString() + "32",
|
||||
_ => throw new PlatformNotSupportedException(
|
||||
$"Unsupported architecture: {RuntimeInformation.OSArchitecture}")
|
||||
},
|
||||
_ => throw new Exception($"unknown placeholder in {nativesKey}")
|
||||
};
|
||||
}
|
||||
|
||||
Artifact artifact = null!;
|
||||
if(l.downloads.classifiers != null && !l.downloads.classifiers.TryGetValue(nativesKey, out artifact!))
|
||||
throw new Exception($"can't find artifact for '{l.name}' with nativesKey '{nativesKey}'");
|
||||
|
||||
@@ -17,7 +17,7 @@ public static class Буржуазия
|
||||
&& os.arch switch
|
||||
{
|
||||
null => true,
|
||||
"x86" => RuntimeInformation.OSArchitecture == Architecture.X86,
|
||||
"i386" or "x86" => RuntimeInformation.OSArchitecture == Architecture.X86,
|
||||
"x64" => RuntimeInformation.OSArchitecture == Architecture.X64,
|
||||
"arm64" => RuntimeInformation.OSArchitecture == Architecture.Arm64,
|
||||
_ => false
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Млаумчерб.Клиент.видимое;
|
||||
using Млаумчерб.Клиент.зримое;
|
||||
|
||||
namespace Млаумчерб.Клиент.классы;
|
||||
|
||||
@@ -7,14 +7,14 @@ public static class Пути
|
||||
public static IOPath GetAssetIndexFilePath(string id) =>
|
||||
Path.Concat(Приложение.Настройки.путь_к_кубачу, $"assets/indexes/{id}.json");
|
||||
|
||||
public static IOPath GetVersionDescriptorDir() =>
|
||||
Path.Concat(Приложение.Настройки.путь_к_кубачу, "version_descriptors");
|
||||
public static IOPath GetVersionDescriptorsDir() =>
|
||||
Path.Concat(Приложение.Настройки.путь_к_кубачу, "versions");
|
||||
|
||||
public static string GetVersionDescriptorName(IOPath path) =>
|
||||
path.LastName().RemoveExtension().ToString();
|
||||
|
||||
public static IOPath GetVersionDescriptorPath(string name) =>
|
||||
Path.Concat(GetVersionDescriptorDir(), Path.ReplaceRestrictedChars(name) + ".json");
|
||||
Path.Concat(GetVersionDescriptorsDir(), Path.ReplaceRestrictedChars(name) + ".json");
|
||||
|
||||
public static IOPath GetVersionDir(string id) =>
|
||||
Path.Concat(Приложение.Настройки.путь_к_кубачу, "versions", id);
|
||||
|
||||
Reference in New Issue
Block a user