public GameVersion GetGameVersion(string mcversion) { VersionsVersion oVersion = null; try { if (_versions == null) { GetVersionManifest(); } foreach (VersionsVersion version in _versions.Versions) { if (version.Id.Equals(mcversion)) { oVersion = version; break; } } // throw execption when version not found if (oVersion == null) { throw new Exception("Minecraft version not found."); } string sVersion = Http.GET(oVersion.Url); return(GameVersion.FromJson(sVersion)); } catch (Exception ex) { throw ex; } }
private VersionsVersion GetVersion(string sVersion) { VersionsVersion oVersion = null; try { if (_versions == null) { GetVersionManifest(); } foreach (VersionsVersion version in _versions.Versions) { if (version.Id.Equals(sVersion)) { oVersion = version; break; } } // throw execption when version not found if (oVersion == null) { throw new Exception("Minecraft version not found."); } //return verison object return(oVersion); } catch (Exception ex) { throw ex; } }
public void DownloadVersionJson(string mcversion) { try { // create directory if not exists if (!Directory.Exists(VersionDir + @"\" + mcversion)) { Directory.CreateDirectory(VersionDir + @"\" + mcversion); } VersionsVersion version = GetVersion(mcversion); // delete and download json if (File.Exists(VersionDir + @"\" + mcversion + @"\" + mcversion + ".json")) { File.Delete(VersionDir + @"\" + mcversion + @"\" + mcversion + ".json"); } dhelper.DownloadFileTo(version.Url, VersionDir + @"\" + mcversion + @"\" + mcversion + ".json", false); } catch (Exception ex) { throw ex; } }