mirror of
https://github.com/refactorinqq/SLC-1.8.9.git
synced 2024-11-10 07:01:32 +01:00
Better Hypixel/RuHypixel Detection
This commit is contained in:
parent
a527252426
commit
5ba46b437e
@ -1,22 +1,21 @@
|
|||||||
package net.silentclient.client.mods.util;
|
package net.silentclient.client.mods.util;
|
||||||
|
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class Server {
|
public class Server {
|
||||||
public static boolean isHypixel() {
|
public static boolean isHypixel() {
|
||||||
if(Minecraft.getMinecraft().isSingleplayer()) {
|
if(Minecraft.getMinecraft().isSingleplayer()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String serverIp = Minecraft.getMinecraft().getCurrentServerData().serverIP.toString();
|
String serverIp = Minecraft.getMinecraft().getCurrentServerData().serverIP;
|
||||||
if(!serverIp.startsWith("http") && !serverIp.startsWith("https")){
|
final String regex = "^(?:.*\\.)?hypixel\\.(?:net|io)\\.?";
|
||||||
serverIp = "http://" + serverIp;
|
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
|
||||||
}
|
|
||||||
URL serverUrl = new URL(serverIp);
|
return pattern.matcher(serverIp).matches();
|
||||||
|
|
||||||
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"));
|
|
||||||
} catch (Exception err) {
|
} catch (Exception err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -44,13 +43,11 @@ public class Server {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String serverIp = Minecraft.getMinecraft().getCurrentServerData().serverIP.toString();
|
String serverIp = Minecraft.getMinecraft().getCurrentServerData().serverIP;
|
||||||
if(!serverIp.startsWith("http") && !serverIp.startsWith("https")){
|
final String regex = "^(?:.*\\.)?ruhypixel\\.(?:net)\\.?";
|
||||||
serverIp = "http://" + serverIp;
|
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
|
||||||
}
|
|
||||||
URL serverUrl = new URL(serverIp);
|
return pattern.matcher(serverIp).matches();
|
||||||
|
|
||||||
return (serverUrl.getHost().toString().toLowerCase().equals("ruhypixel.net"));
|
|
||||||
} catch (Exception err) {
|
} catch (Exception err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user