-
Notifications
You must be signed in to change notification settings - Fork 0
/
Library.cs
53 lines (47 loc) · 1.62 KB
/
Library.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace AtlasClient.FabricInstallerUtil
{
public class Library : IDisposable
{
public string name { get; private set; }
public string url { get; private set; }
public string inputPath { get; private set; }
public Library(string name, string url, string inputPath)
{
this.name = name;
this.url = url;
this.inputPath = inputPath;
}
public Library(JsonElement json)
{
this.name = json.GetProperty("name").GetString();
this.url = json.GetProperty("url").GetString();
this.inputPath = null;
}
public string GetURL()
{
string[] parts = this.name.Split(new char[] { ':' }, 3);
string path = $"{parts[0].Replace(".", "/")}/{parts[1]}/{parts[2]}/{parts[1]}-{parts[2]}.jar";
return this.url + path;
}
public string GetPath()
{
string[] parts = this.name.Split(new char[] { ':' }, 3);
string path = $"{parts[0].Replace(".", Path.DirectorySeparatorChar.ToString())}{Path.DirectorySeparatorChar}{parts[1]}{Path.DirectorySeparatorChar}{parts[2]}{Path.DirectorySeparatorChar}{parts[1]}-{parts[2]}.jar";
return Regex.Replace(path, " ", "_");
}
public void Dispose()
{
this.name = null;
this.url = null;
this.inputPath = null;
}
}
}