public static List <ClassifierLibrary> SiphonClassifiers(MinecraftProfile ver) { List <ClassifierLibrary> result = new List <ClassifierLibrary>(); foreach (var libc in ver.Libraries) { if (libc.Downloads != null) { JObject obj = libc.Downloads.JSON; if (obj["downloads"]["classifiers"] != null) { if (obj["downloads"]["classifiers"]["natives-windows"] != null) { ClassifierLibrary lib = new ClassifierLibrary(); lib.LibraryDirector = obj["downloads"]["classifiers"]["natives-windows"]["path"].ToString(); lib.SiteURL = obj["downloads"]["classifiers"]["natives-windows"]["url"].ToString(); lib.HashCode = obj["downloads"]["classifiers"]["natives-windows"]["sha1"].ToString(); lib.Profile = ver; result.Add(lib); } } } } return(result); }
public static APIConfig GetFromMinecraft(MinecraftProfile profile) { return(new APIConfig() { GameProfile = profile }); }
public LibraryDownloads(JObject json, MinecraftProfile profile, VersionLibrary parent) { this.Parent = parent; JSON = json; this.Profile = profile; Download.AddRange(ArtifactLibrary.GetLibraryFromLibDownload(this)); Download.AddRange(ClassifierLibrary.GetLibraryFromLibDownload(this)); }
public static AssetIndex FromVersion(MinecraftProfile profile) { AssetIndex index = new AssetIndex(); index.JSON = JObject.Parse(File.ReadAllText(Path.Combine(GameSettings.SelectedGameDirectory.ToString(), "assets\\indexes", profile.VersionName, profile.VersionName + ".json"))); index.ID = profile.JSON["assetIndex"]["id"].ToString(); index.HashCode = profile.JSON["assetIndex"]["sha1"].ToString(); return(index); }
public static List <ArtifactLibrary> SiphonArtifact(MinecraftProfile ver) { List <ArtifactLibrary> result = new List <ArtifactLibrary>(); foreach (var libc in ver.Libraries) { if (libc.Downloads != null) { JObject obj = libc.Downloads.JSON; if (obj["downloads"]["artifact"] == null && obj["downloads"]["classifiers"] == null) { obj = libc.Downloads.JSON; ArtifactLibrary lib = new ArtifactLibrary(); //Probably some api's JSON,Only provide program name and URL; if (obj["url"] == null) { lib.SiteURL = "https://libraries.minecraft.net/"; } else { lib.SiteURL = obj["url"].ToString(); } lib.LibraryName = LibraryName.Parse(obj["name"].ToString()); lib.HashCode = ""; lib.Profile = libc.Downloads.Profile; result.Add(lib); } else if (obj["downloads"]["artifact"] == null) { } else { ArtifactLibrary lib = new ArtifactLibrary(); lib.LibraryName = LibraryName.Parse(obj["name"].ToString()); lib.HashCode = obj["downloads"]["artifact"]["sha1"].ToString(); obj = libc.Downloads.Profile.JSON; if (obj["url"] == null) { lib.SiteURL = "https://libraries.minecraft.net/"; } else { lib.SiteURL = obj["url"].ToString(); } lib.Profile = ver; result.Add(lib); } return(result); } } return(result); }
/// <summary> /// 开始下载 /// </summary> public void Download(DownloadingEventHandler eve) { percent = 0; DownloadProgressRefreshed(this, new EventArgs()); if (MinecraftVersion == null) { throw new Exception("Minecraft Version Can't be NULL"); } else { MinecraftProfile profile = MinecraftProfile.GetFromVersion(MinecraftVersion, VersionName); profile.SaveToLocalPath(); profile.InstallVersion((float f) => { eve(f * (1f - ((float)APIVersions.Count / 10f))); }); if (APIVersions.Count == 0) { } else { int count = APIVersions.Values.Count; int dldd = 0; foreach (var api in APIVersions.Values) { MinecraftAPI mcapi = api.GetMinecraftAPI(); mcapi.profile = profile; profile.APIConfig.InstallAPI(mcapi, (float f) => { eve((1f - ((float)APIVersions.Count / 10f)) + (float)(f / 10f) + (float)(dldd / 10f)); }); dldd++; } } } }