Пример #1
0
 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));
 }
Пример #2
0
        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);
        }
Пример #3
0
        public static List <ArtifactLibrary> GetLibraryFromLibDownload(LibraryDownloads download)
        {
            List <ArtifactLibrary> result = new List <ArtifactLibrary>();
            JObject obj = download.JSON;

            if (obj["downloads"]["artifact"] == null && obj["downloads"]["classifiers"] == null)
            {
                obj = download.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     = download.Profile;
                result.Add(lib);
            }
            else if (obj["downloads"]["artifact"] == null)
            {
            }
            else
            {
                ArtifactLibrary lib = new ArtifactLibrary();
                lib.LibraryName = LibraryName.Parse(obj["name"].ToString());
                lib.SerialsUrl  = obj["downloads"]["artifact"]["url"].ToString();
                lib.HashCode    = obj["downloads"]["artifact"]["sha1"].ToString();
                obj             = download.Profile.JSON;
                if (obj["url"] == null)
                {
                    lib.SiteURL = "https://libraries.minecraft.net/";
                }
                else
                {
                    lib.SiteURL = obj["url"].ToString();
                }
                lib.Profile = download.Profile;
                lib.JSON    = obj;
                result.Add(lib);
            }
            return(result);
        }