From 41d9ff1ee4af8056addaff25adf2d48a611e6ed2 Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Tue, 7 Nov 2023 02:19:14 +0600 Subject: [PATCH] Guess The Build Mod --- .../java/net/silentclient/client/Client.java | 2 +- .../client/mods/ModInstances.java | 12 +- .../client/mods/hypixel/GuessTheBuildMod.java | 122 ++++++++++++++++++ .../silentclient/client/utils/GTBHelper.java | 9 ++ 4 files changed, 134 insertions(+), 11 deletions(-) create mode 100644 src/main/java/net/silentclient/client/mods/hypixel/GuessTheBuildMod.java create mode 100644 src/main/java/net/silentclient/client/utils/GTBHelper.java diff --git a/src/main/java/net/silentclient/client/Client.java b/src/main/java/net/silentclient/client/Client.java index 413c15f..cf501fb 100644 --- a/src/main/java/net/silentclient/client/Client.java +++ b/src/main/java/net/silentclient/client/Client.java @@ -646,7 +646,7 @@ public class Client { } public boolean isTest() { - return getBuildData().getBranch().equals("test"); + return getBuildData().getBranch().equals("TEST2"); } public boolean isDebug() { diff --git a/src/main/java/net/silentclient/client/mods/ModInstances.java b/src/main/java/net/silentclient/client/mods/ModInstances.java index b063610..a1dde4c 100644 --- a/src/main/java/net/silentclient/client/mods/ModInstances.java +++ b/src/main/java/net/silentclient/client/mods/ModInstances.java @@ -2,10 +2,7 @@ package net.silentclient.client.mods; import net.silentclient.client.Client; import net.silentclient.client.mods.hud.*; -import net.silentclient.client.mods.hypixel.AutoGGMod; -import net.silentclient.client.mods.hypixel.AutoTipMod; -import net.silentclient.client.mods.hypixel.LevelHeadMod; -import net.silentclient.client.mods.hypixel.QuickPlayMod; +import net.silentclient.client.mods.hypixel.*; import net.silentclient.client.mods.hypixel.togglechat.ToggleChatMod; import net.silentclient.client.mods.player.*; import net.silentclient.client.mods.render.*; @@ -13,9 +10,6 @@ import net.silentclient.client.mods.settings.CosmeticsMod; import net.silentclient.client.mods.settings.FPSBoostMod; import net.silentclient.client.mods.settings.GeneralMod; import net.silentclient.client.mods.settings.RenderMod; -import net.silentclient.client.mods.staff.DebugNpcMod; -import net.silentclient.client.mods.staff.FPSSpoofer; -import net.silentclient.client.mods.staff.HitDelayFixMod; import net.silentclient.client.mods.staff.TestMod; import net.silentclient.client.mods.world.FullBrightMod; import net.silentclient.client.mods.world.PlayerCounterMod; @@ -179,9 +173,7 @@ public class ModInstances { mods.add(new BlockInfoMod()); if(Client.getInstance().isDebug() || Client.getInstance().isTest()) { mods.add(new TestMod()); - mods.add(new DebugNpcMod()); - mods.add(new HitDelayFixMod()); - mods.add(new FPSSpoofer()); + mods.add(new GuessTheBuildMod()); } mods.add(new NewMotionBlurMod()); if(Client.getInstance().getBuildData().getBranch().equals("fushka")) { diff --git a/src/main/java/net/silentclient/client/mods/hypixel/GuessTheBuildMod.java b/src/main/java/net/silentclient/client/mods/hypixel/GuessTheBuildMod.java new file mode 100644 index 0000000..6b8eecf --- /dev/null +++ b/src/main/java/net/silentclient/client/mods/hypixel/GuessTheBuildMod.java @@ -0,0 +1,122 @@ +package net.silentclient.client.mods.hypixel; + +import com.google.common.reflect.TypeToken; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import net.minecraft.network.play.server.S02PacketChat; +import net.minecraft.util.EnumChatFormatting; +import net.silentclient.client.Client; +import net.silentclient.client.event.EventTarget; +import net.silentclient.client.event.impl.EventReceivePacket; +import net.silentclient.client.gui.hud.ScreenPosition; +import net.silentclient.client.mods.ModCategory; +import net.silentclient.client.mods.ModDraggable; +import net.silentclient.client.mods.util.Server; +import net.silentclient.client.utils.GTBHelper; +import net.silentclient.client.utils.Requests; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class GuessTheBuildMod extends ModDraggable { + + public static ArrayList words; + public static List lastWords = null; + private String lastActionBar = ""; + + public GuessTheBuildMod() { + super("Guess The Build", ModCategory.MODS, null); + } + + @Override + public void setup() { + super.setup(); + words = new ArrayList<>(); + try { + InputStream in = getClass().getResourceAsStream("/assets/minecraft/silentclient/mods/guessthebuild/words.txt"); + BufferedReader reader = new BufferedReader(new InputStreamReader(in)); + StringBuffer content = new StringBuffer(); + String inputLine; + while ((inputLine = reader.readLine()) != null) { + content.append(inputLine); + } + + words = new ArrayList<>(Arrays.asList(content.toString().split("\n"))); + in.close(); + } catch (Exception e1) { + Client.logger.catching(e1); + } + } + + @EventTarget + public void onMessage(EventReceivePacket event) { + if(event.getPacket() instanceof S02PacketChat) { + final S02PacketChat chatPacket = (S02PacketChat) event.getPacket(); + if(chatPacket.getType() == 2 && Server.isHypixel()) { + if(chatPacket.getChatComponent() != null) { + String actionBar = chatPacket.getChatComponent().getFormattedText(); + if (!GTBHelper.isGTBActionBar(actionBar)) { + lastWords = null; + return; + } + + actionBar = EnumChatFormatting.getTextWithoutFormattingCodes(actionBar).replace("The theme is ", ""); + + if (actionBar.equals(lastActionBar)) return; + lastActionBar = actionBar; + + (new Thread(() -> { + try { + String arrayString = Requests.get("https://hypixel.silentclient.net/guessthebuild/check?word=" + lastActionBar); + GsonBuilder builder = new GsonBuilder(); + Gson gson = builder.create(); + + Type listType = new TypeToken>(){}.getType(); + ArrayList response = gson.fromJson(arrayString, listType); + lastWords = response; + } catch (Exception err) { + lastWords = null; + } + })).start(); + } else { + lastWords = null; + } + } + } + } + + @Override + public int getWidth() { + return 100; + } + + @Override + public int getHeight() { + return font.FONT_HEIGHT + ((lastWords != null ? lastWords.size() : 0) * font.FONT_HEIGHT); + } + + @Override + public boolean render(ScreenPosition pos) { + if(lastWords != null) { + int y = 0; + font.drawString("Words:", 0, y, -1, true); + y += font.FONT_HEIGHT; + for(String word : lastWords) { + font.drawString(word, 0, y, -1, true); + y += font.FONT_HEIGHT; + } + } + return true; + } + + @Override + public void renderDummy(ScreenPosition pos) { + super.renderDummy(pos); + font.drawString("Words:", 0, 0, -1, true); + } +} diff --git a/src/main/java/net/silentclient/client/utils/GTBHelper.java b/src/main/java/net/silentclient/client/utils/GTBHelper.java new file mode 100644 index 0000000..e9b0fdb --- /dev/null +++ b/src/main/java/net/silentclient/client/utils/GTBHelper.java @@ -0,0 +1,9 @@ +package net.silentclient.client.utils; + +public class GTBHelper { + public static Boolean isGTBActionBar(final String actionBar) { + return actionBar.contains("§b") + && actionBar.contains("§e") + && actionBar.contains("_"); + } +} \ No newline at end of file