/// <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); }
public static async Task <bool> IsLostAssetsAsync(DownloadSource source, LaunchHandler core, Version ver) { string assetsPath = core.GetAssetsIndexPath(ver.Assets); if (!File.Exists(assetsPath)) { return(ver.AssetIndex != null); } else { var assets = await core.GetAssetsAsync(ver); return(await Task.Factory.StartNew(() => { return IsLostAnyAssetsFromJassets(core, assets); })); } }
public JAssets GetAssets(Modules.Version version) { try { lock (locker) { string assetsPath = handler.GetAssetsIndexPath(version.Assets); if (!File.Exists(assetsPath)) { return(null); } var ja = GetAssetsByJson(File.ReadAllText(assetsPath)); return(ja); } } catch (Exception) { return(null); } }
/// <summary> /// 获取丢失的资源文件下载任务 /// </summary> /// <param name="source"></param> /// <param name="core"></param> /// <param name="version"></param> /// <returns></returns> public static List <DownloadTask> GetLostAssetsDownloadTask(DownloadSource source, LaunchHandler core, Version 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 = FunctionAPIHandler.HttpGet(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); if (!tasks.Contains(task)) { tasks.Add(task); } } return(tasks); }
public static async Task <bool> IsLostAssetsAsync(DownloadSource source, LaunchHandler core, Version ver) { string assetsPath = core.GetAssetsIndexPath(ver.Assets); if (!File.Exists(assetsPath)) { if (ver.AssetIndex == null) { return(false); } else { return(true); } } else { var assets = await core.GetAssetsAsync(ver); return(await Task.Factory.StartNew(() => { foreach (var item in assets.Objects) { if (File.Exists(core.GetAssetsPath(item.Value))) { continue; } else { return true; } } return false; })); } }