Merge pull request #69 from Silent-Client/TEST2

Test2
This commit is contained in:
kirillsaint 2023-10-28 18:18:24 +06:00 committed by GitHub
commit 7dc8c033ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 19 deletions

View File

@ -512,7 +512,6 @@ public class Client {
this.updateUserInformation();
Client.logger.info("Update Connection Server: " + event.getServerData().serverIP);
silentSocket.getSocket().emit("update_information", event.getServerData().serverIP);
lastServerData = event.getServerData();
}
@EventTarget

View File

@ -57,6 +57,7 @@ public class GuiConnecting extends SilentScreen
private void connectServerData(final ServerData serverData)
{
logger.info("Connecting to " + serverData.serverIP);
Client.getInstance().lastServerData = serverData;
(new Thread("Server Connector #" + CONNECTION_ID.incrementAndGet())
{
public void run()
@ -126,6 +127,7 @@ public class GuiConnecting extends SilentScreen
private void connect(final String ip, final int port)
{
logger.info("Connecting to " + ip + ", " + port);
Client.getInstance().lastServerData = new ServerData("Minecraft Server", ip, false);
(new Thread("Server Connector #" + CONNECTION_ID.incrementAndGet())
{
public void run()

View File

@ -18,6 +18,7 @@ import org.lwjgl.input.Keyboard;
import java.awt.*;
import java.io.IOException;
import java.util.regex.Pattern;
public class AddServerGui extends SilentScreen {
private final SilentMultiplayerGui parentScreen;
@ -56,7 +57,8 @@ public class AddServerGui extends SilentScreen {
this.buttonList.add(this.serverResourcePacks = new Button(2, x + 3, y + 23 + 25 + 25, this.modalWidth - 6, 20, "Server Resource Packs: " + this.serverData.getResourceMode().getMotd().getFormattedText()));
this.buttonList.add(new Button(3, x + 3, y + this.modalHeight - 23, this.modalWidth - 6, 20, "Done"));
this.silentInputs.add(new Input("Server Name", this.serverData.serverName));
this.silentInputs.add(new Input("Server IP", this.serverData.serverIP));
this.silentInputs.add(new Input("Server IP", this.serverData.serverIP, -1, Pattern
.compile("^[~`!@#$%^&*()_+=[\\\\]\\\\\\\\\\\\{\\\\}|;':\\\",.\\\\/<>?a-zA-Z0-9-\\s]+$"), 60, false));
}
@Override

View File

@ -18,6 +18,7 @@ import org.lwjgl.input.Keyboard;
import java.awt.*;
import java.io.IOException;
import java.util.regex.Pattern;
public class DirectConnectGui extends SilentScreen {
private final SilentMultiplayerGui parentScreen;
@ -44,7 +45,8 @@ public class DirectConnectGui extends SilentScreen {
int y = height / 2 - (this.modalHeight / 2);
this.buttonList.add(new IconButton(1, x + this.modalWidth - 14 - 3, y + 3, 14, 14, 8, 8, new ResourceLocation("silentclient/icons/exit.png")));
this.buttonList.add(new Button(3, x + 3, y + this.modalHeight - 23, this.modalWidth - 6, 20, "Done"));
this.silentInputs.add(new Input("Server IP", this.mc.gameSettings.lastServer != null ? this.mc.gameSettings.lastServer : ""));
this.silentInputs.add(new Input("Server IP", this.mc.gameSettings.lastServer != null ? this.mc.gameSettings.lastServer : "", -1, Pattern
.compile("^[~`!@#$%^&*()_+=[\\\\]\\\\\\\\\\\\{\\\\}|;':\\\",.\\\\/<>?a-zA-Z0-9-\\s]+$"), 60, false));
}
@Override

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;
}