private bool CheckRequiredPaths(IProgressReceiver progressReceiver, out byte[] javaResources, out byte[] bedrockResources) { bedrockResources = null; try { Log.Info($"Verifiying assets..."); string path = AssetsUtil.EnsureTargetReleaseAsync(JavaProtocol.VersionId, progressReceiver).Result; if (!Storage.TryReadBytes(path, out javaResources)) { Log.Error($"Could not load any assets! Are you connected to the internet?"); javaResources = null; //bedrockResources = null; return(false); } string bedrockPath = BedrockAssetUtil.CheckAndDownloadResources(progressReceiver).Result; if (!Storage.TryReadBytes(bedrockPath, out bedrockResources)) { Log.Error("Could not load any of the required Bedrock assets! Are you connected to the internet?"); return(false); } } catch (Exception ex) { Log.Error(ex, $"Could not check for latests assets! Do you have a internet connection up?"); javaResources = null; //bedrockResources = null; return(false); } return(true); }
private bool CheckBedrockAssets(IProgressReceiver progressReceiver, out string bedrockResources) { bedrockResources = null; try { string targetPath = Path.Combine("assets", "bedrock"); string bedrockPath; if (!BedrockAssetUtil.CheckUpdate(progressReceiver, out bedrockPath)) { if (Storage.TryGetDirectory(targetPath, out var directoryInfo)) { bedrockResources = directoryInfo.FullName; return(true); } } if (string.IsNullOrWhiteSpace(bedrockPath) || !Storage.Exists(bedrockPath)) { Log.Warn("Could not load any of the required Bedrock assets! Are you connected to the internet?"); Log.Warn($"A manual fix is available, see: https://github.com/kennyvv/Alex/wiki/Bedrock-Assets"); return(false); } Storage.TryDeleteDirectory(targetPath); if (Storage.TryCreateDirectory(targetPath) && Storage.TryGetDirectory(targetPath, out var di)) { using (ZipArchive zipArchive = new ZipArchive(Storage.OpenFileStream(bedrockPath, FileMode.Open))) { zipArchive.ExtractToDirectory(di.FullName); } bedrockResources = di.FullName; return(true); } } catch (Exception ex) { Log.Error(ex, $"Could not check for latests assets! Are you connected to the internet?"); return(false); } return(false); }
private bool CheckBedrockAssets(IProgressReceiver progressReceiver, out byte[] bedrockResources) { bedrockResources = null; try { string bedrockPath = BedrockAssetUtil.CheckAndDownloadResources(progressReceiver).Result; if (string.IsNullOrWhiteSpace(bedrockPath) || !Storage.TryReadBytes(bedrockPath, out bedrockResources)) { Log.Warn("Could not load any of the required Bedrock assets! Are you connected to the internet?"); Log.Warn($"A manual fix is available, see: https://github.com/kennyvv/Alex/wiki/Bedrock-Assets"); return(false); } } catch (Exception ex) { Log.Error(ex, $"Could not check for latests assets! Are you connected to the internet?"); return(false); } return(true); }