private bool CheckDownloadRequireLibrary(MLibrary lib) { return(lib.IsRequire && lib.Path != "" && lib.Url != "" && !CheckFileValidation(lib.Path, lib.Hash)); }
private static MLibrary createMLibrary(string name, string nativeId, JObject job) { var path = job["path"]?.ToString(); if (path == null || path == "") { path = NameToPath(name, nativeId); } var url = job["url"]?.ToString(); if (url == null) { url = DefaultLibraryServer + path; } else if (url.Split('/').Last() == "") { url += path; } var hash = job["sha1"] ?? job["checksums"]?[0]; var library = new MLibrary(); library.Hash = hash?.ToString() ?? ""; library.IsNative = (nativeId != ""); library.Name = name; library.Path = System.IO.Path.Combine(Minecraft.Library, path); library.Url = url; return(library); }
private static MProfile ParseFromJson(string json) { var profile = new MProfile(); var job = JObject.Parse(json); profile.Id = job["id"]?.ToString(); var assetindex = (JObject)job["assetIndex"]; if (assetindex != null) { profile.AssetId = n(assetindex["id"]?.ToString()); profile.AssetUrl = n(assetindex["url"]?.ToString()); profile.AssetHash = n(assetindex["sha1"]?.ToString()); } var client = job["downloads"]?["client"]; if (client != null) { profile.ClientDownloadUrl = client["url"]?.ToString(); profile.ClientHash = client["sha1"]?.ToString(); } profile.Libraries = MLibrary.ParseJson((JArray)job["libraries"]); profile.MainClass = n(job["mainClass"]?.ToString()); var ma = job["minecraftArguments"]?.ToString(); if (ma != null) { profile.MinecraftArguments = ma; } var ag = job["arguments"]?.ToString(); if (ag != null) { profile.Arguments = ag; } profile.ReleaseTime = job["releaseTime"]?.ToString(); var ype = job["type"]?.ToString(); profile.TypeStr = ype; switch (ype) { case "release": profile.Type = MProfileType.Release; break; case "snapshot": profile.Type = MProfileType.Snapshot; break; case "old_alpha": profile.Type = MProfileType.OldAlpha; break; default: profile.Type = MProfileType.Unknown; break; } if (job["jar"] != null) { profile.IsForge = true; profile.InnerJarId = job["jar"].ToString(); } var path = Minecraft.Versions + profile.Id; Directory.CreateDirectory(path); File.WriteAllText(path + "\\" + profile.Id + ".json", json); return(profile); }
internal static MLibrary[] ParseJson(JArray json) { var list = new List <MLibrary>(json.Count); foreach (JObject item in json) { try { var name = item["name"]?.ToString(); // FORGE 라이브러리 if (item["downloads"] == null) { bool isn = item["natives"]?["windows"] != null; var nativeStr = ""; if (isn) { nativeStr = item["natives"]["windows"].ToString(); } if (name == null) { continue; } list.Add(new MLibrary(name, nativeStr, item)); continue; } // NATIVE 라이브러리 var classif = item["downloads"]["classifiers"]; if (classif != null) { JObject job = null; bool isgo = true; var nativeId = ""; if (classif["natives-windows-64"] != null && Environment.Is64BitOperatingSystem) { nativeId = "natives-windows-64"; } else if (classif["natives-windows-32"] != null) { nativeId = "natives-windows-32"; } else if (classif["natives-windows"] != null) { nativeId = "natives-windows"; } else { isgo = false; } job = (JObject)classif[nativeId]; if (isgo) { var obj = new MLibrary(name, nativeId, job); list.Add(obj); } } // 일반 LIBRARY var arti = item["downloads"]["artifact"]; if (arti != null) { var job = (JObject)arti; var obj = new MLibrary(name, "", job); list.Add(obj); } } catch { } } return(list.ToArray()); }