diff --git a/src/main/java/net/silentclient/client/mods/util/Server.java b/src/main/java/net/silentclient/client/mods/util/Server.java index 9f4d645..7bba487 100644 --- a/src/main/java/net/silentclient/client/mods/util/Server.java +++ b/src/main/java/net/silentclient/client/mods/util/Server.java @@ -1,22 +1,21 @@ package net.silentclient.client.mods.util; -import java.net.URL; - import net.minecraft.client.Minecraft; +import java.net.URL; +import java.util.regex.Pattern; + public class Server { public static boolean isHypixel() { if(Minecraft.getMinecraft().isSingleplayer()) { return false; } try { - String serverIp = Minecraft.getMinecraft().getCurrentServerData().serverIP.toString(); - if(!serverIp.startsWith("http") && !serverIp.startsWith("https")){ - serverIp = "http://" + serverIp; - } - URL serverUrl = new URL(serverIp); - - return (serverUrl.getHost().toString().toLowerCase().equals("hypixel.net") || serverUrl.getHost().toString().toLowerCase().equals("www.hypixel.net") || serverUrl.getHost().toString().toLowerCase().equals("mc.hypixel.net") || serverUrl.getHost().toString().toLowerCase().equals("play.hypixel.net") || serverUrl.getHost().toString().toLowerCase().equals("stuck.hypixel.net") || serverUrl.getHost().toString().toLowerCase().equals("proxy.hypixel.net") || serverUrl.getHost().toString().toLowerCase().equals("eu.hypixel.net") || serverUrl.getHost().toString().toLowerCase().equals("play.hypixel.net")); + String serverIp = Minecraft.getMinecraft().getCurrentServerData().serverIP; + final String regex = "^(?:.*\\.)?hypixel\\.(?:net|io)\\.?"; + final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE); + + return pattern.matcher(serverIp).matches(); } catch (Exception err) { return false; } @@ -44,13 +43,11 @@ public class Server { return false; } try { - String serverIp = Minecraft.getMinecraft().getCurrentServerData().serverIP.toString(); - if(!serverIp.startsWith("http") && !serverIp.startsWith("https")){ - serverIp = "http://" + serverIp; - } - URL serverUrl = new URL(serverIp); - - return (serverUrl.getHost().toString().toLowerCase().equals("ruhypixel.net")); + String serverIp = Minecraft.getMinecraft().getCurrentServerData().serverIP; + final String regex = "^(?:.*\\.)?ruhypixel\\.(?:net)\\.?"; + final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE); + + return pattern.matcher(serverIp).matches(); } catch (Exception err) { return false; }