From 2e1d9bd9b33b15dcdc125a501ef4eb759fc2e37a Mon Sep 17 00:00:00 2001 From: CoocooFroggy <45371102+CoocooFroggy@users.noreply.github.com> Date: Thu, 24 Mar 2022 23:26:30 -0400 Subject: [PATCH] Download FRGUI prerelease versions if on a prerelease --- src/main/java/FRUtils.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/FRUtils.java b/src/main/java/FRUtils.java index 53a219c..c876946 100644 --- a/src/main/java/FRUtils.java +++ b/src/main/java/FRUtils.java @@ -119,11 +119,19 @@ public static File downloadFRGUI(MainMenu mainMenuInstance, String frguiDownload String frguiDownloadName = null; String frguiDownloadUrl = null; try { - System.out.println("Finding download..."); - URL releasesApiUrl = new URL("https://api.github.com/repos/CoocooFroggy/FutureRestore-GUI/releases/latest"); - String releasesApiResponse = IOUtils.toString(releasesApiUrl.openConnection().getInputStream(), StandardCharsets.UTF_8); Gson gson = new Gson(); - Map latestReleaseApi = gson.fromJson(releasesApiResponse, Map.class); + System.out.println("Finding download..."); + Map latestReleaseApi; + if (Main.futureRestoreGUIPrerelease) { + URL releasesApiUrl = new URL("https://api.github.com/repos/CoocooFroggy/FutureRestore-GUI/releases"); + String releasesApiResponse = IOUtils.toString(releasesApiUrl.openConnection().getInputStream(), StandardCharsets.UTF_8); + ArrayList> releasesApi = gson.fromJson(releasesApiResponse, ArrayList.class); + latestReleaseApi = releasesApi.get(0); + } else { + URL releasesApiUrl = new URL("https://api.github.com/repos/CoocooFroggy/FutureRestore-GUI/releases/latest"); + String releasesApiResponse = IOUtils.toString(releasesApiUrl.openConnection().getInputStream(), StandardCharsets.UTF_8); + latestReleaseApi = gson.fromJson(releasesApiResponse, Map.class); + } ArrayList> assetsApi = (ArrayList>) latestReleaseApi.get("assets");