Skip to content

Commit

Permalink
woahh
Browse files Browse the repository at this point in the history
- change combat test 8 to archive.org link
- improve error showing to user
- make install location and button not change sizes when moving tabs
  • Loading branch information
not-coded committed Aug 2, 2024
1 parent e344203 commit 951016e
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/nexia/installer/game/VersionHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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"));

Expand Down
5 changes: 2 additions & 3 deletions src/main/java/com/nexia/installer/util/InstallerHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});

Expand Down
21 changes: 12 additions & 9 deletions src/main/java/com/nexia/installer/util/InstallerUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}
}
}
Expand Down Expand Up @@ -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();
Expand All @@ -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);
}
Expand All @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/nexia/installer/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ public static void downloadFile(URL url, Path path) {
t.addSuppressed(t2);
}

InstallerUtils.showError(t.getMessage());
t.printStackTrace();
InstallerUtils.showError(t);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand All @@ -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 {
Expand Down Expand Up @@ -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.....
Expand All @@ -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);
}
});

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/lang/installer.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 951016e

Please sign in to comment.