diff --git a/src/main/java/com/nexia/installer/game/VersionHandler.java b/src/main/java/com/nexia/installer/game/VersionHandler.java index d7157d4..91c0e53 100644 --- a/src/main/java/com/nexia/installer/game/VersionHandler.java +++ b/src/main/java/com/nexia/installer/game/VersionHandler.java @@ -10,7 +10,7 @@ public class VersionHandler { public static GameVersion CombatTest8b = new GameVersion("Combat Test 8b", "1.16_combat-5", new Download("9b2b984d635d373564b50803807225c75d7fd447", "https://launcher.mojang.com/experiments/combat/9b2b984d635d373564b50803807225c75d7fd447/1_16_combat-5.zip")); - public static GameVersion CombatTest8 = new GameVersion("Combat Test 8", "1.16_combat-4", new Download("b4306b421183bd084b2831bd8d33a5db05ae9f9c", "https://notcoded.needs.rest/r/1_16_combat-4.zip")); + public static GameVersion CombatTest8 = new GameVersion("Combat Test 8", "1.16_combat-4", new Download("b4306b421183bd084b2831bd8d33a5db05ae9f9c", "https://archive.org/download/1-16-combat-4_202404/1_16_combat-4.zip")); public static GameVersion CombatTest7c = new GameVersion("Combat Test 7c", "1.16_combat-3", new Download("2557b99d95588505e988886220779087d7d6b1e9", "https://piston-data.mojang.com/experiments/combat/2557b99d95588505e988886220779087d7d6b1e9/1_16_combat-3.zip")); diff --git a/src/main/java/com/nexia/installer/util/InstallerHelper.java b/src/main/java/com/nexia/installer/util/InstallerHelper.java index daa2ae6..6eeceb5 100644 --- a/src/main/java/com/nexia/installer/util/InstallerHelper.java +++ b/src/main/java/com/nexia/installer/util/InstallerHelper.java @@ -57,9 +57,8 @@ public JPanel setPanel(InstallerGUI gui) { buttonInstall.setEnabled(false); try { launch(); - } catch (IOException | RuntimeException ex) { - InstallerUtils.showError(ex.getMessage()); - ex.printStackTrace(); + } catch (Exception ex) { + InstallerUtils.showError(ex); } }); diff --git a/src/main/java/com/nexia/installer/util/InstallerUtils.java b/src/main/java/com/nexia/installer/util/InstallerUtils.java index 9ca0d9b..80fc73c 100644 --- a/src/main/java/com/nexia/installer/util/InstallerUtils.java +++ b/src/main/java/com/nexia/installer/util/InstallerUtils.java @@ -7,10 +7,7 @@ import javax.swing.*; import java.io.File; import java.net.URI; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.StandardCopyOption; +import java.nio.file.*; import java.text.MessageFormat; import java.util.List; @@ -31,10 +28,10 @@ public static Path findDefaultInstallDir() { if (Main.os.equals(Main.OS.LINUX) && !Files.exists(dir)) { // https://github.com/flathub/com.mojang.Minecraft - final Path flatpack = homeDir.resolve(".var").resolve("app").resolve("com.mojang.Minecraft").resolve(".minecraft"); + final Path flatpak = homeDir.resolve(".var").resolve("app").resolve("com.mojang.Minecraft").resolve(".minecraft"); - if (Files.exists(flatpack)) { - dir = flatpack; + if (Files.exists(flatpak)) { + dir = flatpak; } } } @@ -92,6 +89,7 @@ public static void install(Path mcDir, VersionHandler.GameVersion gameVersion) { Files.copy(aProfileJson, profileJson, StandardCopyOption.REPLACE_EXISTING); + //System.out.println(Utils.sha1String(zipFile.toPath()).equalsIgnoreCase(gameVersion.getDownload().sha1)); aProfileJson.toFile().delete(); aProfileDir.toFile().delete(); @@ -106,7 +104,7 @@ public static void install(Path mcDir, VersionHandler.GameVersion gameVersion) { } showDone(gameVersion); } catch (Exception e) { - e.printStackTrace(); + InstallerUtils.showError(e); } finally { InstallerHelper.buttonInstall.setEnabled(true); } @@ -133,10 +131,15 @@ public static ProfileInstaller.LauncherType showLauncherTypeSelection() { return result == JOptionPane.YES_OPTION ? ProfileInstaller.LauncherType.MICROSOFT_STORE : ProfileInstaller.LauncherType.WIN32; } + public static void showError(Throwable throwable) { + throwable.printStackTrace(); + showError(throwable.getClass().getSimpleName() + ": " + throwable.getMessage()); + } + public static void showError(String error) { Object[] options = {"Restart Program"}; int result = JOptionPane.showOptionDialog(null, - error, + Main.BUNDLE.getString("installer.prompt.install.error") + "\n\n" + error, Main.BUNDLE.getString("installer.title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.ERROR_MESSAGE, diff --git a/src/main/java/com/nexia/installer/util/Utils.java b/src/main/java/com/nexia/installer/util/Utils.java index b828cdb..3ba56af 100644 --- a/src/main/java/com/nexia/installer/util/Utils.java +++ b/src/main/java/com/nexia/installer/util/Utils.java @@ -69,8 +69,7 @@ public static void downloadFile(URL url, Path path) { t.addSuppressed(t2); } - InstallerUtils.showError(t.getMessage()); - t.printStackTrace(); + InstallerUtils.showError(t); } } diff --git a/src/main/java/com/nexia/installer/util/fabric/FabricInstallerHelper.java b/src/main/java/com/nexia/installer/util/fabric/FabricInstallerHelper.java index 42c4034..4ca5fde 100644 --- a/src/main/java/com/nexia/installer/util/fabric/FabricInstallerHelper.java +++ b/src/main/java/com/nexia/installer/util/fabric/FabricInstallerHelper.java @@ -2,7 +2,10 @@ import com.nexia.installer.InstallerGUI; import com.nexia.installer.Main; -import com.nexia.installer.util.*; +import com.nexia.installer.util.HttpAPI; +import com.nexia.installer.util.InstallerHelper; +import com.nexia.installer.util.InstallerUtils; +import com.nexia.installer.util.Utils; import mjson.Json; import javax.swing.*; @@ -18,7 +21,6 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.text.MessageFormat; -import java.util.List; import java.util.Objects; public class FabricInstallerHelper extends InstallerHelper { @@ -50,7 +52,7 @@ public JPanel setPanel(InstallerGUI gui) { } addRow(panel, c, "installer.prompt.select.location", - installLocation = new JTextField(20), + installLocation = new JTextField(21), selectFolderButton = new JButton()); selectFolderButton.setText("..."); // It looks better when the width is set to height, so..... @@ -68,9 +70,8 @@ public JPanel setPanel(InstallerGUI gui) { buttonInstall.setEnabled(false); try { launch(); - } catch (IOException | RuntimeException ex) { - InstallerUtils.showError(ex.getMessage()); - ex.printStackTrace(); + } catch (Exception ex) { + InstallerUtils.showError(ex); } }); @@ -129,13 +130,13 @@ public void launch() throws IOException { if (successBufferedInputStream.available() == 0) hasError = true; if(hasError) { - InstallerUtils.showError(Main.BUNDLE.getString("installer.prompt.install.error")); + InstallerUtils.showError("The Fabric installer has had an unknown error."); } else { this.showDone(gameVersion); } - } catch (Exception ignored) { - InstallerUtils.showError(Main.BUNDLE.getString("installer.prompt.install.error")); + } catch (Exception e) { + InstallerUtils.showError(e); } buttonInstall.setEnabled(true); diff --git a/src/main/resources/lang/installer.properties b/src/main/resources/lang/installer.properties index 30e9bb0..8370894 100644 --- a/src/main/resources/lang/installer.properties +++ b/src/main/resources/lang/installer.properties @@ -11,7 +11,7 @@ installer.prompt.launcher.type.win32=Standalone (Win32) installer.title=Combat Test Installer installer.option.create.profile=Create profile -installer.prompt.install.error=An error has occurred, click "OK" to restart the program or click "Cancel" to continue. +installer.prompt.install.error=An error has occurred, click "Restart Program" to restart the program.\nIt would be appreciated if you sent a screenshot of this error to the developers. installer.button.fabric=Open the Fabric Installer installer.tab.vanilla=Vanilla