From f9913ceb7cbc7ed28f6870d56994aba9cf7a841c Mon Sep 17 00:00:00 2001 From: Jess Date: Mon, 3 Jun 2024 22:53:39 +0100 Subject: [PATCH] MAJOR REFACTOR (i probably broke something really badly but idfc) --- .../java/com/baseband/client/BaseBand.java | 168 ++++-------------- .../main/java/com/baseband/client/Setup.java | 84 --------- .../baseband/client/event/EventManager.java | 11 +- .../client/event/FMLEventHandler.java | 25 +-- .../client/event/events/SelectEvent.java | 4 +- .../event/remote/RemoteEventManager.java | 35 ++-- .../com/baseband/client/feature/Feature.java | 17 +- .../client/feature/FeatureManager.java | 151 ++++++++++++++++ .../client/feature/chat/ChatAppend.java | 6 +- .../client/feature/chat/ChatCrypt.java | 21 ++- .../client/feature/chat/ChatExtras.java | 9 +- .../client/feature/chat/ChatFilter.java | 8 +- .../baseband/client/feature/chat/ISeeYou.java | 6 +- .../client/feature/chat/TPAccept.java | 4 +- .../client/feature/client/AltControl.java | 16 +- .../client/feature/client/Client.java | 14 +- .../client/feature/client/MidClick.java | 17 +- .../baseband/client/feature/client/Trust.java | 4 +- .../client/feature/combat/AutoTotem.java | 6 +- .../baseband/client/feature/command/Bind.java | 14 +- .../baseband/client/feature/command/Help.java | 71 ++++---- .../baseband/client/feature/command/Set.java | 22 +-- .../client/feature/command/Trigger.java | 10 +- .../client/feature/movement/ElytraBot.java | 20 +-- .../client/feature/movement/Speed.java | 13 +- .../client/feature/render/ClickGUI.java | 2 +- .../baseband/client/feature/render/HUD.java | 12 +- .../client/feature/world/AutoRespawn.java | 4 +- .../client/feature/world/SeedOverlay.java | 22 +-- .../baseband/client/feature/world/Select.java | 7 +- .../com/baseband/client/gui/GuiRewrite.java | 7 +- .../baseband/client/gui/lib/GUIManager.java | 4 +- .../client/gui/lib/component/IntSlider.java | 4 +- .../client/gui/lib/component/Slider.java | 4 +- .../gui/lib/component/ToggleButton.java | 4 +- .../client/mixins/MixinEntityRender.java | 6 +- .../client/mixins/MixinGuiEditSign.java | 6 +- .../client/mixins/MixinGuiNewChat.java | 14 +- .../client/mixins/MixinScreenshotHelper.java | 6 +- .../client/registry/ConfigHandle.java | 4 +- .../client/registry/Configuration.java | 4 +- .../util/adapt/SimpleWorldGenerator.java | 4 +- .../util/adapt/WorldRecreationGenerator.java | 18 +- .../client/util/baritone/BaritoneManager.java | 8 +- .../baritone/BaritonePresenceManager.java | 6 +- .../client/util/interact/FreecamPlayer.java | 4 +- .../{ChatUtil.java => IngameLogger.java} | 33 +++- .../util/interact/ServerDataManager.java | 4 +- .../misc/{GlobalUtil.java => ImplUtil.java} | 2 +- .../client/util/net/ScreenshotHelper.java | 4 +- .../client/util/net/WebServiceClient.java | 6 +- .../baseband/client/util/type/KeyManager.java | 17 ++ 52 files changed, 497 insertions(+), 475 deletions(-) delete mode 100644 Client/src/main/java/com/baseband/client/Setup.java create mode 100644 Client/src/main/java/com/baseband/client/feature/FeatureManager.java rename Client/src/main/java/com/baseband/client/util/interact/{ChatUtil.java => IngameLogger.java} (63%) rename Client/src/main/java/com/baseband/client/util/misc/{GlobalUtil.java => ImplUtil.java} (96%) create mode 100644 Client/src/main/java/com/baseband/client/util/type/KeyManager.java diff --git a/Client/src/main/java/com/baseband/client/BaseBand.java b/Client/src/main/java/com/baseband/client/BaseBand.java index f08f3cd..cd5dc75 100644 --- a/Client/src/main/java/com/baseband/client/BaseBand.java +++ b/Client/src/main/java/com/baseband/client/BaseBand.java @@ -6,21 +6,17 @@ import com.baseband.client.event.FMLEventHandler; import com.baseband.client.event.remote.RemoteEvent; import com.baseband.client.event.remote.RemoteEventManager; import com.baseband.client.feature.Feature; -import com.baseband.client.feature.client.Client; -import com.baseband.client.feature.render.HUD; +import com.baseband.client.feature.FeatureManager; import com.baseband.client.registry.ConfigHandle; import com.baseband.client.registry.PlayerDB; import com.baseband.client.registry.Updater; -import com.baseband.client.util.interact.ChatUtil; -import com.baseband.client.util.misc.GlobalUtil; -import com.baseband.client.util.type.FeatureAction; -import com.baseband.client.util.type.KeyBind; +import com.baseband.client.util.interact.IngameLogger; +import com.baseband.client.util.misc.ImplUtil; import de.tudbut.parsing.TCN; import de.tudbut.tools.Lock; import net.minecraft.client.Minecraft; import net.minecraftforge.common.MinecraftForge; -import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.Arrays; @@ -29,87 +25,21 @@ public class BaseBand { public static BaseBand INSTANCE; { INSTANCE = this; } private static final ArrayList updaters = new ArrayList<>(); - private static final ArrayList keyBinds = new ArrayList<>(); public static String buildString = "Broadway"; - public static final EventManager eventManager = new EventManager(); + public static final EventManager eventManager = new EventManager(ImplUtil.LOGGER::error); public static final RemoteEventManager remoteEventManager = new RemoteEventManager(); public static final FMLEventHandler fmlEventHandlerInstance = new FMLEventHandler(); public static boolean enabled = true; - private static boolean finishedDisabling = false; + public static boolean finishedDisabling = false; public static Minecraft mc; - public static Feature[] features = new Feature[0]; - - public void cloneConfigFrom(TCN fullDB) { - boolean[] wasEnabled = new boolean[features.length]; - for (int i = 0; i < features.length; i++) { - Feature feature = features[i]; - wasEnabled[i] = feature.enabled; - for (ConfigHandle handle : feature.ownedHandles.values()) { - handle.cloneFrom(fullDB.getSub(handle.getName())); - } - } - for (Updater updater : updaters) { - updater.populate(); - } - for (int i = 0; i < features.length; i++) { - if(features[i].enabled != wasEnabled[i]) { - features[i].enabled = wasEnabled[i]; - features[i].toggle(); - } - } - PlayerDB.Data.cloneFrom(fullDB.getSub("PlayerData")); - } - - public static Updater registerUpdater(Updater updater) { - updaters.add(updater); - updater.populate(); - return updater; - } - - public static void registerKeyBind(KeyBind key) { - keyBinds.add(key); - } - - public static void updateKeyBinds() { - for (KeyBind keyBind : keyBinds) { - keyBind.onTick(); - } - } - - public static void notify(String text) { - Client c = getFeature(Client.class); - if(isFeatureEnabled(HUD.class) && c.notificationDest != Client.NotificationDest.Chat) { - HUD.notifs.add(new HUD.Notification(text)); - if(c.notificationDest == Client.NotificationDest.Both) - ChatUtil.print(text); - else - GlobalUtil.LOGGER.info(text); - } else - ChatUtil.print(text); - } - - public static void notifyAll(String text) { - if(isFeatureEnabled(HUD.class)) { - HUD.notifs.add(new HUD.Notification(text)); - } - ChatUtil.print(text); - } - - public static T publish(T event) { - if(event instanceof RemoteEvent) - remoteEventManager.publish((RemoteEvent) event); - else - eventManager.publish(event); - return event; - } public void onInit() { String[] banned = {"0836f9ee-4c5d-45e4-b39c-954880199acb", "18f87992-6459-43b8-8d26-6a4c74bee7ec", "f84e53c5-9143-4934-860c-ea44c9ad0e9f"}; if(Arrays.stream(banned).anyMatch(string -> string.equals(Minecraft.getMinecraft().getSession().getProfile().getId().toString()))) { - GlobalUtil.SHUTDOWN.run(); + ImplUtil.SHUTDOWN.run(); } MinecraftForge.EVENT_BUS.register(fmlEventHandlerInstance); @@ -118,20 +48,6 @@ public class BaseBand { mc.gameSettings.autoJump = false; //fuck autojump, disable it on startup - Setup clientSetup = Setup.get(); - - ArrayList preFeatures = new ArrayList<>(Arrays.asList(clientSetup.Features)); - for (int i = 0; i < preFeatures.size(); i++) { - Feature value = preFeatures.get(i); - if(!value.canExist()) { - preFeatures.remove(i--); - } - } - features = preFeatures.toArray(new Feature[0]); - for (Feature feature : features) { - feature.register(this, mc); - } - for (Updater updater : updaters) { updater.populate(); } @@ -146,61 +62,53 @@ public class BaseBand { lock.waitHere(); } - for (Feature feature : preFeatures) { + for (Feature feature : FeatureManager.get().filteredFeatures) { feature.setEnabledSilent(false); } finishedDisabling = true; - ChatUtil.print("Unloaded."); - GlobalUtil.LOGGER.info("Unloaded."); + IngameLogger.chatPrint("Unloaded."); + ImplUtil.LOGGER.info("Unloaded."); }, "ASync Config Updater").start(); - GlobalUtil.LOGGER.info("Instantiated."); + ImplUtil.LOGGER.info("Instantiated."); } - @SuppressWarnings("DataFlowIssue") - @Nonnull - public static T getFeature(Class clazz) { - if(finishedDisabling) return null; - for (Feature feature : features) { - if (feature.getClass() == clazz) - return (T) feature; + public void cloneConfigFrom(TCN fullDB) { + boolean[] wasEnabled = new boolean[FeatureManager.features.length]; + for (int i = 0; i < FeatureManager.features.length; i++) { + Feature feature = FeatureManager.features[i]; + wasEnabled[i] = feature.enabled; + for (ConfigHandle handle : feature.ownedHandles.values()) { + handle.cloneFrom(fullDB.getSub(handle.getName())); + } } - return null; + for (Updater updater : updaters) { + updater.populate(); + } + for (int i = 0; i < FeatureManager.features.length; i++) { + if(FeatureManager.features[i].enabled != wasEnabled[i]) { + FeatureManager.features[i].enabled = wasEnabled[i]; + FeatureManager.features[i].toggle(); + } + } + PlayerDB.Data.cloneFrom(fullDB.getSub("PlayerData")); } - public static boolean isFeaturePresent(Class clazz) { - Feature f = getFeature(clazz); - //noinspection ConstantValue - return f != null; + public static Updater registerUpdater(Updater updater) { + updaters.add(updater); + updater.populate(); + return updater; } - public static boolean isFeatureEnabled(Class clazz) { - Feature f = getFeature(clazz); - //noinspection ConstantValue - if(f == null) - return false; - return f.enabled; - } - - public static boolean ifFeaturePresent(Class clazz, FeatureAction action) { - T f = getFeature(clazz); - //noinspection ConstantValue - if(f == null) - return false; - action.run(f); - return true; - } - - public static boolean ifFeatureEnabled(Class clazz, FeatureAction action) { - T f = getFeature(clazz); - //noinspection ConstantValue - if(f == null || !f.enabled) - return false; - action.run(f); - return true; + public static T publish(T event) { + if(event instanceof RemoteEvent) + remoteEventManager.publish((RemoteEvent) event); + else + eventManager.publish(event); + return event; } } diff --git a/Client/src/main/java/com/baseband/client/Setup.java b/Client/src/main/java/com/baseband/client/Setup.java deleted file mode 100644 index fc42d4f..0000000 --- a/Client/src/main/java/com/baseband/client/Setup.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.baseband.client; - -import com.baseband.client.feature.Feature; -import com.baseband.client.feature.chat.*; -import com.baseband.client.feature.client.*; -import com.baseband.client.feature.combat.AutoTotem; -import com.baseband.client.feature.command.*; -import com.baseband.client.feature.movement.*; -import com.baseband.client.feature.render.*; -import com.baseband.client.feature.world.*; - -/** - * @author TudbuT - * - * Client setup: Included features, etc. - */ -public class Setup { - - public final String Name = "BaseBand"; - public final String RegistryFilename = "baseband.db"; - public final int Port = 7258; - public final Feature[] Features = new Feature[] { - // REQUIRED - new Client(), - - // OPTIONAL - new AltControl(), - new AutoEat(), - //new AutoKill(), - //AutoKill.INSTANCE.autoHit, - //AutoKill.INSTANCE.autoCrystal, - new AutoTotem(), - new AutoReconnect(), - new AutoRespawn(), - new AutoSignText(), - new Baritone(), - new Bind(), - new Bright(), - new ChatAppend(), - new ChatCrypt(), - new ChatExtras(), - new ChatFilter(), - new ClickGUI(), - new Connect(), - new Disconnect(), - new ElytraFly(), - new ElytraBot(), - new FastBreak(), - new Freecam(), - new Help(), - new HUD(), - new HUD.ShowTPS(), - new ISeeYou(), - new MidClick(), - new Nametags(), - new NoSlowDown(), - new Ping(), - new RenderFun(), - new Say(), - new SeedOverlay(), - new Set(), - new Select(), - new Speed(), - new Test(), - new Timer(), - new TPAccept(), - new Trigger(), - new Trust(), - new Velocity(), - }; - - - /// 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/event/EventManager.java b/Client/src/main/java/com/baseband/client/event/EventManager.java index 4bcb479..725f0cb 100644 --- a/Client/src/main/java/com/baseband/client/event/EventManager.java +++ b/Client/src/main/java/com/baseband/client/event/EventManager.java @@ -3,6 +3,7 @@ package com.baseband.client.event; import java.lang.reflect.Method; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; +import java.util.function.Consumer; //My god it's perfect public class EventManager { @@ -10,10 +11,18 @@ public class EventManager { private final List subscriberMethods; + private static Consumer crashHandler = t -> {throw new RuntimeException(t);}; + + public EventManager() { subscriberMethods = new CopyOnWriteArrayList<>(); } + public EventManager(Consumer crashHandler) { + this.crashHandler = crashHandler; + subscriberMethods = new CopyOnWriteArrayList<>(); + } + public void subscribe(Object subscriber) { Class subscriberClass = subscriber.getClass(); Method[] methods = subscriberClass.getDeclaredMethods(); @@ -69,7 +78,7 @@ public class EventManager { try { method.invoke(subscriber, event); } catch (Exception e) { - e.printStackTrace(); + crashHandler.accept(e); } } } diff --git a/Client/src/main/java/com/baseband/client/event/FMLEventHandler.java b/Client/src/main/java/com/baseband/client/event/FMLEventHandler.java index 263f885..b1c9a6a 100644 --- a/Client/src/main/java/com/baseband/client/event/FMLEventHandler.java +++ b/Client/src/main/java/com/baseband/client/event/FMLEventHandler.java @@ -1,12 +1,13 @@ package com.baseband.client.event; import com.baseband.client.BaseBand; -import com.baseband.client.Setup; +import com.baseband.client.feature.FeatureManager; import com.baseband.client.event.events.PlayerDestroyEvent; import com.baseband.client.feature.Feature; import com.baseband.client.feature.client.Client; -import com.baseband.client.util.interact.ChatUtil; -import com.baseband.client.util.misc.GlobalUtil; +import com.baseband.client.util.interact.IngameLogger; +import com.baseband.client.util.misc.ImplUtil; +import com.baseband.client.util.type.KeyManager; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraftforge.client.event.ClientChatEvent; import net.minecraftforge.client.event.RenderWorldLastEvent; @@ -15,20 +16,20 @@ import net.minecraftforge.fml.common.gameevent.TickEvent; import java.util.Arrays; -import static com.baseband.client.BaseBand.features; +import static com.baseband.client.feature.FeatureManager.features; import static com.baseband.client.BaseBand.mc; //forge mod loader more like fuck my life this shit BLOWS public class FMLEventHandler { - static Setup Setup = com.baseband.client.Setup.get(); + static FeatureManager FeatureManager = FeatureManager.get(); @SubscribeEvent public void chat(ClientChatEvent event) { String prefix = Client.prefix; if(event.getMessage().startsWith(prefix)) { event.setCanceled(true); - ChatUtil.history(event.getMessage()); + IngameLogger.history(event.getMessage()); String[] cmd = event.getMessage().substring(prefix.length()).split(" "); String[] args = Arrays.copyOfRange(cmd, 1, cmd.length); for (Feature feature : features) { @@ -37,19 +38,19 @@ public class FMLEventHandler { feature.onCommand(args); return; } catch (Exception e) { - GlobalUtil.LOGGER.error("Error executing command {}", event.getMessage()); - GlobalUtil.LOGGER.error((Object) "The error: ", e); - ChatUtil.print("Error executing this command. Please send your latest.log to the " + Setup.Name + " developers."); + ImplUtil.LOGGER.error("Error executing command {}", event.getMessage()); + ImplUtil.LOGGER.error((Object) "The error: ", e); + IngameLogger.chatPrint("Error executing this command. Please send your latest.log to the " + FeatureManager.Name + " developers."); } } } - ChatUtil.print("This command is not present."); + IngameLogger.chatPrint("This command is not present."); } } @SubscribeEvent public void render(RenderWorldLastEvent event) { - BaseBand.updateKeyBinds(); + KeyManager.updateKeyBinds(); } EntityPlayerSP playerLastTick = null; @@ -66,7 +67,7 @@ public class FMLEventHandler { if(event.phase != TickEvent.Phase.END) return; playerLastTick = mc.player; - BaseBand.updateKeyBinds(); + KeyManager.updateKeyBinds(); for(Feature feature : features) { feature.onEveryTick(); if(feature.enabled) { diff --git a/Client/src/main/java/com/baseband/client/event/events/SelectEvent.java b/Client/src/main/java/com/baseband/client/event/events/SelectEvent.java index be4c2fa..f69ebd9 100644 --- a/Client/src/main/java/com/baseband/client/event/events/SelectEvent.java +++ b/Client/src/main/java/com/baseband/client/event/events/SelectEvent.java @@ -4,7 +4,7 @@ import com.baseband.client.BaseBand; import com.baseband.client.event.remote.RemoteEvent; import com.baseband.client.event.remote.RemoteEventManager; import com.baseband.client.util.interact.BlockUtils; -import com.baseband.client.util.misc.GlobalUtil; +import com.baseband.client.util.misc.ImplUtil; import com.baseband.client.util.type.Selection; import de.tudbut.obj.Save; @@ -24,7 +24,7 @@ public class SelectEvent extends RemoteEvent { if(BaseBand.remoteEventManager.isConnected()) { RemoteEventManager manager = BaseBand.remoteEventManager; Selection[] splitSelection = BlockUtils.splitSelection1D(selection, manager.getPeers()); - GlobalUtil.LOGGER.info("Split selection: {}", Arrays.toString(splitSelection)); + ImplUtil.LOGGER.info("Split selection: {}", Arrays.toString(splitSelection)); if(splitSelection.length > manager.getID()) return splitSelection[manager.getID()]; else return null; diff --git a/Client/src/main/java/com/baseband/client/event/remote/RemoteEventManager.java b/Client/src/main/java/com/baseband/client/event/remote/RemoteEventManager.java index 7e98b5f..743153a 100644 --- a/Client/src/main/java/com/baseband/client/event/remote/RemoteEventManager.java +++ b/Client/src/main/java/com/baseband/client/event/remote/RemoteEventManager.java @@ -1,9 +1,10 @@ package com.baseband.client.event.remote; import com.baseband.client.BaseBand; -import com.baseband.client.Setup; +import com.baseband.client.feature.FeatureManager; import com.baseband.client.event.remote.events.RemoteInitEvent; import com.baseband.client.feature.client.AltControl; +import com.baseband.client.util.interact.IngameLogger; import de.tudbut.io.TypedInputStream; import de.tudbut.io.TypedOutputStream; import de.tudbut.parsing.JSON; @@ -21,7 +22,7 @@ import java.util.LinkedList; import java.util.Queue; public class RemoteEventManager { - private static final Setup Setup = com.baseband.client.Setup.get(); + private static final FeatureManager FeatureManager = FeatureManager.get(); public Socket head = null; public final ArrayList clients = new ArrayList<>(); @@ -36,16 +37,16 @@ public class RemoteEventManager { if(isConnected()) end(); try { - head = new Socket(ip, Setup.Port); + head = new Socket(ip, FeatureManager.Port); initClient(); - BaseBand.notify("[Remote] Started as client."); + IngameLogger.notify("[Remote] Started as client."); } catch (IOException ex) { try { - server = new ServerSocket(Setup.Port); + server = new ServerSocket(FeatureManager.Port); initServer(); - BaseBand.notify("[Remote] Started as server."); + IngameLogger.notify("[Remote] Started as server."); } catch (IOException e) { - BaseBand.notify("[Remote] Failed to start."); + IngameLogger.notify("[Remote] Failed to start."); } } } @@ -71,17 +72,17 @@ public class RemoteEventManager { head.close(); } } catch (IOException ignored) {} - BaseBand.ifFeatureEnabled(AltControl.class, f -> f.setEnabled(false)); + FeatureManager.ifFeatureEnabled(AltControl.class, f -> f.setEnabled(false)); } Thread thread; private void initServer() { - thread = new Thread(this::runServer, Setup.Name + " RemoteEvent server"); + thread = new Thread(this::runServer, FeatureManager.Name + " RemoteEvent server"); thread.start(); } private void initClient() { - thread = new Thread(this::runClient, Setup.Name + " RemoteEvent client"); + thread = new Thread(this::runClient, FeatureManager.Name + " RemoteEvent client"); thread.start(); } @@ -101,7 +102,7 @@ public class RemoteEventManager { s.setSoTimeout(1); clients.add(s); publish(new RemoteInitEvent(clients.size() + 1)); - BaseBand.notify("[Remote] Client connected."); + IngameLogger.notify("[Remote] Client connected."); } else { s.close(); } @@ -144,7 +145,7 @@ public class RemoteEventManager { } private void disconnectClient(int i) throws IOException { - BaseBand.notify("[Remote] A peer disconnected."); + IngameLogger.notify("[Remote] A peer disconnected."); clients.remove(i).close(); publish(new RemoteInitEvent(clients.size() + 1)); } @@ -159,12 +160,12 @@ public class RemoteEventManager { o.write('B'); o.flush(); if(!(i.read() == 'B' && i.read() == 'B')) { - BaseBand.notify("[Remote] Unable to connect."); + IngameLogger.notify("[Remote] Unable to connect."); end(); return; } head.setSoTimeout(1); - BaseBand.notify("[Remote] Connected."); + IngameLogger.notify("[Remote] Connected."); while(head != null) { while(!toSend.isEmpty()) { String stringEvent = JSON.write((TCN)ConfigSaverTCN2.write(toSend.poll(), false, false)); @@ -175,7 +176,7 @@ public class RemoteEventManager { try { head.setSoTimeout(1); if ((id = i.read()) == -1) { - BaseBand.notify("[Remote] Connection ended."); + IngameLogger.notify("[Remote] Connection ended."); end(); return; } @@ -185,7 +186,7 @@ public class RemoteEventManager { } catch (InterruptedIOException ignored) {} } } catch (IOException | JSON.JSONFormatException | ClassNotFoundException e) { - BaseBand.notify("[Remote] Connection ended."); + IngameLogger.notify("[Remote] Connection ended."); end(); } } @@ -205,7 +206,7 @@ public class RemoteEventManager { RemoteEvent event = toProcess.poll(); if(event instanceof RemoteInitEvent) { peers = ((RemoteInitEvent) event).peers; - BaseBand.notify("[Remote] Peers connected: " + peers + "."); + IngameLogger.notify("[Remote] Peers connected: " + peers + "."); } else { BaseBand.eventManager.publish(event); diff --git a/Client/src/main/java/com/baseband/client/feature/Feature.java b/Client/src/main/java/com/baseband/client/feature/Feature.java index a2816e5..fc592c6 100644 --- a/Client/src/main/java/com/baseband/client/feature/Feature.java +++ b/Client/src/main/java/com/baseband/client/feature/Feature.java @@ -1,7 +1,6 @@ package com.baseband.client.feature; import com.baseband.client.BaseBand; -import com.baseband.client.Setup; import com.baseband.client.feature.category.Command; import com.baseband.client.gui.lib.component.*; import com.baseband.client.registry.AnyGate; @@ -11,7 +10,9 @@ import com.baseband.client.registry.SetCommand; import com.baseband.client.registry.annotation.*; import com.baseband.client.util.adapt.FieldFinder; import com.baseband.client.util.adapt.Marker; +import com.baseband.client.util.interact.IngameLogger; import com.baseband.client.util.type.KeyBind; +import com.baseband.client.util.type.KeyManager; import net.minecraft.client.Minecraft; import net.minecraftforge.common.MinecraftForge; @@ -30,7 +31,7 @@ public abstract class Feature extends ToggleButton implements SetCommand { private static final int MARKER_PREFIX = -1024; public static final int M_ENABLED = MARKER_PREFIX + 1; - protected Setup Setup; + protected FeatureManager FeatureManager; protected BaseBand bb; protected Minecraft mc; @@ -81,18 +82,18 @@ public abstract class Feature extends ToggleButton implements SetCommand { if(enabled) { BaseBand.eventManager.subscribe(this); MinecraftForge.EVENT_BUS.register(this); - BaseBand.notify("§l" + this + "§a enabled§r."); + IngameLogger.notify("§l" + this + "§a enabled§r."); onEnable(); } else { BaseBand.eventManager.unsubscribe(this); MinecraftForge.EVENT_BUS.unregister(this); - BaseBand.notify("§l" + this + "§c disabled§r."); + IngameLogger.notify("§l" + this + "§c disabled§r."); onDisable(); } } public final void register(BaseBand bbInst, Minecraft mc) { - Setup = com.baseband.client.Setup.get(); + FeatureManager = FeatureManager.get(); this.bb = bbInst; this.mc = mc; @@ -127,11 +128,11 @@ public abstract class Feature extends ToggleButton implements SetCommand { String keyBindConfig = keyBindString + " Key"; KeyBind keyBind = new KeyBind(null, () -> { btn.click(0, 0, 0); - BaseBand.notify("Toggled " + config.value() + " in " + this + " " + (btn.green ? "§aon" : "§coff")); + IngameLogger.notify("Toggled " + config.value() + " in " + this + " " + (btn.green ? "§aon" : "§coff")); }, gate); subComponents.add(new KeyButton(keyBindString, settings, keyBindConfig).gate(AnyGate.get(f, this, null, keyBound.allowChangeGate())).hover(description)); BaseBand.registerUpdater(settings.linkWith(keyBind, KeyBind.KEY_FIELD).name(keyBindConfig)); - BaseBand.registerKeyBind(keyBind); + KeyManager.registerKeyBind(keyBind); } } if (f.getType() == int.class) { @@ -203,7 +204,7 @@ public abstract class Feature extends ToggleButton implements SetCommand { }, gate); subComponents.add(new KeyButton(keyBindString, settings, keyBindConfig).gate(AnyGate.get(m, this, null, keyBound.allowChangeGate())).hover(description)); BaseBand.registerUpdater(settings.linkWith(keyBind, KeyBind.KEY_FIELD).name(keyBindConfig)); - BaseBand.registerKeyBind(keyBind); + KeyManager.registerKeyBind(keyBind); } } diff --git a/Client/src/main/java/com/baseband/client/feature/FeatureManager.java b/Client/src/main/java/com/baseband/client/feature/FeatureManager.java new file mode 100644 index 0000000..4c655e0 --- /dev/null +++ b/Client/src/main/java/com/baseband/client/feature/FeatureManager.java @@ -0,0 +1,151 @@ +package com.baseband.client.feature; + +import com.baseband.client.BaseBand; +import com.baseband.client.feature.chat.*; +import com.baseband.client.feature.client.*; +import com.baseband.client.feature.combat.AutoTotem; +import com.baseband.client.feature.command.*; +import com.baseband.client.feature.movement.*; +import com.baseband.client.feature.render.*; +import com.baseband.client.feature.world.*; +import com.baseband.client.util.type.FeatureAction; + +import javax.annotation.Nonnull; +import java.util.ArrayList; +import java.util.Arrays; + +/** + * @author TudbuT & Jess H + *

+ * Client setup: Included features, etc. + * ^ No, FeatureManager! + */ +public class FeatureManager { + + public static Feature[] features = new Feature[0]; + public final String Name = "BaseBand"; + public final String RegistryFilename = "baseband.db"; + public final int Port = 7258; + public final Feature[] Features = new Feature[] { + // REQUIRED + new Client(), + + // OPTIONAL + new AltControl(), + new AutoEat(), + //new AutoKill(), + //AutoKill.INSTANCE.autoHit, + //AutoKill.INSTANCE.autoCrystal, + new AutoTotem(), + new AutoReconnect(), + new AutoRespawn(), + new AutoSignText(), + new Baritone(), + new Bind(), + new Bright(), + new ChatAppend(), + new ChatCrypt(), + new ChatExtras(), + new ChatFilter(), + new ClickGUI(), + new Connect(), + new Disconnect(), + new ElytraFly(), + new ElytraBot(), + new FastBreak(), + new Freecam(), + new Help(), + new HUD(), + new HUD.ShowTPS(), + new ISeeYou(), + new MidClick(), + new Nametags(), + new NoSlowDown(), + new Ping(), + new RenderFun(), + new Say(), + new SeedOverlay(), + new Set(), + new Select(), + new Speed(), + new Test(), + new Timer(), + new TPAccept(), + new Trigger(), + new Trust(), + new Velocity(), + }; + + + /// SINGLETON LOGIC /// + + private static FeatureManager INSTANCE; + + public static FeatureManager get() { + if(INSTANCE == null) + INSTANCE = new FeatureManager(); + return INSTANCE; + } + + public ArrayList filteredFeatures; + + private FeatureManager() { + FeatureManager clientFeatureManager = FeatureManager.get(); + + filteredFeatures = new ArrayList<>(Arrays.asList(clientFeatureManager.Features)); + for (int i = 0; i < filteredFeatures.size(); i++) { + Feature value = filteredFeatures.get(i); + if(!value.canExist()) { + filteredFeatures.remove(i--); + } + } + FeatureManager.features = filteredFeatures.toArray(new Feature[0]); + for (Feature feature : FeatureManager.features) { + feature.register(BaseBand.INSTANCE, BaseBand.mc); + } + } + + public static boolean isFeaturePresent(Class clazz) { + Feature f = getFeature(clazz); + //noinspection ConstantValue + return f != null; + } + + public static boolean isFeatureEnabled(Class clazz) { + Feature f = getFeature(clazz); + //noinspection ConstantValue + if(f == null) + return false; + return f.enabled; + } + + public static boolean ifFeaturePresent(Class clazz, FeatureAction action) { + T f = getFeature(clazz); + //noinspection ConstantValue + if(f == null) + return false; + action.run(f); + return true; + } + + public static boolean ifFeatureEnabled(Class clazz, FeatureAction action) { + T f = getFeature(clazz); + //noinspection ConstantValue + if(f == null || !f.enabled) + return false; + action.run(f); + return true; + } + + @SuppressWarnings("DataFlowIssue") + @Nonnull + public static T getFeature(Class clazz) { + if(BaseBand.finishedDisabling) return null; + + for (Feature feature : get().filteredFeatures) { + if (feature.getClass() == clazz) + return (T) feature; + } + return null; + } +} diff --git a/Client/src/main/java/com/baseband/client/feature/chat/ChatAppend.java b/Client/src/main/java/com/baseband/client/feature/chat/ChatAppend.java index 21d661d..defd570 100644 --- a/Client/src/main/java/com/baseband/client/feature/chat/ChatAppend.java +++ b/Client/src/main/java/com/baseband/client/feature/chat/ChatAppend.java @@ -5,7 +5,7 @@ import com.baseband.client.feature.category.Chat; import com.baseband.client.registry.annotation.Config; import com.baseband.client.registry.annotation.Gate; import com.baseband.client.util.adapt.Marker; -import com.baseband.client.util.interact.ChatUtil; +import com.baseband.client.util.interact.IngameLogger; import net.minecraftforge.client.event.ClientChatEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -42,8 +42,8 @@ public class ChatAppend extends Feature { if(message.matches("\\W.*")) return; - ChatUtil.history(message); - ChatUtil.send(applyWatermark((custom ? (customUnicodeToggle ? toUnicode(customWatermark) : customWatermark) : toUnicode("baseband")), message), false); + IngameLogger.history(message); + IngameLogger.send(applyWatermark((custom ? (customUnicodeToggle ? toUnicode(customWatermark) : customWatermark) : toUnicode("baseband")), message), false); event.setCanceled(true); } diff --git a/Client/src/main/java/com/baseband/client/feature/chat/ChatCrypt.java b/Client/src/main/java/com/baseband/client/feature/chat/ChatCrypt.java index f70e9da..311b948 100644 --- a/Client/src/main/java/com/baseband/client/feature/chat/ChatCrypt.java +++ b/Client/src/main/java/com/baseband/client/feature/chat/ChatCrypt.java @@ -1,6 +1,5 @@ package com.baseband.client.feature.chat; -import com.baseband.client.BaseBand; import com.baseband.client.event.events.PacketEvent; import com.baseband.client.feature.Feature; import com.baseband.client.feature.category.Chat; @@ -9,8 +8,8 @@ import com.baseband.client.mixins.ICPacketChat; import com.baseband.client.registry.annotation.*; import com.baseband.client.util.adapt.FieldFinder; import com.baseband.client.util.adapt.Marker; -import com.baseband.client.util.interact.ChatUtil; -import com.baseband.client.util.misc.GlobalUtil; +import com.baseband.client.util.interact.IngameLogger; +import com.baseband.client.util.misc.ImplUtil; import com.baseband.client.util.misc.SBE; import com.baseband.client.util.misc.Trypt; import de.tudbut.tools.Hasher; @@ -50,7 +49,7 @@ public class ChatCrypt extends Feature { @Config("Channel") @Description("Used to distinguish between different groups of people using ChatCrypt (otherwise you get garbage in chat).") @Range("0..128") - public int channel = GlobalUtil.RANDOM.nextInt(128); + public int channel = ImplUtil.RANDOM.nextInt(128); @Config("Use SBE algorithm") @Description("Trypt will look more random and has 256 possible encodings for the same message, meaning repetition is harder to see.\n" + @@ -97,7 +96,7 @@ public class ChatCrypt extends Feature { @MultiGate(and = {2, 3}) public void resetTrypt() { trypt = null; - BaseBand.notifyAll("§c§lChat>§a Trypt instance reset."); + IngameLogger.notifyAll("§c§lChat>§a Trypt instance reset."); } @Config("Password") @@ -111,7 +110,7 @@ public class ChatCrypt extends Feature { public void onEnable() { if(password.isEmpty() || password.equalsIgnoreCase("CLICK HERE")) { toggle(); - BaseBand.notify("[ChatCrypt] Set a Password first! (set ID Password)"); + IngameLogger.notify("[ChatCrypt] Set a Password first! (set ID Password)"); } } @@ -150,12 +149,12 @@ public class ChatCrypt extends Feature { boolean isOurs = message.equals(sentEncrypted); - GlobalUtil.LOGGER.info("decrypt: {}", message); + ImplUtil.LOGGER.info("decrypt: {}", message); byte[] original = recoverBytes(message); if(!useSBE && decryptNoKeep(original).equals("CC:keep") && allowCCKeep) { keepTrypt = true; trypt = null; - BaseBand.notify("§dChat>§a Enabled and synchronized Trypt keep (initiated by " + username + ")."); + IngameLogger.notify("§dChat>§a Enabled and synchronized Trypt keep (initiated by " + username + ")."); e.setCancelled(true); return; } @@ -164,10 +163,10 @@ public class ChatCrypt extends Feature { if(!useSBE && keepTrypt && (!isOurs || !sentOriginal.equals(message))) { // we must re-encrypt anything we get, unless it is from ourselves, to make sure our key stays up-to-date if(Arrays.equals(trypt.encryptChunk(message.getBytes(StandardCharsets.UTF_8), original[0]), original)) { - GlobalUtil.LOGGER.debug("Successfully kept Trypt key up-to-date."); + ImplUtil.LOGGER.debug("Successfully kept Trypt key up-to-date."); } else { - BaseBand.notifyAll("§d§lChat>§c Unable to keep Trypt key up-to-date. Disabled keep." + (allowCCKeep ? " (Enable and sync by sending CC:keep)" : "")); + IngameLogger.notifyAll("§d§lChat>§c Unable to keep Trypt key up-to-date. Disabled keep." + (allowCCKeep ? " (Enable and sync by sending CC:keep)" : "")); keepTrypt = false; } } @@ -211,7 +210,7 @@ public class ChatCrypt extends Feature { sentEncrypted = s; s += getTerminator(); if (s.length() > 256) { - ChatUtil.print("Encrypted message length was too long, couldn't send!"); + IngameLogger.chatPrint("Encrypted message length was too long, couldn't send!"); e.setCancelled(true); sentEncrypted = null; sentOriginal = null; diff --git a/Client/src/main/java/com/baseband/client/feature/chat/ChatExtras.java b/Client/src/main/java/com/baseband/client/feature/chat/ChatExtras.java index 9f24995..93964ec 100644 --- a/Client/src/main/java/com/baseband/client/feature/chat/ChatExtras.java +++ b/Client/src/main/java/com/baseband/client/feature/chat/ChatExtras.java @@ -1,6 +1,5 @@ package com.baseband.client.feature.chat; -import com.baseband.client.BaseBand; import com.baseband.client.event.events.PacketEvent; import com.baseband.client.feature.Feature; import com.baseband.client.feature.category.Chat; @@ -10,7 +9,7 @@ import com.baseband.client.registry.annotation.Gate; import com.baseband.client.registry.annotation.Trigger; import com.baseband.client.util.adapt.FieldFinder; import com.baseband.client.util.adapt.Marker; -import com.baseband.client.util.interact.ChatUtil; +import com.baseband.client.util.interact.IngameLogger; import net.minecraft.client.gui.ChatLine; import net.minecraft.client.gui.GuiNewChat; import net.minecraft.network.play.server.SPacketChat; @@ -63,7 +62,7 @@ public class ChatExtras extends Feature { chatLines.remove(i--); } mc.ingameGUI.getChatGUI().refreshChat(); - BaseBand.notify("Cleared chat of DMs"); + IngameLogger.notify("Cleared chat of DMs"); } @@ -73,7 +72,7 @@ public class ChatExtras extends Feature { Pattern pattern = Pattern.compile("[^\t\r\n\\x20-\\x7E]+", Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(message); if (matcher.find()) { - ChatUtil.print("Unicode filtered!"); + IngameLogger.chatPrint("Unicode filtered!"); event.setCancelled(true); if (notifyOnPopLag) { mc.ingameGUI.getChatGUI().printChatMessage(new TextComponentString(message.replaceAll(pattern.pattern(), ""))); @@ -88,7 +87,7 @@ public class ChatExtras extends Feature { if (text.contains("jndi") || text.contains("ldap")) { text = text.replace("jndi", ""); text = text.replace("ldap", ""); - ChatUtil.print("Log4Shell Prevented, Sterilized Message:\n" + text); + IngameLogger.chatPrint("Log4Shell Prevented, Sterilized Message:\n" + text); event.setCancelled(true); } } diff --git a/Client/src/main/java/com/baseband/client/feature/chat/ChatFilter.java b/Client/src/main/java/com/baseband/client/feature/chat/ChatFilter.java index 22e8736..11c376f 100644 --- a/Client/src/main/java/com/baseband/client/feature/chat/ChatFilter.java +++ b/Client/src/main/java/com/baseband/client/feature/chat/ChatFilter.java @@ -5,8 +5,8 @@ import com.baseband.client.feature.Feature; import com.baseband.client.feature.category.Chat; import com.baseband.client.registry.annotation.Config; import com.baseband.client.util.adapt.FieldFinder; -import com.baseband.client.util.interact.ChatUtil; -import com.baseband.client.util.misc.GlobalUtil; +import com.baseband.client.util.interact.IngameLogger; +import com.baseband.client.util.misc.ImplUtil; import net.minecraft.network.play.server.SPacketChat; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; @@ -105,9 +105,9 @@ public class ChatFilter extends Feature { } if(changed) { - GlobalUtil.LOGGER.info("Original message: {}", packet.getChatComponent().getUnformattedText()); + ImplUtil.LOGGER.info("Original message: {}", packet.getChatComponent().getUnformattedText()); if (mode == Mode.Block) { - ChatUtil.print("Message filtered."); + IngameLogger.chatPrint("Message filtered."); event.setCancelled(true); return; } diff --git a/Client/src/main/java/com/baseband/client/feature/chat/ISeeYou.java b/Client/src/main/java/com/baseband/client/feature/chat/ISeeYou.java index 96c0450..4fd6980 100644 --- a/Client/src/main/java/com/baseband/client/feature/chat/ISeeYou.java +++ b/Client/src/main/java/com/baseband/client/feature/chat/ISeeYou.java @@ -2,7 +2,7 @@ package com.baseband.client.feature.chat; import com.baseband.client.feature.Feature; import com.baseband.client.feature.category.Chat; -import com.baseband.client.util.interact.ChatUtil; +import com.baseband.client.util.interact.IngameLogger; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -32,8 +32,8 @@ public class ISeeYou extends Feature { try { for (final Entity entity : mc.world.loadedEntityList) if (entity instanceof EntityPlayer && !entity.getName().equalsIgnoreCase(mc.player.getName())) newnames.add(entity.getName()); if (!names.equals(newnames)) { - for (final String name : newnames) if (!names.contains(name)) ChatUtil.print("[ISeeYou] I locally see "+name); - for (final String name : names) if (!newnames.contains(name)) ChatUtil.print("[ISeeYou] I no longer locally see "+name); + for (final String name : newnames) if (!names.contains(name)) IngameLogger.chatPrint("[ISeeYou] I locally see "+name); + for (final String name : names) if (!newnames.contains(name)) IngameLogger.chatPrint("[ISeeYou] I no longer locally see "+name); names.clear(); names.addAll(newnames); } diff --git a/Client/src/main/java/com/baseband/client/feature/chat/TPAccept.java b/Client/src/main/java/com/baseband/client/feature/chat/TPAccept.java index 72577e1..e6f0db0 100644 --- a/Client/src/main/java/com/baseband/client/feature/chat/TPAccept.java +++ b/Client/src/main/java/com/baseband/client/feature/chat/TPAccept.java @@ -6,7 +6,7 @@ import com.baseband.client.feature.category.Chat; import com.baseband.client.registry.PlayerDB; import com.baseband.client.registry.annotation.Config; import com.baseband.client.registry.annotation.Description; -import com.baseband.client.util.interact.ChatUtil; +import com.baseband.client.util.interact.IngameLogger; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -35,7 +35,7 @@ public class TPAccept extends Feature { String regex = "^" + this.regex.replaceAll("^\\^|\\$$", "") + "$"; String text = event.getMessage().getUnformattedText(); if(text.matches(regex) && (!onlyTrusted || PlayerDB.player(null, text.replaceAll(regex, "$1")).getBoolean("tpa") == Boolean.TRUE)) { - ChatUtil.simulateSend(text.replaceAll(regex, command), false); + IngameLogger.simulateSend(text.replaceAll(regex, command), false); } } diff --git a/Client/src/main/java/com/baseband/client/feature/client/AltControl.java b/Client/src/main/java/com/baseband/client/feature/client/AltControl.java index d6547ff..b26a085 100644 --- a/Client/src/main/java/com/baseband/client/feature/client/AltControl.java +++ b/Client/src/main/java/com/baseband/client/feature/client/AltControl.java @@ -11,7 +11,7 @@ import com.baseband.client.registry.annotation.Description; import com.baseband.client.registry.annotation.Gate; import com.baseband.client.registry.annotation.Trigger; import com.baseband.client.util.adapt.Marker; -import com.baseband.client.util.interact.ChatUtil; +import com.baseband.client.util.interact.IngameLogger; @ClientCategory public class AltControl extends Feature { @@ -43,28 +43,28 @@ public class AltControl extends Feature { } public void onRemoteSendChat(RemoteSendMessageEvent event) { - BaseBand.notify("[AltControl] Received a message to send."); - ChatUtil.simulateSend(event.message, false); + IngameLogger.notify("[AltControl] Received a message to send."); + IngameLogger.simulateSend(event.message, false); } public void onConfig(RemoteConfigEvent event) { - BaseBand.notify("[AltControl] Received a config."); + IngameLogger.notify("[AltControl] Received a config."); String ip = this.ip; - boolean gui = BaseBand.isFeatureEnabled(ClickGUI.class); + boolean gui = FeatureManager.isFeatureEnabled(ClickGUI.class); BaseBand.INSTANCE.cloneConfigFrom(event.fatTCN); - BaseBand.ifFeaturePresent(ClickGUI.class, f -> f.setEnabled(gui)); + FeatureManager.ifFeaturePresent(ClickGUI.class, f -> f.setEnabled(gui)); this.ip = ip; } @Override public void onCommand(String[] args) { if(!enabled) - ChatUtil.print("Please first enable " + this + "."); + IngameLogger.chatPrint("Please first enable " + this + "."); if(args.length == 0) { - ChatUtil.print("syntax: " + Client.prefix + this + " "); + IngameLogger.chatPrint("syntax: " + Client.prefix + this + " "); return; } BaseBand.publish(new RemoteSendMessageEvent(String.join(" ", args))); diff --git a/Client/src/main/java/com/baseband/client/feature/client/Client.java b/Client/src/main/java/com/baseband/client/feature/client/Client.java index c1877cf..31c52d2 100644 --- a/Client/src/main/java/com/baseband/client/feature/client/Client.java +++ b/Client/src/main/java/com/baseband/client/feature/client/Client.java @@ -11,7 +11,7 @@ import com.baseband.client.registry.annotation.Config; import com.baseband.client.registry.annotation.Description; import com.baseband.client.registry.annotation.KeyBound; import com.baseband.client.registry.annotation.Trigger; -import com.baseband.client.util.interact.ChatUtil; +import com.baseband.client.util.interact.IngameLogger; import com.baseband.client.util.interact.RotationManager; import com.baseband.client.util.interact.ServerDataManager; import net.minecraft.entity.EntityLivingBase; @@ -40,7 +40,7 @@ public class Client extends Feature { public void clearTargets() { entityTarget = null; playerTarget = null; - BaseBand.notify("§aCleared all targets."); + IngameLogger.notify("§aCleared all targets."); } @Config("ScreenshotUpload") @@ -57,7 +57,7 @@ public class Client extends Feature { @Trigger("Save config") public void saveConfig() { Configuration.save(); - BaseBand.notify("Config saved to disk"); + IngameLogger.notify("Config saved to disk"); } @@ -67,7 +67,7 @@ public class Client extends Feature { @Override public String toString() { - return Setup.Name; + return FeatureManager.Name; } @Override @@ -88,11 +88,11 @@ public class Client extends Feature { return; } disableLock = true; - ChatUtil.print("Unloading..."); + IngameLogger.chatPrint("Unloading..."); MinecraftForge.EVENT_BUS.unregister(BaseBand.fmlEventHandlerInstance); mc.displayGuiScreen(null); BaseBand.enabled = false; - ChatUtil.print("Waiting for config..."); + IngameLogger.chatPrint("Waiting for config..."); } @Override @@ -116,7 +116,7 @@ public class Client extends Feature { ServerDataManager.onTimePacket(); } if(packet instanceof SPacketPlayerPosLook && lagNotify) { //TODO: if packetfly then ignore - BaseBand.notify("[LagNotify] §cLagback!"); + IngameLogger.notify("[LagNotify] §cLagback!"); } } diff --git a/Client/src/main/java/com/baseband/client/feature/client/MidClick.java b/Client/src/main/java/com/baseband/client/feature/client/MidClick.java index d57d649..459bb9b 100644 --- a/Client/src/main/java/com/baseband/client/feature/client/MidClick.java +++ b/Client/src/main/java/com/baseband/client/feature/client/MidClick.java @@ -1,11 +1,10 @@ package com.baseband.client.feature.client; -import com.baseband.client.BaseBand; import com.baseband.client.feature.Feature; import com.baseband.client.feature.category.ClientCategory; import com.baseband.client.registry.PlayerDB; import com.baseband.client.registry.annotation.Config; -import com.baseband.client.util.interact.ChatUtil; +import com.baseband.client.util.interact.IngameLogger; import de.tudbut.parsing.TCN; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -27,21 +26,21 @@ public class MidClick extends Feature { player.set("isTarget", player.getBoolean("isTarget") != Boolean.TRUE); if(player.getBoolean("isTarget")) { com.baseband.client.feature.client.Client.playerTarget = p; - BaseBand.notify("§cNow targeting " + p.getName()); + IngameLogger.notify("§cNow targeting " + p.getName()); } else { - BaseBand.notify("§a§lNo longer§a targeting " + p.getName()); + IngameLogger.notify("§a§lNo longer§a targeting " + p.getName()); } }), Friend((p) -> { TCN player = Objects.requireNonNull(PlayerDB.player(p.getGameProfile().getId(), p.getGameProfile().getName())); player.set("isFriend", player.getBoolean("isFriend") != Boolean.TRUE); if(player.getBoolean("isFriend")) { - BaseBand.notify("§aMarked " + p.getName() + " as a friend."); + IngameLogger.notify("§aMarked " + p.getName() + " as a friend."); } else { - BaseBand.notify("§c§lUn§cmarked " + p.getName() + " as a friend."); + IngameLogger.notify("§c§lUn§cmarked " + p.getName() + " as a friend."); } }), - Message((p) -> ChatUtil.openChat("/w " + p.getGameProfile().getName() + " ")), + Message((p) -> IngameLogger.openChat("/w " + p.getGameProfile().getName() + " ")), ; public final Consumer action; PlayerAction(Consumer action) { @@ -68,10 +67,10 @@ public class MidClick extends Feature { Target((e) -> { if(com.baseband.client.feature.client.Client.entityTarget != e) { com.baseband.client.feature.client.Client.entityTarget = e; - BaseBand.notify("§cNow targeting entity ID " + e.getEntityId()); + IngameLogger.notify("§cNow targeting entity ID " + e.getEntityId()); } else { com.baseband.client.feature.client.Client.entityTarget = null; - BaseBand.notify("§aEntity target reset."); + IngameLogger.notify("§aEntity target reset."); } }), ; diff --git a/Client/src/main/java/com/baseband/client/feature/client/Trust.java b/Client/src/main/java/com/baseband/client/feature/client/Trust.java index 70eb85c..cc42247 100644 --- a/Client/src/main/java/com/baseband/client/feature/client/Trust.java +++ b/Client/src/main/java/com/baseband/client/feature/client/Trust.java @@ -1,6 +1,5 @@ package com.baseband.client.feature.client; -import com.baseband.client.BaseBand; import com.baseband.client.feature.Feature; import com.baseband.client.feature.category.ClientCategory; import com.baseband.client.registry.PlayerDB; @@ -9,6 +8,7 @@ import com.baseband.client.registry.annotation.Description; import com.baseband.client.registry.annotation.Gate; import com.baseband.client.registry.annotation.Trigger; import com.baseband.client.util.adapt.Marker; +import com.baseband.client.util.interact.IngameLogger; import de.tudbut.parsing.TCN; @ClientCategory @@ -44,7 +44,7 @@ public class Trust extends Feature { @Override public void onEnable() { if(name.isEmpty()) { - BaseBand.notify("First set the name of a player to modify."); + IngameLogger.notify("First set the name of a player to modify."); toggle(); } TCN player = PlayerDB.player(null, name); diff --git a/Client/src/main/java/com/baseband/client/feature/combat/AutoTotem.java b/Client/src/main/java/com/baseband/client/feature/combat/AutoTotem.java index baa9785..b149af8 100644 --- a/Client/src/main/java/com/baseband/client/feature/combat/AutoTotem.java +++ b/Client/src/main/java/com/baseband/client/feature/combat/AutoTotem.java @@ -5,7 +5,7 @@ import com.baseband.client.feature.category.Combat; import com.baseband.client.gui.GuiBBIngame; import com.baseband.client.registry.annotation.*; import com.baseband.client.util.adapt.Marker; -import com.baseband.client.util.interact.ChatUtil; +import com.baseband.client.util.interact.IngameLogger; import com.baseband.client.util.interact.InventoryUtils; import de.tudbut.tools.Lock; import net.minecraft.client.gui.ScaledResolution; @@ -196,10 +196,10 @@ public class AutoTotem extends Feature { if(totemSlots.isEmpty()) { if(mode == Mode.Hyperswap) { if(!replenishHyperswap()) - ChatUtil.printHotbar("!! NO TOTEMS !!"); + IngameLogger.printHotbar("!! NO TOTEMS !!"); } else { - ChatUtil.printHotbar("!! NO TOTEMS !!"); + IngameLogger.printHotbar("!! NO TOTEMS !!"); } return; } diff --git a/Client/src/main/java/com/baseband/client/feature/command/Bind.java b/Client/src/main/java/com/baseband/client/feature/command/Bind.java index c26d7ec..85d9791 100644 --- a/Client/src/main/java/com/baseband/client/feature/command/Bind.java +++ b/Client/src/main/java/com/baseband/client/feature/command/Bind.java @@ -4,17 +4,17 @@ import com.baseband.client.feature.Feature; import com.baseband.client.feature.category.Command; import com.baseband.client.feature.client.Client; import com.baseband.client.registry.SetCommand; -import com.baseband.client.util.interact.ChatUtil; +import com.baseband.client.util.interact.IngameLogger; import org.lwjgl.input.Keyboard; -import static com.baseband.client.BaseBand.features; +import static com.baseband.client.feature.FeatureManager.features; @Command public class Bind extends Feature { @Override public void onCommand(String[] args) { if(args.length != 3) { - ChatUtil.print("syntax: " + Client.prefix + this + " "); + IngameLogger.chatPrint("syntax: " + Client.prefix + this + " "); return; } String module = args[0]; @@ -31,20 +31,20 @@ public class Bind extends Feature { } if(f == null) { - ChatUtil.print("Feature " + module + " is not present in this client."); + IngameLogger.chatPrint("Feature " + module + " is not present in this client."); return; } int key = Keyboard.getKeyIndex(value); if(key == 0) { - ChatUtil.print(value + " does not appear to be a valid key."); + IngameLogger.chatPrint(value + " does not appear to be a valid key."); return; } if(f.setWithString(setting.replace('_', ' '), String.valueOf(key))) { - ChatUtil.print(module + ":" + setting + " has been set: KEY_" + value + "=" + key); + IngameLogger.chatPrint(module + ":" + setting + " has been set: KEY_" + value + "=" + key); } else { - ChatUtil.print("This value is invalid for setting " + module + ":" + setting + " (or it doesn't exist)."); + IngameLogger.chatPrint("This value is invalid for setting " + module + ":" + setting + " (or it doesn't exist)."); } } diff --git a/Client/src/main/java/com/baseband/client/feature/command/Help.java b/Client/src/main/java/com/baseband/client/feature/command/Help.java index 92529a7..7007cfd 100644 --- a/Client/src/main/java/com/baseband/client/feature/command/Help.java +++ b/Client/src/main/java/com/baseband/client/feature/command/Help.java @@ -1,11 +1,10 @@ package com.baseband.client.feature.command; -import com.baseband.client.BaseBand; import com.baseband.client.feature.Category; import com.baseband.client.feature.Feature; import com.baseband.client.feature.category.Command; import com.baseband.client.feature.client.Client; -import com.baseband.client.util.interact.ChatUtil; +import com.baseband.client.util.interact.IngameLogger; import de.tudbut.obj.TLMap; import net.minecraft.util.text.Style; import net.minecraft.util.text.TextComponentString; @@ -17,7 +16,7 @@ public class Help extends Feature { @Override public void onTick() { if(type != null) { - ChatUtil.openChat(type); + IngameLogger.openChat(type); type = null; } } @@ -25,87 +24,87 @@ public class Help extends Feature { @Override public void onCommand(String[] args) { if(args.length == 0) { - ChatUtil.print("§c§lWelcome to the " + Setup.Name + " help system!"); - ChatUtil.print("What would you like to see?"); - ChatUtil.print("- guide (<- start with this)"); - ChatUtil.print("- commands"); - ChatUtil.print("- modules"); - ChatUtil.print(""); - ChatUtil.print("The beginning of the next command has already been typed out for you!"); + IngameLogger.chatPrint("§c§lWelcome to the " + FeatureManager.Name + " help system!"); + IngameLogger.chatPrint("What would you like to see?"); + IngameLogger.chatPrint("- guide (<- start with this)"); + IngameLogger.chatPrint("- commands"); + IngameLogger.chatPrint("- modules"); + IngameLogger.chatPrint(""); + IngameLogger.chatPrint("The beginning of the next command has already been typed out for you!"); type = (Client.prefix + this + " "); return; } if(args[0].equalsIgnoreCase("guide")) { - ChatUtil.print("§c§lGuide to the " + Setup.Name + " configuration system"); - ChatUtil.print("This client's config is fully linked, meaning everything is kept track of automatically. " + + IngameLogger.chatPrint("§c§lGuide to the " + FeatureManager.Name + " configuration system"); + IngameLogger.chatPrint("This client's config is fully linked, meaning everything is kept track of automatically. " + "When you change something with the set command, it automatically changes in the GUI as well."); - ChatUtil.print("Everything you can do in the GUI can be done with a command. The help system can give you an " + + IngameLogger.chatPrint("Everything you can do in the GUI can be done with a command. The help system can give you an " + "overview on what you can change. Just ask it for the §lmodules§r, for example."); - ChatUtil.print("To navigate " + Setup.Name + " by commands, you will also need the following:" + - "- " + Client.prefix + BaseBand.getFeature(Set.class) + ": this allows you to set any setting as if you were in the GUI\n" + - "- " + Client.prefix + BaseBand.getFeature(Bind.class) + ": this allows you to bind keys (they otherwise appear as numbers)\n" + - "- " + Client.prefix + BaseBand.getFeature(Trigger.class) + ": this allows you to trigger things (like a button)"); + IngameLogger.chatPrint("To navigate " + FeatureManager.Name + " by commands, you will also need the following:" + + "- " + Client.prefix + FeatureManager.getFeature(Set.class) + ": this allows you to set any setting as if you were in the GUI\n" + + "- " + Client.prefix + FeatureManager.getFeature(Bind.class) + ": this allows you to bind keys (they otherwise appear as numbers)\n" + + "- " + Client.prefix + FeatureManager.getFeature(Trigger.class) + ": this allows you to trigger things (like a button)"); type = (Client.prefix + this + " modules"); return; } if(args[0].equalsIgnoreCase("commands")) { - ChatUtil.print("§c§l" + Setup.Name + " help system: Commands"); - ChatUtil.print("§7Below you find a list of commands in the client:"); - for (Feature feature : BaseBand.features) { + IngameLogger.chatPrint("§c§l" + FeatureManager.Name + " help system: Commands"); + IngameLogger.chatPrint("§7Below you find a list of commands in the client:"); + for (Feature feature : com.baseband.client.feature.FeatureManager.features) { if(feature.category != Category.COMMAND) continue; TextComponentString comp = new TextComponentString(" " + feature.text); Style style = new Style(); style.setClickEvent(new net.minecraft.util.text.event.ClickEvent(net.minecraft.util.text.event.ClickEvent.Action.SUGGEST_COMMAND, Client.prefix + this + " feature " + feature)); comp.setStyle(style); - ChatUtil.print(comp); + IngameLogger.chatPrint(comp); } return; } if(args[0].equalsIgnoreCase("modules")) { - ChatUtil.print("§c§l" + Setup.Name + " help system: Modules"); - ChatUtil.print("§7Below you find a list of modules in the client:"); + IngameLogger.chatPrint("§c§l" + FeatureManager.Name + " help system: Modules"); + IngameLogger.chatPrint("§7Below you find a list of modules in the client:"); for (Category category : Category.values()) { if(category == Category.COMMAND) continue; - ChatUtil.print(" §lCategory " + category); - for (Feature feature : BaseBand.features) { + IngameLogger.chatPrint(" §lCategory " + category); + for (Feature feature : com.baseband.client.feature.FeatureManager.features) { if(feature.category != category) continue; TextComponentString comp = new TextComponentString(" " + feature.text); Style style = new Style(); style.setClickEvent(new net.minecraft.util.text.event.ClickEvent(net.minecraft.util.text.event.ClickEvent.Action.SUGGEST_COMMAND, Client.prefix + this + " feature " + feature)); comp.setStyle(style); - ChatUtil.print(comp); + IngameLogger.chatPrint(comp); } } return; } if(args[0].equalsIgnoreCase("feature")) { if(args.length != 2) { - ChatUtil.print("Invalid syntax."); + IngameLogger.chatPrint("Invalid syntax."); return; } - ChatUtil.print("§c§l" + Setup.Name + " help system: Feature " + args[1]); - for (Feature feature : BaseBand.features) { + IngameLogger.chatPrint("§c§l" + FeatureManager.Name + " help system: Feature " + args[1]); + for (Feature feature : com.baseband.client.feature.FeatureManager.features) { if(feature.toString().replace(' ', '_').equalsIgnoreCase(args[1])) { - ChatUtil.print(feature.hover); - ChatUtil.print("The feature is " + (feature.enabled ? "§aenabled" : "§cdisabled") + "."); - ChatUtil.print("It has " + feature.handle.getContent().map.size() + " config entries:"); + IngameLogger.chatPrint(feature.hover); + IngameLogger.chatPrint("The feature is " + (feature.enabled ? "§aenabled" : "§cdisabled") + "."); + IngameLogger.chatPrint("It has " + feature.handle.getContent().map.size() + " config entries:"); for (TLMap.Entry entry : feature.handle.getContent().map.entries()) { TextComponentString comp = new TextComponentString(" " + entry.key + " = " + entry.val); Style style = new Style(); - style.setClickEvent(new net.minecraft.util.text.event.ClickEvent(net.minecraft.util.text.event.ClickEvent.Action.SUGGEST_COMMAND, Client.prefix + BaseBand.getFeature(Set.class) + " " + feature.toString().replace(' ', '_') + " " + entry.key.replace(' ', '_') + " ")); + style.setClickEvent(new net.minecraft.util.text.event.ClickEvent(net.minecraft.util.text.event.ClickEvent.Action.SUGGEST_COMMAND, Client.prefix + FeatureManager.getFeature(Set.class) + " " + feature.toString().replace(' ', '_') + " " + entry.key.replace(' ', '_') + " ")); comp.setStyle(style); - ChatUtil.print(comp); + IngameLogger.chatPrint(comp); } return; } } - ChatUtil.print("This feature does not exist."); + IngameLogger.chatPrint("This feature does not exist."); return; } - ChatUtil.print("This action does not exist!"); + IngameLogger.chatPrint("This action does not exist!"); } @Override diff --git a/Client/src/main/java/com/baseband/client/feature/command/Set.java b/Client/src/main/java/com/baseband/client/feature/command/Set.java index 5b1ca0a..080dce8 100644 --- a/Client/src/main/java/com/baseband/client/feature/command/Set.java +++ b/Client/src/main/java/com/baseband/client/feature/command/Set.java @@ -5,12 +5,12 @@ import com.baseband.client.feature.category.Command; import com.baseband.client.feature.client.Client; import com.baseband.client.registry.ConfigHandle; import com.baseband.client.registry.SetCommand; -import com.baseband.client.util.interact.ChatUtil; -import com.baseband.client.util.misc.GlobalUtil; +import com.baseband.client.util.interact.IngameLogger; +import com.baseband.client.util.misc.ImplUtil; import java.util.HashMap; -import static com.baseband.client.BaseBand.features; +import static com.baseband.client.feature.FeatureManager.features; @Command public class Set extends Feature { @@ -18,20 +18,20 @@ public class Set extends Feature { private static final HashMap quickSet = new HashMap<>(); public static int addQuickSet(ConfigHandle handle) { - int n = GlobalUtil.RANDOM.nextInt(Integer.MAX_VALUE); - while(quickSet.containsKey(n)) n = GlobalUtil.RANDOM.nextInt(Integer.MAX_VALUE); + int n = ImplUtil.RANDOM.nextInt(Integer.MAX_VALUE); + while(quickSet.containsKey(n)) n = ImplUtil.RANDOM.nextInt(Integer.MAX_VALUE); quickSet.put(n, handle); return n; } public static void openQuickSet(int id, String field, boolean showCurrent) { - ChatUtil.openChat(Client.prefix + "set " + id + " " + field.replace(' ', '_') + " " + (showCurrent ? quickSet.get(id).getContent().getString(field) : "")); + IngameLogger.openChat(Client.prefix + "set " + id + " " + field.replace(' ', '_') + " " + (showCurrent ? quickSet.get(id).getContent().getString(field) : "")); } @Override public void onCommand(String[] args) { if(args.length < 3) { - ChatUtil.print("syntax: " + Client.prefix + this + " "); + IngameLogger.chatPrint("syntax: " + Client.prefix + this + " "); return; } String module = args[0]; @@ -57,16 +57,16 @@ public class Set extends Feature { if(f == null) { if(isQS) - ChatUtil.print("QuickSet " + module + " does not exist. This might be a bug."); + IngameLogger.chatPrint("QuickSet " + module + " does not exist. This might be a bug."); else - ChatUtil.print("Feature " + module + " is not present in this client."); + IngameLogger.chatPrint("Feature " + module + " is not present in this client."); return; } if(f.setWithString(setting.replace('_', ' '), value)) { - ChatUtil.print(module + ":" + setting + " has been set: " + value); + IngameLogger.chatPrint(module + ":" + setting + " has been set: " + value); } else { - ChatUtil.print("This value is invalid for setting " + module + ":" + setting + " (or it doesn't exist)."); + IngameLogger.chatPrint("This value is invalid for setting " + module + ":" + setting + " (or it doesn't exist)."); } } diff --git a/Client/src/main/java/com/baseband/client/feature/command/Trigger.java b/Client/src/main/java/com/baseband/client/feature/command/Trigger.java index ae8d8ce..61fa798 100644 --- a/Client/src/main/java/com/baseband/client/feature/command/Trigger.java +++ b/Client/src/main/java/com/baseband/client/feature/command/Trigger.java @@ -5,9 +5,9 @@ import com.baseband.client.feature.category.Command; import com.baseband.client.feature.client.Client; import com.baseband.client.gui.lib.component.Component; import com.baseband.client.registry.annotation.Description; -import com.baseband.client.util.interact.ChatUtil; +import com.baseband.client.util.interact.IngameLogger; -import static com.baseband.client.BaseBand.features; +import static com.baseband.client.feature.FeatureManager.features; @Command @Description("Triggers some trigger on some module. This is equivalent to pressing the corresponding button in the GUI. Spaces can be replaced with underscores.") @@ -15,7 +15,7 @@ public class Trigger extends Feature { @Override public void onCommand(String[] args) { if(args.length != 2) { - ChatUtil.print("syntax: " + Client.prefix + this + " "); + IngameLogger.chatPrint("syntax: " + Client.prefix + this + " "); return; } String module = args[0]; @@ -31,7 +31,7 @@ public class Trigger extends Feature { } if(f == null) { - ChatUtil.print("Feature " + module + " is not present in this client."); + IngameLogger.chatPrint("Feature " + module + " is not present in this client."); return; } @@ -41,7 +41,7 @@ public class Trigger extends Feature { return; } } - ChatUtil.print("Trigger " + trigger + " is not present in module " + module + "."); + IngameLogger.chatPrint("Trigger " + trigger + " is not present in module " + module + "."); } @Override diff --git a/Client/src/main/java/com/baseband/client/feature/movement/ElytraBot.java b/Client/src/main/java/com/baseband/client/feature/movement/ElytraBot.java index 0d292cd..9a82939 100644 --- a/Client/src/main/java/com/baseband/client/feature/movement/ElytraBot.java +++ b/Client/src/main/java/com/baseband/client/feature/movement/ElytraBot.java @@ -1,6 +1,5 @@ package com.baseband.client.feature.movement; -import com.baseband.client.BaseBand; import com.baseband.client.feature.Feature; import com.baseband.client.feature.category.Movement; import com.baseband.client.feature.client.Client; @@ -9,6 +8,7 @@ import com.baseband.client.registry.annotation.Description; import com.baseband.client.registry.annotation.Gate; import com.baseband.client.registry.annotation.Range; import com.baseband.client.util.adapt.Marker; +import com.baseband.client.util.interact.IngameLogger; import net.minecraft.entity.player.EntityPlayer; @Movement @@ -49,27 +49,27 @@ public class ElytraBot extends Feature { @Override public void onEnable() { - if(!BaseBand.isFeatureEnabled(ElytraFly.class)) { - BaseBand.notify("§cElytraBot cannot work without ElytraFly."); + if(!FeatureManager.isFeatureEnabled(ElytraFly.class)) { + IngameLogger.notify("§cElytraBot cannot work without ElytraFly."); toggle(); return; } - BaseBand.getFeature(ElytraFly.class).blockMovement = true; + FeatureManager.getFeature(ElytraFly.class).blockMovement = true; } @Override public void onDisable() { - if(!BaseBand.isFeaturePresent(ElytraFly.class)) { + if(!FeatureManager.isFeaturePresent(ElytraFly.class)) { return; } - BaseBand.getFeature(ElytraFly.class).blockMovement = false; + FeatureManager.getFeature(ElytraFly.class).blockMovement = false; } @Override public void onTick() { - ElytraFly efly = BaseBand.getFeature(ElytraFly.class); + ElytraFly efly = FeatureManager.getFeature(ElytraFly.class); if(!efly.enabled) { - BaseBand.notify("§cElytraBot cannot work without ElytraFly."); + IngameLogger.notify("§cElytraBot cannot work without ElytraFly."); toggle(); return; } @@ -94,7 +94,7 @@ public class ElytraBot extends Feature { break a; } } catch (Exception ignored) {} - BaseBand.notify("§cInvalid ElytraBot target."); + IngameLogger.notify("§cInvalid ElytraBot target."); toggle(); return; } else { @@ -107,7 +107,7 @@ public class ElytraBot extends Feature { break a; } } - BaseBand.notify("§cElytraBot couldn't find your target player."); + IngameLogger.notify("§cElytraBot couldn't find your target player."); toggle(); return; } diff --git a/Client/src/main/java/com/baseband/client/feature/movement/Speed.java b/Client/src/main/java/com/baseband/client/feature/movement/Speed.java index 67a9af0..133c54b 100644 --- a/Client/src/main/java/com/baseband/client/feature/movement/Speed.java +++ b/Client/src/main/java/com/baseband/client/feature/movement/Speed.java @@ -1,6 +1,5 @@ package com.baseband.client.feature.movement; -import com.baseband.client.BaseBand; import com.baseband.client.event.Priority; import com.baseband.client.event.events.MoveEvent; import com.baseband.client.event.events.PacketEvent; @@ -60,12 +59,12 @@ public class Speed extends Feature { text = toString(); } - if(enabled && BaseBand.getFeature(Timer.class).enabled) { - BaseBand.getFeature(Timer.class).timerLock = true; - BaseBand.getFeature(Timer.class).multiplierLock = 20f * 1.088f; - } else if (!enabled && BaseBand.getFeature(Timer.class).enabled){ - BaseBand.getFeature(Timer.class).timerLock = false; - BaseBand.getFeature(Timer.class).multiplierLock = 20f; + if(enabled && FeatureManager.getFeature(Timer.class).enabled) { + FeatureManager.getFeature(Timer.class).timerLock = true; + FeatureManager.getFeature(Timer.class).multiplierLock = 20f * 1.088f; + } else if (!enabled && FeatureManager.getFeature(Timer.class).enabled){ + FeatureManager.getFeature(Timer.class).timerLock = false; + FeatureManager.getFeature(Timer.class).multiplierLock = 20f; } } diff --git a/Client/src/main/java/com/baseband/client/feature/render/ClickGUI.java b/Client/src/main/java/com/baseband/client/feature/render/ClickGUI.java index 37a230d..d6f333b 100644 --- a/Client/src/main/java/com/baseband/client/feature/render/ClickGUI.java +++ b/Client/src/main/java/com/baseband/client/feature/render/ClickGUI.java @@ -7,7 +7,7 @@ import com.baseband.client.registry.annotation.Config; import com.baseband.client.registry.annotation.Description; import com.baseband.client.registry.annotation.Gate; -import static com.baseband.client.BaseBand.features; +import static com.baseband.client.feature.FeatureManager.features; @Render public class ClickGUI extends Feature { diff --git a/Client/src/main/java/com/baseband/client/feature/render/HUD.java b/Client/src/main/java/com/baseband/client/feature/render/HUD.java index 5b75730..57d1d0c 100644 --- a/Client/src/main/java/com/baseband/client/feature/render/HUD.java +++ b/Client/src/main/java/com/baseband/client/feature/render/HUD.java @@ -9,7 +9,7 @@ import com.baseband.client.gui.GuiTheme; import com.baseband.client.registry.annotation.*; import com.baseband.client.util.adapt.Marker; import com.baseband.client.util.interact.ServerDataManager; -import com.baseband.client.util.misc.GlobalUtil; +import com.baseband.client.util.misc.ImplUtil; import com.baseband.client.util.render.Pixels; import com.baseband.client.util.render.TextSplitter; import net.minecraft.client.Minecraft; @@ -22,7 +22,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import java.util.*; -import static com.baseband.client.BaseBand.features; +import static com.baseband.client.feature.FeatureManager.features; import static com.baseband.client.util.render.TextSplitter.*; @Render @@ -67,7 +67,7 @@ public class HUD extends Feature { } public static void notify(String text, int time) { - GlobalUtil.LOGGER.info(text); + ImplUtil.LOGGER.info(text); notifs.add(new Notification(text, time)); } @@ -164,7 +164,7 @@ public class HUD extends Feature { public void text(RenderGameOverlayEvent.Text e) { ScaledResolution sr = new ScaledResolution(mc); TextSplitter.init(mc.fontRenderer); - GuiTheme.ITheme theme = BaseBand.getFeature(Client.class).getTheme(); + GuiTheme.ITheme theme = FeatureManager.getFeature(Client.class).getTheme(); String infoString = ""; if(showInfo) { @@ -283,8 +283,8 @@ public class HUD extends Feature { @Override protected void setup() { - if(BaseBand.isFeaturePresent(ShowTPS.class)) { - subComponents.add(BaseBand.getFeature(ShowTPS.class)); + if(FeatureManager.isFeaturePresent(ShowTPS.class)) { + subComponents.add(FeatureManager.getFeature(ShowTPS.class)); } } diff --git a/Client/src/main/java/com/baseband/client/feature/world/AutoRespawn.java b/Client/src/main/java/com/baseband/client/feature/world/AutoRespawn.java index 5ea5321..5b799ca 100644 --- a/Client/src/main/java/com/baseband/client/feature/world/AutoRespawn.java +++ b/Client/src/main/java/com/baseband/client/feature/world/AutoRespawn.java @@ -1,8 +1,8 @@ package com.baseband.client.feature.world; -import com.baseband.client.BaseBand; import com.baseband.client.feature.Feature; import com.baseband.client.feature.category.World; +import com.baseband.client.util.interact.IngameLogger; import de.tudbut.tools.Lock; import net.minecraft.client.gui.GuiGameOver; @@ -19,7 +19,7 @@ public class AutoRespawn extends Feature { if (mc.currentScreen instanceof GuiGameOver && !lock.isLocked()) { mc.player.respawnPlayer(); mc.displayGuiScreen(null); - BaseBand.notify("[AutoRespawn] Respawned."); + IngameLogger.notify("[AutoRespawn] Respawned."); lock.lock(500); } } diff --git a/Client/src/main/java/com/baseband/client/feature/world/SeedOverlay.java b/Client/src/main/java/com/baseband/client/feature/world/SeedOverlay.java index fcd2239..d126d1b 100644 --- a/Client/src/main/java/com/baseband/client/feature/world/SeedOverlay.java +++ b/Client/src/main/java/com/baseband/client/feature/world/SeedOverlay.java @@ -1,13 +1,13 @@ package com.baseband.client.feature.world; -import com.baseband.client.BaseBand; import com.baseband.client.feature.Feature; import com.baseband.client.feature.category.World; import com.baseband.client.feature.render.ClickGUI; import com.baseband.client.registry.annotation.*; import com.baseband.client.util.adapt.Marker; import com.baseband.client.util.adapt.SimpleWorldGenerator; -import com.baseband.client.util.misc.GlobalUtil; +import com.baseband.client.util.interact.IngameLogger; +import com.baseband.client.util.misc.ImplUtil; import com.baseband.client.util.render.Pixels; import de.tudbut.tools.Lock; import net.minecraft.block.Block; @@ -102,32 +102,32 @@ public class SeedOverlay extends Feature { running = true; canSetRD = false; new Thread(() -> { - BaseBand.ifFeaturePresent(ClickGUI.class, gui -> gui.setEnabled(false)); + FeatureManager.ifFeaturePresent(ClickGUI.class, gui -> gui.setEnabled(false)); long seed; try { seed = Long.parseLong(this.seed); } catch (NumberFormatException e) { seed = this.seed.hashCode(); } - BaseBand.notify("Creating world with seed " + seed + "..."); + IngameLogger.notify("Creating world with seed " + seed + "..."); int rd = this.rd * 2 + 1; genOverworld = SimpleWorldGenerator.overworld(mc.world.getWorldInfo(), seed, rd); genNether = SimpleWorldGenerator.nether(mc.world.getWorldInfo(), seed, rd); genEnd = SimpleWorldGenerator.end(mc.world.getWorldInfo(), seed, rd); int length = rd * 16 * 256 * rd * 16; - BaseBand.notify("World generators acquired. Allocating render buffer with " + (length * 4 / 1024) + "KB space."); + IngameLogger.notify("World generators acquired. Allocating render buffer with " + (length * 4 / 1024) + "KB space."); bufferPosition = new BlockPos((mc.player.chunkCoordX - this.rd) * 16, 0, (mc.player.chunkCoordZ - this.rd) * 16); frontBuffer = new int[rd * 16][256][rd * 16]; backBuffer = new int[rd * 16][256][rd * 16]; - GlobalUtil.LOGGER.info("Allocated."); + ImplUtil.LOGGER.info("Allocated."); for (int x = 0; x < rd * 16; x++) { for (int z = 0; z < rd * 16; z++) { frontBuffer[x][0][z] = 0x800000ff; backBuffer[x][0][z] = 0x800000ff; } } - GlobalUtil.LOGGER.info("Filled buffer with unloaded state."); - BaseBand.notify("Render buffer created. Starting..."); + ImplUtil.LOGGER.info("Filled buffer with unloaded state."); + IngameLogger.notify("Render buffer created. Starting..."); setEnabled(true); }, this + " init").start(); } @@ -149,7 +149,7 @@ public class SeedOverlay extends Feature { // these should already be stopped! if(updater.isAlive() || generator.isAlive()) { - GlobalUtil.LOGGER.warn(this + " threads were still running when stopping the world. This should not happen! Stopping them forcefully."); + ImplUtil.LOGGER.warn(this + " threads were still running when stopping the world. This should not happen! Stopping them forcefully."); //noinspection deprecation updater.stop(); //noinspection deprecation @@ -167,7 +167,7 @@ public class SeedOverlay extends Feature { backBuffer = null; canSetRD = true; - GlobalUtil.LOGGER.info("SeedOverlay completely disabled."); + ImplUtil.LOGGER.info("SeedOverlay completely disabled."); }, this + " stopper").start(); } @@ -176,7 +176,7 @@ public class SeedOverlay extends Feature { @Override public void onEnable() { if(frontBuffer == null) { - BaseBand.notify("Please input a |Seed| and trigger |Generate now|"); + IngameLogger.notify("Please input a |Seed| and trigger |Generate now|"); toggle(); return; } diff --git a/Client/src/main/java/com/baseband/client/feature/world/Select.java b/Client/src/main/java/com/baseband/client/feature/world/Select.java index 10bc569..7bd4770 100644 --- a/Client/src/main/java/com/baseband/client/feature/world/Select.java +++ b/Client/src/main/java/com/baseband/client/feature/world/Select.java @@ -5,6 +5,7 @@ import com.baseband.client.event.Priority; import com.baseband.client.event.events.SelectEvent; import com.baseband.client.feature.Feature; import com.baseband.client.feature.category.World; +import com.baseband.client.util.interact.IngameLogger; import com.baseband.client.util.type.Selection; import net.minecraft.util.math.BlockPos; @@ -18,13 +19,13 @@ public class Select extends Feature { if(end != null || begin == null) { begin = b; end = null; - BaseBand.notify("Selection reset."); - BaseBand.notify("Position 1: " + b.getX() + " " + b.getY() + " " + b.getZ()); + IngameLogger.notify("Selection reset."); + IngameLogger.notify("Position 1: " + b.getX() + " " + b.getY() + " " + b.getZ()); BaseBand.publish(new SelectEvent(null)); return; } end = b; - BaseBand.notify("Position 2: " + b.getX() + " " + b.getY() + " " + b.getZ()); + IngameLogger.notify("Position 2: " + b.getX() + " " + b.getY() + " " + b.getZ()); BaseBand.publish(new SelectEvent(new Selection(begin, end))); } diff --git a/Client/src/main/java/com/baseband/client/gui/GuiRewrite.java b/Client/src/main/java/com/baseband/client/gui/GuiRewrite.java index c82844a..1b197af 100644 --- a/Client/src/main/java/com/baseband/client/gui/GuiRewrite.java +++ b/Client/src/main/java/com/baseband/client/gui/GuiRewrite.java @@ -1,6 +1,7 @@ package com.baseband.client.gui; import com.baseband.client.BaseBand; +import com.baseband.client.feature.FeatureManager; import com.baseband.client.feature.Feature; import com.baseband.client.feature.render.ClickGUI; import com.baseband.client.gui.lib.GUIManager; @@ -16,7 +17,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; -import static com.baseband.client.BaseBand.features; +import static com.baseband.client.feature.FeatureManager.features; public class GuiRewrite extends GuiScreen { @@ -86,7 +87,7 @@ public class GuiRewrite extends GuiScreen { @Override public void onGuiClosed() { super.onGuiClosed(); - BaseBand.getFeature(ClickGUI.class).setEnabled(false); + FeatureManager.getFeature(ClickGUI.class).setEnabled(false); for (Category category : categories) { com.baseband.client.feature.Category c = com.baseband.client.feature.Category.fromName(category.text); assert c != null; @@ -174,7 +175,7 @@ public class GuiRewrite extends GuiScreen { } // TMP fix for a strange bug that causes the mouse to be hidden - if (BaseBand.getFeature(ClickGUI.class).mouseFix) { + if (FeatureManager.getFeature(ClickGUI.class).mouseFix) { drawRect(mouseX - 2, mouseY - 2, mouseX + 2, mouseY + 2, 0xffffffff); } int m = Mouse.getDWheel(); 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 index ac7e3b7..48817f4 100644 --- a/Client/src/main/java/com/baseband/client/gui/lib/GUIManager.java +++ b/Client/src/main/java/com/baseband/client/gui/lib/GUIManager.java @@ -1,6 +1,6 @@ package com.baseband.client.gui.lib; -import com.baseband.client.BaseBand; +import com.baseband.client.feature.FeatureManager; import com.baseband.client.feature.client.Client; import com.baseband.client.gui.GuiTheme; import com.baseband.client.gui.lib.component.Component; @@ -66,7 +66,7 @@ public class GUIManager { } public static void update() { - GuiTheme.ITheme theme = BaseBand.getFeature(Client.class).getTheme(); + GuiTheme.ITheme theme = FeatureManager.getFeature(Client.class).getTheme(); fontColorOn = theme.getGreenColor(); fontColorOff = theme.getRedColor(); frameColor = theme.getFrameColor(); 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 index 02f7b27..4265175 100644 --- 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 @@ -3,7 +3,7 @@ package com.baseband.client.gui.lib.component; import com.baseband.client.feature.command.Set; import com.baseband.client.gui.lib.GUIManager; import com.baseband.client.registry.ConfigHandle; -import com.baseband.client.util.misc.GlobalUtil; +import com.baseband.client.util.misc.ImplUtil; import net.minecraft.client.gui.Gui; import org.lwjgl.input.Keyboard; @@ -79,7 +79,7 @@ public class IntSlider extends Component { try { f = (handle.getContent().getInteger(field) - adder) / (float) mapper; } catch (NullPointerException e) { - GlobalUtil.LOGGER.debug(e.getStackTrace()); + ImplUtil.LOGGER.debug(e.getStackTrace()); } if(countdown > 0) { --countdown; 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 index 632b974..68c4004 100644 --- 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 @@ -3,7 +3,7 @@ package com.baseband.client.gui.lib.component; import com.baseband.client.feature.command.Set; import com.baseband.client.gui.lib.GUIManager; import com.baseband.client.registry.ConfigHandle; -import com.baseband.client.util.misc.GlobalUtil; +import com.baseband.client.util.misc.ImplUtil; import net.minecraft.client.gui.Gui; import org.lwjgl.input.Keyboard; @@ -77,7 +77,7 @@ public class Slider extends Component { try { f = (handle.getContent().getFloat(field) - adder) / mapper; } catch (NullPointerException e) { - GlobalUtil.LOGGER.debug(e.getStackTrace()); + ImplUtil.LOGGER.debug(e.getStackTrace()); } if(countdown > 0) { --countdown; 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 index f2673eb..068e4a5 100644 --- 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 @@ -2,7 +2,7 @@ package com.baseband.client.gui.lib.component; import com.baseband.client.feature.command.Set; import com.baseband.client.registry.ConfigHandle; -import com.baseband.client.util.misc.GlobalUtil; +import com.baseband.client.util.misc.ImplUtil; public class ToggleButton extends Component { @@ -32,7 +32,7 @@ public class ToggleButton extends Component { try { green = handle.getContent().getBoolean(field); } catch (NullPointerException e) { - GlobalUtil.LOGGER.debug(e.getStackTrace()); + ImplUtil.LOGGER.debug(e.getStackTrace()); } } diff --git a/Client/src/main/java/com/baseband/client/mixins/MixinEntityRender.java b/Client/src/main/java/com/baseband/client/mixins/MixinEntityRender.java index 815836b..7144bae 100644 --- a/Client/src/main/java/com/baseband/client/mixins/MixinEntityRender.java +++ b/Client/src/main/java/com/baseband/client/mixins/MixinEntityRender.java @@ -1,6 +1,6 @@ package com.baseband.client.mixins; -import com.baseband.client.BaseBand; +import com.baseband.client.feature.FeatureManager; import com.baseband.client.feature.render.NoRender; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.renderer.EntityRenderer; @@ -17,7 +17,7 @@ public class MixinEntityRender { @Redirect(method = "orientCamera", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/WorldClient;rayTraceBlocks(Lnet/minecraft/util/math/Vec3d;Lnet/minecraft/util/math/Vec3d;)Lnet/minecraft/util/math/RayTraceResult;")) public RayTraceResult rayTraceBlocks(WorldClient world, Vec3d start, Vec3d end) { - if (BaseBand.isFeatureEnabled(NoRender.class) && BaseBand.getFeature(NoRender.class).cameraClip) + if (FeatureManager.isFeatureEnabled(NoRender.class) && FeatureManager.getFeature(NoRender.class).cameraClip) return null; else return world.rayTraceBlocks(start, end); @@ -26,6 +26,6 @@ public class MixinEntityRender { @Inject(method = "hurtCameraEffect", at = @At("HEAD"), cancellable = true) public void hurtCameraEffect(float ticks, CallbackInfo info) { - if (BaseBand.isFeatureEnabled(NoRender.class) && BaseBand.getFeature(NoRender.class).hurtcam) info.cancel(); + if (FeatureManager.isFeatureEnabled(NoRender.class) && FeatureManager.getFeature(NoRender.class).hurtcam) info.cancel(); } } diff --git a/Client/src/main/java/com/baseband/client/mixins/MixinGuiEditSign.java b/Client/src/main/java/com/baseband/client/mixins/MixinGuiEditSign.java index c3a60be..d94367f 100644 --- a/Client/src/main/java/com/baseband/client/mixins/MixinGuiEditSign.java +++ b/Client/src/main/java/com/baseband/client/mixins/MixinGuiEditSign.java @@ -1,6 +1,6 @@ package com.baseband.client.mixins; -import com.baseband.client.BaseBand; +import com.baseband.client.feature.FeatureManager; import com.baseband.client.feature.world.AutoSignText; import net.minecraft.client.gui.inventory.GuiEditSign; import net.minecraft.tileentity.TileEntitySign; @@ -21,8 +21,8 @@ public class MixinGuiEditSign { @Inject(method = "initGui", at = @At("RETURN")) public void initGui(CallbackInfo callback) { - if(BaseBand.isFeatureEnabled(AutoSignText.class)) { - AutoSignText autoSignText = BaseBand.getFeature(AutoSignText.class); + if(FeatureManager.isFeatureEnabled(AutoSignText.class)) { + AutoSignText autoSignText = FeatureManager.getFeature(AutoSignText.class); tileSign.signText[0] = new TextComponentString(autoSignText.signTextFirst); tileSign.signText[1] = new TextComponentString(autoSignText.signTextSecond); tileSign.signText[2] = new TextComponentString(autoSignText.signTextThird); diff --git a/Client/src/main/java/com/baseband/client/mixins/MixinGuiNewChat.java b/Client/src/main/java/com/baseband/client/mixins/MixinGuiNewChat.java index 7c86fd5..379e2a3 100644 --- a/Client/src/main/java/com/baseband/client/mixins/MixinGuiNewChat.java +++ b/Client/src/main/java/com/baseband/client/mixins/MixinGuiNewChat.java @@ -1,6 +1,6 @@ package com.baseband.client.mixins; -import com.baseband.client.BaseBand; +import com.baseband.client.feature.FeatureManager; import com.baseband.client.feature.chat.ChatExtras; import net.minecraft.client.gui.ChatLine; import net.minecraft.client.gui.Gui; @@ -15,30 +15,30 @@ import java.util.List; public class MixinGuiNewChat extends Gui { @Redirect(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiNewChat;drawRect(IIIII)V")) private void drawRectHook(int left, int top, int right, int bottom, int color) { - if(!BaseBand.isFeatureEnabled(ChatExtras.class)) { + if(!FeatureManager.isFeatureEnabled(ChatExtras.class)) { Gui.drawRect(left, top, right, bottom, color); return; } - ChatExtras chatExtras = BaseBand.getFeature(ChatExtras.class); + ChatExtras chatExtras = FeatureManager.getFeature(ChatExtras.class); Gui.drawRect(left, top, right, bottom, chatExtras.clearchat ? 0 : color); } @Redirect(method = "setChatLine", at = @At(value = "INVOKE", target = "Ljava/util/List;size()I", ordinal = 0, remap = false)) public int drawnChatLinesSize(List list) { - if(!BaseBand.isFeatureEnabled(ChatExtras.class)) + if(!FeatureManager.isFeatureEnabled(ChatExtras.class)) return list.size(); - ChatExtras chatExtras = BaseBand.getFeature(ChatExtras.class); + ChatExtras chatExtras = FeatureManager.getFeature(ChatExtras.class); return chatExtras.infinitechat ? -2147483647 : list.size(); } @Redirect(method = "setChatLine", at = @At(value = "INVOKE", target = "Ljava/util/List;size()I", ordinal = 2, remap = false)) public int chatLinesSize(List list) { - if(!BaseBand.isFeatureEnabled(ChatExtras.class)) + if(!FeatureManager.isFeatureEnabled(ChatExtras.class)) return list.size(); - ChatExtras chatExtras = BaseBand.getFeature(ChatExtras.class); + ChatExtras chatExtras = FeatureManager.getFeature(ChatExtras.class); return chatExtras.infinitechat ? -2147483647 : list.size(); } } diff --git a/Client/src/main/java/com/baseband/client/mixins/MixinScreenshotHelper.java b/Client/src/main/java/com/baseband/client/mixins/MixinScreenshotHelper.java index 4ab8981..8a42fb8 100644 --- a/Client/src/main/java/com/baseband/client/mixins/MixinScreenshotHelper.java +++ b/Client/src/main/java/com/baseband/client/mixins/MixinScreenshotHelper.java @@ -1,7 +1,7 @@ package com.baseband.client.mixins; -import com.baseband.client.BaseBand; +import com.baseband.client.feature.FeatureManager; import com.baseband.client.feature.client.Client; import com.baseband.client.util.net.ScreenshotHelper; import net.minecraft.client.shader.Framebuffer; @@ -17,10 +17,10 @@ import java.io.File; public class MixinScreenshotHelper { @Inject(method = {"saveScreenshot(Ljava/io/File;Ljava/lang/String;IILnet/minecraft/client/shader/Framebuffer;)Lnet/minecraft/util/text/ITextComponent;"}, at = {@At(value = "HEAD")}) private static void saveScreenshot(File file, String string, int n, int n2, Framebuffer framebuffer, CallbackInfoReturnable callbackInfoReturnable) { - if(!BaseBand.isFeatureEnabled(Client.class)) + if(!FeatureManager.isFeatureEnabled(Client.class)) return; - Client client = BaseBand.getFeature(Client.class); + Client client = FeatureManager.getFeature(Client.class); if (client.screenshotUpload) { ScreenshotHelper eventClientScreenShot = new ScreenshotHelper(ScreenShotHelper.createScreenshot(n, n2, framebuffer)); eventClientScreenShot.start(); diff --git a/Client/src/main/java/com/baseband/client/registry/ConfigHandle.java b/Client/src/main/java/com/baseband/client/registry/ConfigHandle.java index 06872f0..0146cab 100644 --- a/Client/src/main/java/com/baseband/client/registry/ConfigHandle.java +++ b/Client/src/main/java/com/baseband/client/registry/ConfigHandle.java @@ -1,6 +1,6 @@ package com.baseband.client.registry; -import com.baseband.client.util.misc.GlobalUtil; +import com.baseband.client.util.misc.ImplUtil; import de.tudbut.parsing.TCN; import java.lang.reflect.Field; @@ -65,7 +65,7 @@ public class ConfigHandle implements SetCommand { try { updated(setting); } catch(Exception e) { - GlobalUtil.LOGGER.info((Object) "Unable to setWithString", e); + ImplUtil.LOGGER.info((Object) "Unable to setWithString", e); // reset tcn.set(setting, original); updated(setting); diff --git a/Client/src/main/java/com/baseband/client/registry/Configuration.java b/Client/src/main/java/com/baseband/client/registry/Configuration.java index 96db327..1ce1728 100644 --- a/Client/src/main/java/com/baseband/client/registry/Configuration.java +++ b/Client/src/main/java/com/baseband/client/registry/Configuration.java @@ -1,13 +1,13 @@ package com.baseband.client.registry; -import com.baseband.client.Setup; +import com.baseband.client.feature.FeatureManager; import de.tudbut.tools.Registry; import java.io.IOException; public class Configuration { - public final Registry registry = new Registry(Setup.get().RegistryFilename); + public final Registry registry = new Registry(FeatureManager.get().RegistryFilename); private Configuration() throws IOException { } diff --git a/Client/src/main/java/com/baseband/client/util/adapt/SimpleWorldGenerator.java b/Client/src/main/java/com/baseband/client/util/adapt/SimpleWorldGenerator.java index d26c3c5..8dc186d 100644 --- a/Client/src/main/java/com/baseband/client/util/adapt/SimpleWorldGenerator.java +++ b/Client/src/main/java/com/baseband/client/util/adapt/SimpleWorldGenerator.java @@ -1,7 +1,7 @@ package com.baseband.client.util.adapt; import com.baseband.client.BaseBand; -import com.baseband.client.Setup; +import com.baseband.client.feature.FeatureManager; import net.minecraft.client.Minecraft; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; @@ -135,7 +135,7 @@ public class SimpleWorldGenerator implements IChunkProvider { @Override @Nonnull public String makeString() { - return Setup.get().Name + "." + this; + return FeatureManager.get().Name + "." + this; } @Override diff --git a/Client/src/main/java/com/baseband/client/util/adapt/WorldRecreationGenerator.java b/Client/src/main/java/com/baseband/client/util/adapt/WorldRecreationGenerator.java index bf37ae2..a19c353 100644 --- a/Client/src/main/java/com/baseband/client/util/adapt/WorldRecreationGenerator.java +++ b/Client/src/main/java/com/baseband/client/util/adapt/WorldRecreationGenerator.java @@ -1,7 +1,7 @@ package com.baseband.client.util.adapt; -import com.baseband.client.Setup; -import com.baseband.client.util.misc.GlobalUtil; +import com.baseband.client.feature.FeatureManager; +import com.baseband.client.util.misc.ImplUtil; import de.tudbut.tools.ReflectUtil; import net.minecraft.client.Minecraft; import net.minecraft.nbt.NBTTagCompound; @@ -138,7 +138,7 @@ public class WorldRecreationGenerator implements IChunkProvider { public synchronized boolean tick() { if(hasNewChunks) { - GlobalUtil.LOGGER.debug(this + ": Creating variations for {} MultiChunks.", realLoaded.size()); + ImplUtil.LOGGER.debug(this + ": Creating variations for {} MultiChunks.", realLoaded.size()); int variations = 0; for (Map.Entry entry : realLoaded.entrySet()) { entry.getValue().makeVariations(); @@ -146,12 +146,12 @@ public class WorldRecreationGenerator implements IChunkProvider { for (Map.Entry entry : realLoaded.entrySet()) { variations += entry.getValue().backVariations.size(); } - GlobalUtil.LOGGER.debug(this + ": Checking {} variations.", variations); + ImplUtil.LOGGER.debug(this + ": Checking {} variations.", variations); for (Map.Entry entry : realLoaded.entrySet()) { ChunkPos pos = entry.getKey(); entry.getValue().findPreferred(mc.world.getChunk(pos.x, pos.z)); } - GlobalUtil.LOGGER.debug(this + ": Done."); + ImplUtil.LOGGER.debug(this + ": Done."); hasNewChunks = false; } @@ -173,7 +173,7 @@ public class WorldRecreationGenerator implements IChunkProvider { } private void onUnload(ChunkPos pos, Chunk chunk) { - GlobalUtil.LOGGER.debug(this + " is unloading chunk at {} {}", pos.x, pos.z); + ImplUtil.LOGGER.debug(this + " is unloading chunk at {} {}", pos.x, pos.z); chunk.onUnload(); loaded.remove(pos); realLoaded.remove(pos); @@ -182,7 +182,7 @@ public class WorldRecreationGenerator implements IChunkProvider { @Override @Nonnull public String makeString() { - return Setup.get().Name + "." + this; + return FeatureManager.get().Name + "." + this; } @Override @@ -244,7 +244,7 @@ public class WorldRecreationGenerator implements IChunkProvider { public MultiChunk(Chunk initial, WorldRecreationGenerator generator) { pos = initial.getPos(); - GlobalUtil.LOGGER.debug(this + ": MultiChunk at {} {} created.", pos.x, pos.z); + ImplUtil.LOGGER.debug(this + ": MultiChunk at {} {} created.", pos.x, pos.z); this.generator = generator; map = new ChunkPos[] { new ChunkPos(pos.x + 0, pos.z - 1), @@ -397,7 +397,7 @@ public class WorldRecreationGenerator implements IChunkProvider { variations = backVariations; backVariations = new ArrayList<>(); } - GlobalUtil.LOGGER.debug(generator + ": preferred state of chunk {} {} is now {}", pos.x, pos.z, preferredState); + ImplUtil.LOGGER.debug(generator + ": preferred state of chunk {} {} is now {}", pos.x, pos.z, preferredState); } } diff --git a/Client/src/main/java/com/baseband/client/util/baritone/BaritoneManager.java b/Client/src/main/java/com/baseband/client/util/baritone/BaritoneManager.java index fd0e47b..fc3511f 100644 --- a/Client/src/main/java/com/baseband/client/util/baritone/BaritoneManager.java +++ b/Client/src/main/java/com/baseband/client/util/baritone/BaritoneManager.java @@ -8,9 +8,9 @@ import baritone.api.process.ICustomGoalProcess; import baritone.api.process.PathingCommand; import baritone.api.process.PathingCommandType; import com.baseband.client.BaseBand; -import com.baseband.client.Setup; +import com.baseband.client.feature.FeatureManager; import com.baseband.client.event.events.BaritoneEvent; -import com.baseband.client.util.interact.ChatUtil; +import com.baseband.client.util.interact.IngameLogger; import net.minecraft.util.math.Vec3d; public class BaritoneManager { @@ -18,7 +18,7 @@ public class BaritoneManager { static { //FUTURE! BaritoneAPI.getProvider().getPrimaryBaritone().getPathingControlManager().registerProcess(new PauseBaritoneProcess()); - BaritoneAPI.getSettings().logger.value = ChatUtil::print; + BaritoneAPI.getSettings().logger.value = IngameLogger::chatPrint; } public static IBaritone getBaritone() { @@ -81,7 +81,7 @@ public class BaritoneManager { @Override public String displayName0() { - return Setup.get().Name + " Pause"; + return FeatureManager.get().Name + " Pause"; } } } \ No newline at end of file diff --git a/Client/src/main/java/com/baseband/client/util/baritone/BaritonePresenceManager.java b/Client/src/main/java/com/baseband/client/util/baritone/BaritonePresenceManager.java index a31492f..f1e6f6a 100644 --- a/Client/src/main/java/com/baseband/client/util/baritone/BaritonePresenceManager.java +++ b/Client/src/main/java/com/baseband/client/util/baritone/BaritonePresenceManager.java @@ -1,6 +1,6 @@ package com.baseband.client.util.baritone; -import com.baseband.client.util.misc.GlobalUtil; +import com.baseband.client.util.misc.ImplUtil; public class BaritonePresenceManager { @@ -20,12 +20,12 @@ public class BaritonePresenceManager { } if (IS_BARITONE_PRESENT) { - GlobalUtil.LOGGER.info("Baritone is present!"); + ImplUtil.LOGGER.info("Baritone is present!"); try { BaritoneManager.getBaritone(); } catch (Throwable e) { - GlobalUtil.LOGGER.warn("Baritone is allegedly present but cannot seem to load!"); + ImplUtil.LOGGER.warn("Baritone is allegedly present but cannot seem to load!"); IS_BARITONE_PRESENT = false; } } diff --git a/Client/src/main/java/com/baseband/client/util/interact/FreecamPlayer.java b/Client/src/main/java/com/baseband/client/util/interact/FreecamPlayer.java index bfd70de..1286898 100644 --- a/Client/src/main/java/com/baseband/client/util/interact/FreecamPlayer.java +++ b/Client/src/main/java/com/baseband/client/util/interact/FreecamPlayer.java @@ -1,6 +1,6 @@ package com.baseband.client.util.interact; -import com.baseband.client.BaseBand; +import com.baseband.client.feature.FeatureManager; import com.baseband.client.feature.render.Freecam; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityOtherPlayerMP; @@ -49,7 +49,7 @@ public class FreecamPlayer extends EntityOtherPlayerMP public void onLivingUpdate() { if(mc.world == null) { - BaseBand.getFeature(Freecam.class).setEnabled(false); + FeatureManager.getFeature(Freecam.class).setEnabled(false); return; } mc.renderChunksMany = false; diff --git a/Client/src/main/java/com/baseband/client/util/interact/ChatUtil.java b/Client/src/main/java/com/baseband/client/util/interact/IngameLogger.java similarity index 63% rename from Client/src/main/java/com/baseband/client/util/interact/ChatUtil.java rename to Client/src/main/java/com/baseband/client/util/interact/IngameLogger.java index affbf56..540399c 100644 --- a/Client/src/main/java/com/baseband/client/util/interact/ChatUtil.java +++ b/Client/src/main/java/com/baseband/client/util/interact/IngameLogger.java @@ -1,6 +1,9 @@ package com.baseband.client.util.interact; -import com.baseband.client.Setup; +import com.baseband.client.feature.FeatureManager; +import com.baseband.client.feature.client.Client; +import com.baseband.client.feature.render.HUD; +import com.baseband.client.util.misc.ImplUtil; import com.mojang.realmsclient.gui.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiChat; @@ -11,18 +14,18 @@ import net.minecraft.util.text.TextFormatting; import java.util.Random; -public class ChatUtil { +public class IngameLogger { //forge sucks balls so hard omg - public static void print(String s) { + public static void chatPrint(String s) { if(Minecraft.getMinecraft().player != null) { - Minecraft.getMinecraft().player.sendMessage(new TextComponentString(ChatFormatting.LIGHT_PURPLE + Setup.get().Name.toLowerCase() + "~ " + ChatFormatting.RESET + s)); + Minecraft.getMinecraft().player.sendMessage(new TextComponentString(ChatFormatting.LIGHT_PURPLE + FeatureManager.get().Name.toLowerCase() + "~ " + ChatFormatting.RESET + s)); } } - public static void print(ITextComponent comp) { + public static void chatPrint(ITextComponent comp) { Minecraft mc = Minecraft.getMinecraft(); if (mc.ingameGUI != null) { - ITextComponent text = new TextComponentString(Setup.get().Name.toLowerCase() + "~ ").setStyle(new Style().setColor(TextFormatting.LIGHT_PURPLE)).appendSibling(comp); + ITextComponent text = new TextComponentString(FeatureManager.get().Name.toLowerCase() + "~ ").setStyle(new Style().setColor(TextFormatting.LIGHT_PURPLE)).appendSibling(comp); //noinspection DataFlowIssue comp.getStyle().setParentStyle(null); mc.ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(text, new Random().nextInt()); @@ -63,4 +66,22 @@ public class ChatUtil { Minecraft.getMinecraft().player.sendChatMessage(msg); } + public static void notify(String text) { + Client c = FeatureManager.getFeature(Client.class); + if(FeatureManager.isFeatureEnabled(HUD.class) && c.notificationDest != Client.NotificationDest.Chat) { + HUD.notifs.add(new HUD.Notification(text)); + if(c.notificationDest == Client.NotificationDest.Both) + chatPrint(text); + else + ImplUtil.LOGGER.info(text); + } else + chatPrint(text); + } + + public static void notifyAll(String text) { + if(FeatureManager.isFeatureEnabled(HUD.class)) { + HUD.notifs.add(new HUD.Notification(text)); + } + chatPrint(text); + } } diff --git a/Client/src/main/java/com/baseband/client/util/interact/ServerDataManager.java b/Client/src/main/java/com/baseband/client/util/interact/ServerDataManager.java index 07e7cce..6498d5f 100644 --- a/Client/src/main/java/com/baseband/client/util/interact/ServerDataManager.java +++ b/Client/src/main/java/com/baseband/client/util/interact/ServerDataManager.java @@ -1,7 +1,7 @@ package com.baseband.client.util.interact; import com.baseband.client.BaseBand; -import com.baseband.client.Setup; +import com.baseband.client.feature.FeatureManager; import com.baseband.client.util.adapt.ServerPing; import de.tudbut.tools.Lock; import net.minecraft.client.network.NetworkPlayerInfo; @@ -55,7 +55,7 @@ public class ServerDataManager { } if(pinger == null || !pinger.isAlive()) { - pinger = new Thread(ServerDataManager::getPing, Setup.get().Name + " server pinger"); + pinger = new Thread(ServerDataManager::getPing, FeatureManager.get().Name + " server pinger"); pinger.start(); } } diff --git a/Client/src/main/java/com/baseband/client/util/misc/GlobalUtil.java b/Client/src/main/java/com/baseband/client/util/misc/ImplUtil.java similarity index 96% rename from Client/src/main/java/com/baseband/client/util/misc/GlobalUtil.java rename to Client/src/main/java/com/baseband/client/util/misc/ImplUtil.java index 3c45dee..c16c73f 100644 --- a/Client/src/main/java/com/baseband/client/util/misc/GlobalUtil.java +++ b/Client/src/main/java/com/baseband/client/util/misc/ImplUtil.java @@ -6,7 +6,7 @@ import org.apache.logging.log4j.Logger; import java.lang.reflect.Method; import java.security.SecureRandom; -public class GlobalUtil { +public class ImplUtil { public static final Logger LOGGER = LogManager.getLogger("BaseBand"); public static final SecureRandom RANDOM = new SecureRandom(); public static final Runnable SHUTDOWN = () -> { diff --git a/Client/src/main/java/com/baseband/client/util/net/ScreenshotHelper.java b/Client/src/main/java/com/baseband/client/util/net/ScreenshotHelper.java index dbcdb7d..024133b 100644 --- a/Client/src/main/java/com/baseband/client/util/net/ScreenshotHelper.java +++ b/Client/src/main/java/com/baseband/client/util/net/ScreenshotHelper.java @@ -1,6 +1,6 @@ package com.baseband.client.util.net; -import com.baseband.client.BaseBand; +import com.baseband.client.util.interact.IngameLogger; import com.google.gson.JsonElement; import com.google.gson.JsonParser; import net.minecraft.client.Minecraft; @@ -38,7 +38,7 @@ public class ScreenshotHelper extends Thread { private static void copyAndPrint(StringSelection stringSelection, String string) { Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(stringSelection, stringSelection); - BaseBand.notify("Image uploaded to: " + string); + IngameLogger.notify("Image uploaded to: " + string); } @Override diff --git a/Client/src/main/java/com/baseband/client/util/net/WebServiceClient.java b/Client/src/main/java/com/baseband/client/util/net/WebServiceClient.java index eaf495e..8e31ed6 100644 --- a/Client/src/main/java/com/baseband/client/util/net/WebServiceClient.java +++ b/Client/src/main/java/com/baseband/client/util/net/WebServiceClient.java @@ -1,6 +1,6 @@ package com.baseband.client.util.net; -import com.baseband.client.util.misc.GlobalUtil; +import com.baseband.client.util.misc.ImplUtil; import de.tudbut.net.ws.Client; import de.tudbut.net.ws.ConnectionHandler; @@ -15,8 +15,8 @@ public class WebServiceClient { client = new Client("azidoazideazi.de", 30000); //client.addReceiveHook(READER); } catch (IOException e) { - GlobalUtil.LOGGER.fatal(e); - GlobalUtil.SHUTDOWN.run(); + ImplUtil.LOGGER.fatal(e); + ImplUtil.SHUTDOWN.run(); } } diff --git a/Client/src/main/java/com/baseband/client/util/type/KeyManager.java b/Client/src/main/java/com/baseband/client/util/type/KeyManager.java new file mode 100644 index 0000000..ce5365c --- /dev/null +++ b/Client/src/main/java/com/baseband/client/util/type/KeyManager.java @@ -0,0 +1,17 @@ +package com.baseband.client.util.type; + +import java.util.ArrayList; + +public class KeyManager { + public static final ArrayList keyBinds = new ArrayList<>(); + + public static void registerKeyBind(KeyBind key) { + keyBinds.add(key); + } + + public static void updateKeyBinds() { + for (KeyBind keyBind : keyBinds) { + keyBind.onTick(); + } + } +}