Skip to content

Commit

Permalink
Output error messages when using UI
Browse files Browse the repository at this point in the history
  • Loading branch information
ChachyDev committed Jun 4, 2021
1 parent 2964c1b commit c8aac3c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static Installer getInstaller(File forgeJar) {
}

if (installer == null) {
throw new IllegalStateException("There are no installers currently available for the provided jar...");
throw new IllegalStateException("There are no installers currently available for the provided jar, is it a Forge jar...?");
}

return installer;
Expand Down
26 changes: 18 additions & 8 deletions user-interface/src/main/java/club/chachy/multimc4forge/ui/UI.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,28 @@
import java.io.File;

public class UI {
public static void main(String[] args) throws Throwable {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

File forgeJar = getFile(new JFileChooser(), "Please select a Forge INSTALLER jar", "You MUST provide a Forge Installer jar...", new JarFilter(), new ZipFilter());
File forgeJar = getFile(new JFileChooser(), "Please select a Forge INSTALLER jar", "You MUST provide a Forge Installer jar...", new JarFilter(), new ZipFilter());

if (forgeJar != null) {
File multiMcDirectory = getFile(new JFileChooser(), "Please provide your Multi", "You MUST provide a MultiMC install directory", new DirectoryFilter());
if (forgeJar != null) {
File multiMcDirectory = getFile(new JFileChooser(), "Please provide your Multi", "You MUST provide a MultiMC install directory", new DirectoryFilter());

if (multiMcDirectory != null) {
File location = Installers.getInstaller(forgeJar).install(multiMcDirectory, forgeJar);
JOptionPane.showMessageDialog(null, "Successfully installed Forge to " + location.getAbsolutePath() + "! Make sure to restart MultiMC if it was already opened", "Success! :)", JOptionPane.PLAIN_MESSAGE);
if (multiMcDirectory != null) {
File location = Installers.getInstaller(forgeJar).install(multiMcDirectory, forgeJar);
JOptionPane.showMessageDialog(null, "Successfully installed Forge to " + location.getAbsolutePath() + "! Make sure to restart MultiMC if it was already opened", "Success! :)", JOptionPane.PLAIN_MESSAGE);
}
}
} catch (Throwable t) {
String message = t.getMessage();

if (message != null) {
JOptionPane.showMessageDialog(null, message, "An error occurred :(", JOptionPane.ERROR_MESSAGE);
}

t.printStackTrace();
}
}

Expand Down

0 comments on commit c8aac3c

Please sign in to comment.