Better Hypixel/RuHypixel Detection

This commit is contained in:
kirillsaint 2023-10-28 17:44:28 +06:00
parent a527252426
commit 5ba46b437e

View File

@ -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);
String serverIp = Minecraft.getMinecraft().getCurrentServerData().serverIP;
final String regex = "^(?:.*\\.)?hypixel\\.(?:net|io)\\.?";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
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"));
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);
String serverIp = Minecraft.getMinecraft().getCurrentServerData().serverIP;
final String regex = "^(?:.*\\.)?ruhypixel\\.(?:net)\\.?";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
return (serverUrl.getHost().toString().toLowerCase().equals("ruhypixel.net"));
return pattern.matcher(serverIp).matches();
} catch (Exception err) {
return false;
}