make unloading a bit more unterrible, fix warnings
This commit is contained in:
parent
4e6ccd102c
commit
2c9a14750d
16 changed files with 98 additions and 74 deletions
|
@ -22,7 +22,7 @@ public class FMLEventHandler {
|
|||
|
||||
@SubscribeEvent
|
||||
public void chat(ClientChatEvent event) {
|
||||
String prefix = BaseBand.getModule(Client.class).prefix;
|
||||
String prefix = BaseBand.getFeature(Client.class).prefix;
|
||||
if(event.getMessage().startsWith(prefix)) {
|
||||
event.setCanceled(true);
|
||||
ChatUtil.history(event.getMessage());
|
||||
|
|
|
@ -26,8 +26,8 @@ public class GuiRewrite extends GuiScreen {
|
|||
private boolean allowMouse = false;
|
||||
|
||||
public GuiRewrite() {
|
||||
this.mc = BaseBand.INSTANCE.mc;
|
||||
ClickGUI clickGUI = BaseBand.getModule(ClickGUI.class);
|
||||
this.mc = BaseBand.mc;
|
||||
ClickGUI clickGUI = BaseBand.getFeature(ClickGUI.class);
|
||||
if(!clickGUI.enabled)
|
||||
clickGUI.toggle();
|
||||
createComponents();
|
||||
|
@ -89,7 +89,7 @@ public class GuiRewrite extends GuiScreen {
|
|||
@Override
|
||||
public void onGuiClosed() {
|
||||
super.onGuiClosed();
|
||||
BaseBand.getModule(ClickGUI.class).setEnabled(false);
|
||||
BaseBand.getFeature(ClickGUI.class).setEnabled(false);
|
||||
for (Category category : categories) {
|
||||
com.baseband.client.module.Category c = com.baseband.client.module.Category.fromName(category.text);
|
||||
c.show = category.subComponentsShown;
|
||||
|
@ -165,24 +165,24 @@ public class GuiRewrite extends GuiScreen {
|
|||
cy = mouseY;
|
||||
|
||||
GUIManager.renderedComponents = new HashMap<>();
|
||||
for (int i = 0 ; i < categories.length ; i++) {
|
||||
if(categories[i].location.getY() < -10000) {
|
||||
categories[i].location.setY(categories[i].location.getY() + 10000);
|
||||
for (Category category : categories) {
|
||||
if (category.location.getY() < -10000) {
|
||||
category.location.setY(category.location.getY() + 10000);
|
||||
}
|
||||
if(categories[i].location.getY() > 10000) {
|
||||
categories[i].location.setY(categories[i].location.getY() - 10000);
|
||||
if (category.location.getY() > 10000) {
|
||||
category.location.setY(category.location.getY() - 10000);
|
||||
}
|
||||
categories[i].render();
|
||||
category.render();
|
||||
}
|
||||
|
||||
// TMP fix for a strange bug that causes the mouse to be hidden
|
||||
if (BaseBand.getModule(ClickGUI.class).mouseFix) {
|
||||
if (BaseBand.getFeature(ClickGUI.class).mouseFix) {
|
||||
drawRect(mouseX - 2, mouseY - 2, mouseX + 2, mouseY + 2, 0xffffffff);
|
||||
}
|
||||
int m = Mouse.getDWheel();
|
||||
if(m != 0) {
|
||||
for (int i = 0 ; i < categories.length ; i++) {
|
||||
categories[i].location.setY(categories[i].location.getY() + m);
|
||||
for (Category category : categories) {
|
||||
category.location.setY(category.location.getY() + m);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ public class GUIManager {
|
|||
}
|
||||
|
||||
public static void update() {
|
||||
GuiTheme.ITheme theme = BaseBand.getModule(Client.class).getTheme();
|
||||
GuiTheme.ITheme theme = BaseBand.getFeature(Client.class).getTheme();
|
||||
fontColorOn = theme.getGreenColor();
|
||||
fontColorOff = theme.getRedColor();
|
||||
frameColor = theme.getFrameColor();
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.baseband.client.init;
|
|||
import com.baseband.client.configuration.Updater;
|
||||
import com.baseband.client.event.EventManager;
|
||||
import com.baseband.client.event.FMLEventHandler;
|
||||
import com.baseband.client.gui.GuiRewrite;
|
||||
import com.baseband.client.module.Feature;
|
||||
import com.baseband.client.util.config.KeyBind;
|
||||
import com.baseband.client.util.ingame.ChatUtil;
|
||||
|
@ -11,6 +10,7 @@ import com.baseband.client.util.misc.GlobalUtil;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
@ -21,7 +21,6 @@ public class BaseBand {
|
|||
private static final ArrayList<Updater> updaters = new ArrayList<>();
|
||||
private static final ArrayList<KeyBind> keyBinds = new ArrayList<>();
|
||||
private static boolean finishedDisabling = false;
|
||||
public static GuiRewrite guiRewrite;
|
||||
public static String buildString = "Broadway";
|
||||
public static final EventManager eventManager = new EventManager();
|
||||
public static FMLEventHandler fmlEventHandlerInstance = new FMLEventHandler();
|
||||
|
@ -58,12 +57,10 @@ public class BaseBand {
|
|||
|
||||
Setup clientSetup = Setup.get();
|
||||
Feature[] features = clientSetup.Features;
|
||||
for (int i = 0; i < features.length; i++) {
|
||||
features[i].register(this, mc);
|
||||
for (Feature value : features) {
|
||||
value.register(this, mc);
|
||||
}
|
||||
|
||||
guiRewrite = new GuiRewrite();
|
||||
|
||||
for (Updater updater : updaters) {
|
||||
GlobalUtil.LOGGER.info("populating updater " + updater);
|
||||
updater.populate();
|
||||
|
@ -82,9 +79,7 @@ public class BaseBand {
|
|||
}
|
||||
|
||||
for (Feature feature : features) {
|
||||
MinecraftForge.EVENT_BUS.unregister(feature);
|
||||
eventManager.unsubscribe(feature);
|
||||
feature.onDisable();
|
||||
feature.setEnabledSilent(false);
|
||||
}
|
||||
|
||||
finishedDisabling = true;
|
||||
|
@ -97,14 +92,25 @@ public class BaseBand {
|
|||
GlobalUtil.LOGGER.info("Instantiated.");
|
||||
}
|
||||
|
||||
public static <T extends Feature> T getModule(Class<? extends T> clazz) {
|
||||
@SuppressWarnings("DataFlowIssue")
|
||||
@Nonnull
|
||||
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)
|
||||
//noinspection unchecked untrue
|
||||
return (T) feature;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isFeatureEnabled(Class<? extends Feature> clazz) {
|
||||
Feature f = getFeature(clazz);
|
||||
//noinspection ConstantValue
|
||||
if(f == null)
|
||||
return false;
|
||||
return f.enabled;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.baseband.client.module.client.Client;
|
|||
import com.baseband.client.module.client.MidClick;
|
||||
import com.baseband.client.module.combat.AutoKill;
|
||||
import com.baseband.client.module.combat.AutoTotem;
|
||||
import com.baseband.client.module.command.Bind;
|
||||
import com.baseband.client.module.command.Set;
|
||||
import com.baseband.client.module.command.Test;
|
||||
import com.baseband.client.module.movement.ElytraFly;
|
||||
|
@ -35,6 +36,7 @@ public class Setup {
|
|||
new ClickGUI(),
|
||||
new HUD(),
|
||||
new Set(),
|
||||
new Bind(),
|
||||
new ChatCrypt(),
|
||||
new Freecam(),
|
||||
new AutoTotem(),
|
||||
|
|
|
@ -21,8 +21,8 @@ public class MixinGuiEditSign {
|
|||
|
||||
@Inject(method = "initGui", at = @At("RETURN"))
|
||||
public void initGui(CallbackInfo callback) {
|
||||
AutoSignText autoSignText = BaseBand.getModule(AutoSignText.class);
|
||||
if(autoSignText != null && autoSignText.enabled) {
|
||||
if(BaseBand.isFeatureEnabled(AutoSignText.class)) {
|
||||
AutoSignText autoSignText = BaseBand.getFeature(AutoSignText.class);
|
||||
tileSign.signText[0] = new TextComponentString(autoSignText.signTextFirst);
|
||||
tileSign.signText[1] = new TextComponentString(autoSignText.signTextSecond);
|
||||
tileSign.signText[2] = new TextComponentString(autoSignText.signTextThird);
|
||||
|
|
|
@ -15,22 +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) {
|
||||
ExtraChat extraChat = BaseBand.getModule(ExtraChat.class);
|
||||
if(!BaseBand.isFeatureEnabled(ExtraChat.class)) {
|
||||
Gui.drawRect(left, top, right, bottom, color);
|
||||
return;
|
||||
}
|
||||
|
||||
Gui.drawRect(left, top, right, bottom, extraChat == null || extraChat.clearchat && extraChat.enabled ? 0 : color);
|
||||
ExtraChat extraChat = BaseBand.getFeature(ExtraChat.class);
|
||||
Gui.drawRect(left, top, right, bottom, extraChat.clearchat ? 0 : color);
|
||||
}
|
||||
|
||||
@Redirect(method = "setChatLine", at = @At(value = "INVOKE", target = "Ljava/util/List;size()I", ordinal = 0, remap = false))
|
||||
public int drawnChatLinesSize(List<ChatLine> list) {
|
||||
ExtraChat extraChat = BaseBand.getModule(ExtraChat.class);
|
||||
if(!BaseBand.isFeatureEnabled(ExtraChat.class))
|
||||
return list.size();
|
||||
|
||||
return extraChat == null || extraChat.infinitechat && extraChat.enabled ? -2147483647 : list.size();
|
||||
ExtraChat extraChat = BaseBand.getFeature(ExtraChat.class);
|
||||
return extraChat.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<ChatLine> list) {
|
||||
ExtraChat extraChat = BaseBand.getModule(ExtraChat.class);
|
||||
if(!BaseBand.isFeatureEnabled(ExtraChat.class))
|
||||
return list.size();
|
||||
|
||||
return extraChat == null || extraChat.infinitechat && extraChat.enabled ? -2147483647 : list.size();
|
||||
ExtraChat extraChat = BaseBand.getFeature(ExtraChat.class);
|
||||
return extraChat.infinitechat ? -2147483647 : list.size();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,9 +16,12 @@ import java.io.File;
|
|||
@Mixin(value = {ScreenShotHelper.class}, priority = Integer.MAX_VALUE)
|
||||
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) {
|
||||
Client client = BaseBand.getModule(Client.class);
|
||||
if (client != null && client.screenshotUpload) {
|
||||
private static void saveScreenshot(File file, String string, int n, int n2, Framebuffer framebuffer, CallbackInfoReturnable<?> callbackInfoReturnable) {
|
||||
if(!BaseBand.isFeatureEnabled(Client.class))
|
||||
return;
|
||||
|
||||
Client client = BaseBand.getFeature(Client.class);
|
||||
if (client.screenshotUpload) {
|
||||
ScreenshotHelper eventClientScreenShot = new ScreenshotHelper(ScreenShotHelper.createScreenshot(n, n2, framebuffer));
|
||||
eventClientScreenShot.start();
|
||||
}
|
||||
|
|
|
@ -166,9 +166,7 @@ public abstract class Feature extends ToggleButton implements SetCommand {
|
|||
handle = settings;
|
||||
BaseBand.registerUpdater(settings.linkWith(this, FieldFinder.findMarked(Feature.class, 1)).name("Enabled"));
|
||||
|
||||
if(category != Category.COMMAND) {
|
||||
updateEnabled();
|
||||
}
|
||||
updateEnabled();
|
||||
setup();
|
||||
}
|
||||
|
||||
|
@ -204,13 +202,18 @@ public abstract class Feature extends ToggleButton implements SetCommand {
|
|||
try {
|
||||
ConfigHandle h = Configuration.register("Feature/" + getID() + "/" + handle);
|
||||
ownedHandles.put(handle, h);
|
||||
System.out.println("Feature " + toString() + " registered config: " + handle);
|
||||
System.out.println("Feature " + this + " registered config: " + handle);
|
||||
return h;
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void setEnabledSilent(boolean enable) {
|
||||
enabled = enable;
|
||||
updateEnabled();
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enable) {
|
||||
if(enable != enabled)
|
||||
toggle();
|
||||
|
|
|
@ -39,7 +39,7 @@ public class ChatAppend extends Feature {
|
|||
|
||||
public void packetWrite(PacketEvent.Send event) {
|
||||
if(event.getPacket() instanceof CPacketChatMessage) {
|
||||
if (BaseBand.getModule(ChatCrypt.class).enabled) {
|
||||
if (BaseBand.isFeatureEnabled(ChatCrypt.class)) {
|
||||
ChatUtil.print("ChatAppend toggled, As using it simultaneously with ChatCrypt is not supported.");
|
||||
toggle();
|
||||
return;
|
||||
|
@ -62,31 +62,31 @@ public class ChatAppend extends Feature {
|
|||
|
||||
private String toUnicode(String s) {
|
||||
return s.toLowerCase()
|
||||
.replace("a", "\u1d00")
|
||||
.replace("b", "\u0299")
|
||||
.replace("c", "\u1d04")
|
||||
.replace("d", "\u1d05")
|
||||
.replace("e", "\u1d07")
|
||||
.replace("f", "\ua730")
|
||||
.replace("g", "\u0262")
|
||||
.replace("h", "\u029c")
|
||||
.replace("i", "\u026a")
|
||||
.replace("j", "\u1d0a")
|
||||
.replace("k", "\u1d0b")
|
||||
.replace("l", "\u029f")
|
||||
.replace("m", "\u1d0d")
|
||||
.replace("n", "\u0274")
|
||||
.replace("o", "\u1d0f")
|
||||
.replace("p", "\u1d18")
|
||||
.replace("q", "\u01eb")
|
||||
.replace("r", "\u0280")
|
||||
.replace("s", "\ua731")
|
||||
.replace("t", "\u1d1b")
|
||||
.replace("u", "\u1d1c")
|
||||
.replace("v", "\u1d20")
|
||||
.replace("w", "\u1d21")
|
||||
.replace("x", "\u02e3")
|
||||
.replace("y", "\u028f")
|
||||
.replace("z", "\u1d22");
|
||||
.replace("a", "ᴀ")
|
||||
.replace("b", "ʙ")
|
||||
.replace("c", "ᴄ")
|
||||
.replace("d", "ᴅ")
|
||||
.replace("e", "ᴇ")
|
||||
.replace("f", "ꜰ")
|
||||
.replace("g", "ɢ")
|
||||
.replace("h", "ʜ")
|
||||
.replace("i", "ɪ")
|
||||
.replace("j", "ᴊ")
|
||||
.replace("k", "ᴋ")
|
||||
.replace("l", "ʟ")
|
||||
.replace("m", "ᴍ")
|
||||
.replace("n", "ɴ")
|
||||
.replace("o", "ᴏ")
|
||||
.replace("p", "ᴘ")
|
||||
.replace("q", "ǫ")
|
||||
.replace("r", "ʀ")
|
||||
.replace("s", "ꜱ")
|
||||
.replace("t", "ᴛ")
|
||||
.replace("u", "ᴜ")
|
||||
.replace("v", "ᴠ")
|
||||
.replace("w", "ᴡ")
|
||||
.replace("x", "ˣ")
|
||||
.replace("y", "ʏ")
|
||||
.replace("z", "ᴢ");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,5 +50,6 @@ public class Client extends Feature {
|
|||
MinecraftForge.EVENT_BUS.unregister(BaseBand.fmlEventHandlerInstance);
|
||||
mc.displayGuiScreen(null);
|
||||
BaseBand.disabled = true;
|
||||
ChatUtil.print("Waiting for config...");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ public class Bind extends Feature {
|
|||
@Override
|
||||
public void onCommand(String[] args) {
|
||||
if(args.length != 3) {
|
||||
ChatUtil.print("syntax: " + BaseBand.getModule(Client.class).prefix + toString() + " <module> <binding> <key>");
|
||||
ChatUtil.print("syntax: " + BaseBand.getFeature(Client.class).prefix + this + " <module> <binding> <key>");
|
||||
return;
|
||||
}
|
||||
String module = args[0];
|
||||
|
|
|
@ -24,13 +24,13 @@ public class Set extends Feature {
|
|||
}
|
||||
|
||||
public static void openQuickSet(int id, String field) {
|
||||
ChatUtil.openChat(BaseBand.getModule(Client.class).prefix + "set " + id + " " + field.replace(' ', '_') + " ");
|
||||
ChatUtil.openChat(BaseBand.getFeature(Client.class).prefix + "set " + id + " " + field.replace(' ', '_') + " ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(String[] args) {
|
||||
if(args.length < 3) {
|
||||
ChatUtil.print("syntax: " + BaseBand.getModule(Client.class).prefix + toString() + " <module> <setting> <value...>");
|
||||
ChatUtil.print("syntax: " + BaseBand.getFeature(Client.class).prefix + this + " <module> <setting> <value...>");
|
||||
return;
|
||||
}
|
||||
String module = args[0];
|
||||
|
|
|
@ -3,12 +3,13 @@ package com.baseband.client.module.render;
|
|||
import com.baseband.client.configuration.annotation.Config;
|
||||
import com.baseband.client.configuration.annotation.Gate;
|
||||
import com.baseband.client.gui.GuiRewrite;
|
||||
import com.baseband.client.init.BaseBand;
|
||||
import com.baseband.client.module.Feature;
|
||||
import com.baseband.client.module.category.Render;
|
||||
|
||||
@Render
|
||||
public class ClickGUI extends Feature {
|
||||
public GuiRewrite guiRewrite = new GuiRewrite();
|
||||
|
||||
public enum SaveExpandedMode {
|
||||
Always,
|
||||
UntilExit,
|
||||
|
@ -78,7 +79,7 @@ public class ClickGUI extends Feature {
|
|||
feature.subComponentsShown = false;
|
||||
}
|
||||
}
|
||||
mc.displayGuiScreen(BaseBand.guiRewrite);
|
||||
mc.displayGuiScreen(guiRewrite);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -121,10 +121,10 @@ public class HUD extends Feature {
|
|||
public void text(RenderGameOverlayEvent.Text e) {
|
||||
ScaledResolution sr = new ScaledResolution(mc);
|
||||
|
||||
mc.fontRenderer.drawStringWithShadow("§lBaseBand§r - \"" + BaseBand.buildString + "\"", 2,2, BaseBand.getModule(Client.class).getTheme().getGreenColor());
|
||||
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.category != Category.CLIENT && !m.toString().equals("HUD")).sorted(Comparator.comparingDouble(value -> -Minecraft.getMinecraft().fontRenderer.getStringWidth(value.toString()))).toArray(Feature[]::new)) {
|
||||
mc.fontRenderer.drawStringWithShadow(f.toString(), 2, y, BaseBand.getModule(Client.class).getTheme().getGreenColor());
|
||||
mc.fontRenderer.drawStringWithShadow(f.toString(), 2, y, BaseBand.getFeature(Client.class).getTheme().getGreenColor());
|
||||
y = y + mc.fontRenderer.FONT_HEIGHT;
|
||||
}
|
||||
if(notifications) {
|
||||
|
|
|
@ -49,7 +49,7 @@ public class FreecamPlayer extends EntityOtherPlayerMP
|
|||
public void onLivingUpdate()
|
||||
{
|
||||
if(mc.world == null) {
|
||||
BaseBand.getModule(Freecam.class).setEnabled(false);
|
||||
BaseBand.getFeature(Freecam.class).setEnabled(false);
|
||||
return;
|
||||
}
|
||||
mc.renderChunksMany = false;
|
||||
|
|
Loading…
Add table
Reference in a new issue