/// <summary> /// Download a new copy of the BuildTools jar /// </summary> /// <returns>True if the update was successful</returns> public bool UpdateJar() { if (!Directory.Exists(Dir)) { Directory.CreateDirectory(Dir); } _form.AppendText("Checking for update"); _form.ProgressShow(); _form.ProgressIndeterminate(); bool update = CheckUpdate(out bool bad); if (update) { _form.AppendText("Update needed for BuildTools"); if (!GetJson()) { return(false); } if (File.Exists(Dir + (string)_json["buildTools"]["name"])) { _form.AppendText("Deleting current BuildTools"); File.Delete(Dir + (string)_json["buildTools"]["name"]); } string baseUrl = (string)_api["url"]; string relativePath = (string)_api["artifacts"][0]["relativePath"]; string fullUrl = baseUrl + "artifact/" + relativePath; _form.AppendText("Downloading BuildTools"); if (!DownloadFile(fullUrl, Dir + (string)_json["buildTools"]["name"])) { _form.AppendText("BuildTools failed to download"); return(false); } _form.AppendText("Download complete"); } else { if (!bad) { _form.AppendText("BuildTools is up to date, no need to update"); } else { return(false); } } return(true); }