diff --git a/launch/src/main/java/meteordevelopment/meteorclient/Main.java b/launch/src/main/java/meteordevelopment/meteorclient/Main.java index b65233ae08..16071e0a5b 100644 --- a/launch/src/main/java/meteordevelopment/meteorclient/Main.java +++ b/launch/src/main/java/meteordevelopment/meteorclient/Main.java @@ -6,9 +6,11 @@ package meteordevelopment.meteorclient; import javax.swing.*; +import java.awt.*; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; +import java.net.URI; import java.net.URL; import java.util.Locale; @@ -20,28 +22,40 @@ public static void main(String[] args) throws UnsupportedLookAndFeelException, C null, "To install Meteor Client you need to put it in your mods folder and run Fabric for latest Minecraft version.", "Meteor Client", - JOptionPane.YES_NO_OPTION, + JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.ERROR_MESSAGE, null, - new String[] { "Open Wiki", "Open Mods Folder" }, + new String[] { "Open Wiki", "Open Mods Folder", "Join our Discord" }, null ); switch (option) { - case 0: getOS().open("https://meteorclient.com/installation"); break; + case 0: { + try { + Desktop.getDesktop().browse(URI.create("https://meteorclient.com/faq/installation")); + } catch (IOException ignored) {} + break; + } case 1: { String path; switch (getOS()) { case WINDOWS: path = System.getenv("AppData") + "/.minecraft/mods"; break; case OSX: path = System.getProperty("user.home") + "/Library/Application Support/minecraft/mods"; break; - default: path = System.getProperty("user.home") + "/.minecraft"; break; + default: path = System.getProperty("user.home") + "/.minecraft/mods"; break; } File mods = new File(path); if (!mods.exists()) mods.mkdirs(); - - getOS().open(mods); + try { + Desktop.getDesktop().open(mods); + } catch (IOException ignored) {} + break; + } + case 2: { + try { + Desktop.getDesktop().browse(URI.create("https://discord.com/invite/bBGQZvd")); + } catch (IOException ignored) {} break; } } @@ -59,52 +73,8 @@ private static OperatingSystem getOS() { private enum OperatingSystem { LINUX, - WINDOWS { - @Override - protected String[] getURLOpenCommand(URL url) { - return new String[] { "rundll32", "url.dll,FileProtocolHandler", url.toString() }; - } - }, - OSX { - @Override - protected String[] getURLOpenCommand(URL url) { - return new String[] { "open", url.toString() }; - } - }, + WINDOWS, + OSX, UNKNOWN; - - public void open(URL url) { - try { - Runtime.getRuntime().exec(getURLOpenCommand(url)); - } catch (IOException e) { - e.printStackTrace(); - } - } - - public void open(String url) { - try { - open(new URL(url)); - } catch (MalformedURLException e) { - e.printStackTrace(); - } - } - - public void open(File file) { - try { - open(file.toURI().toURL()); - } catch (MalformedURLException e) { - e.printStackTrace(); - } - } - - protected String[] getURLOpenCommand(URL url) { - String string = url.toString(); - - if ("file".equals(url.getProtocol())) { - string = string.replace("file:", "file://"); - } - - return new String[] { "xdg-open", string }; - } } }