public override List <DownloadAPI> GetFromVersion(GameVersion version) { List <DownloadAPI> result = new List <DownloadAPI>(); JArray arr = JArray.Parse(Post.Get_Data(AddrTranslater.TranslateURL("https://bmclapi2.bangbang93.com/forge/minecraft/") + version.VersionName, new System.Net.CookieContainer(), "utf-8", "")); foreach (JObject obj in arr) { bool r = false; foreach (JObject file in obj["files"] as JArray) { if (file["category"].ToString() == "installer") { Logger.LogInfo("Find Forge Version " + obj["version"] + " for " + version.VersionName); Forge forge = new Forge(); forge.mc = version; forge.time = DateTime.Parse(obj["modified"].ToString()).ToString("yyyy-MM-dd"); forge.version = obj["version"].ToString(); result.Add(forge); } } } result.Reverse(); return(result); }
public static List <GameVersion> GetAllVersions() { List <GameVersion> result = new List <GameVersion>(); JObject obj = JObject.Parse(Post.Get_Data(AddrTranslater.TranslateURL("http://launchermeta.mojang.com/mc/game/version_manifest.json"), new System.Net.CookieContainer(), "utf-8", "")); string version = obj["latest"]["release"].ToString(); string snapshot = obj["latest"]["snapshot"].ToString(); foreach (JObject ver in obj["versions"] as JArray) { GameVersion item = new GameVersion(); item.VersionName = ver["id"].ToString(); item.UpdateDate = DateTime.Parse(ver["releaseTime"].ToString()).ToString("yyyy-MM-dd"); item.JSONURL = ver["url"].ToString(); if (item.VersionName == "1.12.2") { item.isRecommended = true; } if (item.VersionName == "1.8.9") { item.isRecommended = true; } if (item.VersionName == version) { item.isRecommended = true; } if (item.VersionName == snapshot) { item.isRecommended = true; } if (ver["type"].ToString() == "release") { item.versionType = GameVersionTypes.Release; } else if (ver["type"].ToString() == "snapshot") { item.versionType = GameVersionTypes.Snapshot; } else { item.versionType = GameVersionTypes.Old; } result.Add(item); } return(result); }
public override List <DownloadAPI> GetFromVersion(GameVersion version) { try { List <DownloadAPI> result = new List <DownloadAPI>(); JArray arr = JArray.Parse(Post.Get_Data(AddrTranslater.TranslateURL("https://meta.fabricmc.net/v2/versions/loader/") + version.VersionName, new System.Net.CookieContainer(), "utf-8", "")); foreach (JObject obj in arr) { Logger.LogInfo("Find Fabric Version " + obj["loader"]["version"] + " for " + version.VersionName); Fabric fabric = new Fabric(); fabric.mc = version; fabric.time = version.UpdateDate; fabric.version = obj["loader"]["version"].ToString().Replace("+build.", "."); { string package = ""; package = obj["loader"]["maven"].ToString(); string[] splitedPackage = package.Split(':'); string url = "https://meta.fabricmc.net/"; url += splitedPackage[0].Replace(".", "/") + "/"; url += splitedPackage[1] + "/"; url += splitedPackage[2] + "/"; url += splitedPackage[1] + "-" + splitedPackage[2] + ".jar"; fabric.addr = url; } result.Add(fabric); } return(result); } catch (Exception ex) { if (ex.Message.Contains("404")) { return(new List <DownloadAPI>()); } else { return(new List <DownloadAPI>()); } } }