Skip to content

Commit

Permalink
ACTUALLY implemented builder pattern for constructing settings. (i me…
Browse files Browse the repository at this point in the history
…ssed up 😅)
  • Loading branch information
coltonk9043 committed Sep 21, 2024
1 parent e67cc19 commit 8e34d4d
Show file tree
Hide file tree
Showing 105 changed files with 2,359 additions and 1,232 deletions.
6 changes: 6 additions & 0 deletions src/main/java/net/aoba/AobaClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import net.aoba.settings.SettingManager;
import net.aoba.settings.friends.FriendsList;
import net.aoba.utils.discord.RPCManager;
import net.aoba.utils.rotation.RotationManager;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.entrypoint.EntrypointContainer;
import net.minecraft.client.MinecraftClient;
Expand All @@ -52,6 +53,7 @@ public class AobaClient {
public static IMinecraftClient IMC;

// Systems
public RotationManager rotationManager;
public ModuleManager moduleManager;
public CommandManager commandManager;
public AltManager altManager;
Expand Down Expand Up @@ -111,6 +113,8 @@ public void loadAssets() {
fontManager.Initialize();
LogUtils.getLogger().info("[Aoba] Initializing Combat Manager");
combatManager = new CombatManager();
LogUtils.getLogger().info("[Aoba] Initializing Rotation Manager");
rotationManager = new RotationManager();
LogUtils.getLogger().info("[Aoba] Initializing GUI");
guiManager = new GuiManager();
guiManager.Initialize();
Expand All @@ -122,6 +126,8 @@ public void loadAssets() {
rpcManager.startRpc();
LogUtils.getLogger().info("[Aoba] Aoba-chan initialized and ready to play!");



SettingManager.loadSettings(settingManager.configContainer);
SettingManager.loadSettings(settingManager.modulesContainer);
SettingManager.loadSettings(settingManager.hiddenContainer);
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/net/aoba/cmd/CommandManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ public class CommandManager {
private final Map<String, Command> commands = new HashMap<>();
private final List<String> commandHistory = new ArrayList<>();

public static StringSetting PREFIX = new StringSetting("Prefix", "Prefix", ".aoba");

public static StringSetting PREFIX = StringSetting.builder()
.id("aoba_prefix")
.displayName("Prefix")
.defaultValue(".aoba")
.build();

// Commands
public final CmdAimbot aimbot = new CmdAimbot();
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/net/aoba/cmd/GlobalChat.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,14 @@ public enum ChatType {
private BufferedReader in;
private boolean started = false;

private BooleanSetting enabled;
private BooleanSetting enabled = BooleanSetting.builder()
.id("global_chat_enabled")
.description("Whether or not global chat is enabled or disabled.")
.defaultValue(true)
.build();

public GlobalChat() {
gson = new Gson();
enabled = new BooleanSetting("global_chat_enabled", "Whether or not global chat is enabled or disabled.", true);
SettingManager.registerSetting(this.enabled, Aoba.getInstance().settingManager.modulesContainer);
}

Expand All @@ -81,7 +84,6 @@ private void SendChatMessage(String message) {
}
}


public void StartListener() {
if (started) {
LogUtils.getLogger().info("Socket listener already started.");
Expand Down
65 changes: 44 additions & 21 deletions src/main/java/net/aoba/gui/GuiManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import net.aoba.module.Category;
import net.aoba.module.Module;
import net.aoba.settings.SettingManager;
import net.aoba.settings.types.BooleanSetting;
import net.aoba.settings.types.ColorSetting;
import net.aoba.settings.types.FloatSetting;
import net.aoba.settings.types.KeybindSetting;
Expand All @@ -68,8 +67,13 @@ public class GuiManager implements KeyDownListener, TickListener, Render2DListen
private static final MinecraftClient MC = MinecraftClient.getInstance();
private static CursorStyle currentCursor = CursorStyle.Default;
private static String tooltip = null;

public KeybindSetting clickGuiButton = KeybindSetting.builder()
.id("key.clickgui")
.displayName("ClickGUI Key")
.defaultValue(InputUtil.fromKeyCode(GLFW.GLFW_KEY_GRAVE_ACCENT, 0))
.build();

public KeybindSetting clickGuiButton = new KeybindSetting("key.clickgui", "ClickGUI Key", InputUtil.fromKeyCode(GLFW.GLFW_KEY_GRAVE_ACCENT, 0));
private final KeyBinding esc = new KeyBinding("key.esc", GLFW.GLFW_KEY_ESCAPE, "key.categories.aoba");

private boolean clickGuiOpen = false;
Expand All @@ -82,19 +86,48 @@ public class GuiManager implements KeyDownListener, TickListener, Render2DListen
public Page hudPane = new Page("Hud");

// Global HUD Settings
public static ColorSetting foregroundColor;
public static ColorSetting borderColor;
public static ColorSetting backgroundColor;
public static FloatSetting roundingRadius;
public static FloatSetting dragSmoothening;
public static ColorSetting foregroundColor = ColorSetting.builder()
.id("hud_foreground_color")
.displayName("GUI Foreground Color")
.description("Color of the foreground.")
.defaultValue(new Color(1.0f, 1.0f, 1.0f))
.build();

public static ColorSetting borderColor = ColorSetting.builder()
.id("hud_border_color")
.displayName("GUI Border Color")
.description("Color of the borders.")
.defaultValue(new Color(0, 0, 0))
.build();

public static ColorSetting backgroundColor = ColorSetting.builder()
.id("hud_background_color")
.displayName("GUI Background Color")
.description("Color of the background.")
.defaultValue(new Color(0, 0, 0, 50))
.build();

public static FloatSetting roundingRadius = FloatSetting.builder()
.id("hud_rounding_radius")
.description("The radius of the rounding on hud.")
.defaultValue(6f)
.minValue(0f)
.maxValue(10f)
.step(1f)
.build();

public static FloatSetting dragSmoothening = FloatSetting.builder()
.id("gui_drag_smoothening")
.description("The value for the dragging smoothening")
.defaultValue(1.0f)
.minValue(0.1f)
.maxValue(2.0f)
.step(0.1f)
.build();

public static RainbowColor rainbowColor = new RainbowColor();
public static RandomColor randomColor = new RandomColor();

public FloatSetting effectSpeed = new FloatSetting("color_speed", "Effect Spd", 4f, 1f, 20f, 0.1f, null);
public BooleanSetting rainbow = new BooleanSetting("rainbow_mode", "Rainbow", false, null);
public BooleanSetting ah = new BooleanSetting("armorhud_toggle", "ArmorHUD", false, null);

public ModuleSelectorHud moduleSelector;
public ArmorHud armorHud;
public RadarHud radarHud;
Expand All @@ -109,11 +142,6 @@ public class GuiManager implements KeyDownListener, TickListener, Render2DListen
public SpeedHud speedHud;

public GuiManager() {
borderColor = new ColorSetting("hud_border_color", "Color of the borders.", new Color(0, 0, 0));
backgroundColor = new ColorSetting("hud_background_color", "Color of the background.", new Color(0, 0, 0, 50));
foregroundColor = new ColorSetting("hud_foreground_color", "The color of the HUD", new Color(1.0f, 1.0f, 1.0f));
roundingRadius = new FloatSetting("hud_rounding_radius", "The radius of the rounding on hud.", 6f, 0f, 10f, 1f);
dragSmoothening = new FloatSetting("gui_drag_smoothening", "The value for the dragging smoothening", 1f, 0.1f, 2f, 0.1f);
clickGuiNavBar = new NavigationBar();

SettingManager.registerSetting(borderColor, Aoba.getInstance().settingManager.configContainer);
Expand Down Expand Up @@ -175,11 +203,6 @@ public void Initialize() {
clickGuiNavBar.addPane(modulesPane);
clickGuiNavBar.addPane(toolsPane);
clickGuiNavBar.addPane(hudPane);
// clickGuiNavBar.addPane(settingsPane);

SettingManager.registerSetting(effectSpeed, Aoba.getInstance().settingManager.configContainer);
SettingManager.registerSetting(rainbow, Aoba.getInstance().settingManager.configContainer);
SettingManager.registerSetting(ah, Aoba.getInstance().settingManager.configContainer);

clickGuiNavBar.setSelectedIndex(0);
}
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/net/aoba/gui/components/SliderComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import net.aoba.gui.Margin;
import net.aoba.gui.Rectangle;
import net.aoba.gui.colors.Color;
import net.aoba.gui.colors.Colors;
import net.aoba.utils.render.Render2D;
import net.aoba.settings.types.FloatSetting;
import net.aoba.utils.types.MouseAction;
Expand Down Expand Up @@ -145,9 +146,15 @@ public void draw(DrawContext drawContext, float partialTicks) {
float actualWidth = this.getActualSize().getWidth();

float filledLength = actualWidth * currentSliderPosition;

Render2D.drawBox(matrix4f, actualX, actualY + 35, filledLength, 2, GuiManager.foregroundColor.getValue());
Render2D.drawBox(matrix4f, actualX + filledLength, actualY + 35, (actualWidth - filledLength), 2, new Color(255, 255, 255, 255));

if(floatSetting != null) {
float defaultLength = actualWidth * ((floatSetting.getDefaultValue() - minValue) / (maxValue - minValue));
Render2D.drawBox(matrix4f, actualX + defaultLength - 2, actualY + 28, 4, 14, Colors.White);
}

Render2D.drawBox(matrix4f, actualX, actualY + 34, filledLength, 2, GuiManager.foregroundColor.getValue());
Render2D.drawBox(matrix4f, actualX + filledLength, actualY + 34, (actualWidth - filledLength), 2, new Color(255, 255, 255, 255));

Render2D.drawCircle(matrix4f, actualX + filledLength, actualY + 35, 6, GuiManager.foregroundColor.getValue());
Render2D.drawString(drawContext, this.text, actualX, actualY + 8, 0xFFFFFF);

Expand Down
8 changes: 7 additions & 1 deletion src/main/java/net/aoba/gui/font/FontManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ public FontManager() {
fontRenderers = new ConcurrentHashMap<>();
MC = MinecraftClient.getInstance();

fontSetting = new StringSetting("font", "The font that Aoba will use.", "minecraft");
fontSetting = StringSetting.builder()
.id("aoba_font")
.displayName("Font")
.description("The font that Aoba will use.")
.defaultValue("minecraft")
.build();

fontSetting.addOnUpdate((i) -> {
FontManager font = Aoba.getInstance().fontManager;
font.SetRenderer(font.fontRenderers.get(i));
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/net/aoba/gui/navigation/HudWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ public class HudWindow extends Window {

public HudWindow(String ID, float x, float y, float width, float height) {
super(ID, x, y, width, height);

activated = new BooleanSetting(ID + "_activated", ID + " Activated", false, (Boolean val) -> onActivatedChanged(val));

activated = BooleanSetting.builder()
.id(ID + "_activated")
.defaultValue(false)
.onUpdate(val -> onActivatedChanged(val))
.build();

SettingManager.registerSetting(activated, Aoba.getInstance().settingManager.configContainer);
}

Expand Down
9 changes: 6 additions & 3 deletions src/main/java/net/aoba/gui/navigation/PinnableWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ public class PinnableWindow extends Window {

public PinnableWindow(String ID, float x, float y, float width, float height) {
super(ID, x, y, width, height);

isPinned = new BooleanSetting(ID + "_pinned", "IS PINNED", false);


isPinned = BooleanSetting.builder()
.id(ID + "_pinned")
.defaultValue(false)
.build();

SettingManager.registerSetting(isPinned, Aoba.getInstance().settingManager.hiddenContainer);
}

Expand Down
9 changes: 7 additions & 2 deletions src/main/java/net/aoba/gui/navigation/Window.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,13 @@ public Window(String ID, float x, float y, float width, float height) {
this.parent = null;
this.ID = ID;
this.title = ID;
this.position = new RectangleSetting(ID + "_position", ID + "Position", new Rectangle(x, y, width, height),
(Rectangle vec) -> UpdateAll());

position = RectangleSetting.builder()
.id(ID + "_position")
.displayName(ID + "Position")
.defaultValue(new Rectangle(x, y, width, height))
.onUpdate((Rectangle vec) -> UpdateAll())
.build();

SettingManager.registerSetting(position, Aoba.getInstance().settingManager.configContainer);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package net.aoba.gui.navigation.huds;

import net.aoba.Aoba;
import net.aoba.AobaClient;
import net.aoba.event.events.MouseClickEvent;
import net.aoba.gui.GuiManager;
import net.aoba.gui.Rectangle;
Expand All @@ -16,11 +15,15 @@
import java.util.Comparator;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Stream;

import net.aoba.gui.TextAlign;

public class ModuleArrayListHud extends HudWindow {
private EnumSetting<TextAlign> textAlign = new EnumSetting<TextAlign>("ModuleArrayListHudText_TextAlign", "Text Align", "Text Alignment", TextAlign.Left);
private EnumSetting<TextAlign> textAlign = EnumSetting.<TextAlign>builder()
.id("ModuleArrayListHudText_TextAlign")
.displayName("Text Align")
.description("Text Alignment")
.defaultValue(TextAlign.Left)
.build();

public ModuleArrayListHud(int x, int y) {
super("ModuleArrayListHud", x, y, 0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@
public class AuthCrackerWindow extends Window {
private ButtonComponent start;

private FloatSetting delay = new FloatSetting("authcracker_delay", "Delay", 100, 50, 50000, 1, null);
private FloatSetting delay = FloatSetting.builder()
.id("authcracker_delay")
.displayName("Delay")
.defaultValue(100f)
.minValue(50f)
.maxValue(50000f).build();

private AuthCracker authCracker;

Expand Down
Loading

0 comments on commit 8e34d4d

Please sign in to comment.