aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/help/FeaturesCommand.java17
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java7
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java25
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java20
4 files changed, 31 insertions, 38 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/FeaturesCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/help/FeaturesCommand.java
index bc389ad4..bbabc172 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/FeaturesCommand.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/help/FeaturesCommand.java
@@ -29,11 +29,6 @@ import net.minecraft.event.ClickEvent;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
-import java.awt.*;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
public class FeaturesCommand extends ClientCommandBase {
public FeaturesCommand() {
super("neufeatures");
@@ -48,13 +43,11 @@ public class FeaturesCommand extends ClientCommandBase {
}
String url = Constants.MISC.get("featureslist").getAsString();
- Desktop desk = Desktop.getDesktop();
- try {
- desk.browse(new URI(url));
- Utils.addChatMessage( EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.BOLD + "NEU" + EnumChatFormatting.RESET +
- EnumChatFormatting.GOLD + "> Opening Feature List in browser.");
- } catch (URISyntaxException | IOException ignored) {
-
+ if (Utils.openUrl(url)) {
+ Utils.addChatMessage(
+ EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.BOLD + "NEU" + EnumChatFormatting.RESET +
+ EnumChatFormatting.GOLD + "> Opening Feature List in browser.");
+ } else {
ChatComponentText clickTextFeatures = new ChatComponentText(
EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.BOLD + "NEU" + EnumChatFormatting.RESET +
EnumChatFormatting.GOLD + "> Click here to open the Feature List in your browser.");
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java
index e3881f44..fe1f0af4 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java
@@ -44,8 +44,6 @@ import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
-import java.awt.*;
-import java.net.URI;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
@@ -737,10 +735,7 @@ public class NEUConfigEditor extends GuiElement {
if (mouseX >= socialLeft && mouseX <= socialLeft + 16 &&
mouseY >= y + 6 && mouseY <= y + 23) {
- try {
- Desktop.getDesktop().browse(new URI(socialsLink[socialIndex]));
- } catch (Exception ignored) {
- }
+ Utils.openUrl(socialsLink[socialIndex]);
return true;
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
index 63717093..4bf65cc6 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
@@ -20,19 +20,16 @@
package io.github.moulberry.notenoughupdates.profileviewer;
import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.cosmetics.ShaderManager;
import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField;
-import io.github.moulberry.notenoughupdates.miscfeatures.PetInfoOverlay;
import io.github.moulberry.notenoughupdates.profileviewer.bestiary.BestiaryPage;
import io.github.moulberry.notenoughupdates.profileviewer.trophy.TrophyFishPage;
import io.github.moulberry.notenoughupdates.profileviewer.weight.weight.DungeonsWeight;
import io.github.moulberry.notenoughupdates.profileviewer.weight.weight.SkillsWeight;
import io.github.moulberry.notenoughupdates.util.AsyncDependencyLoader;
-import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.PronounDB;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
@@ -58,8 +55,6 @@ import org.lwjgl.opengl.GL20;
import java.awt.*;
import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
@@ -843,21 +838,11 @@ public class GuiProfileViewer extends GuiScreen {
profileId != null
) {
if (mouseY > guiTop + sizeY + 3 && mouseY < guiTop + sizeY + 23) {
- try {
- Desktop desk = Desktop.getDesktop();
- desk.browse(
- new URI(
- "https://sky.shiiyu.moe/stats/" + profile.getHypixelProfile().get("displayname").getAsString() + "/" +
- profileId
- )
- );
- Utils.playPressSound();
- return;
- } catch (UnsupportedOperationException | IOException | URISyntaxException ignored) {
- //no idea how this sounds, but ya know just in case
- Utils.playSound(new ResourceLocation("game.player.hurt"), true);
- return;
- }
+ String url = "https://sky.shiiyu.moe/stats/" + profile.getHypixelProfile().get("displayname").getAsString() + "/" +
+ profileId;
+ Utils.openUrl(url);
+ Utils.playPressSound();
+ return;
}
}
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;
+ }
+ }
+ }
}