forge support
This commit is contained in:
@@ -21,6 +21,7 @@ public class GameVersionDescriptor
|
||||
|
||||
public class Artifact
|
||||
{
|
||||
public string? path = null;
|
||||
[JsonRequired] public string url { get; set; } = "";
|
||||
[JsonRequired] public string sha1 { get; set; } = "";
|
||||
[JsonRequired] public int size { get; set; }
|
||||
|
||||
@@ -7,18 +7,22 @@ public class Libraries
|
||||
{
|
||||
private static readonly string[] enabled_features = [];
|
||||
|
||||
public record JarLib(string name, IOPath? jarFilePath, Artifact artifact);
|
||||
public record NativeLib(string name, IOPath? jarFilePath, Artifact artifact, Extract? extractionOptions)
|
||||
public record JarLib(string name, IOPath jarFilePath, Artifact artifact);
|
||||
public record NativeLib(string name, IOPath jarFilePath, Artifact artifact, Extract? extractionOptions)
|
||||
: JarLib(name, jarFilePath, artifact);
|
||||
|
||||
public IReadOnlyCollection<JarLib> Libs { get; }
|
||||
|
||||
private IOPath? TryGetJarFilePath(Artifact artifact)
|
||||
private IOPath GetJarFilePath(Artifact artifact)
|
||||
{
|
||||
if(string.IsNullOrEmpty(artifact.url))
|
||||
return null;
|
||||
string urlTail = artifact.url.AsSpan().After("://").After('/').ToString();
|
||||
return Path.Concat(PathHelper.GetLibrariesDir(), urlTail);
|
||||
string relativePath;
|
||||
if (!string.IsNullOrEmpty(artifact.path))
|
||||
relativePath = artifact.path;
|
||||
else if (!string.IsNullOrEmpty(artifact.url))
|
||||
relativePath = artifact.url.AsSpan().After("://").After('/').ToString();
|
||||
else throw new ArgumentException("Artifact must have a path or url");
|
||||
|
||||
return Path.Concat(PathHelper.GetLibrariesDir(), relativePath);
|
||||
}
|
||||
|
||||
public Libraries(GameVersionDescriptor descriptor)
|
||||
@@ -63,7 +67,7 @@ public class Libraries
|
||||
if(!libHashes.Add(artifact.sha1))
|
||||
continue;
|
||||
|
||||
libs.Add(new NativeLib(l.name, TryGetJarFilePath(artifact), artifact, l.extract));
|
||||
libs.Add(new NativeLib(l.name, GetJarFilePath(artifact), artifact, l.extract));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -75,7 +79,7 @@ public class Libraries
|
||||
if(!libHashes.Add(artifact.sha1))
|
||||
continue;
|
||||
|
||||
libs.Add(new JarLib(l.name, TryGetJarFilePath(artifact), artifact));
|
||||
libs.Add(new JarLib(l.name, GetJarFilePath(artifact), artifact));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user