/// <summary>
        /// 联网获取指定版本所有的FABRIC
        /// </summary>
        /// <param name="version">要搜索的版本</param>
        /// <returns>Forge列表</returns>
        public async Task <List <JWFabric> > GetFabricList(MCVersion version)
        {
            string json = await HttpRequesterAPI.HttpGetStringAsync(FabricListVEURL);

            var    e = JsonConvert.DeserializeObject <List <JWFabric> >(json);
            string ver;

            if (string.IsNullOrWhiteSpace(version.InheritsVersion))
            {
                ver = version.ID;
            }
            else
            {
                ver = version.InheritsVersion;
            }
            var a = e.Where(b => b.Version == ver).ToList();

            if (a.Count == 0)
            {
                return(null);
            }
            json = await HttpRequesterAPI.HttpGetStringAsync(FabricListURL);

            e = JsonConvert.DeserializeObject <List <JWFabric> >(json);
            return(e);
        }
Beispiel #2
0
        public async Task <BitmapImage> GetByJson(string url)
        {
            string data = await HttpRequesterAPI.HttpGetStringAsync(url);

            if (string.IsNullOrWhiteSpace(data) || data.Contains("error"))
            {
                return(bitmap);
            }
            var obj1       = JObject.Parse(data);
            var properties = obj1["properties"];

            byte[] inArray = Convert.FromBase64String(properties[0]["value"].ToString());
            string c       = Encoding.UTF8.GetString(inArray);

            if (!string.IsNullOrWhiteSpace(c))
            {
                var obj2 = JObject.Parse(c);
                var obj3 = obj2["textures"];
                if (obj3.HasValues)
                {
                    var textures             = obj3["SKIN"]["url"].ToString();
                    HttpResponseMessage temp = await HttpRequesterAPI.HttpGetAsync(textures);

                    var img = Image.FromStream(await temp.Content.ReadAsStreamAsync());
                    return(CaptureImage(img));
                }
                return(bitmap);
            }
            return(bitmap);
        }
Beispiel #3
0
        /// <summary>
        /// 获取丢失的资源文件下载任务
        /// </summary>
        /// <param name="source"></param>
        /// <param name="core"></param>
        /// <param name="version"></param>
        /// <returns></returns>
        public async static Task <List <DownloadTask> > GetLostAssetsDownloadTaskAsync(DownloadSource source, LaunchHandler core, MCVersion ver)
        {
            List <DownloadTask> tasks  = new List <DownloadTask>();
            JAssets             assets = null;

            string assetsPath = core.GetAssetsIndexPath(ver.Assets);

            if (!File.Exists(assetsPath))
            {
                if (ver.AssetIndex != null)
                {
                    string jsonUrl    = GetDownloadUrl.DoURLReplace(source, ver.AssetIndex.URL);
                    string assetsJson = await HttpRequesterAPI.HttpGetStringAsync(jsonUrl);

                    assets = core.GetAssetsByJson(assetsJson);
                    tasks.Add(new DownloadTask("资源文件引导", jsonUrl, assetsPath));
                }
                else
                {
                    return(tasks);
                }
            }
            else
            {
                assets = core.GetAssets(ver);
            }
            var lostAssets = GetLostAssets(core, assets);

            foreach (var item in lostAssets)
            {
                DownloadTask task = GetDownloadUrl.GetAssetsDownloadTask(source, item.Value, core);
                tasks.Add(task);
            }
            return(tasks);
        }
Beispiel #4
0
        public async Task <DownloadTask> GetLatestAICoreDownloadTask(DownloadSource source, string downloadTo)
        {
            string apiBase = string.Empty;

            switch (source)
            {
            case DownloadSource.Mojang:
                apiBase = "https://authlib-injector.yushi.moe/artifact/latest.json";
                break;

            case DownloadSource.BMCLAPI:
                apiBase = "https://bmclapi2.bangbang93.com/mirrors/authlib-injector/artifact/latest.json";
                break;

            default:
                apiBase = "https://authlib-injector.yushi.moe/artifact/latest.json";
                break;
            }
            var    jobj        = JObject.Parse(await HttpRequesterAPI.HttpGetStringAsync(apiBase));
            string downloadURL = jobj.Value <string>("download_url");
            string sha256      = jobj["checksums"].Value <string>("sha256");

            return(new DownloadTask("AuthlibInjector核心", downloadURL, downloadTo)
            {
                Checker = new Util.Checker.SHA256Checker()
                {
                    CheckSum = sha256,
                    FilePath = downloadTo
                }
            });
        }
        /// <summary>
        /// 联网获取指定版本所有的FORGE
        /// </summary>
        /// <param name="version">要搜索的版本</param>
        /// <returns>Forge列表</returns>
        public async Task <List <JWForge> > GetForgeList(MCVersion version)
        {
            string json = await HttpRequesterAPI.HttpGetStringAsync(string.Format("{0}/{1}", ForgeListURL, version.ID));

            var e = JsonConvert.DeserializeObject <List <JWForge> >(json);

            return(e);
        }
        /// <summary>
        /// 联网获取指定版本所有的Liteloader
        /// </summary>
        /// <param name="version">要搜索的版本</param>
        /// <returns>Liteloader列表</returns>
        public async Task <JWLiteloader> GetLiteloaderList(MCVersion version)
        {
            string json = await HttpRequesterAPI.HttpGetStringAsync(string.Format("{0}/?mcversion={1}", LiteloaderListURL, version.ID));

            var e = JsonConvert.DeserializeObject <JWLiteloader>(json);

            return(e);
        }
Beispiel #7
0
        public async Task <APIModules> GetInfoAsync()
        {
            string json = await HttpRequesterAPI.HttpGetStringAsync(string.Format("https://auth2.nide8.com:233/{0}", Nide8ID));

            return(await Task.Factory.StartNew(() =>
            {
                return JsonConvert.DeserializeObject <APIModules>(json);
            }));
        }
Beispiel #8
0
        /// <summary>
        /// 获取全部丢失的文件下载任务
        /// </summary>
        /// <param name="source">下载源</param>
        /// <param name="core">使用的核心</param>
        /// <param name="version">检查的版本</param>
        /// <returns></returns>
        public async static Task <List <DownloadTask> > GetLostDependDownloadTaskAsync(DownloadSource source, LaunchHandler core, MCVersion version, MetroWindow window)
        {
            var lostLibs              = GetLostLibs(core, version);
            var lostNatives           = GetLostNatives(core, version);
            List <DownloadTask> tasks = new List <DownloadTask>();

            if (IsLostJarCore(core, version))
            {
                if (version.Jar == null)
                {
                    tasks.Add(GetDownloadUrl.GetCoreJarDownloadTask(source, version, core));
                }
            }

            if (version.InheritsVersion != null)
            {
                string innerJsonPath = core.GetJsonPath(version.InheritsVersion);
                string innerJsonStr;
                if (!File.Exists(innerJsonPath))
                {
                    innerJsonStr = await HttpRequesterAPI.HttpGetStringAsync(GetDownloadUrl.GetCoreJsonDownloadURL(source, version.InheritsVersion));

                    if (innerJsonStr == null)
                    {
                        await window.ShowMessageAsync("检查错误", "检查源错误,请切换下载源后重试");

                        return(new List <DownloadTask>());
                    }
                    string jsonFolder = Path.GetDirectoryName(innerJsonPath);
                    if (!Directory.Exists(jsonFolder))
                    {
                        Directory.CreateDirectory(jsonFolder);
                    }
                    File.WriteAllText(innerJsonPath, innerJsonStr);
                }
                else
                {
                    innerJsonStr = File.ReadAllText(innerJsonPath);
                }
                MCVersion innerVer = core.JsonToVersion(innerJsonStr);
                if (innerVer != null)
                {
                    tasks.AddRange(await GetLostDependDownloadTaskAsync(source, core, innerVer, window));
                }
            }
            foreach (var item in lostLibs)
            {
                tasks.Add(GetDownloadUrl.GetLibDownloadTask(source, item));
            }
            foreach (var item in lostNatives)
            {
                tasks.Add(GetDownloadUrl.GetNativeDownloadTask(source, item));
            }
            return(tasks);
        }
        /// <summary>
        /// 联网获取版本列表
        /// </summary>
        /// <returns>版本列表</returns>
        public async Task <List <JWVersion> > GetVersionList()
        {
            string json = await HttpRequesterAPI.HttpGetStringAsync(VersionListURL);

            if (json != null)
            {
                var e = JsonConvert.DeserializeObject <JWVersions>(json);
                return(e.Versions);
            }
            return(null);
        }