Skip to content

Commit

Permalink
errors get shown now
Browse files Browse the repository at this point in the history
  • Loading branch information
not-coded committed Mar 7, 2024
1 parent efe491c commit 3cdad23
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 32 deletions.
5 changes: 3 additions & 2 deletions src/main/java/com/nexia/installer/util/InstallerHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ public JPanel setPanel(InstallerGUI gui) {
buttonInstall.setEnabled(false);
try {
launch();
} catch (IOException ex) {
throw new RuntimeException(ex);
} catch (IOException | RuntimeException ex) {
InstallerUtils.showError(ex.getMessage());
ex.printStackTrace();
}
});

Expand Down
23 changes: 23 additions & 0 deletions src/main/java/com/nexia/installer/util/InstallerUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,29 @@ public static ProfileInstaller.LauncherType showLauncherTypeSelection() {
return result == JOptionPane.YES_OPTION ? ProfileInstaller.LauncherType.MICROSOFT_STORE : ProfileInstaller.LauncherType.WIN32;
}

public static void showError(String error) {
Object[] options = {"Restart Program"};
int result = JOptionPane.showOptionDialog(null,
error,
Main.BUNDLE.getString("installer.title"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.ERROR_MESSAGE,
null,
options,
options[0]
);

if(result == JOptionPane.OK_OPTION) {
try {
InstallerGUI.instance.dispose();
Main.main(new String[]{});
} catch (Exception ignored) {
System.exit(0);
}
}

}

private static void showDone(VersionHandler.GameVersion gameVersion) {
Object[] options = {"OK", "Install Fabric"};
int result = JOptionPane.showOptionDialog(null,
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/nexia/installer/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public static String getProfileIcon() {

return "data:image/png;base64," + Base64.getEncoder().encodeToString(Arrays.copyOf(ret, offset));
} catch (IOException e) {
return "furnace"; // Fallback to furnace icon if we cant load Nexia icon.
return "furnace"; // Fallback to default icon if we cant load the icon.
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ public JPanel setPanel(InstallerGUI gui) {
buttonInstall.setEnabled(false);
try {
launch();
} catch (IOException ex) {
throw new RuntimeException(ex);
} catch (IOException | RuntimeException ex) {
InstallerUtils.showError(ex.getMessage());
ex.printStackTrace();
}
});

Expand Down Expand Up @@ -124,13 +125,13 @@ public void launch() throws IOException {
if (successBufferedInputStream.available() == 0) hasError = true;

if(hasError) {
this.error();
InstallerUtils.showError(Main.BUNDLE.getString("installer.prompt.install.error"));
} else {
this.showDone(gameVersion);
}

} catch (Exception ignored) {
this.error();
InstallerUtils.showError(Main.BUNDLE.getString("installer.prompt.install.error"));
}

buttonInstall.setEnabled(true);
Expand Down Expand Up @@ -170,7 +171,7 @@ private File getJarFile() throws IOException {

private String getFabricVersion() {

String version = "0.11.1";
String version = "0.11.2";

try {
String response = HttpAPI.get("https://api.github.com/repos/rizecookey/fabric-installer/releases/latest");
Expand All @@ -197,29 +198,5 @@ private void showDone(FabricVersionHandler.GameVersion gameVersion) {

if(result == JOptionPane.NO_OPTION) InstallerGUI.instance.pane.setSelectedComponent(InstallerGUI.instance.vanilla);
}

private void error() {
Object[] options = {"OK", "Cancel"};
int result = JOptionPane.showOptionDialog(null,
MessageFormat.format(Main.BUNDLE.getString("installer.prompt.install.error"), ""),
Main.BUNDLE.getString("installer.title"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.ERROR_MESSAGE,
null,
options,
options[0]
);

if(result == JOptionPane.OK_OPTION) {
try {
InstallerGUI.instance.dispose();
Main.main(new String[]{});
} catch (Exception ignored) {
System.exit(0);
}
}

buttonInstall.setEnabled(true);
}
}

1 change: 1 addition & 0 deletions src/main/resources/lang/installer.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ installer.button.install=Install
installer.prompt.install.done={0} has been installed, if you want to install fabric then click on the "Install Fabric" button.
installer.prompt.install.done.fabric={0} has been installed, if you want to install vanilla then click on the "Install Vanilla" button.
installer.exception.no.launcher.directory=No launcher directory found!
installer.exception.no.launcher.profile=No launcher profile.json found!
installer.prompt.launcher.type.body=The Combat Test Installer has detected 2 different installations of the Minecraft Launcher, which launcher do you wish to install the Combat Tests to?\n\n- Select Microsoft Store if you are playing Minecraft through the Xbox App or the Windows Store.\n- Select Standalone if you downloaded the Minecraft launcher directly from the Minecraft.net website.\n\nIf you are unsure try the Microsoft Store option first, you can always re-run the installer.
installer.prompt.launcher.type.xbox=Microsoft Store / Xbox
installer.prompt.launcher.type.win32=Standalone (Win32)
Expand Down

0 comments on commit 3cdad23

Please sign in to comment.