diff --git a/Client/src/main/java/com/baseband/client/BaseBand.java b/Client/src/main/java/com/baseband/client/BaseBand.java index 2a43629..eb6f3c1 100644 --- a/Client/src/main/java/com/baseband/client/BaseBand.java +++ b/Client/src/main/java/com/baseband/client/BaseBand.java @@ -4,7 +4,7 @@ import com.baseband.client.configuration.Updater; import com.baseband.client.event.EventManager; import com.baseband.client.event.FMLEventHandler; import com.baseband.client.module.Feature; -import com.baseband.client.module.render.HUD; +import com.baseband.client.module.render.*; import com.baseband.client.util.config.KeyBind; import com.baseband.client.util.ingame.ChatUtil; import com.baseband.client.util.misc.GlobalUtil; @@ -28,6 +28,8 @@ public class BaseBand { public static boolean disabled = false; public static Minecraft mc; + public static Feature[] features = new Feature[0]; + public static void registerUpdater(Updater updater) { updaters.add(updater); updater.populate(); @@ -62,10 +64,19 @@ public class BaseBand { mc = Minecraft.getMinecraft(); Setup clientSetup = Setup.get(); - Feature[] features = clientSetup.Features; - for (Feature value : features) { - value.register(this, mc); + + 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) { GlobalUtil.LOGGER.info("populating updater {}", updater); @@ -84,7 +95,7 @@ public class BaseBand { } } - for (Feature feature : features) { + for (Feature feature : preFeatures) { feature.setEnabledSilent(false); } @@ -103,7 +114,6 @@ public class BaseBand { public static T getFeature(Class clazz) { if(finishedDisabling) return null; - Feature[] features = Setup.get().Features; for (Feature feature : features) { if (feature.getClass() == clazz) return (T) feature; diff --git a/Client/src/main/java/com/baseband/client/Setup.java b/Client/src/main/java/com/baseband/client/Setup.java index 05b586d..77fd06d 100644 --- a/Client/src/main/java/com/baseband/client/Setup.java +++ b/Client/src/main/java/com/baseband/client/Setup.java @@ -5,6 +5,7 @@ import com.baseband.client.module.chat.ChatAppend; import com.baseband.client.module.chat.ChatCrypt; import com.baseband.client.module.chat.ChatFilter; import com.baseband.client.module.chat.ExtraChat; +import com.baseband.client.module.client.Baritone; import com.baseband.client.module.client.Client; import com.baseband.client.module.client.MidClick; import com.baseband.client.module.client.Timer; @@ -57,6 +58,7 @@ public class Setup { new HUD.ShowTPS(), new ElytraBot(), new ChatFilter(), + new Baritone(), }; 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 f89ab1e..2a0320a 100644 --- a/Client/src/main/java/com/baseband/client/event/FMLEventHandler.java +++ b/Client/src/main/java/com/baseband/client/event/FMLEventHandler.java @@ -15,12 +15,13 @@ import net.minecraftforge.fml.common.gameevent.TickEvent; import java.util.Arrays; +import static com.baseband.client.BaseBand.features; import static com.baseband.client.BaseBand.mc; //forge mod loader more like fuck my life this shit BLOWS public class FMLEventHandler { - private static final Setup Setup = com.baseband.client.Setup.get(); + static Setup Setup = com.baseband.client.Setup.get(); @SubscribeEvent public void chat(ClientChatEvent event) { @@ -30,7 +31,7 @@ public class FMLEventHandler { ChatUtil.history(event.getMessage()); String[] cmd = event.getMessage().substring(prefix.length()).split(" "); String[] args = Arrays.copyOfRange(cmd, 1, cmd.length); - for (Feature feature : Setup.Features) { + for (Feature feature : features) { if (feature.toString().equalsIgnoreCase(cmd[0])) { try { feature.onCommand(args); @@ -63,7 +64,7 @@ public class FMLEventHandler { } playerLastTick = mc.player; BaseBand.updateKeyBinds(); - for(Feature feature : Setup.Features) { + for(Feature feature : features) { feature.onEveryTick(); if(feature.enabled) { feature.onTick(); 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 4b36a8e..fddd0b7 100644 --- a/Client/src/main/java/com/baseband/client/gui/GuiRewrite.java +++ b/Client/src/main/java/com/baseband/client/gui/GuiRewrite.java @@ -1,7 +1,6 @@ package com.baseband.client.gui; import com.baseband.client.BaseBand; -import com.baseband.client.Setup; import com.baseband.client.gui.lib.GUIManager; import com.baseband.client.gui.lib.component.Category; import com.baseband.client.gui.lib.component.Component; @@ -17,6 +16,8 @@ import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; +import static com.baseband.client.BaseBand.features; + public class GuiRewrite extends GuiScreen { // The mouse X and Y @@ -56,21 +57,20 @@ public class GuiRewrite extends GuiScreen { ArrayList categories = new ArrayList<>(); int y = 10; TLMap map = new TLMap<>(); - for (int i = 0; i < Setup.get().Features.length ; i++) { - Feature feature = Setup.get().Features[i]; - if(!feature.displayOnClickGUI()) { + for (Feature feature : features) { + if (!feature.displayOnClickGUI()) { continue; } Category category; - if((category = map.get(feature.category)) == null) { + if ((category = map.get(feature.category)) == null) { map.set(feature.category, category = new Category() {{ text = feature.category.name; }}); - if((feature.category.x | feature.category.y) != 0) { + if ((feature.category.x | feature.category.y) != 0) { category.location = new Point(feature.category.x, feature.category.y); category.subComponentsShown = feature.category.show; } - if(category.location == null) { + if (category.location == null) { category.location = new Point(10, y); y += 20; } diff --git a/Client/src/main/java/com/baseband/client/module/Feature.java b/Client/src/main/java/com/baseband/client/module/Feature.java index 2376a27..f4ac783 100644 --- a/Client/src/main/java/com/baseband/client/module/Feature.java +++ b/Client/src/main/java/com/baseband/client/module/Feature.java @@ -225,4 +225,8 @@ public abstract class Feature extends ToggleButton implements SetCommand { public boolean setWithString(String setting, String value) { return handle.setWithString(setting, value); } + + public boolean canExist() { + return true; + } } diff --git a/Client/src/main/java/com/baseband/client/module/client/Baritone.java b/Client/src/main/java/com/baseband/client/module/client/Baritone.java index a0e8c13..0e0c548 100644 --- a/Client/src/main/java/com/baseband/client/module/client/Baritone.java +++ b/Client/src/main/java/com/baseband/client/module/client/Baritone.java @@ -2,6 +2,7 @@ package com.baseband.client.module.client; import com.baseband.client.module.Feature; import com.baseband.client.module.category.Client; +import com.baseband.client.util.baritone.BaritoneManager; @Client public class Baritone extends Feature { @@ -20,4 +21,9 @@ public class Baritone extends Feature { public void onDisable() { toggle(); } + + @Override + public boolean canExist() { + return BaritoneManager.IS_BARITONE_PRESENT; + } } diff --git a/Client/src/main/java/com/baseband/client/module/command/Bind.java b/Client/src/main/java/com/baseband/client/module/command/Bind.java index c38e250..2d51698 100644 --- a/Client/src/main/java/com/baseband/client/module/command/Bind.java +++ b/Client/src/main/java/com/baseband/client/module/command/Bind.java @@ -8,6 +8,8 @@ import com.baseband.client.util.ingame.ChatUtil; import com.baseband.client.util.config.SetCommand; import org.lwjgl.input.Keyboard; +import static com.baseband.client.BaseBand.features; + @Command public class Bind extends Feature { @Override @@ -22,7 +24,7 @@ public class Bind extends Feature { SetCommand f = null; - for(Feature feature : Setup.Features) { + for(Feature feature : features) { if(feature.toString().equalsIgnoreCase(module)) { f = feature; break; diff --git a/Client/src/main/java/com/baseband/client/module/command/Set.java b/Client/src/main/java/com/baseband/client/module/command/Set.java index 8205ba0..5f9efac 100644 --- a/Client/src/main/java/com/baseband/client/module/command/Set.java +++ b/Client/src/main/java/com/baseband/client/module/command/Set.java @@ -11,6 +11,8 @@ import com.baseband.client.util.misc.GlobalUtil; import java.util.HashMap; +import static com.baseband.client.BaseBand.features; + @Command public class Set extends Feature { @@ -47,7 +49,7 @@ public class Set extends Feature { isQS = true; } catch (NumberFormatException ignored) {} - for(Feature feature : Setup.Features) { + for(Feature feature : features) { if(feature.toString().equalsIgnoreCase(module)) { f = feature; break; diff --git a/Client/src/main/java/com/baseband/client/module/render/ClickGUI.java b/Client/src/main/java/com/baseband/client/module/render/ClickGUI.java index dab7d83..6a6fecf 100644 --- a/Client/src/main/java/com/baseband/client/module/render/ClickGUI.java +++ b/Client/src/main/java/com/baseband/client/module/render/ClickGUI.java @@ -6,6 +6,8 @@ import com.baseband.client.gui.GuiRewrite; import com.baseband.client.module.Feature; import com.baseband.client.module.category.Render; +import static com.baseband.client.BaseBand.features; + @Render public class ClickGUI extends Feature { public static GuiRewrite guiRewrite; @@ -62,7 +64,7 @@ public class ClickGUI extends Feature { @Override protected void setup() { if(saveExpanded == SaveExpandedMode.UntilExit) { - for (Feature feature : Setup.Features) { + for (Feature feature : features) { feature.subComponentsShown = false; } } @@ -76,7 +78,7 @@ public class ClickGUI extends Feature { } if(guiRewrite == null) guiRewrite = new GuiRewrite(); if(saveExpanded == SaveExpandedMode.Never) { - for (Feature feature : Setup.Features) { + for (Feature feature : features) { feature.subComponentsShown = false; } } diff --git a/Client/src/main/java/com/baseband/client/module/render/HUD.java b/Client/src/main/java/com/baseband/client/module/render/HUD.java index d990c78..f2bfdc9 100644 --- a/Client/src/main/java/com/baseband/client/module/render/HUD.java +++ b/Client/src/main/java/com/baseband/client/module/render/HUD.java @@ -20,6 +20,8 @@ import java.util.Arrays; import java.util.Comparator; import java.util.Date; +import static com.baseband.client.BaseBand.features; + @Render public class HUD extends Feature { @@ -117,7 +119,7 @@ public class HUD extends Feature { mc.fontRenderer.drawStringWithShadow("§lBaseBand§r - \"" + BaseBand.buildString + "\"", 2,2, BaseBand.getFeature(Client.class).getTheme().getGreenColor()); int y = 11; - for (Feature f : Arrays.stream(Setup.Features).filter(m -> m.enabled && m.category != Category.COMMAND && m.getClass() != Client.class && m != this).sorted(Comparator.comparingDouble(value -> -Minecraft.getMinecraft().fontRenderer.getStringWidth(value.toString()))).toArray(Feature[]::new)) { + for (Feature f : Arrays.stream(features).filter(m -> m.enabled && m.category != Category.COMMAND && m.getClass() != Client.class && m != this).sorted(Comparator.comparingDouble(value -> -Minecraft.getMinecraft().fontRenderer.getStringWidth(value.toString()))).toArray(Feature[]::new)) { mc.fontRenderer.drawStringWithShadow(f.text, 2, y, BaseBand.getFeature(Client.class).getTheme().getGreenColor()); y = y + mc.fontRenderer.FONT_HEIGHT; }