From 5ba46b437ec11e295b71545e65eb3ee537062c92 Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Sat, 28 Oct 2023 17:44:28 +0600 Subject: [PATCH 1/3] Better Hypixel/RuHypixel Detection --- .../silentclient/client/mods/util/Server.java | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) 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; } From 44fb06f9290f083c9b854fb767aecb0894b5641c Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Sat, 28 Oct 2023 17:57:27 +0600 Subject: [PATCH 2/3] Better Multiplayer Gui --- src/main/java/net/silentclient/client/Client.java | 1 - .../net/silentclient/client/gui/minecraft/GuiConnecting.java | 2 ++ .../net/silentclient/client/gui/multiplayer/AddServerGui.java | 4 +++- .../silentclient/client/gui/multiplayer/DirectConnectGui.java | 4 +++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/silentclient/client/Client.java b/src/main/java/net/silentclient/client/Client.java index 4d02ae9..09cf576 100644 --- a/src/main/java/net/silentclient/client/Client.java +++ b/src/main/java/net/silentclient/client/Client.java @@ -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 diff --git a/src/main/java/net/silentclient/client/gui/minecraft/GuiConnecting.java b/src/main/java/net/silentclient/client/gui/minecraft/GuiConnecting.java index c58526c..89dda59 100644 --- a/src/main/java/net/silentclient/client/gui/minecraft/GuiConnecting.java +++ b/src/main/java/net/silentclient/client/gui/minecraft/GuiConnecting.java @@ -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() diff --git a/src/main/java/net/silentclient/client/gui/multiplayer/AddServerGui.java b/src/main/java/net/silentclient/client/gui/multiplayer/AddServerGui.java index dcc2f8e..fd4abb7 100644 --- a/src/main/java/net/silentclient/client/gui/multiplayer/AddServerGui.java +++ b/src/main/java/net/silentclient/client/gui/multiplayer/AddServerGui.java @@ -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 diff --git a/src/main/java/net/silentclient/client/gui/multiplayer/DirectConnectGui.java b/src/main/java/net/silentclient/client/gui/multiplayer/DirectConnectGui.java index 3d60118..49ea73c 100644 --- a/src/main/java/net/silentclient/client/gui/multiplayer/DirectConnectGui.java +++ b/src/main/java/net/silentclient/client/gui/multiplayer/DirectConnectGui.java @@ -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 From f511e8ff281d6d39d7b3d4ddba8afb7f22d4dcc5 Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Sat, 28 Oct 2023 19:49:03 +0600 Subject: [PATCH 3/3] Update PotionHudMod.java --- .../silentclient/client/mods/hud/PotionHudMod.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/silentclient/client/mods/hud/PotionHudMod.java b/src/main/java/net/silentclient/client/mods/hud/PotionHudMod.java index 5e32826..155d398 100644 --- a/src/main/java/net/silentclient/client/mods/hud/PotionHudMod.java +++ b/src/main/java/net/silentclient/client/mods/hud/PotionHudMod.java @@ -1,9 +1,5 @@ package net.silentclient.client.mods.hud; -import java.awt.Color; -import java.util.ArrayList; -import java.util.Collection; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.renderer.GlStateManager; @@ -18,6 +14,10 @@ import net.silentclient.client.mods.CustomFontRenderer; import net.silentclient.client.mods.ModCategory; import net.silentclient.client.mods.ModDraggable; +import java.awt.*; +import java.util.ArrayList; +import java.util.Collection; + public class PotionHudMod extends ModDraggable { public PotionHudMod() { @@ -72,9 +72,6 @@ public class PotionHudMod extends ModDraggable { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.disableLighting(); int k = 18; - if (collection.size() > 5) { - k = 132 / (collection.size() - 1); - } for (PotionEffect potioneffect : this.mc.thePlayer.getActivePotionEffects()) { Potion potion = Potion.potionTypes[potioneffect.getPotionID()]; GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);