private bool CheckJavaAssets(IProgressReceiver progressReceiver, out byte[] javaResources) { try { 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); } } catch (Exception ex) { Log.Error(ex, $"Could not check for latests assets! Are you connected to the internet?"); javaResources = null; //bedrockResources = null; return(false); } return(true); }
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 CheckJavaAssets(IProgressReceiver progressReceiver, out string javaResources) { try { string assetDirectory = Path.Combine("assets", "java"); string storedVersion; AssetsUtil.TryGetStoredVersion(out storedVersion); DirectoryInfo directoryInfo = null; if (storedVersion == null || !storedVersion.Equals(JavaProtocol.VersionId) || !Storage.TryGetDirectory(assetDirectory, out directoryInfo)) { Storage.TryDeleteDirectory(assetDirectory); var zipPath = AssetsUtil.EnsureTargetReleaseAsync(JavaProtocol.VersionId, progressReceiver) .Result; if (Storage.TryCreateDirectory(assetDirectory) && Storage.TryGetDirectory(assetDirectory, out directoryInfo)) { Log.Info($"Extracting resources...."); using (ZipArchive zipArchive = new ZipArchive(Storage.OpenFileStream(zipPath, FileMode.Open))) { zipArchive.ExtractToDirectory(directoryInfo.FullName, true); } } } if (directoryInfo != null) { javaResources = directoryInfo.FullName; return(true); } javaResources = null; return(false); } catch (Exception ex) { Log.Error(ex, $"Could not check for latests assets! Are you connected to the internet?"); javaResources = null; //bedrockResources = null; return(false); } return(true); }