make Setup.Features specify included features and BaseBand.features specify usable features
This commit is contained in:
parent
4415c186fc
commit
77367a0637
10 changed files with 52 additions and 21 deletions
|
@ -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<Feature> 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 extends Feature> T getFeature(Class<? extends T> clazz) {
|
||||
if(finishedDisabling) return null;
|
||||
|
||||
Feature[] features = Setup.get().Features;
|
||||
for (Feature feature : features) {
|
||||
if (feature.getClass() == clazz)
|
||||
return (T) feature;
|
||||
|
|
|
@ -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(),
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<Category> categories = new ArrayList<>();
|
||||
int y = 10;
|
||||
TLMap<com.baseband.client.module.Category, Category> 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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue