From e227527eeb43e415f5cc3fda234c8d77c9d145d3 Mon Sep 17 00:00:00 2001 From: TudbuT Date: Sat, 25 May 2024 21:37:38 +0200 Subject: [PATCH] make unloading a bit more unterrible, fix a crash, fix warnings --- Client/.gitignore | 5 --- .../java/com/baseband/client/DevStub.java | 1 - .../client/configuration/ConfigHandle.java | 2 +- .../client/configuration/Configuration.java | 2 +- .../client/configuration/Updater.java | 4 +- .../configuration/annotation/AnyGate.java | 6 +-- .../baseband/client/event/EventManager.java | 3 -- .../client/event/events/MoveEvent.java | 2 +- .../com/baseband/client/gui/GuiRewrite.java | 4 +- .../client/gui/lib/component/Category.java | 3 +- .../client/gui/lib/component/Component.java | 4 +- .../client/gui/lib/component/KeyButton.java | 6 +-- .../gui/lib/component/StringButton.java | 6 +-- .../gui/lib/component/ToggleButton.java | 2 +- .../com/baseband/client/init/BaseBand.java | 5 +-- .../mixins/MixinFMLNetworkRegistry.java | 2 +- .../com/baseband/client/module/Category.java | 7 ++-- .../client/module/chat/ChatAppend.java | 2 +- .../client/module/chat/ChatCrypt.java | 21 +++++----- .../baseband/client/module/client/Client.java | 4 +- .../client/module/client/MidClick.java | 38 +++++++------------ .../client/module/combat/AutoKill.java | 10 ++--- .../client/module/combat/AutoTotem.java | 28 ++++++-------- .../baseband/client/module/command/Test.java | 5 --- .../client/module/movement/ElytraFly.java | 16 ++++---- .../client/module/render/ClickGUI.java | 6 +-- .../baseband/client/module/render/HUD.java | 14 +++---- .../client/module/render/Nametags.java | 14 +++---- .../client/module/world/AutoSignText.java | 8 ++-- .../baseband/client/util/config/KeyBind.java | 6 +-- .../client/util/ingame/FreecamPlayer.java | 4 +- .../client/util/ingame/ScreenshotHelper.java | 2 +- .../client/util/misc/FieldFinder.java | 35 ++++++++--------- .../com/baseband/client/util/misc/SBE.java | 2 +- .../com/baseband/client/util/misc/Trypt.java | 11 ++---- .../client/webservices/WebServiceClient.java | 1 + .../main/java/old/baseband/installer/Key.java | 1 - .../util/minecraft/MinecraftFiles.java | 2 - .../classloader/CustomClassLoader.java | 9 ++--- .../org/baseband/launcher/util/RSAKey.java | 12 +++--- .../main/java/dev/baseband/server/Main.java | 2 - .../baseband/server/WebServiceHandler.java | 4 +- 42 files changed, 137 insertions(+), 184 deletions(-) diff --git a/Client/.gitignore b/Client/.gitignore index 9968a49..a4f9756 100644 --- a/Client/.gitignore +++ b/Client/.gitignore @@ -42,8 +42,3 @@ bin/ ### Mac OS ### .DS_Store - - - - -run/ \ No newline at end of file diff --git a/Client/src/main/java/com/baseband/client/DevStub.java b/Client/src/main/java/com/baseband/client/DevStub.java index 9005cfb..a1f5ac2 100644 --- a/Client/src/main/java/com/baseband/client/DevStub.java +++ b/Client/src/main/java/com/baseband/client/DevStub.java @@ -4,7 +4,6 @@ import com.baseband.client.init.BaseBand; import net.minecraftforge.common.ForgeVersion; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/Client/src/main/java/com/baseband/client/configuration/ConfigHandle.java b/Client/src/main/java/com/baseband/client/configuration/ConfigHandle.java index 83d2e56..f507a9a 100644 --- a/Client/src/main/java/com/baseband/client/configuration/ConfigHandle.java +++ b/Client/src/main/java/com/baseband/client/configuration/ConfigHandle.java @@ -12,7 +12,7 @@ public class ConfigHandle implements SetCommand { final String name; TCN tcn; - ArrayList onUpdate = new ArrayList<>(); + final ArrayList onUpdate = new ArrayList<>(); public ConfigHandle(String name, TCN tcn) { this.name = name; diff --git a/Client/src/main/java/com/baseband/client/configuration/Configuration.java b/Client/src/main/java/com/baseband/client/configuration/Configuration.java index 942ef6b..bbfad41 100644 --- a/Client/src/main/java/com/baseband/client/configuration/Configuration.java +++ b/Client/src/main/java/com/baseband/client/configuration/Configuration.java @@ -12,7 +12,7 @@ public class Configuration { private Configuration() throws IOException { } - private static Configuration INSTANCE; + private static final Configuration INSTANCE; static { try { diff --git a/Client/src/main/java/com/baseband/client/configuration/Updater.java b/Client/src/main/java/com/baseband/client/configuration/Updater.java index 0ea7d65..4b942e3 100644 --- a/Client/src/main/java/com/baseband/client/configuration/Updater.java +++ b/Client/src/main/java/com/baseband/client/configuration/Updater.java @@ -9,8 +9,8 @@ public class Updater { final ConfigHandle handle; String id = "*"; - Object o; - Field field; + final Object o; + final Field field; Updater(ConfigHandle handle, Object o, Field field) { this.handle = handle; diff --git a/Client/src/main/java/com/baseband/client/configuration/annotation/AnyGate.java b/Client/src/main/java/com/baseband/client/configuration/annotation/AnyGate.java index 48ceaa4..ed9f7b3 100644 --- a/Client/src/main/java/com/baseband/client/configuration/annotation/AnyGate.java +++ b/Client/src/main/java/com/baseband/client/configuration/annotation/AnyGate.java @@ -6,9 +6,9 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class AnyGate { - Gate gate; - MultiGate multiGate; - Object o; + final Gate gate; + final MultiGate multiGate; + final Object o; public AnyGate(@Nullable Gate gate, @Nullable MultiGate multiGate, @Nonnull Object o) { this.gate = gate; 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 6acc5f3..008f9f8 100644 --- a/Client/src/main/java/com/baseband/client/event/EventManager.java +++ b/Client/src/main/java/com/baseband/client/event/EventManager.java @@ -1,7 +1,5 @@ package com.baseband.client.event; -import com.baseband.client.util.misc.GlobalUtil; - import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; @@ -23,7 +21,6 @@ public class EventManager { for (Method method : methods) { Class[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length == 1 && Event.class.isAssignableFrom(parameterTypes[0])) { - //noinspection unchecked Class eventType = (Class) parameterTypes[0]; List eventSubscribers = subscribers.getOrDefault(eventType, new ArrayList<>()); eventSubscribers.add(new SubscriberMethod(subscriber, method)); diff --git a/Client/src/main/java/com/baseband/client/event/events/MoveEvent.java b/Client/src/main/java/com/baseband/client/event/events/MoveEvent.java index 0be026a..63ad079 100644 --- a/Client/src/main/java/com/baseband/client/event/events/MoveEvent.java +++ b/Client/src/main/java/com/baseband/client/event/events/MoveEvent.java @@ -4,7 +4,7 @@ import com.baseband.client.event.Event; import net.minecraft.entity.MoverType; public class MoveEvent extends Event { - public MoverType type; + public final MoverType type; public double x; public double y; public double z; 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 7cb57ee..9e25188 100644 --- a/Client/src/main/java/com/baseband/client/gui/GuiRewrite.java +++ b/Client/src/main/java/com/baseband/client/gui/GuiRewrite.java @@ -27,9 +27,6 @@ public class GuiRewrite extends GuiScreen { public GuiRewrite() { this.mc = BaseBand.mc; - ClickGUI clickGUI = BaseBand.getFeature(ClickGUI.class); - if(!clickGUI.enabled) - clickGUI.toggle(); createComponents(); } @@ -92,6 +89,7 @@ public class GuiRewrite extends GuiScreen { BaseBand.getFeature(ClickGUI.class).setEnabled(false); for (Category category : categories) { com.baseband.client.module.Category c = com.baseband.client.module.Category.fromName(category.text); + assert c != null; c.show = category.subComponentsShown; c.x = category.location.getX(); c.y = category.location.getY(); diff --git a/Client/src/main/java/com/baseband/client/gui/lib/component/Category.java b/Client/src/main/java/com/baseband/client/gui/lib/component/Category.java index 29f3f0a..58bfc10 100644 --- a/Client/src/main/java/com/baseband/client/gui/lib/component/Category.java +++ b/Client/src/main/java/com/baseband/client/gui/lib/component/Category.java @@ -29,8 +29,7 @@ public class Category extends Component { fontRenderer.drawString(text, x, y.get(), green ? GUIManager.fontColorOn : GUIManager.fontColorOff); y.addAndGet(size()); if(subComponentsShown) { - for (int i = 0 ; i < subComponents.size() ; i++) { - Component component = subComponents.get(i); + for (Component component : subComponents) { component.render(x, y, 0, false, component.size()); } } diff --git a/Client/src/main/java/com/baseband/client/gui/lib/component/Component.java b/Client/src/main/java/com/baseband/client/gui/lib/component/Component.java index b9aadca..46c2b76 100644 --- a/Client/src/main/java/com/baseband/client/gui/lib/component/Component.java +++ b/Client/src/main/java/com/baseband/client/gui/lib/component/Component.java @@ -27,8 +27,8 @@ public abstract class Component { public Point loc; private AnyGate visibilityGate = null; - FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; - public ArrayList subComponents = new ArrayList<>(); + final FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; + public final ArrayList subComponents = new ArrayList<>(); public String text = ""; public boolean green = false; diff --git a/Client/src/main/java/com/baseband/client/gui/lib/component/KeyButton.java b/Client/src/main/java/com/baseband/client/gui/lib/component/KeyButton.java index 72838f4..d4bf402 100644 --- a/Client/src/main/java/com/baseband/client/gui/lib/component/KeyButton.java +++ b/Client/src/main/java/com/baseband/client/gui/lib/component/KeyButton.java @@ -4,9 +4,9 @@ import com.baseband.client.configuration.ConfigHandle; import org.lwjgl.input.Keyboard; public class KeyButton extends Button { - protected String name; - protected ConfigHandle handle; - protected String field; + protected final String name; + protected final ConfigHandle handle; + protected final String field; public KeyButton(String name, ConfigHandle handle, String field) { super(name + ": " + (handle.getContent().get(field) != null ? Keyboard.getKeyName(handle.getContent().getInteger(field)) : "NONE"), it -> ((KeyButton) it).press()); diff --git a/Client/src/main/java/com/baseband/client/gui/lib/component/StringButton.java b/Client/src/main/java/com/baseband/client/gui/lib/component/StringButton.java index 0ed6872..205bc50 100644 --- a/Client/src/main/java/com/baseband/client/gui/lib/component/StringButton.java +++ b/Client/src/main/java/com/baseband/client/gui/lib/component/StringButton.java @@ -4,9 +4,9 @@ import com.baseband.client.configuration.ConfigHandle; import com.baseband.client.module.command.Set; public class StringButton extends Button { - protected String name; - protected ConfigHandle handle; - protected String field; + protected final String name; + protected final ConfigHandle handle; + protected final String field; public StringButton(String name, ConfigHandle handle, String field) { super(name + ": --UNINIT", new ClickEvent() { 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 6738bf4..3ec69ac 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 @@ -7,7 +7,7 @@ import com.baseband.client.util.misc.GlobalUtil; public class ToggleButton extends Component { protected ConfigHandle handle; - protected String field; + protected final String field; private Runnable lambda; public ToggleButton(String s, ConfigHandle handle, String field) { diff --git a/Client/src/main/java/com/baseband/client/init/BaseBand.java b/Client/src/main/java/com/baseband/client/init/BaseBand.java index df3dcb5..720ff80 100644 --- a/Client/src/main/java/com/baseband/client/init/BaseBand.java +++ b/Client/src/main/java/com/baseband/client/init/BaseBand.java @@ -23,7 +23,7 @@ public class BaseBand { private static boolean finishedDisabling = false; public static String buildString = "Broadway"; public static final EventManager eventManager = new EventManager(); - public static FMLEventHandler fmlEventHandlerInstance = new FMLEventHandler(); + public static final FMLEventHandler fmlEventHandlerInstance = new FMLEventHandler(); public static boolean disabled = false; public static Minecraft mc; @@ -62,7 +62,7 @@ public class BaseBand { } for (Updater updater : updaters) { - GlobalUtil.LOGGER.info("populating updater " + updater); + GlobalUtil.LOGGER.info("populating updater {}", updater); updater.populate(); } @@ -100,7 +100,6 @@ public class BaseBand { Feature[] features = Setup.get().Features; for (Feature feature : features) { if (feature.getClass() == clazz) - //noinspection unchecked untrue return (T) feature; } return null; diff --git a/Client/src/main/java/com/baseband/client/mixins/MixinFMLNetworkRegistry.java b/Client/src/main/java/com/baseband/client/mixins/MixinFMLNetworkRegistry.java index 4c2d582..94d2cbe 100644 --- a/Client/src/main/java/com/baseband/client/mixins/MixinFMLNetworkRegistry.java +++ b/Client/src/main/java/com/baseband/client/mixins/MixinFMLNetworkRegistry.java @@ -16,7 +16,7 @@ import java.util.Map; @Mixin(NetworkRegistry.class) public class MixinFMLNetworkRegistry { @Shadow(remap = false) - private EnumMap> channels = Maps.newEnumMap(Side.class); + private final EnumMap> channels = Maps.newEnumMap(Side.class); @Overwrite(remap = false) public EnumMap newChannel(ModContainer container, String name, ChannelHandler... handlers) diff --git a/Client/src/main/java/com/baseband/client/module/Category.java b/Client/src/main/java/com/baseband/client/module/Category.java index 1a03ad8..e54dbca 100644 --- a/Client/src/main/java/com/baseband/client/module/Category.java +++ b/Client/src/main/java/com/baseband/client/module/Category.java @@ -7,7 +7,6 @@ import com.baseband.client.module.category.*; import com.baseband.client.util.misc.FieldFinder; import com.baseband.client.util.misc.Marker; -import javax.annotation.Nonnull; import java.lang.annotation.Annotation; public enum Category { @@ -36,8 +35,9 @@ public enum Category { } } - private Class annotationClass; - private ConfigHandle handle; + private final Class annotationClass; + @SuppressWarnings("FieldCanBeLocal") + private final ConfigHandle handle; @Marker(1) public int x; @Marker(2) @@ -51,7 +51,6 @@ public enum Category { return name; } - @Nonnull public static Category fromName(String s) { for (Category c : values()) { if(c.name.equals(s)) diff --git a/Client/src/main/java/com/baseband/client/module/chat/ChatAppend.java b/Client/src/main/java/com/baseband/client/module/chat/ChatAppend.java index b4040c1..8babfa7 100644 --- a/Client/src/main/java/com/baseband/client/module/chat/ChatAppend.java +++ b/Client/src/main/java/com/baseband/client/module/chat/ChatAppend.java @@ -31,7 +31,7 @@ public class ChatAppend extends Feature { @Config("CustomText") @Gate(0) - public String customWatermark = "baseband"; + public final String customWatermark = "baseband"; @Config("CustomTextUnicode") @Gate(0) diff --git a/Client/src/main/java/com/baseband/client/module/chat/ChatCrypt.java b/Client/src/main/java/com/baseband/client/module/chat/ChatCrypt.java index 9e4e4bb..78dd08d 100644 --- a/Client/src/main/java/com/baseband/client/module/chat/ChatCrypt.java +++ b/Client/src/main/java/com/baseband/client/module/chat/ChatCrypt.java @@ -43,14 +43,14 @@ public class ChatCrypt extends Feature { } @Config("Notification mode") - public NotifMode mode = NotifMode.Chat; + public final NotifMode mode = NotifMode.Chat; @Config("Send") public boolean send; @Config("Use SBE algorithm (preferred)") @Marker(1) - public boolean useSBE = true; + public final boolean useSBE = true; @Marker(2) public boolean useTrypt = false; @@ -61,17 +61,17 @@ public class ChatCrypt extends Feature { @Config("Seed") @Range("-4096..4096") - public int seed = 256; + public final int seed = 256; @Config("Box Size") @Range("256..4096") @Gate(1) - public int boxSize = 256; + public final int boxSize = 256; @Config("Keep Trypt instance") @Gate(2) @Marker(3) - public boolean keepTrypt = false; + public final boolean keepTrypt = false; @Config("Warning! More secure, worse QOL") @MultiGate(and = {3, -2}) @@ -80,17 +80,16 @@ public class ChatCrypt extends Feature { @Config("Reset Trypt") @MultiGate(and = {2, 3}) - public Button.ClickEvent resetTrypt = btn -> { - trypt = null; - }; + public Button.ClickEvent resetTrypt = btn -> trypt = null; private Trypt trypt; private final Pattern CHAT_PATTERN = Pattern.compile("(<.*?> )|(.*?: )"); @Config("Password") - public String password = "CLICK HERE"; + public final String password = "CLICK HERE"; + @SuppressWarnings("ConstantValue") public void onEnable() { if(password.isEmpty() || password.equalsIgnoreCase("CLICK HERE")) { toggle(); @@ -205,8 +204,8 @@ public class ChatCrypt extends Feature { } } - char[] table = "!#$%&'()*+,-0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~¡¢£¥¦«²³¹»ÆÇÈÉÊÑÒÓÖÙÚÜßàáäåæçèéêñòóöùü×".toCharArray(); - byte[] rtable = new byte[256]; + final char[] table = "!#$%&'()*+,-0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~¡¢£¥¦«²³¹»ÆÇÈÉÊÑÒÓÖÙÚÜßàáäåæçèéêñòóöùü×".toCharArray(); + final byte[] rtable = new byte[256]; { for (int i = 0; i < 128; i++) { rtable[table[i]] = (byte) i; diff --git a/Client/src/main/java/com/baseband/client/module/client/Client.java b/Client/src/main/java/com/baseband/client/module/client/Client.java index 7301e04..6dca380 100644 --- a/Client/src/main/java/com/baseband/client/module/client/Client.java +++ b/Client/src/main/java/com/baseband/client/module/client/Client.java @@ -11,13 +11,13 @@ import net.minecraftforge.common.MinecraftForge; public class Client extends Feature { @Config("Prefix") - public String prefix = "&"; + public final String prefix = "&"; @Config("ScreenshotUpload") public boolean screenshotUpload; @Config("Theme") - public GuiTheme.Theme theme = GuiTheme.Theme.TTC; + public final GuiTheme.Theme theme = GuiTheme.Theme.TTC; public GuiTheme.ITheme getTheme() { return theme; diff --git a/Client/src/main/java/com/baseband/client/module/client/MidClick.java b/Client/src/main/java/com/baseband/client/module/client/MidClick.java index 291c03c..c5d15f8 100644 --- a/Client/src/main/java/com/baseband/client/module/client/MidClick.java +++ b/Client/src/main/java/com/baseband/client/module/client/MidClick.java @@ -7,7 +7,6 @@ import com.baseband.client.module.combat.AutoKill; import com.baseband.client.module.world.Selection; import com.baseband.client.util.config.PlayerDB; import com.baseband.client.util.ingame.ChatUtil; -import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.math.BlockPos; @@ -15,6 +14,7 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraftforge.client.event.RenderWorldLastEvent; import org.lwjgl.input.Mouse; +import java.util.Objects; import java.util.function.Consumer; @Client @@ -22,17 +22,11 @@ public class MidClick extends Feature { public enum PlayerAction { None((p) -> {}), - Target((p) -> { - PlayerDB.player(p.getGameProfile().getId(), p.getGameProfile().getName()).set("isTarget", true); - }), - Friend((p) -> { - PlayerDB.player(p.getGameProfile().getId(), p.getGameProfile().getName()).set("isFriend", true); - }), - Message((p) -> { - ChatUtil.openChat("/w " + p.getGameProfile().getName() + " "); - }), + Target((p) -> Objects.requireNonNull(PlayerDB.player(p.getGameProfile().getId(), p.getGameProfile().getName())).set("isTarget", true)), + Friend((p) -> Objects.requireNonNull(PlayerDB.player(p.getGameProfile().getId(), p.getGameProfile().getName())).set("isFriend", true)), + Message((p) -> ChatUtil.openChat("/w " + p.getGameProfile().getName() + " ")), ; - public Consumer action; + public final Consumer action; PlayerAction(Consumer action) { this.action = action; } @@ -44,11 +38,9 @@ public class MidClick extends Feature { Selection.begin = b; Selection.end = b; }), - Corner((b) -> { - Selection.select(b); - }), + Corner(Selection::select), ; - public Consumer action; + public final Consumer action; BlockAction(Consumer action) { this.action = action; } @@ -56,24 +48,22 @@ public class MidClick extends Feature { public enum EntityAction { None((e) -> {}), - Target((e) -> { - AutoKill.prioritizedTarget = e; - }), + Target((e) -> AutoKill.prioritizedTarget = e), ; - public Consumer action; + public final Consumer action; EntityAction(Consumer action) { this.action = action; } } @Config("PlayerAction") - public PlayerAction playerAction = PlayerAction.Message; + public final PlayerAction playerAction = PlayerAction.Message; @Config("BlockAction") - public BlockAction blockAction = BlockAction.Corner; + public final BlockAction blockAction = BlockAction.Corner; @Config("EntityAction") - public EntityAction entityAction = EntityAction.Target; + public final EntityAction entityAction = EntityAction.Target; public void onRender(RenderWorldLastEvent event) { doCheck(); @@ -97,9 +87,7 @@ public class MidClick extends Feature { return; } } - if(hover.getBlockPos() != null) { - blockAction.action.accept(hover.getBlockPos()); - } + blockAction.action.accept(hover.getBlockPos()); } } diff --git a/Client/src/main/java/com/baseband/client/module/combat/AutoKill.java b/Client/src/main/java/com/baseband/client/module/combat/AutoKill.java index 2afba69..e79d367 100644 --- a/Client/src/main/java/com/baseband/client/module/combat/AutoKill.java +++ b/Client/src/main/java/com/baseband/client/module/combat/AutoKill.java @@ -17,21 +17,21 @@ import java.util.ArrayList; public class AutoKill extends Feature { public static EntityLivingBase prioritizedTarget; - public AutoHit autoHit = new AutoHit(); - public AutoCrystal autoCrystal = new AutoCrystal(); + public final AutoHit autoHit = new AutoHit(); + public final AutoCrystal autoCrystal = new AutoCrystal(); public static AutoKill INSTANCE; { INSTANCE = this; } @Config("Attack non-players") - public boolean attackEntities = false; + public final boolean attackEntities = false; @Config("Attack players") @Marker(1) - public boolean attackPlayers = false; + public final boolean attackPlayers = false; @Config("Attack targets") @Gate(1) - public boolean attackTargets = true; + public final boolean attackTargets = true; ArrayList getAttackable() { ArrayList allowed = new ArrayList<>(); diff --git a/Client/src/main/java/com/baseband/client/module/combat/AutoTotem.java b/Client/src/main/java/com/baseband/client/module/combat/AutoTotem.java index ce103df..bf6065f 100644 --- a/Client/src/main/java/com/baseband/client/module/combat/AutoTotem.java +++ b/Client/src/main/java/com/baseband/client/module/combat/AutoTotem.java @@ -57,64 +57,64 @@ public class AutoTotem extends Feature { /// GATES END @Config("Render totem amount") - public boolean renderTots = true; + public final boolean renderTots = true; @Config("Mode") - public Mode mode = Mode.Hypermove; + public final Mode mode = Mode.Hypermove; /// CONFIG FOR SINGLE @Config("Use swap instead of click") @Gate(M_SINGLE) @Marker(M_SINGLESTACK) - public boolean preferSwap = false; + public final boolean preferSwap = false; /// CONFIG FOR HYPERSWITCH @Config("Speed (ticks/switch)") @Range("1..10") @Gate(M_HYPERSWITCH) - public int hCooldownAmount = 4 ; + public final int hCooldownAmount = 4 ; /// CONFIG FOR ^+HYPERSWAP @Config("Hotbar slots to use") @Range("1..4") @Gate(M_HYPERSWAP) - public int hotbarSlots = 2; + public final int hotbarSlots = 2; @Config("Replenish rate (ticks)") @Range("3..20") @Gate(M_HYPERSWAP) - public int replenishRate = 7; + public final int replenishRate = 7; @Config("Redownload inventory") @Gate(M_HYPERSWAP) - public boolean redownload = true; + public final boolean redownload = true; @Config("Stacked totems") @Gate(M_HYPERSWAP) @Marker(M_HYPERSWAP_STACK) - public boolean hsStacked = false; + public final boolean hsStacked = false; /// CONFIG FOR STACK @Config("Prep count") @Range("0..15") @Gate(M_STACK) - public int prepCount = 3; + public final int prepCount = 3; @Config("Switch count") @Range("0..15") @MultiGate(or = {M_STACK, M_HYPERSWAP_STACK}) - public int switchCount = 4; + public final int switchCount = 4; /// MULTI @Config("Cooldown (ms)") @Range("0..1000") @MultiGate(or = {M_STACK, M_SINGLESTACK}) - public int sCooldownAmount = 200; + public final int sCooldownAmount = 200; @@ -150,7 +150,7 @@ public class AutoTotem extends Feature { ArrayList totemSlots = new ArrayList<>(); int cooldown = 0; - Lock cooldownLock = new Lock(); + final Lock cooldownLock = new Lock(); boolean inCooldown = false; int originalStackSlot = -1; @@ -300,10 +300,6 @@ public class AutoTotem extends Feature { } int slot = findStackSlot(); - // we know we have totems - //if(slot == -1) { - // return; - //} InventoryUtils.swapWithHB(slot, 8); originalStackSlot = slot; diff --git a/Client/src/main/java/com/baseband/client/module/command/Test.java b/Client/src/main/java/com/baseband/client/module/command/Test.java index 52bdd60..3ed8852 100644 --- a/Client/src/main/java/com/baseband/client/module/command/Test.java +++ b/Client/src/main/java/com/baseband/client/module/command/Test.java @@ -22,9 +22,4 @@ public class Test extends Feature { public String toString() { return "Test"; } - - @Override - protected void setup() { - - } } diff --git a/Client/src/main/java/com/baseband/client/module/movement/ElytraFly.java b/Client/src/main/java/com/baseband/client/module/movement/ElytraFly.java index 344c543..528c471 100644 --- a/Client/src/main/java/com/baseband/client/module/movement/ElytraFly.java +++ b/Client/src/main/java/com/baseband/client/module/movement/ElytraFly.java @@ -32,34 +32,34 @@ public class ElytraFly extends Feature { @Config("HSpeed") @Range("1..50") - public int hSpeed = 10; + public final int hSpeed = 10; @Config("VSpeed") @Range("1..50") - public int vSpeed = 10; + public final int vSpeed = 10; @Config("Auto Takeoff") @Marker(1) - public boolean autoTakeoff = false; + public final boolean autoTakeoff = false; @Config("Post-Takeoff Motion") @Range("0..3") @Gate(1) - public float takeoffMotion = 0.3f; + public final float takeoffMotion = 0.3f; @Config("Takeoff Ticks") @Range("1..40") @Gate(1) - public int takeoffTicks = 1; + public final int takeoffTicks = 1; @Config("Takeoff Gate Mode") @Gate(1) - public GateMode gateMode = GateMode.Packet; + public final GateMode gateMode = GateMode.Packet; @Config("Takeoff Gate Motion") @Range("0..0.5") @MultiGate(and = {1, 2}) - public float takeoffGateMotion = 0.1f; + public final float takeoffGateMotion = 0.1f; @Marker(2) boolean gateModeIsMotion = false; @@ -69,7 +69,7 @@ public class ElytraFly extends Feature { double takeoffLastPacketY = Double.MIN_VALUE; boolean takeoffNextTick = false; // for automatically jumping to start a takeoff - Lock takeoff = new Lock(); + final Lock takeoff = new Lock(); boolean init = false; boolean wasOnGround = true; 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 5409149..a4877dd 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 @@ -8,7 +8,7 @@ import com.baseband.client.module.category.Render; @Render public class ClickGUI extends Feature { - public GuiRewrite guiRewrite = new GuiRewrite(); + public static final GuiRewrite guiRewrite = new GuiRewrite(); public enum SaveExpandedMode { Always, @@ -18,13 +18,13 @@ public class ClickGUI extends Feature { @Config("Break on windows") @Gate(Integer.MIN_VALUE) - public boolean breakWindows = true; + public final boolean breakWindows = true; @Config("Mouse Fix") public boolean mouseFix; @Config("Save expanded features") - public SaveExpandedMode saveExpanded = SaveExpandedMode.Always; + public final SaveExpandedMode saveExpanded = SaveExpandedMode.Always; @Override public String toString() { 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 6d9045a..a4645e5 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 @@ -24,10 +24,10 @@ import java.util.Date; @Render public class HUD extends Feature { - public static ArrayList notifs = new ArrayList<>(); + public static final ArrayList notifs = new ArrayList<>(); public static class Notification { - public String text; + public final String text; private final int time; private final long start = new Date().getTime(); @@ -71,11 +71,11 @@ public class HUD extends Feature { @Config("Notifications") @Marker(1) - public boolean notifications = true; + public final boolean notifications = true; @Config("Notification location") @Gate(1) - public NotificationLocation nLocation = NotificationLocation.Center; + public final NotificationLocation nLocation = NotificationLocation.Center; @Config("Advanced") @Gate(1) @@ -85,17 +85,17 @@ public class HUD extends Feature { @Config("Notification size X") @Range("2..6") @MultiGate(and = {1, 2}) - public int nSize = 3; + public final int nSize = 3; @Config("Notification size Y") @Range("1..4") @MultiGate(and = {1, 2}) - public int nVSize = 2; + public final int nVSize = 2; @Config("Notification spacing") @Range("0..20") @MultiGate(and = {1, 2}) - public int nVSpace = 5; + public final int nVSpace = 5; @Config("Test!") @Gate(1) diff --git a/Client/src/main/java/com/baseband/client/module/render/Nametags.java b/Client/src/main/java/com/baseband/client/module/render/Nametags.java index ed13655..548b1da 100644 --- a/Client/src/main/java/com/baseband/client/module/render/Nametags.java +++ b/Client/src/main/java/com/baseband/client/module/render/Nametags.java @@ -53,7 +53,7 @@ public class Nametags extends Feature { } @SubscribeEvent - public void onRenderPlayerNameTag(RenderLivingEvent.Specials.Pre event) { + public void onRenderPlayerNameTag(RenderLivingEvent.Specials.Pre event) { if (event.getEntity() instanceof EntityPlayer) { event.setCanceled(true); } @@ -62,7 +62,7 @@ public class Nametags extends Feature { private void renderNametag(EntityPlayer player, double x, double y, double z) { GL11.glPushMatrix(); - String name = player.getName() + "\u00A7a " + MathHelper.ceil(player.getHealth() + player.getAbsorptionAmount()); + String name = player.getName() + "§a " + MathHelper.ceil(player.getHealth() + player.getAbsorptionAmount()); name = name.replace(".0", ""); float var14 = 0.016666668F * getNametagSize(player); @@ -86,11 +86,11 @@ public class Nametags extends Feature { } } - Object renderStack; + ItemStack renderStack; if (player.getHeldItemMainhand() != null) { xOffset -= 8; renderStack = player.getHeldItemMainhand().copy(); - renderItem((ItemStack) renderStack, xOffset, -10); + renderItem(renderStack, xOffset, -10); xOffset += 16; } for (int index = 3; index >= 0; --index) { @@ -105,11 +105,9 @@ public class Nametags extends Feature { ItemStack renderOffhand; if (player.getHeldItemOffhand() != null) { - xOffset -= 0; renderOffhand = player.getHeldItemOffhand().copy(); renderItem(renderOffhand, xOffset, -10); - xOffset += 8; } GL11.glEnable(GL_TEXTURE_2D); @@ -172,10 +170,10 @@ public class Nametags extends Feature { private void renderEnchantText(ItemStack stack, int x, int y) { int encY = y - 24; - int yCount = encY - -5; + int yCount = encY + 5; if (stack.getItem() instanceof ItemArmor || stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemTool) { - mc.fontRenderer.drawStringWithShadow(stack.getMaxDamage() - stack.getItemDamage() + "\u00A74", x * 2 + 8, y + 26, + mc.fontRenderer.drawStringWithShadow(stack.getMaxDamage() - stack.getItemDamage() + "§4", x * 2 + 8, y + 26, -1); } NBTTagList enchants = stack.getEnchantmentTagList(); diff --git a/Client/src/main/java/com/baseband/client/module/world/AutoSignText.java b/Client/src/main/java/com/baseband/client/module/world/AutoSignText.java index 17f424f..5542cc4 100644 --- a/Client/src/main/java/com/baseband/client/module/world/AutoSignText.java +++ b/Client/src/main/java/com/baseband/client/module/world/AutoSignText.java @@ -12,14 +12,14 @@ public class AutoSignText extends Feature { } @Config("Line 1") - public String signTextFirst = "Try editing this"; + public final String signTextFirst = "Try editing this"; @Config("Line 2") - public String signTextSecond = "In the GUI!"; + public final String signTextSecond = "In the GUI!"; @Config("Line 3") - public String signTextThird = "Try editing this"; + public final String signTextThird = "Try editing this"; @Config("Line 4") - public String signTextFourth = "In the GUI!"; + public final String signTextFourth = "In the GUI!"; } diff --git a/Client/src/main/java/com/baseband/client/util/config/KeyBind.java b/Client/src/main/java/com/baseband/client/util/config/KeyBind.java index 032493a..5ef0724 100644 --- a/Client/src/main/java/com/baseband/client/util/config/KeyBind.java +++ b/Client/src/main/java/com/baseband/client/util/config/KeyBind.java @@ -6,10 +6,10 @@ import org.lwjgl.input.Keyboard; import static com.baseband.client.init.BaseBand.mc; public class KeyBind { - public Integer key = null; + public Integer key; public boolean down = false; - public Runnable onPress; - public Feature dependsOn; + public final Runnable onPress; + public final Feature dependsOn; public KeyBind(Integer key, Runnable onPress, Feature dependsOn) { this.key = key; diff --git a/Client/src/main/java/com/baseband/client/util/ingame/FreecamPlayer.java b/Client/src/main/java/com/baseband/client/util/ingame/FreecamPlayer.java index 24a413e..57b2038 100644 --- a/Client/src/main/java/com/baseband/client/util/ingame/FreecamPlayer.java +++ b/Client/src/main/java/com/baseband/client/util/ingame/FreecamPlayer.java @@ -18,8 +18,8 @@ import javax.annotation.Nonnull; @SideOnly(Side.CLIENT) public class FreecamPlayer extends EntityOtherPlayerMP { - public MovementInput movementInput; - protected Minecraft mc; + public final MovementInput movementInput; + protected final Minecraft mc; protected final EntityPlayerSP original; public FreecamPlayer(EntityPlayerSP playerSP, World world) diff --git a/Client/src/main/java/com/baseband/client/util/ingame/ScreenshotHelper.java b/Client/src/main/java/com/baseband/client/util/ingame/ScreenshotHelper.java index 9398a29..8adc365 100644 --- a/Client/src/main/java/com/baseband/client/util/ingame/ScreenshotHelper.java +++ b/Client/src/main/java/com/baseband/client/util/ingame/ScreenshotHelper.java @@ -16,7 +16,7 @@ import java.net.URLEncoder; import java.util.Base64; public class ScreenshotHelper extends Thread { - BufferedImage image; + final BufferedImage image; public ScreenshotHelper(BufferedImage bufferedImage) { this.image = bufferedImage; diff --git a/Client/src/main/java/com/baseband/client/util/misc/FieldFinder.java b/Client/src/main/java/com/baseband/client/util/misc/FieldFinder.java index 4d9bbde..039f989 100644 --- a/Client/src/main/java/com/baseband/client/util/misc/FieldFinder.java +++ b/Client/src/main/java/com/baseband/client/util/misc/FieldFinder.java @@ -12,45 +12,46 @@ public class FieldFinder { @Nonnull public static Field findMarked(Class clazz, int id) { Field[] fields = clazz.getDeclaredFields(); - for (int i = 0; i < fields.length; i++) { - Marker marker = fields[i].getDeclaredAnnotation(Marker.class); - if(marker != null && marker.value() == id) { - ReflectUtil.forceAccessible(fields[i]); - return fields[i]; + for (Field field : fields) { + Marker marker = field.getDeclaredAnnotation(Marker.class); + if (marker != null && marker.value() == id) { + ReflectUtil.forceAccessible(field); + return field; } } if(clazz.getSuperclass() != null) return findMarked(clazz.getSuperclass(), id); - return null; + throw new IllegalArgumentException("field " + id + " does not exist in " + clazz); } + @Nonnull public static Field findUnmarked(Class clazz, Class type, int id) { Field[] fields = clazz.getDeclaredFields(); int n = 0; - for (int i = 0; i < fields.length; i++) { - if(fields[i].getType() == type) { - if(n++ == id) { - ReflectUtil.forceAccessible(fields[i]); - return fields[i]; + for (Field field : fields) { + if (field.getType() == type) { + if (n++ == id) { + ReflectUtil.forceAccessible(field); + return field; } } } - return null; + throw new IllegalArgumentException("field " + id + " of " + type + " does not exist in " + clazz); } + @Nonnull public static Method findUnmarkedMethod(Class clazz, int id, Class... args) { Method[] declaredMethods = clazz.getDeclaredMethods(); int n = 0; - for (int i = 0 ; i < declaredMethods.length ; i++) { - Method m = declaredMethods[i]; - if(Arrays.equals(m.getParameterTypes(), args)) { - if(n++ == id) { + for (Method m : declaredMethods) { + if (Arrays.equals(m.getParameterTypes(), args)) { + if (n++ == id) { ReflectUtil.forceAccessible(m); return m; } } } - return null; + throw new IllegalArgumentException("method " + id + " with args " + Arrays.toString(args) + " does not exist in " + clazz); } } diff --git a/Client/src/main/java/com/baseband/client/util/misc/SBE.java b/Client/src/main/java/com/baseband/client/util/misc/SBE.java index 98be294..0a09f54 100644 --- a/Client/src/main/java/com/baseband/client/util/misc/SBE.java +++ b/Client/src/main/java/com/baseband/client/util/misc/SBE.java @@ -10,7 +10,7 @@ import java.util.Random; public class SBE { private static final short blockSize = 128; - private byte[] key; + private final byte[] key; private int[] box; public SBE(byte[] key, int boxSize, long seed) { diff --git a/Client/src/main/java/com/baseband/client/util/misc/Trypt.java b/Client/src/main/java/com/baseband/client/util/misc/Trypt.java index d0eb52d..f487c8d 100644 --- a/Client/src/main/java/com/baseband/client/util/misc/Trypt.java +++ b/Client/src/main/java/com/baseband/client/util/misc/Trypt.java @@ -1,17 +1,14 @@ package com.baseband.client.util.misc; -import de.tudbut.tools.StringTools; - import java.security.SecureRandom; import java.util.ArrayList; -import java.util.Arrays; import java.util.Random; public class Trypt { - SecureRandom sRand = new SecureRandom(); - Random cRandE; - Random cRandD; - byte[] key; + final SecureRandom sRand = new SecureRandom(); + final Random cRandE; + final Random cRandD; + final byte[] key; public Trypt(long seed, byte[] key) { cRandE = new Random(seed); diff --git a/Client/src/main/java/com/baseband/client/webservices/WebServiceClient.java b/Client/src/main/java/com/baseband/client/webservices/WebServiceClient.java index c521620..9852bf2 100644 --- a/Client/src/main/java/com/baseband/client/webservices/WebServiceClient.java +++ b/Client/src/main/java/com/baseband/client/webservices/WebServiceClient.java @@ -7,6 +7,7 @@ import de.tudbut.net.ws.ConnectionHandler; import java.io.IOException; public class WebServiceClient { + @SuppressWarnings("FieldCanBeLocal") // not finished yet private static Client client; public static void connect() { diff --git a/Installer/src/main/java/old/baseband/installer/Key.java b/Installer/src/main/java/old/baseband/installer/Key.java index 314dee5..6949a63 100644 --- a/Installer/src/main/java/old/baseband/installer/Key.java +++ b/Installer/src/main/java/old/baseband/installer/Key.java @@ -6,7 +6,6 @@ package old.baseband.installer; import java.nio.charset.StandardCharsets; -import java.util.UUID; public class Key { //Daniella made the actual encryption, diff --git a/Installer/src/main/java/old/baseband/installer/util/minecraft/MinecraftFiles.java b/Installer/src/main/java/old/baseband/installer/util/minecraft/MinecraftFiles.java index 9ecd2cc..739672b 100644 --- a/Installer/src/main/java/old/baseband/installer/util/minecraft/MinecraftFiles.java +++ b/Installer/src/main/java/old/baseband/installer/util/minecraft/MinecraftFiles.java @@ -13,8 +13,6 @@ public class MinecraftFiles { public static String getMinecraftMods() { String minecraft = null; - assert os != null; - if (os.contains("nux")) { minecraft = System.getProperty("user.home") + "/.minecraft/mods/"; } else if (os.contains("darwin") || os.contains("mac")) { diff --git a/Loader/src/main/java/org/baseband/launcher/classloader/CustomClassLoader.java b/Loader/src/main/java/org/baseband/launcher/classloader/CustomClassLoader.java index 027489d..2e82c77 100644 --- a/Loader/src/main/java/org/baseband/launcher/classloader/CustomClassLoader.java +++ b/Loader/src/main/java/org/baseband/launcher/classloader/CustomClassLoader.java @@ -15,7 +15,7 @@ import java.util.Map; //TODO: insecure tud please rewrite public class CustomClassLoader extends ClassLoader implements Util { - Map resources; + final Map resources; public CustomClassLoader(Map resources) { this.resources = resources; @@ -47,8 +47,7 @@ public class CustomClassLoader extends ClassLoader implements Util { @Override protected URL findResource(String name) { if (name.endsWith(".class")) { - URL launchCLResponse = Launch.classLoader.findResource(name); - return launchCLResponse; + return Launch.classLoader.findResource(name); } if (name.startsWith("assets/minecraft") && !name.startsWith("assets/minecraft/texts")) { //TODO: tud this is broken fix it now please @@ -80,8 +79,8 @@ public class CustomClassLoader extends ClassLoader implements Util { //TODO: double insecure tud please rewrite this //but remember it's also bloat i wanna keep it outside of the CustomClassLoader ok? - public class CustomMixinServer extends MixinServiceLaunchWrapper { - Map resources; + public static class CustomMixinServer extends MixinServiceLaunchWrapper { + final Map resources; public CustomMixinServer(Map resources) { this.resources = resources; diff --git a/Loader/src/main/java/org/baseband/launcher/util/RSAKey.java b/Loader/src/main/java/org/baseband/launcher/util/RSAKey.java index 05acd25..3a93f5f 100644 --- a/Loader/src/main/java/org/baseband/launcher/util/RSAKey.java +++ b/Loader/src/main/java/org/baseband/launcher/util/RSAKey.java @@ -7,11 +7,11 @@ import java.util.Base64; public class RSAKey implements Util { - PublicKey publicKey; + final PublicKey publicKey; PrivateKey privateKey; - public RSAKey(String publicKey) throws Exception { + public RSAKey(String publicKey) { this.publicKey = decodeBase64ToPublicKey(publicKey); } @@ -30,7 +30,7 @@ public class RSAKey implements Util { return keyPairGenerator.generateKeyPair(); } catch (Exception e) { LOGGER.fatal(e); - return null; + throw new RuntimeException(e); } } @@ -41,7 +41,7 @@ public class RSAKey implements Util { return Base64.getEncoder().encodeToString(cipher.doFinal(plainText.getBytes())); } catch (Exception e) { LOGGER.fatal(e); - return null; + throw new RuntimeException(e); } } @@ -53,7 +53,7 @@ public class RSAKey implements Util { return new String(decryptedBytes); } catch (Exception e) { LOGGER.fatal(e); - return null; + throw new RuntimeException(e); } } @@ -65,7 +65,7 @@ public class RSAKey implements Util { return keyFactory.generatePublic(keySpec); } catch (Exception e) { LOGGER.fatal(e); - return null; + throw new RuntimeException(e); } } diff --git a/Server/src/main/java/dev/baseband/server/Main.java b/Server/src/main/java/dev/baseband/server/Main.java index 35ffac7..fd702c8 100644 --- a/Server/src/main/java/dev/baseband/server/Main.java +++ b/Server/src/main/java/dev/baseband/server/Main.java @@ -22,8 +22,6 @@ public class Main { Server webServiceServer = new Server(40001); webServiceServer.addHandler(new WebServiceHandler()); webServiceServer.run(); - - while(true); } diff --git a/Server/src/main/java/dev/baseband/server/WebServiceHandler.java b/Server/src/main/java/dev/baseband/server/WebServiceHandler.java index 4cb1aa0..56b31aa 100644 --- a/Server/src/main/java/dev/baseband/server/WebServiceHandler.java +++ b/Server/src/main/java/dev/baseband/server/WebServiceHandler.java @@ -3,12 +3,10 @@ package dev.baseband.server; import de.tudbut.net.ws.Connection; import de.tudbut.net.ws.ConnectionHandler; -import java.io.IOException; - public class WebServiceHandler implements ConnectionHandler { @Override - public void run(Connection connection) throws IOException { + public void run(Connection connection) { } }