diff options
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java')
| -rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index a3f2296c..0ea1dafb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -71,10 +71,13 @@ import java.awt.*; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; +import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.math.BigInteger; +import java.net.URI; +import java.net.URISyntaxException; import java.nio.FloatBuffer; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -2037,4 +2040,21 @@ public class Utils { System.out.println(message); } } + + public static boolean openUrl(String url) { + try { + Desktop desk = Desktop.getDesktop(); + desk.browse(new URI(url)); + return true; + } catch (UnsupportedOperationException | IOException | URISyntaxException ignored) { + Runtime runtime = Runtime.getRuntime(); + try { + runtime.exec("xdg-open " + url); + return true; + } catch (IOException e) { + Utils.playSound(new ResourceLocation("game.player.hurt"), true); + return false; + } + } + } } |
