From 9c73c8de3016d0ca0be0a4cc875e1745e57915ac Mon Sep 17 00:00:00 2001 From: TudbuT Date: Wed, 20 Mar 2024 01:13:18 +0100 Subject: [PATCH] new initial client --- Client/build.gradle | 6 +- .../java/com/baseband/client/BaseBand.java | 217 +-------- .../main/java/com/baseband/client/Setup.java | 34 ++ .../client/configuration/ConfigHandle.java | 39 ++ .../client/configuration/Configuration.java | 35 ++ .../client/configuration/Updater.java | 73 +++ .../configuration/annotation/Config.java | 21 + .../configuration/annotation/Range.java | 20 + .../com/baseband/client/gui/GuiRewrite.java | 161 +++++++ .../java/com/baseband/client/gui/GuiTTC.java | 429 ++++++++++++++++++ .../baseband/client/gui/lib/GUIManager.java | 61 +++ .../client/gui/lib/component/Button.java | 26 ++ .../client/gui/lib/component/Category.java | 59 +++ .../client/gui/lib/component/Component.java | 109 +++++ .../client/gui/lib/component/EnumButton.java | 40 ++ .../client/gui/lib/component/IntSlider.java | 72 +++ .../client/gui/lib/component/Slider.java | 71 +++ .../gui/lib/component/ToggleButton.java | 42 ++ .../com/baseband/client/module/Category.java | 53 +++ .../com/baseband/client/module/Module.java | 187 +++++--- .../baseband/client/module/command/Test.java | 28 ++ .../client/module/render/ClickGUI.java | 19 + .../com/baseband/client/util/FieldUtil.java | 18 + .../java/com/baseband/client/util/Marker.java | 12 + .../baseband/client => old}/ASyncRunner.java | 2 +- Client/src/old/BaseBand.java | 222 +++++++++ .../client => old}/ConfigManager.java | 2 +- .../java/com/baseband/client => old}/Key.java | 2 +- .../baseband/client => old}/MotionUtil.java | 2 +- .../com/baseband/client => old}/Restrict.java | 2 +- .../baseband/client => old}/Tesselator.java | 2 +- .../com/baseband/client => old}/Utils.java | 2 +- .../client => old}/command/Command.java | 0 .../command/CommandManager.java | 0 .../command/commands/CreditsCommand.java | 0 .../command/commands/GenericSetCommand.java | 0 .../command/commands/HelpCommand.java | 0 .../command/commands/VersionCommand.java | 0 .../event/CancellableEvent.java | 0 .../baseband/client => old}/event/Event.java | 0 .../client => old}/event/EventBus.java | 0 .../event/FMLEventProcessor.java | 0 .../client => old}/event/Subscribe.java | 0 .../event/events/MoveEvent.java | 0 .../event/events/PacketEvent.java | 0 .../event/events/SafeTickEvent.java | 0 .../client => old}/guirewrite/Button.java | 0 .../guirewrite/GuiBaseBand.java | 0 .../guirewrite/ModuleButton.java | 0 .../guirewrite/SettingButton.java | 0 .../mixins/ICPacketChatMessage.java | 0 .../client => old}/mixins/IMinecraft.java | 0 .../mixins/ISPacketPlayerPosLook.java | 0 .../mixins/MixinEntityPlayerSP.java | 0 .../client => old}/mixins/MixinForgeBus.java | 0 .../client => old}/mixins/MixinMinecraft.java | 0 .../mixins/MixinNetworkManager.java | 0 .../client => old}/mixins/MixinProxy.java | 0 Client/src/old/module/Module.java | 81 ++++ .../module/modules/ASyncTest.java | 0 .../module/modules/Brightness.java | 0 .../module/modules/ChatCrypt.java | 0 .../module/modules/ChatSuffix.java | 0 .../module/modules/ClickGUI.java | 0 .../module/modules/Crasher.java | 0 .../module/modules/ElytraFly.java | 0 .../module/modules/FastUse.java | 0 .../client => old}/module/modules/HUD.java | 0 .../module/modules/HoleESP.java | 0 .../module/modules/NameTags.java | 0 .../client => old}/module/modules/NoSlip.java | 0 .../module/modules/PacketFly.java | 0 .../module/modules/PacketTest.java | 0 .../client => old}/module/modules/Speed.java | 0 .../module/modules/TPTracker.java | 0 .../client => old}/setting/FloatMeta.java | 0 .../client => old}/setting/IntMeta.java | 0 .../client => old}/setting/Setting.java | 0 Server/build.gradle | 13 +- Server/rsa-priv.pem | 29 -- .../main/java/dev/baseband/server/Main.java | 22 +- .../baseband/server/socket => old}/Bot.java | 2 +- .../server/socket => old}/ClientHandler.java | 2 +- .../baseband/server/socket => old}/Key.java | 3 +- .../server/socket => old}/SocketHandler.java | 2 +- .../server/socket => old}/UserManager.java | 2 +- 86 files changed, 1903 insertions(+), 321 deletions(-) create mode 100644 Client/src/main/java/com/baseband/client/Setup.java create mode 100644 Client/src/main/java/com/baseband/client/configuration/ConfigHandle.java create mode 100644 Client/src/main/java/com/baseband/client/configuration/Configuration.java create mode 100644 Client/src/main/java/com/baseband/client/configuration/Updater.java create mode 100644 Client/src/main/java/com/baseband/client/configuration/annotation/Config.java create mode 100644 Client/src/main/java/com/baseband/client/configuration/annotation/Range.java create mode 100644 Client/src/main/java/com/baseband/client/gui/GuiRewrite.java create mode 100644 Client/src/main/java/com/baseband/client/gui/GuiTTC.java create mode 100644 Client/src/main/java/com/baseband/client/gui/lib/GUIManager.java create mode 100644 Client/src/main/java/com/baseband/client/gui/lib/component/Button.java create mode 100644 Client/src/main/java/com/baseband/client/gui/lib/component/Category.java create mode 100644 Client/src/main/java/com/baseband/client/gui/lib/component/Component.java create mode 100644 Client/src/main/java/com/baseband/client/gui/lib/component/EnumButton.java create mode 100644 Client/src/main/java/com/baseband/client/gui/lib/component/IntSlider.java create mode 100644 Client/src/main/java/com/baseband/client/gui/lib/component/Slider.java create mode 100644 Client/src/main/java/com/baseband/client/gui/lib/component/ToggleButton.java create mode 100644 Client/src/main/java/com/baseband/client/module/Category.java create mode 100644 Client/src/main/java/com/baseband/client/module/command/Test.java create mode 100644 Client/src/main/java/com/baseband/client/module/render/ClickGUI.java create mode 100644 Client/src/main/java/com/baseband/client/util/FieldUtil.java create mode 100644 Client/src/main/java/com/baseband/client/util/Marker.java rename Client/src/{main/java/com/baseband/client => old}/ASyncRunner.java (96%) create mode 100644 Client/src/old/BaseBand.java rename Client/src/{main/java/com/baseband/client => old}/ConfigManager.java (94%) rename Client/src/{main/java/com/baseband/client => old}/Key.java (99%) rename Client/src/{main/java/com/baseband/client => old}/MotionUtil.java (98%) rename Client/src/{main/java/com/baseband/client => old}/Restrict.java (93%) rename Client/src/{main/java/com/baseband/client => old}/Tesselator.java (99%) rename Client/src/{main/java/com/baseband/client => old}/Utils.java (98%) rename Client/src/{main/java/com/baseband/client => old}/command/Command.java (100%) rename Client/src/{main/java/com/baseband/client => old}/command/CommandManager.java (100%) rename Client/src/{main/java/com/baseband/client => old}/command/commands/CreditsCommand.java (100%) rename Client/src/{main/java/com/baseband/client => old}/command/commands/GenericSetCommand.java (100%) rename Client/src/{main/java/com/baseband/client => old}/command/commands/HelpCommand.java (100%) rename Client/src/{main/java/com/baseband/client => old}/command/commands/VersionCommand.java (100%) rename Client/src/{main/java/com/baseband/client => old}/event/CancellableEvent.java (100%) rename Client/src/{main/java/com/baseband/client => old}/event/Event.java (100%) rename Client/src/{main/java/com/baseband/client => old}/event/EventBus.java (100%) rename Client/src/{main/java/com/baseband/client => old}/event/FMLEventProcessor.java (100%) rename Client/src/{main/java/com/baseband/client => old}/event/Subscribe.java (100%) rename Client/src/{main/java/com/baseband/client => old}/event/events/MoveEvent.java (100%) rename Client/src/{main/java/com/baseband/client => old}/event/events/PacketEvent.java (100%) rename Client/src/{main/java/com/baseband/client => old}/event/events/SafeTickEvent.java (100%) rename Client/src/{main/java/com/baseband/client => old}/guirewrite/Button.java (100%) rename Client/src/{main/java/com/baseband/client => old}/guirewrite/GuiBaseBand.java (100%) rename Client/src/{main/java/com/baseband/client => old}/guirewrite/ModuleButton.java (100%) rename Client/src/{main/java/com/baseband/client => old}/guirewrite/SettingButton.java (100%) rename Client/src/{main/java/com/baseband/client => old}/mixins/ICPacketChatMessage.java (100%) rename Client/src/{main/java/com/baseband/client => old}/mixins/IMinecraft.java (100%) rename Client/src/{main/java/com/baseband/client => old}/mixins/ISPacketPlayerPosLook.java (100%) rename Client/src/{main/java/com/baseband/client => old}/mixins/MixinEntityPlayerSP.java (100%) rename Client/src/{main/java/com/baseband/client => old}/mixins/MixinForgeBus.java (100%) rename Client/src/{main/java/com/baseband/client => old}/mixins/MixinMinecraft.java (100%) rename Client/src/{main/java/com/baseband/client => old}/mixins/MixinNetworkManager.java (100%) rename Client/src/{main/java/com/baseband/client => old}/mixins/MixinProxy.java (100%) create mode 100644 Client/src/old/module/Module.java rename Client/src/{main/java/com/baseband/client => old}/module/modules/ASyncTest.java (100%) rename Client/src/{main/java/com/baseband/client => old}/module/modules/Brightness.java (100%) rename Client/src/{main/java/com/baseband/client => old}/module/modules/ChatCrypt.java (100%) rename Client/src/{main/java/com/baseband/client => old}/module/modules/ChatSuffix.java (100%) rename Client/src/{main/java/com/baseband/client => old}/module/modules/ClickGUI.java (100%) rename Client/src/{main/java/com/baseband/client => old}/module/modules/Crasher.java (100%) rename Client/src/{main/java/com/baseband/client => old}/module/modules/ElytraFly.java (100%) rename Client/src/{main/java/com/baseband/client => old}/module/modules/FastUse.java (100%) rename Client/src/{main/java/com/baseband/client => old}/module/modules/HUD.java (100%) rename Client/src/{main/java/com/baseband/client => old}/module/modules/HoleESP.java (100%) rename Client/src/{main/java/com/baseband/client => old}/module/modules/NameTags.java (100%) rename Client/src/{main/java/com/baseband/client => old}/module/modules/NoSlip.java (100%) rename Client/src/{main/java/com/baseband/client => old}/module/modules/PacketFly.java (100%) rename Client/src/{main/java/com/baseband/client => old}/module/modules/PacketTest.java (100%) rename Client/src/{main/java/com/baseband/client => old}/module/modules/Speed.java (100%) rename Client/src/{main/java/com/baseband/client => old}/module/modules/TPTracker.java (100%) rename Client/src/{main/java/com/baseband/client => old}/setting/FloatMeta.java (100%) rename Client/src/{main/java/com/baseband/client => old}/setting/IntMeta.java (100%) rename Client/src/{main/java/com/baseband/client => old}/setting/Setting.java (100%) delete mode 100644 Server/rsa-priv.pem rename Server/src/{main/java/dev/baseband/server/socket => old}/Bot.java (99%) rename Server/src/{main/java/dev/baseband/server/socket => old}/ClientHandler.java (99%) rename Server/src/{main/java/dev/baseband/server/socket => old}/Key.java (98%) rename Server/src/{main/java/dev/baseband/server/socket => old}/SocketHandler.java (99%) rename Server/src/{main/java/dev/baseband/server/socket => old}/UserManager.java (99%) diff --git a/Client/build.gradle b/Client/build.gradle index 2b6af19..dd0f467 100644 --- a/Client/build.gradle +++ b/Client/build.gradle @@ -79,7 +79,7 @@ dependencies { jarLibs(files('libs/TuddyLIB.jar')) // should NOT go into the jar. - implementation(files('libs/mcregistry-1.0.jar')) + //implementation(files('libs/mcregistry-1.0.jar')) //jarLibs 'club.minnced:java-discord-rpc:2.0.2' @@ -112,13 +112,13 @@ compileJava { - def targetFile = file("src/main/java/com/baseband/client/BaseBand.java") + /*def targetFile = file("src/main/java/com/baseband/client/BaseBand.java") def content = targetFile.text def updatedContent = content.replaceFirst("buildNumber = (\\d+)", { _, value -> "buildNumber = ${value.toInteger() + 1}" }) updatedContent = updatedContent.replaceFirst("public static String hash = \".*\";", "public static String hash = \"" + hash + "\";") updatedContent = updatedContent.replaceFirst("public long timeOfCompile = .*;", "public long timeOfCompile = " + new Date().getTime() + "L;") - targetFile.text = updatedContent + targetFile.text = updatedContent*/ } processResources { diff --git a/Client/src/main/java/com/baseband/client/BaseBand.java b/Client/src/main/java/com/baseband/client/BaseBand.java index 7b813ba..42b15be 100644 --- a/Client/src/main/java/com/baseband/client/BaseBand.java +++ b/Client/src/main/java/com/baseband/client/BaseBand.java @@ -1,222 +1,43 @@ -/* - * Copyright (c) 2023 Jess H & Daniella H. All Rights Reserved. - * Unauthorized copying of this file via any medium is Strictly Prohibited. - */ - package com.baseband.client; - -import com.baseband.client.command.CommandManager; -import com.baseband.client.event.EventBus; -import com.baseband.client.event.FMLEventProcessor; +import com.baseband.client.configuration.Updater; import com.baseband.client.module.Module; -import com.baseband.client.module.modules.*; -import de.tudbut.parsing.TCN; -import de.tudbut.tools.Lock; -import de.tudbut.tools.Registry; -import de.tudbut.tools.Tools; import net.minecraft.client.Minecraft; -import net.minecraft.launchwrapper.Launch; -import net.minecraftforge.common.MinecraftForge; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.lwjgl.opengl.Display; -import javax.swing.*; -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.nio.file.StandardCopyOption; +import javax.annotation.Nonnull; import java.util.ArrayList; -import java.util.Arrays; -import java.util.function.Consumer; public class BaseBand { - public static int majorVersion = 1; - public static int buildNumber = 497; - public static String hash = "06b9a1db4ba97794"; - public static String name = "BaseBand"; - public long timeOfCompile = 1710629129384L; - public CommandManager commandRegistry; - public EventBus eventBus; - public ArrayList modules = new ArrayList<>(); - public static BaseBand INSTANCE; - public static Registry Registry; - private static TCN registryData; - - { INSTANCE = this; } + public static BaseBand INSTANCE; { INSTANCE = this; } + private static ArrayList updaters = new ArrayList<>(); - public static final Logger log = LogManager.getLogger("BaseBand"); + public static Minecraft mc; - - public String getWatermark() { - switch (level) { - case 1: { - return "BaseBand+ v"+majorVersion+"."+buildNumber; - } - case 2: { - return "BaseBand b"+BaseBand.majorVersion + "." + BaseBand.buildNumber + "+" + BaseBand.hash; - } - } - return "BaseBand v"+majorVersion; + public static void registerUpdater(Updater updater) { + updaters.add(updater); + updater.populate(); } - public int level = 0; //Standard user - public void onInit() { - Utils.check(); + mc = Minecraft.getMinecraft(); - try { - Object keeper = BaseBand.class.getClassLoader().getClass().getFields()[1].get(BaseBand.class.getClassLoader()); - for (Method access : keeper.getClass().getMethods()) { - if(Arrays.equals(access.getParameterTypes(), new Class[]{Consumer.class}) && access.getDeclaringClass() == keeper.getClass()) { - access.invoke(keeper, (Consumer) accessor -> { - try { - Object registry = Arrays.stream(accessor.getClass().getMethods()).filter(x -> x.getParameterCount() == 0 && x.getDeclaringClass() == accessor.getClass()).findAny().get().invoke(accessor); - for (Method save : registry.getClass().getMethods()) { - if (save.getParameterCount() == 0 && save.getReturnType() == Void.TYPE && save.getDeclaringClass() == registry.getClass()) { - save.invoke(registry); // registry save - break; - } - } - } catch (IllegalAccessException | InvocationTargetException e) { - e.printStackTrace(); - Utils.crash(); - } - }); - } - } - } catch (Exception e) { - e.printStackTrace(); - Utils.crash(); - } - - try { - Registry = new Registry("BaseBand.registry"); - registryData = Registry.register("*"); - } catch (Exception e) { - // tamper detected - Utils.crash(); - } - // cant be a normal if statement because it might be null - if (registryData.getBoolean("LoaderPresent") == Boolean.TRUE) { - String key = registryData.getString("Key"); - TCN data = TCN.readMap(Tools.stringToMap(new Key(key).decryptString(registryData.getString("Data")))); - registryData.set("Key", null); - registryData.set("Data", null); - - this.level = data.getInteger("level"); - } else { - // do other stuff here later? - log.info("No loader present, but able to start anyway ==> Debug environment detected."); - } - // unset so this won't be discovered and manipulated - registryData.set("LoaderPresent", null); - Registry.save(); - - - commandRegistry = new CommandManager(); - eventBus = new EventBus(); - - addModule(new Brightness()); - addModule(new PacketTest()); - addModule(new HUD()); - addModule(new PacketFly()); - addModule(new Speed()); - addModule(new TPTracker()); - addModule(new NoSlip()); - addModule(new FastUse()); - addModule(new ElytraFly()); - addModule(new ChatCrypt()); - addModule(new NameTags()); - addModule(new ChatSuffix()); - - - MinecraftForge.EVENT_BUS.register(new FMLEventProcessor()); - - try { - for (Module m : modules) { - if(m.isEnabled()) { - m.setEnabled(m.isEnabled()); - MinecraftForge.EVENT_BUS.register(m); - eventBus.register(m); - } - } - } catch(Exception e) { - ConfigManager.save(); - } - - new Thread(() -> { - Lock lock = new Lock(); - while(true) { - lock.lock(10000); - ConfigManager.save(); - lock.waitHere(); - } - }, "Config save thread").start(); - - Display.setTitle(getWatermark()); - log.info("BaseBand Instantiated."); - } - - private static void downloadMCRegistry() { - try { - Class.forName("de.tudbut.mcregistry.MCRegistry"); - } catch (Exception e) { - JOptionPane.showMessageDialog(null, "Minecraft might need to restart to download BaseBand's required libraries."); - try { - InputStream uis = new URL("https://github.com/TudbuT/mcregistry/releases/download/v1.0/mcregistry-1.0.jar").openStream(); - Files.copy(uis, Paths.get("mods/mcregistry-1.0.jar"), StandardCopyOption.REPLACE_EXISTING); - Launch.classLoader.addURL(new URL("file://./mods/mcregistry-1.0.jar")); - uis.close(); - try { - Class.forName("de.tudbut.mcregistry.MCRegistry"); - } catch (ClassNotFoundException ex) { - System.out.println("----------- THIS IS NOT A BUG. CRASHING ON PURPOSE TO END GAME QUICKLY."); - throw new Error("THIS IS NOT A BUG!!!"); - } - JOptionPane.showMessageDialog(null, "Libraries installed."); - } catch (IOException ex) { - JOptionPane.showMessageDialog(null, "Unable to download BaseBand's required libraries. Please install mcregistry manually."); - throw new RuntimeException(ex); - } + Setup clientSetup = Setup.get(); + Module[] modules = clientSetup.MODULES; + for (int i = 0; i < modules.length; i++) { + modules[i].register(this, mc); } } - public void addModule(Module m) { - Restrict annotation = m.getClass().getDeclaredAnnotation(Restrict.class); - if (annotation != null) { - if(level < annotation.value().level) - return; - } - modules.add(m); - } - - public static T getModule(Class module) { - for (int i = 0; i < INSTANCE.modules.size(); i++) { - if(INSTANCE.modules.get(i).getClass() == module) { - return (T) INSTANCE.modules.get(i); - } - } - throw new RuntimeException(); - } - - public static Module getModule(String name) { - for (Module m : INSTANCE.modules) { - if (m.toString().equalsIgnoreCase(name)) { - return m; + @Nonnull + public static T getModule(Class clazz) { + Module[] modules = Setup.get().MODULES; + for (int i = 0; i < modules.length; i++) { + if(modules[i].getClass() == clazz) { + return (T) modules[i]; } } return null; } - - public static boolean isIngame() { - return Minecraft.getMinecraft().world != null && Minecraft.getMinecraft().player != null; - } } diff --git a/Client/src/main/java/com/baseband/client/Setup.java b/Client/src/main/java/com/baseband/client/Setup.java new file mode 100644 index 0000000..5388ec6 --- /dev/null +++ b/Client/src/main/java/com/baseband/client/Setup.java @@ -0,0 +1,34 @@ +package com.baseband.client; + +import com.baseband.client.module.Module; +import com.baseband.client.module.command.Test; +import de.tudbut.parsing.TCN; + +/** + * @author TudbuT + * + * Client setup: Included modules, etc. + */ +public class Setup { + + public final String REGISTRY_FILENAME = "baseband.db"; + public final Module[] MODULES = new Module[] { + new Test(), + }; + + + + + + /// SINGLETON LOGIC /// + + private static Setup INSTANCE; + + public static Setup get() { + if(INSTANCE == null) + INSTANCE = new Setup(); + return INSTANCE; + } + + private Setup() {} +} diff --git a/Client/src/main/java/com/baseband/client/configuration/ConfigHandle.java b/Client/src/main/java/com/baseband/client/configuration/ConfigHandle.java new file mode 100644 index 0000000..6061bea --- /dev/null +++ b/Client/src/main/java/com/baseband/client/configuration/ConfigHandle.java @@ -0,0 +1,39 @@ +package com.baseband.client.configuration; + +import de.tudbut.parsing.TCN; + +import java.lang.reflect.Field; +import java.util.ArrayList; + +public class ConfigHandle { + + final String name; + TCN tcn; + + ArrayList onUpdate = new ArrayList<>(); + + public ConfigHandle(String name, TCN tcn) { + this.name = name; + this.tcn = tcn; + } + + public String getName() { + return name; + } + + public TCN getContent() { + return tcn; + } + + public void updated() { + for (Updater updater : onUpdate) { + updater.onUpdateConfig(); + } + } + + public Updater linkWith(Object o, Field f) { + Updater updater = new Updater(this, o, f); + onUpdate.add(updater); + return updater; + } +} diff --git a/Client/src/main/java/com/baseband/client/configuration/Configuration.java b/Client/src/main/java/com/baseband/client/configuration/Configuration.java new file mode 100644 index 0000000..0f2d8bb --- /dev/null +++ b/Client/src/main/java/com/baseband/client/configuration/Configuration.java @@ -0,0 +1,35 @@ +package com.baseband.client.configuration; + +import com.baseband.client.Setup; +import de.tudbut.parsing.TCN; +import de.tudbut.tools.Registry; + +import java.io.IOException; +import java.util.HashMap; + +public class Configuration { + + private final Registry registry = new Registry(Setup.get().REGISTRY_FILENAME); + + private Configuration() throws IOException { + } + + private static Configuration INSTANCE; + + static { + try { + INSTANCE = new Configuration(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public static ConfigHandle register(String handle) throws IllegalAccessException { + return new ConfigHandle(handle, INSTANCE.registry.register(handle)); + } + + static void unregister(ConfigHandle handle) throws IllegalAccessException { + INSTANCE.registry.unregister(handle.name, handle.tcn); + handle.tcn = null; + } +} diff --git a/Client/src/main/java/com/baseband/client/configuration/Updater.java b/Client/src/main/java/com/baseband/client/configuration/Updater.java new file mode 100644 index 0000000..b36f3df --- /dev/null +++ b/Client/src/main/java/com/baseband/client/configuration/Updater.java @@ -0,0 +1,73 @@ +package com.baseband.client.configuration; + +import java.lang.reflect.Field; + +public class Updater { + + final ConfigHandle handle; + String id = "*"; + Object o; + Field field; + + Updater(ConfigHandle handle, Object o, Field field) { + this.handle = handle; + this.o = o; + this.field = field; + } + + void onUpdateConfig() { + try { + if (field.getType() == String.class) { + field.set(o, handle.getContent().getString(id)); + } else if (field.getType() == int.class) { + field.setInt(o, handle.getContent().getInteger(id)); + } else if (field.getType() == long.class) { + field.setLong(o, handle.getContent().getLong(id)); + } else if (field.getType() == float.class) { + field.setFloat(o, handle.getContent().getFloat(id)); + } else if (field.getType() == double.class) { + field.setDouble(o, handle.getContent().getDouble(id)); + } else if (field.getType() == boolean.class) { + field.setBoolean(o, handle.getContent().getBoolean(id)); + } else { + throw new IllegalStateException("Unhandled type of field: " + field.getType()); + } + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + } + void onUpdateField() { + try { + if(field.getType() == String.class || + field.getType() == int.class || + field.getType() == long.class || + field.getType() == float.class || + field.getType() == double.class || + field.getType() == boolean.class) { + handle.getContent().set(id, field.get(o)); + handle.updated(); + } else { + throw new IllegalStateException("Unhandled type of field: " + field.getType()); + } + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + public boolean isInvalid() { + return handle.getContent() == null; + } + + public void poll() { + onUpdateField(); + } + + public void populate() { + onUpdateConfig(); + } + + public Updater name(String id) { + this.id = id; + return this; + } +} diff --git a/Client/src/main/java/com/baseband/client/configuration/annotation/Config.java b/Client/src/main/java/com/baseband/client/configuration/annotation/Config.java new file mode 100644 index 0000000..caf0375 --- /dev/null +++ b/Client/src/main/java/com/baseband/client/configuration/annotation/Config.java @@ -0,0 +1,21 @@ +package com.baseband.client.configuration.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author TudbuT + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Config { + + /** + * Name + * @return the name + * @author TudbuT + */ + String value(); +} diff --git a/Client/src/main/java/com/baseband/client/configuration/annotation/Range.java b/Client/src/main/java/com/baseband/client/configuration/annotation/Range.java new file mode 100644 index 0000000..c18cfca --- /dev/null +++ b/Client/src/main/java/com/baseband/client/configuration/annotation/Range.java @@ -0,0 +1,20 @@ +package com.baseband.client.configuration.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author TudbuT + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Range { + + /** + * n..m + * @return the range + */ + String value(); +} diff --git a/Client/src/main/java/com/baseband/client/gui/GuiRewrite.java b/Client/src/main/java/com/baseband/client/gui/GuiRewrite.java new file mode 100644 index 0000000..f3b5238 --- /dev/null +++ b/Client/src/main/java/com/baseband/client/gui/GuiRewrite.java @@ -0,0 +1,161 @@ +package com.baseband.client.gui; + +import com.baseband.client.BaseBand; +import com.baseband.client.Setup; +import com.baseband.client.gui.lib.GUIManager; +import com.baseband.client.gui.lib.component.Category; +import com.baseband.client.gui.lib.component.Component; +import com.baseband.client.module.Module; +import com.baseband.client.module.render.ClickGUI; +import de.tudbut.obj.TLMap; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import org.lwjgl.input.Mouse; +import org.lwjgl.util.Point; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; + +public class GuiRewrite extends GuiScreen { + + // The mouse X and Y + private int cx; + private int cy; + private Category[] categories = new Category[0]; + + public GuiRewrite() { + this.mc = BaseBand.INSTANCE.mc; + ClickGUI clickGUI = BaseBand.getModule(ClickGUI.class); + if(!clickGUI.enabled) + clickGUI.toggle(); + createComponents(); + } + + // Minecraft wants this + @Override + public boolean doesGuiPauseGame() { + return mc.player.timeInPortal != 0; + } + + // The initiator, this can, for some reason, not be in the constructor + public void initGui() { + + // Minecraft wants this + super.buttonList.clear(); + super.buttonList.add(new GuiButton(0, -500, -500, "")); + super.initGui(); + } + + private void createComponents() { + ArrayList categories = new ArrayList<>(); + int y = 10; + TLMap map = new TLMap<>(); + for (int i = 0 ; i < Setup.get().MODULES.length ; i++) { + Module module = Setup.get().MODULES[i]; + if(!module.displayOnClickGUI()) { + continue; + } + Category category; + if((category = map.get(module.category)) == null) { + map.set(module.category, category = new Category() {{ + text = module.category.name; + }}); + if((module.category.x | module.category.y) != 0) { + category.location = new Point(module.category.x, module.category.y); + category.subComponentsShown = module.category.show; + } + if(category.location == null) { + category.location = new Point(10, y); + y += 20; + } + categories.add(category); + category.subComponents.clear(); + } + category.subComponents.add(module); + } + this.categories = categories.toArray(new Category[0]); + } + + // When ESC is pressed + @Override + public void onGuiClosed() { + super.onGuiClosed(); + BaseBand.getModule(ClickGUI.class).enabled = false; + for (Category category : categories) { + com.baseband.client.module.Category.fromName(category.text).show = category.subComponentsShown; + } + } + + @Override + public void updateScreen() { + for (Component value : GUIManager.renderedComponents.values()) { + value.update(); + } + GUIManager.update(); + } + + + // Called when the user presses a mouse button + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { + super.mouseClicked(mouseX, mouseY, mouseButton); + + // Update cx and cy + cx = mouseX; + cy = mouseY; + + GUIManager.click(mouseX, mouseY, mouseButton); + } + + + + // Update cx and cy + @Override + protected void mouseClickMove(int mouseX, int mouseY, int mouseButton, long timeSinceLastClick) { + cx = mouseX; + cy = mouseY; + + GUIManager.move(mouseX, mouseY, mouseButton); + } + + // Called when the user releases a mouse button + protected void mouseReleased(int mouseX, int mouseY, int state) { + super.mouseReleased(mouseX, mouseY, state); + + // Update cx and cy + cx = mouseX; + cy = mouseY; + } + + // Render the screen + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + + // Update cx and cy + cx = mouseX; + cy = mouseY; + + GUIManager.renderedComponents = new HashMap<>(); + for (int i = 0 ; i < categories.length ; i++) { + if(categories[i].location.getY() < -10000) { + categories[i].location.setY(categories[i].location.getY() + 10000); + } + if(categories[i].location.getY() > 10000) { + categories[i].location.setY(categories[i].location.getY() - 10000); + } + categories[i].render(); + } + + // TMP fix for a strange bug that causes the mouse to be hidden + if (BaseBand.getModule(ClickGUI.class).mouseFix) { + drawRect(mouseX - 2, mouseY - 2, mouseX + 2, mouseY + 2, 0xffffffff); + } + int m = Mouse.getDWheel(); + if(m != 0) { + for (int i = 0 ; i < categories.length ; i++) { + categories[i].location.setY(categories[i].location.getY() + m); + } + } + + super.drawScreen(mouseX, mouseY, partialTicks); + } +} diff --git a/Client/src/main/java/com/baseband/client/gui/GuiTTC.java b/Client/src/main/java/com/baseband/client/gui/GuiTTC.java new file mode 100644 index 0000000..62fb5e7 --- /dev/null +++ b/Client/src/main/java/com/baseband/client/gui/GuiTTC.java @@ -0,0 +1,429 @@ +package com.baseband.client.gui; + +import com.baseband.client.module.Module; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import org.lwjgl.input.Mouse; + +import java.awt.*; +import java.io.IOException; +import java.util.concurrent.atomic.AtomicReference; + +public class GuiTTC extends GuiScreen { + + // The buttons to be rendered (sub buttons are in the button object) + // One button per module + private Button[] buttons; + + // Theme + public interface ITheme { + int getGreenColor(); + int getRedColor(); + int getFrameColor(); + int getBackgroundColor(); + } + public enum Theme implements ITheme { + TTC(0xff80ff00, 0xff008800), + ETERNAL_BLUE(0xff4040ff, 0xffff0000, 0xffffffff, 0xff000030), + DARK(0xff008000, 0xff800000, 0xff808080, 0xff000000), + LIGHT(0xffcccccc, 0xff999999), + BLOOD(0xffaa0000, 0xff880000, 0xff00ffff, 0xaaaaaaaa), + SKY(0xff00cccc, 0xff009999, 0x000000), + KAMI_BLUE(0xbb353642, 0xbb353642, 0xffbbbbbb, 0xaaaaaaaa), + SCHLONGHAX(0xbb553662, 0xbb553662, 0xffbbbbbb, 0xaaaaaaaa), + ORANGE(0xffcc8000, 0xff996000, 0xff404040), + XV11(0xff3f718e, 0xff2d2d2d, 0xff67915f, 0xff000000), + TTC_OLD(0xff00ff00, 0xffff0000), + SOBERSHULKER(0xffff88ff, 0xffaa40aa, 0xffff88ff, 0xff000000), + VIRUS(0xffc0ddff, 0xffffffff, 0x00000000, 0xaa202040), + + ; + + @Override + public int getGreenColor() { + return greenColor; + } + + @Override + public int getRedColor() { + return redColor; + } + + @Override + public int getFrameColor() { + return frameColor; + } + + @Override + public int getBackgroundColor() { + return backgroundColor; + } + + public final int greenColor; + public final int redColor; + public final int frameColor; + public final int backgroundColor; + + Theme(int greenColor, int redColor) { + this.greenColor = greenColor; + this.redColor = redColor; + this.frameColor = 0xffffffff; + this.backgroundColor = 0xA0000000; + } + Theme(int greenColor, int redColor, int frameColor) { + this.greenColor = greenColor; + this.redColor = redColor; + this.frameColor = frameColor; + this.backgroundColor = 0xA0000000; + } + Theme(int greenColor, int redColor, int frameColor, int backgroundColor) { + this.greenColor = greenColor; + this.redColor = redColor; + this.frameColor = frameColor; + this.backgroundColor = backgroundColor; + } + } + + /* + // The mouse X and Y + private int cx; + private int cy; + private int lastScrollPos = Mouse.getEventDWheel(); + + public GuiTTC() { + this.mc = TTCp.mc; + } + + // Minecraft wants this + @Override + public boolean doesGuiPauseGame() { + return mc.player.timeInPortal != 0; + } + + // The initiator, this can, for some reason, not be in the constructor + public void initGui() { + // Creates buttons + buttons = new Button[256]; + resetButtons(); + + // Minecraft wants this + super.buttonList.clear(); + super.buttonList.add(new GuiButton(0, -500, -500, "")); + super.initGui(); + lastScrollPos = Mouse.getEventDWheel(); + } + + // When ESC is pressed + @Override + public void onGuiClosed() { + super.onGuiClosed(); + ClickGUI.getInstance().enabled = false; + } + + // Called every tick, idk why its called update tho + @Override + public void updateScreen() { + // Minecraft is stupid and sometimes forgets to call initScreen, so this is needed + while (buttons == null) { + try { + Thread.sleep(100); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + if (buttons == null) + resetButtons(); + } + // Call onTick on every button + for (int i = 0; i < buttons.length; i++) { + if (buttons[i] != null) + buttons[i].onTick(this); + } + } + + // Reset the buttons array + public void resetButtons() { + Button[] buttons = new Button[TTCp.modules.length]; + for (int i = 0, j = 0; i < TTCp.modules.length; i++) { + int x = j / 15; + int y = j - x * 15; + + // Don't add the button if it isn't requested + if (!TTCp.modules[i].displayOnClickGUI()) + continue; + + // Create the button + int r = i; + Button b = new Button( + 10 + (155 * x), 10 + (y * 25), TTCp.modules[r].toString() + ": " + TTCp.modules[r].enabled, + (text) -> { + if (TTCp.modules[r].enabled = !TTCp.modules[r].enabled) + TTCp.modules[r].onEnable(); + else + TTCp.modules[r].onDisable(); + + }, TTCp.modules[i] + ); + buttons[i] = b; + + j++; + } + this.buttons = buttons; + } + + // Reset text on the buttons + private void updateButtons() { + while (buttons == null) { + try { + Thread.sleep(100); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + if (buttons == null) + resetButtons(); + } + for (int i = 0; i < TTCp.modules.length; i++) { + if (buttons[i] != null) + buttons[i].text.set(TTCp.modules[i].toString() + ": " + TTCp.modules[i].enabled); + } + } + + // Called when the user presses a mouse button + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { + super.mouseClicked(mouseX, mouseY, mouseButton); + + // Update cx and cy + cx = mouseX; + cy = mouseY; + + // Notify buttons + for (int i = 0 ; i < buttons.length ; i++) { + Button button = buttons[i]; + if (button != null) + if (button.mouseClicked(mouseX, mouseY, mouseButton)) + return; + } + } + + + + // Update cx and cy + @Override + protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { + cx = mouseX; + cy = mouseY; + } + + // Called when the user releases a mouse button + protected void mouseReleased(int mouseX, int mouseY, int state) { + super.mouseReleased(mouseX, mouseY, state); + + // Update cx and cy + cx = mouseX; + cy = mouseY; + + // Notify buttons + for (int i = 0 ; i < buttons.length ; i++) { + Button button = buttons[i]; + if (button != null) + button.mouseReleased(); + } + } + + // Render the screen + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + updateButtons(); + + this.drawDefaultBackground(); + + cx = mouseX; + cy = mouseY; + + // Ask the buttons to render themselves + for (int i = 0; i < buttons.length; i++) { + if (buttons[i] != null) + buttons[i].draw(this); + } + + // TMP fix for a strange bug that causes the mouse to be hidden + if (ClickGUI.getInstance().mouseFix) { + drawRect(mouseX - 2, mouseY - 2, mouseX + 2, mouseY + 2, 0xffffffff); + } + int m = -Mouse.getDWheel(); + if(m != 0) { + for (int i = 0; i < buttons.length; i++) { + if(buttons[i] != null) { + int d = (lastScrollPos - m) / 3; + switch (ClickGUI.getInstance().sd) { + case Vertical: + buttons[i].y += d; + break; + case Horizontal: + buttons[i].x += d; + break; + } + } + } + } + + super.drawScreen(mouseX, mouseY, partialTicks); + } + + + public static class Button { + public int x, y; + public AtomicReference text; + // Color for rendering + public int color = 0x8000ff00; + // The associated module, can be null if it is a sub button + public Module module; + // Called when the button is clicked + ButtonClickEvent event; + // If any mouse button is pressed + private boolean mouseDown = false; + // The mouse button that is pressed + private int mouseDownButton = 0; + // The sub buttons of the button, null if no module is associated to provide them + private Button[] subButtons; + + private boolean display = true; + + // Constructor used for sub buttons + public Button(String text, ButtonClickEvent event) { + this(0, 0, text, event, null); + } + + // Constructor used by GuiTTC to construct a button with an associated module + // and main constructor + public Button(int x, int y, String text, ButtonClickEvent event, Module module) { + if (module != null) { + if (module.clickGuiX != null && module.clickGuiY != null) { + x = module.clickGuiX; + y = module.clickGuiY; + } + subButtons = module.subButtons.toArray(new Button[0]); + display = module.displayOnClickGUI(); + } + this.x = x; + this.y = y; + this.text = new AtomicReference<>(text); + this.event = event; + this.module = module; + if(ClickGUI.getInstance() != null) + this.color = ClickGUI.getInstance().getTheme().getGreenColor(); + } + + // Render the button + public void draw(GuiTTC gui) { + if (!display) + return; + + int color = this.color; + + if (gui.cx >= x && gui.cy >= y && gui.cx <= x + 150 && gui.cy <= y + ySize()) { + Color c = new Color(color, true); + int r, g, b, a; + r = c.getRed(); + g = c.getGreen(); + b = c.getBlue(); + a = c.getAlpha(); + r += 0x20; + g += 0x20; + b += 0x20; + a += 0x20; + color = new Color(Math.min(r, 0xff),Math.min(g, 0xff),Math.min(b, 0xff),Math.min(a, 0xff)).getRGB(); + } + + drawRect(x, y, x + 150, y + ySize(), color); + //gui.fontRenderer.drawString(text.get(), x + 6, y + ySize() / 2f - 8 / 2f, ClickGUI.getInstance().getTheme().getFrameColor(), ClickGUI.getInstance().getTheme().hasShadow()); + + // Draw sub buttons + if (module != null && (module.enabled ^ module.clickGuiShow)) { + //subButtons = module.getSubButtons(); + + for (int i = 0; i < subButtons.length; i++) { + Button b = subButtons[i]; + if(b != null) { + b.x = x; + b.y = y + ( ( i + 1 ) * 15 + ( 20 - 15 ) ); + b.color = ClickGUI.getInstance().getTheme().getRedColor(); + b.draw(gui); + } + } + } + } + + public int ySize() { + return module == null ? 15 : 20; + } + + public boolean mouseClicked(int clickX, int clickY, int button) { + if (clickX >= x && clickY >= y) { + if (clickX < x + 150 && clickY < y + ySize()) { + mouseDown = true; + if(ClickGUI.getInstance().flipButtons) { + button = (button == 0 ? 1 : (button == 1 ? 0 : button)); + } + mouseDownButton = button; + click(button); + return true; + } + } + if (module != null && (module.enabled ^ module.clickGuiShow)) { + //subButtons = module.getSubButtons(); + + for (int i = 0; i < subButtons.length; i++) { + Button b = subButtons[i]; + if(b != null) { + b.x = x; + b.y = y + ( ( i + 1 ) * 15 + ( 20 - 15 ) ); + b.color = ClickGUI.getInstance().getTheme().getRedColor(); + if (b.mouseClicked(clickX, clickY, button)) + return true; + } + } + } + return false; + } + + public void mouseReleased() { + mouseDown = false; + if (module != null && (module.enabled ^ module.clickGuiShow)) { + subButtons = module.subButtons.toArray(new Button[0]); + + for (int i = 0; i < subButtons.length; i++) { + subButtons[i].mouseReleased(); + } + } + + } + + // More simple onCLick, only called when the mouse is clicked while on the button + protected void click(int button) { + if (button == 0) + event.run(text); + if (button == 2 && module != null) + module.clickGuiShow = !module.clickGuiShow; + } + + protected void onTick(GuiTTC gui) { + this.color = ClickGUI.getInstance().getTheme().getGreenColor(); + if (module != null) { + if (mouseDown && mouseDownButton == 1) { + x = gui.cx - 150 / 2; + y = gui.cy - 10; + x = (x / 5) * 5; + y = (y / 5) * 5; + } + module.clickGuiX = x; + module.clickGuiY = y; + } + } + + } + + public interface ButtonClickEvent { + void run(AtomicReference text); + }*/ +} diff --git a/Client/src/main/java/com/baseband/client/gui/lib/GUIManager.java b/Client/src/main/java/com/baseband/client/gui/lib/GUIManager.java new file mode 100644 index 0000000..51c6f45 --- /dev/null +++ b/Client/src/main/java/com/baseband/client/gui/lib/GUIManager.java @@ -0,0 +1,61 @@ +package com.baseband.client.gui.lib; + +import com.baseband.client.BaseBand; +import com.baseband.client.gui.GuiTTC; +import com.baseband.client.gui.lib.component.Component; +import com.baseband.client.module.render.ClickGUI; +import org.lwjgl.util.Rectangle; + +import java.util.HashMap; +import java.util.Map; + +@SuppressWarnings("ALL") +public class GUIManager { + + public static int fontColorOn = 0xff00ff00; + public static int fontColorOff = 0xffff0000; + public static int frameColor = 0xffffffff; + public static int frameBackground = 0xA0000000; + public static int sliderBackground = 0xff808080; + public static int sliderColor = 0xffffffff; + + public static HashMap renderedComponents = new HashMap<>(); + + static Component dragging = null; + + public static synchronized void click(int mouseX, int mouseY, int mouseButton) { + dragging = null; + Map.Entry[] entries = renderedComponents.entrySet().toArray(new Map.Entry[0]); + for (int i = 0, entriesSize = entries.length ; i < entriesSize ; i++) { + Map.Entry entry = entries[i]; + if(mouseX >= entry.getKey().getX() && mouseY >= entry.getKey().getY() && mouseX <= entry.getKey().getWidth() && mouseY <= entry.getKey().getHeight()) { + entry.getValue().click(mouseX - entry.getValue().loc.getX(), mouseY - entry.getValue().loc.getY(), mouseButton); + return; + } + } + } + + public static synchronized void move(int mouseX, int mouseY, int mouseButton) { + if(dragging == null) { + Map.Entry[] entries = renderedComponents.entrySet().toArray(new Map.Entry[0]); + for (int i = 0, entriesSize = entries.length; i < entriesSize ; i++) { + Map.Entry entry = entries[i]; + if (mouseX >= entry.getKey().getX() && mouseY >= entry.getKey().getY() && mouseX <= entry.getKey().getWidth() && mouseY <= entry.getKey().getHeight()) { + dragging = entry.getValue(); + break; + } + } + } + if(dragging != null) { + dragging.move(mouseX - dragging.loc.getX(), mouseY - dragging.loc.getY(), mouseButton); + } + } + + public static void update() { + GuiTTC.ITheme theme = BaseBand.getModule(ClickGUI.class).getTheme(); + fontColorOn = theme.getGreenColor(); + fontColorOff = theme.getRedColor(); + frameColor = theme.getFrameColor(); + frameBackground = theme.getBackgroundColor(); + } +} diff --git a/Client/src/main/java/com/baseband/client/gui/lib/component/Button.java b/Client/src/main/java/com/baseband/client/gui/lib/component/Button.java new file mode 100644 index 0000000..54f7221 --- /dev/null +++ b/Client/src/main/java/com/baseband/client/gui/lib/component/Button.java @@ -0,0 +1,26 @@ +package com.baseband.client.gui.lib.component; + +public class Button extends Component { + + private final ClickEvent event; + + {green = true;} + + public Button(String s, ClickEvent event) { + this.text = s; + this.event = event; + } + + @Override + public void click(int x, int y, int mouseButton) { + super.click(x, y, mouseButton); + if(mouseButton == 0) { + green = true; + event.click(this); + } + } + + public interface ClickEvent { + void click(Button it); + } +} diff --git a/Client/src/main/java/com/baseband/client/gui/lib/component/Category.java b/Client/src/main/java/com/baseband/client/gui/lib/component/Category.java new file mode 100644 index 0000000..29f3f0a --- /dev/null +++ b/Client/src/main/java/com/baseband/client/gui/lib/component/Category.java @@ -0,0 +1,59 @@ +package com.baseband.client.gui.lib.component; + +import com.baseband.client.gui.lib.GUIManager; +import de.tudbut.obj.Transient; +import net.minecraft.client.gui.Gui; +import org.lwjgl.util.Point; +import org.lwjgl.util.Rectangle; + +import java.util.concurrent.atomic.AtomicInteger; + +public class Category extends Component { + + {green = true;} + + public Point location; + + public void render() { + render(location.getX(), new AtomicInteger(location.getY()), -1, false, 0); + } + + @Override + public void render(int x, AtomicInteger y, int sub, boolean isLastInList, int yLineSize) { + loc = new Point(x + 8 + sub * 8, y.get()); + GUIManager.renderedComponents.put(new Rectangle(x + sub * 8, y.get(), x + (200 - sub * 8), y.get() + size()), this); + int width = fontRenderer.getStringWidth(text); + Gui.drawRect(x + 2, y.get() + 4, x + 200, y.get() + subSizes() + size(), GUIManager.frameBackground); + Gui.drawRect(x + 200, y.get() + 4, x + 200 - 1, y.get() + subSizes() + size(), GUIManager.frameColor); + Gui.drawRect(x + width, y.get() + 4, x + 200, y.get() + 4 + 1, GUIManager.frameColor); + fontRenderer.drawString(text, x, y.get(), green ? GUIManager.fontColorOn : GUIManager.fontColorOff); + y.addAndGet(size()); + if(subComponentsShown) { + for (int i = 0 ; i < subComponents.size() ; i++) { + Component component = subComponents.get(i); + component.render(x, y, 0, false, component.size()); + } + } + Gui.drawRect(x + 2, y.get(), x + 200, y.get() - 1, GUIManager.frameColor); + } + + @Transient + int clickX = 0, clickY = 0; + + @Override + public void click(int x, int y, int mouseButton) { + if(mouseButton == 0) { + subComponentsShown = !subComponentsShown; + } + clickX = x; + clickY = y; + } + + public void move(int x, int y, int mouseButton) { + if(mouseButton == 1) { + location.setX(location.getX() + x - clickX); + location.setY(location.getY() + y - clickY); + loc = location; + } + } +} diff --git a/Client/src/main/java/com/baseband/client/gui/lib/component/Component.java b/Client/src/main/java/com/baseband/client/gui/lib/component/Component.java new file mode 100644 index 0000000..4b8a04e --- /dev/null +++ b/Client/src/main/java/com/baseband/client/gui/lib/component/Component.java @@ -0,0 +1,109 @@ +package com.baseband.client.gui.lib.component; + +import com.baseband.client.gui.lib.GUIManager; +import de.tudbut.obj.Save; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import org.lwjgl.util.Point; +import org.lwjgl.util.Rectangle; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; + +public abstract class Component { + + public Point loc; + + FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; + public ArrayList subComponents = new ArrayList<>(); + public String text = ""; + public boolean green = false; + @Save + public boolean subComponentsShown = false; + public boolean displayConfirmation = false; + private final Button[] confirmationButtons = new Button[3]; + private static boolean makingCBs = false; + { + if(!makingCBs) { + makingCBs = true; + confirmationButtons[0] = new Button("Are you sure?", it -> { }); + confirmationButtons[1] = new Button("Yes", it -> { + displayConfirmation = false; + onConfirm(true); + }); + confirmationButtons[2] = new Button("No", it -> { + displayConfirmation = false; + onConfirm(false); + }); + makingCBs = false; + } + } + + public void render(int x, AtomicInteger y, int sub, boolean isLastInList, int yLineSize) { + loc = new Point(x + 8 + sub * 8, y.get()); + GUIManager.renderedComponents.put(new Rectangle(x + sub * 8, y.get(), x + (200 - sub * 8), y.get() + size()), this); + if(isLastInList) { + Gui.drawRect(x + 2 + sub * 8, y.get(), x + 2 + sub * 8 + 1, y.get() + 4, GUIManager.frameColor); + } + else { + Gui.drawRect(x + 2 + sub * 8, y.get(), x + 2 + sub * 8 + 1, y.get() + yLineSize, GUIManager.frameColor); + } + Gui.drawRect(x + 2 + sub * 8, y.get(), x + 2 + sub * 8 + 1, y.get() + subSizes() + (isLastInList ? 5 : size()), GUIManager.frameColor); + Gui.drawRect(x + 2 + sub * 8, y.get() + 4, x + 5 + sub * 8 + 1, y.get() + 4 + 1, GUIManager.frameColor); + fontRenderer.drawString(text, x + 8 + sub * 8, y.get(), green ? GUIManager.fontColorOn : GUIManager.fontColorOff); + draw(x + 8 + sub * 8, y.get()); + y.addAndGet(size()); + if(subComponentsShown) { + List subComponents = this.subComponents; + if(displayConfirmation) { + subComponents = Arrays.asList(confirmationButtons); + } + for (int i = 0 ; i < subComponents.size() ; i++) { + Component component = subComponents.get(i); + component.render( + x, y, sub + 1, + i == subComponents.size() - 1, + i == subComponents.size() - 1 && isLastInList && component.subComponents.size() == 0 ? 4 : component.size() + ); + } + } + } + + public void draw(int x, int y) { + + } + + protected int subSizes() { + int size = 0; + if(subComponentsShown) { + if(displayConfirmation) + return 30; + for (int i = 0 ; i < subComponents.size() ; i++) { + size += subComponents.get(i).size() + subComponents.get(i).subSizes(); + } + } + return size; + } + + protected int size() { + return 10; + } + + public void update() { } + + public void click(int x, int y, int mouseButton) { + if(mouseButton == 0) { + green = !green; + } + if(mouseButton == 1 || mouseButton == 2) { + subComponentsShown = !subComponentsShown; + } + } + + public void move(int x, int y, int mouseButton) { } + + public void onConfirm(boolean result) { } +} diff --git a/Client/src/main/java/com/baseband/client/gui/lib/component/EnumButton.java b/Client/src/main/java/com/baseband/client/gui/lib/component/EnumButton.java new file mode 100644 index 0000000..cd0d78a --- /dev/null +++ b/Client/src/main/java/com/baseband/client/gui/lib/component/EnumButton.java @@ -0,0 +1,40 @@ +package com.baseband.client.gui.lib.component; + +import com.baseband.client.configuration.ConfigHandle; + +public class EnumButton extends Component { + ConfigHandle handle; + String field; + Class> enumType; + Enum[] enums; + + {green = true;} + + public EnumButton(Class> enumType, String s, ConfigHandle handle, String field) { + this.enumType = enumType; + enums = enumType.getEnumConstants(); + this.text = s; + this.handle = handle; + this.field = field; + for (int i = 0 ; i < enums.length ; i++) { + Button button; + int finalI = i; + subComponents.add(button = new Button(enums[i].toString(), it -> { + handle.getContent().set(field, finalI); + handle.updated(); + for (Component component : subComponents) { + component.green = false; + } + it.green = true; + })); + button.green = handle.getContent().getInteger(field) == enums[i].ordinal(); + } + } + + @Override + public void click(int x, int y, int mouseButton) { + super.click(x, y, mouseButton); + green = true; + + } +} diff --git a/Client/src/main/java/com/baseband/client/gui/lib/component/IntSlider.java b/Client/src/main/java/com/baseband/client/gui/lib/component/IntSlider.java new file mode 100644 index 0000000..9981759 --- /dev/null +++ b/Client/src/main/java/com/baseband/client/gui/lib/component/IntSlider.java @@ -0,0 +1,72 @@ +package com.baseband.client.gui.lib.component; + +import com.baseband.client.configuration.ConfigHandle; +import com.baseband.client.gui.lib.GUIManager; +import net.minecraft.client.gui.Gui; + +import java.util.function.Function; + +public class IntSlider extends Component { + + public float f = 0; + ConfigHandle handle; + String field; + Function sliderText; + Function updateMethod; + int mapper; + int adder; + + {green = true;} + + public IntSlider(String s, ConfigHandle handle, String field, Function text, int mapper, int adder, Function updateMethod) { + this.text = s; + this.handle = handle; + this.field = field; + this.sliderText = text; + this.mapper = mapper; + this.adder = adder; + this.updateMethod = updateMethod; + update(); + } + + public IntSlider(String s, ConfigHandle handle, String field, Function text, int mapper, int adder) { + this(s, handle, field, text, mapper, adder, t -> true); + } + + @Override + public void draw(int x, int y) { + Gui.drawRect(x, y + 13, x + 101, y + 14, GUIManager.sliderBackground); + Gui.drawRect((int) Math.floor(x + f * 100), y + 11, (int) Math.floor(x + f * 100) + 1, y + 16, GUIManager.sliderColor); + fontRenderer.drawString(sliderText.apply(Math.round(f * mapper + adder)), x + 100 + 4, y + 10, GUIManager.sliderColor); + } + + @Override + public synchronized void update() { + f = (handle.getContent().getInteger(field) - adder) / (float) mapper; + } + + @Override + public synchronized void click(int x, int y, int mouseButton) { + if(mouseButton == 0) + f = Math.max(Math.min(x, 100), 0) / 100f; + + handle.getContent().set(field, Math.round(f * mapper + adder)); + handle.updated(); + if(!updateMethod.apply(Math.round(f * mapper + adder))) { + System.out.println("Something went wrong handling the sliders!"); + throw new RuntimeException(); + } + update(); + } + + @Override + public void move(int x, int y, int mouseButton) { + click(x, y, mouseButton); + } + + @Override + protected int size() { + return 20; + } + +} diff --git a/Client/src/main/java/com/baseband/client/gui/lib/component/Slider.java b/Client/src/main/java/com/baseband/client/gui/lib/component/Slider.java new file mode 100644 index 0000000..c8c415c --- /dev/null +++ b/Client/src/main/java/com/baseband/client/gui/lib/component/Slider.java @@ -0,0 +1,71 @@ +package com.baseband.client.gui.lib.component; + +import com.baseband.client.configuration.ConfigHandle; +import com.baseband.client.gui.lib.GUIManager; +import net.minecraft.client.gui.Gui; + +import java.util.function.Function; + +public class Slider extends Component { + + public float f = 0; + ConfigHandle handle; + String field; + Function sliderText; + Function updateMethod; + float mapper; + float adder; + + {green = true;} + + public Slider(String s, ConfigHandle handle, String field, Function text, float mapper, float adder, Function updateMethod) { + this.text = s; + this.handle = handle; + this.field = field; + this.sliderText = text; + this.mapper = mapper; + this.adder = adder; + this.updateMethod = updateMethod; + update(); + } + + public Slider(String s, ConfigHandle handle, String field, Function text, float mapper, float adder) { + this(s, handle, field, text, mapper, adder, t -> true); + } + + @Override + public void draw(int x, int y) { + Gui.drawRect(x, y + 13, x + 101, y + 14, GUIManager.sliderBackground); + Gui.drawRect((int) Math.floor(x + f * 100), y + 11, (int) Math.floor(x + f * 100) + 1, y + 16, GUIManager.sliderColor); + fontRenderer.drawString(sliderText.apply(f * mapper + adder), x + 100 + 4, y + 10, GUIManager.sliderColor); + } + + @Override + public synchronized void update() { + f = (handle.getContent().getFloat(field) - adder) / mapper; + } + + @Override + public synchronized void click(int x, int y, int mouseButton) { + if(mouseButton == 0) + f = Math.max(Math.min(x, 100), 0) / 100f; + + handle.getContent().set(field, f * mapper + adder); + handle.updated(); + if(!updateMethod.apply(f * mapper + adder)) { + System.out.println("Something went wrong handling the sliders!"); + throw new RuntimeException(); + } + update(); + } + + @Override + public void move(int x, int y, int mouseButton) { + click(x, y, mouseButton); + } + + @Override + protected int size() { + return 20; + } +} diff --git a/Client/src/main/java/com/baseband/client/gui/lib/component/ToggleButton.java b/Client/src/main/java/com/baseband/client/gui/lib/component/ToggleButton.java new file mode 100644 index 0000000..4695c76 --- /dev/null +++ b/Client/src/main/java/com/baseband/client/gui/lib/component/ToggleButton.java @@ -0,0 +1,42 @@ +package com.baseband.client.gui.lib.component; + +import com.baseband.client.configuration.ConfigHandle; + +public class ToggleButton extends Component { + + protected ConfigHandle handle; + protected String field; + private Runnable lambda; + + public ToggleButton(String s, ConfigHandle handle, String field) { + this.text = s; + this.handle = handle; + this.field = field; + update(); + } + public ToggleButton(String s, ConfigHandle handle, String field, Runnable lambda) { + this.lambda = lambda; + this.text = s; + this.handle = handle; + this.field = field; + update(); + } + + @Override + public synchronized void update() { + green = handle.getContent().getBoolean(field); + } + + @Override + public synchronized void click(int x, int y, int mouseButton) { + super.click(x, y, mouseButton); + handle.getContent().set(field, green); + handle.updated(); + if(lambda != null) + lambda.run(); + } + + public interface ClickEvent { + void click(Button it); + } +} diff --git a/Client/src/main/java/com/baseband/client/module/Category.java b/Client/src/main/java/com/baseband/client/module/Category.java new file mode 100644 index 0000000..2917d12 --- /dev/null +++ b/Client/src/main/java/com/baseband/client/module/Category.java @@ -0,0 +1,53 @@ +package com.baseband.client.module; + +import com.baseband.client.BaseBand; +import com.baseband.client.configuration.ConfigHandle; +import com.baseband.client.configuration.Configuration; +import com.baseband.client.util.FieldUtil; +import com.baseband.client.util.Marker; + +import javax.annotation.Nonnull; + +public enum Category { + + COMMAND("Commands"), + RENDER("Render") + + ; + + Category(String name) { + this.name = name; + try { + handle = Configuration.register("Category/" + name.toLowerCase().replace(' ', '_')); + BaseBand.registerUpdater(handle.linkWith(this, FieldUtil.findMarked(getClass(), 1)).name("x")); + BaseBand.registerUpdater(handle.linkWith(this, FieldUtil.findMarked(getClass(), 2)).name("y")); + BaseBand.registerUpdater(handle.linkWith(this, FieldUtil.findMarked(getClass(), 3)).name("show")); + } catch (IllegalAccessException e) { + //:skollerolley: + throw new RuntimeException(e); + } + } + + private ConfigHandle handle; + @Marker(1) + public int x; + @Marker(2) + public int y; + @Marker(3) + public boolean show; + + public final String name; + + public String toString() { + return name; + } + + @Nonnull + public static Category fromName(String s) { + for (Category c : values()) { + if(c.name.equals(s)) + return c; + } + return null; + } +} diff --git a/Client/src/main/java/com/baseband/client/module/Module.java b/Client/src/main/java/com/baseband/client/module/Module.java index 585652b..866d08f 100644 --- a/Client/src/main/java/com/baseband/client/module/Module.java +++ b/Client/src/main/java/com/baseband/client/module/Module.java @@ -1,81 +1,150 @@ -/* - * Copyright (c) 2023 Jess H & Daniella H. All Rights Reserved. - * Unauthorized copying of this file via any medium is Strictly Prohibited. - */ - package com.baseband.client.module; import com.baseband.client.BaseBand; +import com.baseband.client.configuration.ConfigHandle; +import com.baseband.client.configuration.Configuration; +import com.baseband.client.configuration.annotation.Config; +import com.baseband.client.configuration.annotation.Range; +import com.baseband.client.gui.lib.component.IntSlider; +import com.baseband.client.gui.lib.component.Slider; +import com.baseband.client.gui.lib.component.ToggleButton; +import com.baseband.client.util.FieldUtil; +import com.baseband.client.util.Marker; import net.minecraft.client.Minecraft; -import net.minecraftforge.common.MinecraftForge; -import de.tudbut.obj.Save; -import de.tudbut.parsing.TCN; -import de.tudbut.tools.ConfigSaverTCN2; -public abstract class Module { - @Save - boolean isEnabled = defaultEnabled(); - protected boolean defaultEnabled() { return false; } +import java.lang.reflect.Field; +import java.util.HashMap; - @Save - int key = defaultKey(); - protected int defaultKey() { return 0; } +/** + * @author TudbuT + */ +public abstract class Module extends ToggleButton { - public void setEnabled(boolean enabled) { - isEnabled = enabled; + protected BaseBand bb; + protected Minecraft mc; - if(isEnabled) { - enable(); - BaseBand.INSTANCE.eventBus.register(this); - MinecraftForge.EVENT_BUS.register(this); - } else { - disable(); - BaseBand.INSTANCE.eventBus.unregister(this); - MinecraftForge.EVENT_BUS.unregister(this); - } + public Category category; + + @Marker(1) + public boolean enabled = defaultEnable(); + + public Module() { + super("Uninit", null, "Enabled"); + + this.text = toString(); } - TCN data; - { - try { - data = BaseBand.Registry.register(this.toString()); - if(data.getSub("@Save") != null) - ConfigSaverTCN2.read(data.getSub("@Save"), this); - } catch (IllegalAccessException | ClassNotFoundException e) { - throw new RuntimeException(e); - } + // module methods + + protected boolean defaultEnable() { + return false; } - public void updateData() { - data.set("@Save", ConfigSaverTCN2.write(this, false, true)); + public void onDisable() { + } - protected static Minecraft mc = Minecraft.getMinecraft(); + public void onEnable() { - public void setKey(int key) { - this.key = key; - } - - public int getKey() { - return key; - } - - public boolean isEnabled() { - return isEnabled; - } - - public void enable(){} - - public void disable(){} - - public String getHudMeta() { - return ""; } public abstract String toString(); - public void toggle() { - setEnabled(!isEnabled); + protected void setup() {} + + public boolean displayOnClickGUI() { + return true; } + // own methods + + public final void register(BaseBand bbInst, Minecraft mc) { + this.bb = bbInst; + this.mc = mc; + + subComponents.clear(); + + ConfigHandle settings = config("Settings"); + Field[] fields = getClass().getDeclaredFields(); + for (Field f : fields) { + Config config = f.getDeclaredAnnotation(Config.class); + if (config != null) { + BaseBand.registerUpdater(settings.linkWith(this, f).name(config.value())); + if (f.getType() == boolean.class) { + subComponents.add(new ToggleButton(config.value(), settings, config.value())); + } + if (f.getType() == int.class) { + Range range = f.getDeclaredAnnotation(Range.class); + if (range != null) { + String[] r = range.value().split("\\.\\."); + int min = Integer.parseInt(r[0]); + int max = Integer.parseInt(r[1]); + subComponents.add(new IntSlider(config.value(), settings, config.value(), Object::toString, max - min, min)); + } else { + throw new RuntimeException("No range specified for slider"); + } + } + if (f.getType() == float.class) { + Range range = f.getDeclaredAnnotation(Range.class); + if (range != null) { + String[] r = range.value().split("\\.\\."); + float min = Float.parseFloat(r[0]); + float max = Float.parseFloat(r[1]); + subComponents.add(new Slider(config.value(), settings, config.value(), Object::toString, max - min, min)); + } else { + throw new RuntimeException("No range specified for slider"); + } + } + } + } + + handle = settings; + BaseBand.registerUpdater(settings.linkWith(this, FieldUtil.findMarked(getClass(), 1)).name("Enabled")); + + setup(); + } + + protected void check() { + if (bb == null || mc == null) { + throw new RuntimeException(); + } + if (mc.world == null || mc.player == null) { + throw new NullPointerException(); + } + } + + public String getIDCategory() { + return category.toString().toLowerCase(); + } + + public String getIDName() { + return toString().toLowerCase().replace(' ', '_'); + } + + public String getID() { + return getIDCategory() + "." + getIDName(); + } + + private final HashMap ownedHandles = new HashMap<>(); + + protected ConfigHandle config(String handle) { + if(ownedHandles.containsKey(handle)) { + return ownedHandles.get(handle); + } + try { + ConfigHandle h = Configuration.register(getID() + "/" + handle); + ownedHandles.put(handle, h); + return h; + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + public void toggle() { + enabled = !enabled; + if(enabled) + onEnable(); + else + onDisable(); + } } diff --git a/Client/src/main/java/com/baseband/client/module/command/Test.java b/Client/src/main/java/com/baseband/client/module/command/Test.java new file mode 100644 index 0000000..89fd46c --- /dev/null +++ b/Client/src/main/java/com/baseband/client/module/command/Test.java @@ -0,0 +1,28 @@ +package com.baseband.client.module.command; + +import com.baseband.client.configuration.annotation.Config; +import com.baseband.client.configuration.annotation.Range; +import com.baseband.client.module.Module; + +/** + * @author TudbuT + * + * Self-Test command, checks if everything is working + */ +public class Test extends Module { + + @Config("Int Setting") + @Range("0..10") + private int intSetting = 5; + + + @Override + public String toString() { + return "Test"; + } + + @Override + protected void setup() { + + } +} diff --git a/Client/src/main/java/com/baseband/client/module/render/ClickGUI.java b/Client/src/main/java/com/baseband/client/module/render/ClickGUI.java new file mode 100644 index 0000000..48a7333 --- /dev/null +++ b/Client/src/main/java/com/baseband/client/module/render/ClickGUI.java @@ -0,0 +1,19 @@ +package com.baseband.client.module.render; + +import com.baseband.client.configuration.annotation.Config; +import com.baseband.client.gui.GuiTTC; +import com.baseband.client.module.Module; + +public class ClickGUI extends Module { + @Config("Mouse Fix") + public boolean mouseFix; + + @Override + public String toString() { + return "ClickGUI"; + } + + public GuiTTC.ITheme getTheme() { + return GuiTTC.Theme.TTC; + } +} diff --git a/Client/src/main/java/com/baseband/client/util/FieldUtil.java b/Client/src/main/java/com/baseband/client/util/FieldUtil.java new file mode 100644 index 0000000..01ccc0c --- /dev/null +++ b/Client/src/main/java/com/baseband/client/util/FieldUtil.java @@ -0,0 +1,18 @@ +package com.baseband.client.util; + +import javax.annotation.Nonnull; +import java.lang.reflect.Field; + +public class FieldUtil { + + @Nonnull + public static Field findMarked(Class clazz, int id) { + Field[] fields = clazz.getDeclaredFields(); + for (int i = 0; i < fields.length; i++) { + Marker marker = fields[i].getDeclaredAnnotation(Marker.class); + if(marker != null && marker.value() == id) + return fields[i]; + } + return null; + } +} diff --git a/Client/src/main/java/com/baseband/client/util/Marker.java b/Client/src/main/java/com/baseband/client/util/Marker.java new file mode 100644 index 0000000..fc4d5db --- /dev/null +++ b/Client/src/main/java/com/baseband/client/util/Marker.java @@ -0,0 +1,12 @@ +package com.baseband.client.util; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Marker { + int value(); +} diff --git a/Client/src/main/java/com/baseband/client/ASyncRunner.java b/Client/src/old/ASyncRunner.java similarity index 96% rename from Client/src/main/java/com/baseband/client/ASyncRunner.java rename to Client/src/old/ASyncRunner.java index 60fb0e0..3008c60 100644 --- a/Client/src/main/java/com/baseband/client/ASyncRunner.java +++ b/Client/src/old/ASyncRunner.java @@ -3,7 +3,7 @@ * Unauthorized copying of this file via any medium is Strictly Prohibited. */ -package com.baseband.client; +package com.baseband.client.old; //JessSystemV //7:28 AM, 2023-10-05 diff --git a/Client/src/old/BaseBand.java b/Client/src/old/BaseBand.java new file mode 100644 index 0000000..36b9316 --- /dev/null +++ b/Client/src/old/BaseBand.java @@ -0,0 +1,222 @@ +/* + * Copyright (c) 2023 Jess H & Daniella H. All Rights Reserved. + * Unauthorized copying of this file via any medium is Strictly Prohibited. + */ + +package com.baseband.client.old; + + +import com.baseband.client.old.command.CommandManager; +import com.baseband.client.old.event.EventBus; +import com.baseband.client.old.event.FMLEventProcessor; +import com.baseband.client.old.module.Module; +import com.baseband.client.old.module.modules.*; +import de.tudbut.parsing.TCN; +import de.tudbut.tools.Lock; +import de.tudbut.tools.Registry; +import de.tudbut.tools.Tools; +import net.minecraft.client.Minecraft; +import net.minecraft.launchwrapper.Launch; +import net.minecraftforge.common.MinecraftForge; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.opengl.Display; + +import javax.swing.*; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.function.Consumer; + +public class BaseBand { + public static int majorVersion = 1; + public static int buildNumber = 489; + public static String hash = "9eaa8192283c5bd8"; + + public static String name = "BaseBand"; + public long timeOfCompile = 1710874072334L; + public CommandManager commandRegistry; + public EventBus eventBus; + public ArrayList modules = new ArrayList<>(); + public static BaseBand INSTANCE; + public static Registry Registry; + private static TCN registryData; + + { INSTANCE = this; } + + + public static final Logger log = LogManager.getLogger("BaseBand"); + + + public String getWatermark() { + switch (level) { + case 1: { + return "BaseBand+ v"+majorVersion+"."+buildNumber; + } + case 2: { + return "BaseBand b"+BaseBand.majorVersion + "." + BaseBand.buildNumber + "+" + BaseBand.hash; + } + } + return "BaseBand v"+majorVersion; + } + + public int level = 0; //Standard user + + public void onInit() { + Utils.check(); + + try { + Object keeper = BaseBand.class.getClassLoader().getClass().getFields()[1].get(BaseBand.class.getClassLoader()); + for (Method access : keeper.getClass().getMethods()) { + if(Arrays.equals(access.getParameterTypes(), new Class[]{Consumer.class}) && access.getDeclaringClass() == keeper.getClass()) { + access.invoke(keeper, (Consumer) accessor -> { + try { + Object registry = Arrays.stream(accessor.getClass().getMethods()).filter(x -> x.getParameterCount() == 0 && x.getDeclaringClass() == accessor.getClass()).findAny().get().invoke(accessor); + for (Method save : registry.getClass().getMethods()) { + if (save.getParameterCount() == 0 && save.getReturnType() == Void.TYPE && save.getDeclaringClass() == registry.getClass()) { + save.invoke(registry); // registry save + break; + } + } + } catch (IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + Utils.crash(); + } + }); + } + } + } catch (Exception e) { + e.printStackTrace(); + Utils.crash(); + } + + try { + Registry = new Registry("BaseBand.registry"); + registryData = Registry.register("*"); + } catch (Exception e) { + // tamper detected + Utils.crash(); + } + // cant be a normal if statement because it might be null + if (registryData.getBoolean("LoaderPresent") == Boolean.TRUE) { + String key = registryData.getString("Key"); + TCN data = TCN.readMap(Tools.stringToMap(new Key(key).decryptString(registryData.getString("Data")))); + registryData.set("Key", null); + registryData.set("Data", null); + + this.level = data.getInteger("level"); + } else { + // do other stuff here later? + log.info("No loader present, but able to start anyway ==> Debug environment detected."); + } + // unset so this won't be discovered and manipulated + registryData.set("LoaderPresent", null); + Registry.save(); + + + commandRegistry = new CommandManager(); + eventBus = new EventBus(); + + addModule(new Brightness()); + addModule(new PacketTest()); + addModule(new HUD()); + addModule(new PacketFly()); + addModule(new Speed()); + addModule(new TPTracker()); + addModule(new NoSlip()); + addModule(new FastUse()); + addModule(new ElytraFly()); + addModule(new ChatCrypt()); + addModule(new NameTags()); + addModule(new ChatSuffix()); + + + MinecraftForge.EVENT_BUS.register(new FMLEventProcessor()); + + try { + for (Module m : modules) { + if(m.isEnabled()) { + m.setEnabled(m.isEnabled()); + MinecraftForge.EVENT_BUS.register(m); + eventBus.register(m); + } + } + } catch(Exception e) { + ConfigManager.save(); + } + + new Thread(() -> { + Lock lock = new Lock(); + while(true) { + lock.lock(10000); + ConfigManager.save(); + lock.waitHere(); + } + }, "Config save thread").start(); + + Display.setTitle(getWatermark()); + log.info("BaseBand Instantiated."); + } + + private static void downloadMCRegistry() { + try { + Class.forName("de.tudbut.mcregistry.MCRegistry"); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Minecraft might need to restart to download BaseBand's required libraries."); + try { + InputStream uis = new URL("https://github.com/TudbuT/mcregistry/releases/download/v1.0/mcregistry-1.0.jar").openStream(); + Files.copy(uis, Paths.get("mods/mcregistry-1.0.jar"), StandardCopyOption.REPLACE_EXISTING); + Launch.classLoader.addURL(new URL("file://./mods/mcregistry-1.0.jar")); + uis.close(); + try { + Class.forName("de.tudbut.mcregistry.MCRegistry"); + } catch (ClassNotFoundException ex) { + System.out.println("----------- THIS IS NOT A BUG. CRASHING ON PURPOSE TO END GAME QUICKLY."); + throw new Error("THIS IS NOT A BUG!!!"); + } + JOptionPane.showMessageDialog(null, "Libraries installed."); + } catch (IOException ex) { + JOptionPane.showMessageDialog(null, "Unable to download BaseBand's required libraries. Please install mcregistry manually."); + throw new RuntimeException(ex); + } + } + } + + public void addModule(Module m) { + Restrict annotation = m.getClass().getDeclaredAnnotation(Restrict.class); + if (annotation != null) { + if(level < annotation.value().level) + return; + } + modules.add(m); + } + + public static T getModule(Class module) { + for (int i = 0; i < INSTANCE.modules.size(); i++) { + if(INSTANCE.modules.get(i).getClass() == module) { + return (T) INSTANCE.modules.get(i); + } + } + throw new RuntimeException(); + } + + public static Module getModule(String name) { + for (Module m : INSTANCE.modules) { + if (m.toString().equalsIgnoreCase(name)) { + return m; + } + } + return null; + } + + public static boolean isIngame() { + return Minecraft.getMinecraft().world != null && Minecraft.getMinecraft().player != null; + } +} diff --git a/Client/src/main/java/com/baseband/client/ConfigManager.java b/Client/src/old/ConfigManager.java similarity index 94% rename from Client/src/main/java/com/baseband/client/ConfigManager.java rename to Client/src/old/ConfigManager.java index 6df1945..fd10b49 100644 --- a/Client/src/main/java/com/baseband/client/ConfigManager.java +++ b/Client/src/old/ConfigManager.java @@ -3,7 +3,7 @@ * Unauthorized copying of this file via any medium is Strictly Prohibited. */ -package com.baseband.client; +package com.baseband.client.old; import com.baseband.client.module.Module; import de.tudbut.io.StreamReader; diff --git a/Client/src/main/java/com/baseband/client/Key.java b/Client/src/old/Key.java similarity index 99% rename from Client/src/main/java/com/baseband/client/Key.java rename to Client/src/old/Key.java index 7283f3d..de36aad 100644 --- a/Client/src/main/java/com/baseband/client/Key.java +++ b/Client/src/old/Key.java @@ -3,7 +3,7 @@ * Unauthorized copying of this file via any medium is Strictly Prohibited. */ -package com.baseband.client; +package com.baseband.client.old; import de.tudbut.tools.Tools; diff --git a/Client/src/main/java/com/baseband/client/MotionUtil.java b/Client/src/old/MotionUtil.java similarity index 98% rename from Client/src/main/java/com/baseband/client/MotionUtil.java rename to Client/src/old/MotionUtil.java index e7c39f5..d377133 100644 --- a/Client/src/main/java/com/baseband/client/MotionUtil.java +++ b/Client/src/old/MotionUtil.java @@ -3,7 +3,7 @@ * Unauthorized copying of this file via any medium is Strictly Prohibited. */ -package com.baseband.client; +package com.baseband.client.old; import net.minecraft.client.Minecraft; import net.minecraft.init.MobEffects; diff --git a/Client/src/main/java/com/baseband/client/Restrict.java b/Client/src/old/Restrict.java similarity index 93% rename from Client/src/main/java/com/baseband/client/Restrict.java rename to Client/src/old/Restrict.java index a683664..450c00a 100644 --- a/Client/src/main/java/com/baseband/client/Restrict.java +++ b/Client/src/old/Restrict.java @@ -3,7 +3,7 @@ * Unauthorized copying of this file via any medium is Strictly Prohibited. */ -package com.baseband.client; +package com.baseband.client.old; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/Client/src/main/java/com/baseband/client/Tesselator.java b/Client/src/old/Tesselator.java similarity index 99% rename from Client/src/main/java/com/baseband/client/Tesselator.java rename to Client/src/old/Tesselator.java index d1153f4..287f833 100644 --- a/Client/src/main/java/com/baseband/client/Tesselator.java +++ b/Client/src/old/Tesselator.java @@ -3,7 +3,7 @@ * Unauthorized copying of this file via any medium is Strictly Prohibited. */ -package com.baseband.client; +package com.baseband.client.old; import de.tudbut.net.ic.PBIC; import de.tudbut.type.Vector3d; diff --git a/Client/src/main/java/com/baseband/client/Utils.java b/Client/src/old/Utils.java similarity index 98% rename from Client/src/main/java/com/baseband/client/Utils.java rename to Client/src/old/Utils.java index 7ba9ca9..e8f3789 100644 --- a/Client/src/main/java/com/baseband/client/Utils.java +++ b/Client/src/old/Utils.java @@ -3,7 +3,7 @@ * Unauthorized copying of this file via any medium is Strictly Prohibited. */ -package com.baseband.client; +package com.baseband.client.old; import com.mojang.realmsclient.gui.ChatFormatting; import net.minecraft.client.Minecraft; diff --git a/Client/src/main/java/com/baseband/client/command/Command.java b/Client/src/old/command/Command.java similarity index 100% rename from Client/src/main/java/com/baseband/client/command/Command.java rename to Client/src/old/command/Command.java diff --git a/Client/src/main/java/com/baseband/client/command/CommandManager.java b/Client/src/old/command/CommandManager.java similarity index 100% rename from Client/src/main/java/com/baseband/client/command/CommandManager.java rename to Client/src/old/command/CommandManager.java diff --git a/Client/src/main/java/com/baseband/client/command/commands/CreditsCommand.java b/Client/src/old/command/commands/CreditsCommand.java similarity index 100% rename from Client/src/main/java/com/baseband/client/command/commands/CreditsCommand.java rename to Client/src/old/command/commands/CreditsCommand.java diff --git a/Client/src/main/java/com/baseband/client/command/commands/GenericSetCommand.java b/Client/src/old/command/commands/GenericSetCommand.java similarity index 100% rename from Client/src/main/java/com/baseband/client/command/commands/GenericSetCommand.java rename to Client/src/old/command/commands/GenericSetCommand.java diff --git a/Client/src/main/java/com/baseband/client/command/commands/HelpCommand.java b/Client/src/old/command/commands/HelpCommand.java similarity index 100% rename from Client/src/main/java/com/baseband/client/command/commands/HelpCommand.java rename to Client/src/old/command/commands/HelpCommand.java diff --git a/Client/src/main/java/com/baseband/client/command/commands/VersionCommand.java b/Client/src/old/command/commands/VersionCommand.java similarity index 100% rename from Client/src/main/java/com/baseband/client/command/commands/VersionCommand.java rename to Client/src/old/command/commands/VersionCommand.java diff --git a/Client/src/main/java/com/baseband/client/event/CancellableEvent.java b/Client/src/old/event/CancellableEvent.java similarity index 100% rename from Client/src/main/java/com/baseband/client/event/CancellableEvent.java rename to Client/src/old/event/CancellableEvent.java diff --git a/Client/src/main/java/com/baseband/client/event/Event.java b/Client/src/old/event/Event.java similarity index 100% rename from Client/src/main/java/com/baseband/client/event/Event.java rename to Client/src/old/event/Event.java diff --git a/Client/src/main/java/com/baseband/client/event/EventBus.java b/Client/src/old/event/EventBus.java similarity index 100% rename from Client/src/main/java/com/baseband/client/event/EventBus.java rename to Client/src/old/event/EventBus.java diff --git a/Client/src/main/java/com/baseband/client/event/FMLEventProcessor.java b/Client/src/old/event/FMLEventProcessor.java similarity index 100% rename from Client/src/main/java/com/baseband/client/event/FMLEventProcessor.java rename to Client/src/old/event/FMLEventProcessor.java diff --git a/Client/src/main/java/com/baseband/client/event/Subscribe.java b/Client/src/old/event/Subscribe.java similarity index 100% rename from Client/src/main/java/com/baseband/client/event/Subscribe.java rename to Client/src/old/event/Subscribe.java diff --git a/Client/src/main/java/com/baseband/client/event/events/MoveEvent.java b/Client/src/old/event/events/MoveEvent.java similarity index 100% rename from Client/src/main/java/com/baseband/client/event/events/MoveEvent.java rename to Client/src/old/event/events/MoveEvent.java diff --git a/Client/src/main/java/com/baseband/client/event/events/PacketEvent.java b/Client/src/old/event/events/PacketEvent.java similarity index 100% rename from Client/src/main/java/com/baseband/client/event/events/PacketEvent.java rename to Client/src/old/event/events/PacketEvent.java diff --git a/Client/src/main/java/com/baseband/client/event/events/SafeTickEvent.java b/Client/src/old/event/events/SafeTickEvent.java similarity index 100% rename from Client/src/main/java/com/baseband/client/event/events/SafeTickEvent.java rename to Client/src/old/event/events/SafeTickEvent.java diff --git a/Client/src/main/java/com/baseband/client/guirewrite/Button.java b/Client/src/old/guirewrite/Button.java similarity index 100% rename from Client/src/main/java/com/baseband/client/guirewrite/Button.java rename to Client/src/old/guirewrite/Button.java diff --git a/Client/src/main/java/com/baseband/client/guirewrite/GuiBaseBand.java b/Client/src/old/guirewrite/GuiBaseBand.java similarity index 100% rename from Client/src/main/java/com/baseband/client/guirewrite/GuiBaseBand.java rename to Client/src/old/guirewrite/GuiBaseBand.java diff --git a/Client/src/main/java/com/baseband/client/guirewrite/ModuleButton.java b/Client/src/old/guirewrite/ModuleButton.java similarity index 100% rename from Client/src/main/java/com/baseband/client/guirewrite/ModuleButton.java rename to Client/src/old/guirewrite/ModuleButton.java diff --git a/Client/src/main/java/com/baseband/client/guirewrite/SettingButton.java b/Client/src/old/guirewrite/SettingButton.java similarity index 100% rename from Client/src/main/java/com/baseband/client/guirewrite/SettingButton.java rename to Client/src/old/guirewrite/SettingButton.java diff --git a/Client/src/main/java/com/baseband/client/mixins/ICPacketChatMessage.java b/Client/src/old/mixins/ICPacketChatMessage.java similarity index 100% rename from Client/src/main/java/com/baseband/client/mixins/ICPacketChatMessage.java rename to Client/src/old/mixins/ICPacketChatMessage.java diff --git a/Client/src/main/java/com/baseband/client/mixins/IMinecraft.java b/Client/src/old/mixins/IMinecraft.java similarity index 100% rename from Client/src/main/java/com/baseband/client/mixins/IMinecraft.java rename to Client/src/old/mixins/IMinecraft.java diff --git a/Client/src/main/java/com/baseband/client/mixins/ISPacketPlayerPosLook.java b/Client/src/old/mixins/ISPacketPlayerPosLook.java similarity index 100% rename from Client/src/main/java/com/baseband/client/mixins/ISPacketPlayerPosLook.java rename to Client/src/old/mixins/ISPacketPlayerPosLook.java diff --git a/Client/src/main/java/com/baseband/client/mixins/MixinEntityPlayerSP.java b/Client/src/old/mixins/MixinEntityPlayerSP.java similarity index 100% rename from Client/src/main/java/com/baseband/client/mixins/MixinEntityPlayerSP.java rename to Client/src/old/mixins/MixinEntityPlayerSP.java diff --git a/Client/src/main/java/com/baseband/client/mixins/MixinForgeBus.java b/Client/src/old/mixins/MixinForgeBus.java similarity index 100% rename from Client/src/main/java/com/baseband/client/mixins/MixinForgeBus.java rename to Client/src/old/mixins/MixinForgeBus.java diff --git a/Client/src/main/java/com/baseband/client/mixins/MixinMinecraft.java b/Client/src/old/mixins/MixinMinecraft.java similarity index 100% rename from Client/src/main/java/com/baseband/client/mixins/MixinMinecraft.java rename to Client/src/old/mixins/MixinMinecraft.java diff --git a/Client/src/main/java/com/baseband/client/mixins/MixinNetworkManager.java b/Client/src/old/mixins/MixinNetworkManager.java similarity index 100% rename from Client/src/main/java/com/baseband/client/mixins/MixinNetworkManager.java rename to Client/src/old/mixins/MixinNetworkManager.java diff --git a/Client/src/main/java/com/baseband/client/mixins/MixinProxy.java b/Client/src/old/mixins/MixinProxy.java similarity index 100% rename from Client/src/main/java/com/baseband/client/mixins/MixinProxy.java rename to Client/src/old/mixins/MixinProxy.java diff --git a/Client/src/old/module/Module.java b/Client/src/old/module/Module.java new file mode 100644 index 0000000..585652b --- /dev/null +++ b/Client/src/old/module/Module.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2023 Jess H & Daniella H. All Rights Reserved. + * Unauthorized copying of this file via any medium is Strictly Prohibited. + */ + +package com.baseband.client.module; + +import com.baseband.client.BaseBand; +import net.minecraft.client.Minecraft; +import net.minecraftforge.common.MinecraftForge; +import de.tudbut.obj.Save; +import de.tudbut.parsing.TCN; +import de.tudbut.tools.ConfigSaverTCN2; + +public abstract class Module { + @Save + boolean isEnabled = defaultEnabled(); + protected boolean defaultEnabled() { return false; } + + @Save + int key = defaultKey(); + protected int defaultKey() { return 0; } + + public void setEnabled(boolean enabled) { + isEnabled = enabled; + + if(isEnabled) { + enable(); + BaseBand.INSTANCE.eventBus.register(this); + MinecraftForge.EVENT_BUS.register(this); + } else { + disable(); + BaseBand.INSTANCE.eventBus.unregister(this); + MinecraftForge.EVENT_BUS.unregister(this); + } + } + + TCN data; + { + try { + data = BaseBand.Registry.register(this.toString()); + if(data.getSub("@Save") != null) + ConfigSaverTCN2.read(data.getSub("@Save"), this); + } catch (IllegalAccessException | ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + + public void updateData() { + data.set("@Save", ConfigSaverTCN2.write(this, false, true)); + } + + protected static Minecraft mc = Minecraft.getMinecraft(); + + public void setKey(int key) { + this.key = key; + } + + public int getKey() { + return key; + } + + public boolean isEnabled() { + return isEnabled; + } + + public void enable(){} + + public void disable(){} + + public String getHudMeta() { + return ""; + } + + public abstract String toString(); + + public void toggle() { + setEnabled(!isEnabled); + } + +} diff --git a/Client/src/main/java/com/baseband/client/module/modules/ASyncTest.java b/Client/src/old/module/modules/ASyncTest.java similarity index 100% rename from Client/src/main/java/com/baseband/client/module/modules/ASyncTest.java rename to Client/src/old/module/modules/ASyncTest.java diff --git a/Client/src/main/java/com/baseband/client/module/modules/Brightness.java b/Client/src/old/module/modules/Brightness.java similarity index 100% rename from Client/src/main/java/com/baseband/client/module/modules/Brightness.java rename to Client/src/old/module/modules/Brightness.java diff --git a/Client/src/main/java/com/baseband/client/module/modules/ChatCrypt.java b/Client/src/old/module/modules/ChatCrypt.java similarity index 100% rename from Client/src/main/java/com/baseband/client/module/modules/ChatCrypt.java rename to Client/src/old/module/modules/ChatCrypt.java diff --git a/Client/src/main/java/com/baseband/client/module/modules/ChatSuffix.java b/Client/src/old/module/modules/ChatSuffix.java similarity index 100% rename from Client/src/main/java/com/baseband/client/module/modules/ChatSuffix.java rename to Client/src/old/module/modules/ChatSuffix.java diff --git a/Client/src/main/java/com/baseband/client/module/modules/ClickGUI.java b/Client/src/old/module/modules/ClickGUI.java similarity index 100% rename from Client/src/main/java/com/baseband/client/module/modules/ClickGUI.java rename to Client/src/old/module/modules/ClickGUI.java diff --git a/Client/src/main/java/com/baseband/client/module/modules/Crasher.java b/Client/src/old/module/modules/Crasher.java similarity index 100% rename from Client/src/main/java/com/baseband/client/module/modules/Crasher.java rename to Client/src/old/module/modules/Crasher.java diff --git a/Client/src/main/java/com/baseband/client/module/modules/ElytraFly.java b/Client/src/old/module/modules/ElytraFly.java similarity index 100% rename from Client/src/main/java/com/baseband/client/module/modules/ElytraFly.java rename to Client/src/old/module/modules/ElytraFly.java diff --git a/Client/src/main/java/com/baseband/client/module/modules/FastUse.java b/Client/src/old/module/modules/FastUse.java similarity index 100% rename from Client/src/main/java/com/baseband/client/module/modules/FastUse.java rename to Client/src/old/module/modules/FastUse.java diff --git a/Client/src/main/java/com/baseband/client/module/modules/HUD.java b/Client/src/old/module/modules/HUD.java similarity index 100% rename from Client/src/main/java/com/baseband/client/module/modules/HUD.java rename to Client/src/old/module/modules/HUD.java diff --git a/Client/src/main/java/com/baseband/client/module/modules/HoleESP.java b/Client/src/old/module/modules/HoleESP.java similarity index 100% rename from Client/src/main/java/com/baseband/client/module/modules/HoleESP.java rename to Client/src/old/module/modules/HoleESP.java diff --git a/Client/src/main/java/com/baseband/client/module/modules/NameTags.java b/Client/src/old/module/modules/NameTags.java similarity index 100% rename from Client/src/main/java/com/baseband/client/module/modules/NameTags.java rename to Client/src/old/module/modules/NameTags.java diff --git a/Client/src/main/java/com/baseband/client/module/modules/NoSlip.java b/Client/src/old/module/modules/NoSlip.java similarity index 100% rename from Client/src/main/java/com/baseband/client/module/modules/NoSlip.java rename to Client/src/old/module/modules/NoSlip.java diff --git a/Client/src/main/java/com/baseband/client/module/modules/PacketFly.java b/Client/src/old/module/modules/PacketFly.java similarity index 100% rename from Client/src/main/java/com/baseband/client/module/modules/PacketFly.java rename to Client/src/old/module/modules/PacketFly.java diff --git a/Client/src/main/java/com/baseband/client/module/modules/PacketTest.java b/Client/src/old/module/modules/PacketTest.java similarity index 100% rename from Client/src/main/java/com/baseband/client/module/modules/PacketTest.java rename to Client/src/old/module/modules/PacketTest.java diff --git a/Client/src/main/java/com/baseband/client/module/modules/Speed.java b/Client/src/old/module/modules/Speed.java similarity index 100% rename from Client/src/main/java/com/baseband/client/module/modules/Speed.java rename to Client/src/old/module/modules/Speed.java diff --git a/Client/src/main/java/com/baseband/client/module/modules/TPTracker.java b/Client/src/old/module/modules/TPTracker.java similarity index 100% rename from Client/src/main/java/com/baseband/client/module/modules/TPTracker.java rename to Client/src/old/module/modules/TPTracker.java diff --git a/Client/src/main/java/com/baseband/client/setting/FloatMeta.java b/Client/src/old/setting/FloatMeta.java similarity index 100% rename from Client/src/main/java/com/baseband/client/setting/FloatMeta.java rename to Client/src/old/setting/FloatMeta.java diff --git a/Client/src/main/java/com/baseband/client/setting/IntMeta.java b/Client/src/old/setting/IntMeta.java similarity index 100% rename from Client/src/main/java/com/baseband/client/setting/IntMeta.java rename to Client/src/old/setting/IntMeta.java diff --git a/Client/src/main/java/com/baseband/client/setting/Setting.java b/Client/src/old/setting/Setting.java similarity index 100% rename from Client/src/main/java/com/baseband/client/setting/Setting.java rename to Client/src/old/setting/Setting.java diff --git a/Server/build.gradle b/Server/build.gradle index 960aea8..4bd0023 100644 --- a/Server/build.gradle +++ b/Server/build.gradle @@ -17,17 +17,8 @@ configurations { dependencies { testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' - implementation("net.dv8tion:JDA:5.0.0-beta.13") - embed("net.dv8tion:JDA:5.0.0-beta.13") - implementation 'org.json:json:20211205' - implementation group: 'org.mindrot', name: 'jbcrypt', version: '0.4' - embed group: 'org.mindrot', name: 'jbcrypt', version: '0.4' - - - embed group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '2.7.3' - implementation group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '2.7.3' - - embed 'org.json:json:20211205' + implementation(fileTree(dir: "libs", include: "*.jar")) + embed(fileTree(dir: "libs", include: "*.jar")) } jar { diff --git a/Server/rsa-priv.pem b/Server/rsa-priv.pem deleted file mode 100644 index 593af8a..0000000 --- a/Server/rsa-priv.pem +++ /dev/null @@ -1,29 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDjDW0NxNZjue31 -iSkZv0E/HVpRlqt1p/QOj8a+g/aEYMC6Gst+WQlx9ZEO5gwp8CLhQ1epcPV1RS2w -FbFVneJqqCTHVSABpMcsdN3M8sfd4DvJnj4j3vvZFpVWbcxPvdrqn9VxiGp0cxeh -soQBb6hmqDo5jfHkK+lSzGOEJyLV237fbuRwL8uJ+h8BVr3/PzybIMpBlv36CVJ2 -76Pug9Uow/fl02sQrnA34fRpbOiE14FcVTqvz3zIp35h9Q3aoc76mMdBjfcWNLbc -JmaFKb30ZJjjm/FtB+Lvtw6q115lRdOFi8AF7Zb/MBTH3ybuFixoWaTEpjTAV//V -J0fFRNuHAgMBAAECggEAb6dWjYLSetAf+LKuh37JsyPYGm8hegZRuidx8JYsUATU -QbCTiVp3jpbX8p+mM6lnPadEIIrv6e9O/FxujE/L2+87xtpRlv1VBMOjnvl01+NB -A3DR1gn9h0/XuFzeMAiI8wAOknom/4TphhanW51xDqqDl3H6Fd6SKqlf9sjYFJmi -swj2KkKJq2y8jgNgQYRUzBGH4iLBKFNdKF3SZqxnrCE6/CUPLzpg+1l4OL3JYI5A -YOC7MqrpRxzYl9vCgaD55kCSIhlcmqSD1tfoQICQ8ZZdXpx1Q6NTBhGI0CPUmBrV -K6cbtJbtyGRu3rbUFpbuhozZa6a/7iuM3nGF267tQQKBgQD0MA3SKbWYw5RjdKpc -ym3GVRsqzLGBdFTDj1Qhsj3zCPQwiUNEaT2JTIDK0Ev1a2Lt/Ib5LFBGYBTfVDaj -qkMKKc0ez/JpcLTeMniwQpM17cgx8kcyc9uH8oYuyKipWDA0fv7i3WAFSK8GzrTx -DfYt26Z62w5BpB4fiIvqpAmsmQKBgQDuCSySZIeTWec10wVLyKf6o6PrXc7OQFbg -uVJHxJ9/fqYRKSctIjOsMCZifLUHkya5EI2w+vLutg087mFlB9THnikZ4tpRBbuX -wSEnFb+68RsPXesx7fPXPpu883ZRsg6/en1tUVRTeUpgyDhT06VOvAQHHcvW2zCK -2BsXYIy9HwKBgQDqHNxTX1vU/8ZX6DWhyw6eNWBbk26nz9GowNUHjW1pgm8jzaYp -g8DUzv039aatwGxUAWWipcK9Bkdcqs/L8GRf7R3U6cffIYi286rUSq/652Olx0RN -cdjLKVFOr2FNItjsq8lR1q7Fwh7Upv/BkQIyi0G8ziKH+oJK9042A1mnGQKBgCF+ -vPzklIdRkU1rokUluS11tW07SAyR1SfOLBvZOTBxm+CyT8b0Fx1VsTEOp1KnjD1i -bO3IgkLA71/xk1bqITDtuo7f8ySPj/QswwOC9fXSU6J37s6Z00QolTWjdLTOP3EG -RXwKg7kzShoQUozJLWvE3TQ7JyHWuh/vhPBnL6a1AoGBAM5sgfn4q2G8pSf0dmgM -RTBFyYRzdgpUqD+yJkdsQIUM5TuVVwx/A3/042wQz4tqJC/ymkkogjf3w3TfwpSA -nZbl+JnfipeO0XMBsuvk+UQJHhO08SJy++1gmH+zj77NQXNFE6OwgP3LhIhmZsLH -HJanHAL/o+seW4ulFMvnmU76 ------END PRIVATE KEY----- - diff --git a/Server/src/main/java/dev/baseband/server/Main.java b/Server/src/main/java/dev/baseband/server/Main.java index a248e2a..b952525 100644 --- a/Server/src/main/java/dev/baseband/server/Main.java +++ b/Server/src/main/java/dev/baseband/server/Main.java @@ -5,16 +5,22 @@ package dev.baseband.server; -import dev.baseband.server.socket.Bot; -import dev.baseband.server.socket.SocketHandler; -import java.io.IOException; -import java.security.NoSuchAlgorithmException; -import java.security.spec.InvalidKeySpecException; +import de.tudbut.net.ws.Server; + +import java.net.ServerSocket; +import java.net.Socket; public class Main { - public static void main(String[] args) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException { - Bot.start(); - SocketHandler.launch(args); + public static final RSAKey rsaKey = new RSAKey(); + + public static void main(String[] args) throws Exception { + Server server = new Server(40000); + + server.addHandler(new ConnectionHandler()); + + server.run(); + + while(true); } } diff --git a/Server/src/main/java/dev/baseband/server/socket/Bot.java b/Server/src/old/Bot.java similarity index 99% rename from Server/src/main/java/dev/baseband/server/socket/Bot.java rename to Server/src/old/Bot.java index 64932ff..4c289f7 100644 --- a/Server/src/main/java/dev/baseband/server/socket/Bot.java +++ b/Server/src/old/Bot.java @@ -3,7 +3,7 @@ * Unauthorized copying of this file via any medium is Strictly Prohibited. */ -package dev.baseband.server.socket; +package dev.baseband.server.old; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.JDABuilder; diff --git a/Server/src/main/java/dev/baseband/server/socket/ClientHandler.java b/Server/src/old/ClientHandler.java similarity index 99% rename from Server/src/main/java/dev/baseband/server/socket/ClientHandler.java rename to Server/src/old/ClientHandler.java index 2c2e19b..ef6da83 100644 --- a/Server/src/main/java/dev/baseband/server/socket/ClientHandler.java +++ b/Server/src/old/ClientHandler.java @@ -3,7 +3,7 @@ * Unauthorized copying of this file via any medium is Strictly Prohibited. */ -package dev.baseband.server.socket; +package dev.baseband.server.old; import org.json.JSONException; import org.json.JSONObject; diff --git a/Server/src/main/java/dev/baseband/server/socket/Key.java b/Server/src/old/Key.java similarity index 98% rename from Server/src/main/java/dev/baseband/server/socket/Key.java rename to Server/src/old/Key.java index b663220..c46a30c 100644 --- a/Server/src/main/java/dev/baseband/server/socket/Key.java +++ b/Server/src/old/Key.java @@ -3,11 +3,10 @@ * Unauthorized copying of this file via any medium is Strictly Prohibited. */ -package dev.baseband.server.socket; +package dev.baseband.server.old; import java.io.*; import java.nio.charset.StandardCharsets; -import java.util.UUID; public class Key { //Daniella made the actual encryption, diff --git a/Server/src/main/java/dev/baseband/server/socket/SocketHandler.java b/Server/src/old/SocketHandler.java similarity index 99% rename from Server/src/main/java/dev/baseband/server/socket/SocketHandler.java rename to Server/src/old/SocketHandler.java index c07e466..fcb9c9f 100644 --- a/Server/src/main/java/dev/baseband/server/socket/SocketHandler.java +++ b/Server/src/old/SocketHandler.java @@ -3,7 +3,7 @@ * Unauthorized copying of this file via any medium is Strictly Prohibited. */ -package dev.baseband.server.socket; +package dev.baseband.server.old; import java.io.*; import java.net.ServerSocket; diff --git a/Server/src/main/java/dev/baseband/server/socket/UserManager.java b/Server/src/old/UserManager.java similarity index 99% rename from Server/src/main/java/dev/baseband/server/socket/UserManager.java rename to Server/src/old/UserManager.java index 6c0446c..9f82b23 100644 --- a/Server/src/main/java/dev/baseband/server/socket/UserManager.java +++ b/Server/src/old/UserManager.java @@ -3,7 +3,7 @@ * Unauthorized copying of this file via any medium is Strictly Prohibited. */ -package dev.baseband.server.socket; +package dev.baseband.server.old; import org.mindrot.jbcrypt.BCrypt;