Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Commit

Permalink
Improvements (ProxyWindow, Surround, LegitHelper, BreadCrumbs, etc.)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pan4ur committed Jul 21, 2024
1 parent bb494c6 commit c4433a6
Show file tree
Hide file tree
Showing 45 changed files with 533 additions and 393 deletions.
3 changes: 0 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ dependencies {
libImpl("io.netty:netty-handler-proxy:${project.netty_version}") { transitive = false }
libImpl("io.netty:netty-codec-socks:${project.netty_version}") { transitive = false }


compileOnlyApi("org.apiguardian:apiguardian-api:1.1.2")

configurations.libImpl.dependencies.each {
implementation(it)
}
Expand Down
170 changes: 35 additions & 135 deletions src/main/java/thunder/hack/ThunderHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
import meteordevelopment.orbit.IEventBus;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.entrypoint.EntrypointContainer;
import net.fabricmc.loader.api.metadata.ModMetadata;
import net.minecraft.client.MinecraftClient;
import net.minecraft.util.math.BlockPos;
import thunder.hack.api.IAddon;
import thunder.hack.core.Core;
import thunder.hack.core.impl.*;
import thunder.hack.utility.ThunderUtility;
Expand All @@ -21,28 +19,29 @@
import java.lang.invoke.MethodHandles;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Objects;


public class ThunderHack implements ModInitializer {
public static final ModMetadata MOD_META;


public static final String MOD_ID = "thunderhack";
public static final String VERSION = "1.6b305";
public static String GITH_HASH = "0";
public static String BUILD_DATE = "1 Jan 1970";

public static final IEventBus EVENT_BUS = new EventBus();
public static MinecraftClient mc;
public static final boolean baritone = FabricLoader.getInstance().isModLoaded("baritone") || FabricLoader.getInstance().isModLoaded("baritone-meteor");

public static final IEventBus EVENT_BUS = new EventBus();
public static String[] contributors = new String[32];
public static Color copy_color = new Color(-1);
public static KeyListening currentKeyListener;
public static boolean isOutdated = false;
public static float TICK_TIMER = 1f;
public static BlockPos gps_position;
public static Color copy_color = new Color(-1);
public static float TICK_TIMER = 1f;
public static MinecraftClient mc;
public static long initTime;
public static KeyListening currentKeyListener;
public static String[] contributors = new String[16];
public static final boolean baritone = FabricLoader.getInstance().isModLoaded("baritone") || FabricLoader.getInstance().isModLoaded("baritone-meteor");


/*----------------- Managers ---------------------*/
public static NotificationManager notificationManager = new NotificationManager();
Expand All @@ -55,6 +54,7 @@ public class ThunderHack implements ModInitializer {
public static CombatManager combatManager = new CombatManager();
public static ConfigManager configManager = new ConfigManager();
public static ShaderManager shaderManager = new ShaderManager();
public static AddonManager addonManager = new AddonManager();
public static AsyncManager asyncManager = new AsyncManager();
public static MacroManager macroManager = new MacroManager();
public static SoundManager soundManager = new SoundManager();
Expand All @@ -65,18 +65,18 @@ public class ThunderHack implements ModInitializer {
/*--------------------------------------------------------*/

static {
MOD_META = FabricLoader.getInstance()
.getModContainer(MOD_ID)
.orElseThrow()
.getMetadata();
MOD_META = FabricLoader.getInstance().getModContainer(MOD_ID).orElseThrow().getMetadata();
}


@Override
public void onInitialize() {
mc = MinecraftClient.getInstance();
initTime = System.currentTimeMillis();

BUILD_DATE = ThunderUtility.readManifestField("Build-Timestamp");
GITH_HASH = ThunderUtility.readManifestField("Git-Commit");
ThunderUtility.syncVersion();

EVENT_BUS.registerLambdaFactory("thunder.hack", (lookupInMethod, klass) -> (MethodHandles.Lookup) lookupInMethod.invoke(null, klass, MethodHandles.lookup()));

EVENT_BUS.subscribe(notificationManager);
Expand All @@ -87,107 +87,25 @@ public void onInitialize() {
EVENT_BUS.subscribe(telemetryManager);
EVENT_BUS.subscribe(core);

FriendManager.loadFriends();

LogUtils.getLogger().info("Starting addon initialization.");

for (EntrypointContainer<IAddon> entrypoint : FabricLoader.getInstance().getEntrypointContainers("thunderhack", IAddon.class)) {
IAddon addon = entrypoint.getEntrypoint();

try {
LogUtils.getLogger().info("Initializing addon: " + addon.getClass().getName());
LogUtils.getLogger().debug("Addon class loader: " + addon.getClass().getClassLoader());
addon.onInitialize();
LogUtils.getLogger().info("Addon initialized successfully: " + addon.getClass().getName());

AddonManager.incrementAddonCount();
LogUtils.getLogger().debug("Addon count incremented.");

AddonManager.addAddon(addon);
LogUtils.getLogger().debug("Addon added to manager.");
EVENT_BUS.registerLambdaFactory(addon.getPackage(), (lookupInMethod, klass) -> (MethodHandles.Lookup) lookupInMethod.invoke(null, klass, MethodHandles.lookup()));

// Register Modules
addon.getModules().stream().filter(Objects::nonNull).forEach(module -> {
try {
LogUtils.getLogger().info("Registering module: " + module.getClass().getName());
LogUtils.getLogger().debug("Module class loader: " + module.getClass().getClassLoader());
moduleManager.registerModule(module);
LogUtils.getLogger().info("Module registered successfully: " + module.getClass().getName());
} catch (Exception e) {
LogUtils.getLogger().error("Error registering module: " + module.getClass().getName(), e);
}
});

// Register Commands
addon.getCommands().stream().filter(Objects::nonNull).forEach(command -> {
try {
LogUtils.getLogger().info("Registering command: " + command.getClass().getName());
LogUtils.getLogger().debug("Command class loader: " + command.getClass().getClassLoader());
commandManager.registerCommand(command);
LogUtils.getLogger().info("Command registered successfully: " + command.getClass().getName());
} catch (Exception e) {
LogUtils.getLogger().error("Error registering command: " + command.getClass().getName(), e);
}
});

// Register HUD Elements
addon.getHudElements().stream().filter(Objects::nonNull).forEach(hudElement -> {
try {
LogUtils.getLogger().info("Registering HUD element: " + hudElement.getClass().getName());
LogUtils.getLogger().debug("HUD element class loader: " + hudElement.getClass().getClassLoader());
moduleManager.registerHudElement(hudElement);
LogUtils.getLogger().info("HUD element registered successfully: " + hudElement.getClass().getName());
} catch (Exception e) {
LogUtils.getLogger().error("Error registering HUD element: " + hudElement.getClass().getName(), e);
}
});

} catch (Exception e) {
LogUtils.getLogger().error("Error initializing addon: " + addon.getClass().getName(), e);
}
}

LogUtils.getLogger().info("Addon initialization complete.");

addonManager.initAddons();
configManager.load(configManager.getCurrentConfig());
moduleManager.onLoad("none");

Runtime.getRuntime().addShutdownHook(new Thread(() -> {
if (ModuleManager.unHook.isEnabled())
ModuleManager.unHook.disable();
FriendManager.saveFriends();
configManager.save(configManager.getCurrentConfig());
wayPointManager.saveWayPoints();
macroManager.saveMacro();
proxyManager.saveProxies();
for (IAddon addon : AddonManager.getAddons()) {
try {
addon.onShutdown();
} catch (Exception e) {
LogUtils.getLogger().error("Error running addon onShutdown method: " + addon.getClass().getName(), e);
}
}
}));

friendManager.loadFriends();
macroManager.onLoad();
wayPointManager.onLoad();
proxyManager.onLoad();
Render2DEngine.initShaders();

BUILD_DATE = ThunderUtility.readManifestField("Build-Timestamp");
GITH_HASH = ThunderUtility.readManifestField("Git-Commit");

soundManager.registerSounds();

// TODO Move to dedicated Thread
syncVersion();
syncContributors();
ThunderUtility.parseStarGazer();
ThunderUtility.parseCommits();
ModuleManager.rpc.startRpc();
asyncManager.run(() -> {
ThunderUtility.syncContributors();
ThunderUtility.parseStarGazer();
ThunderUtility.parseCommits();
telemetryManager.fetchData();
});

telemetryManager.fetchData();
ModuleManager.rpc.startRpc();

LogUtils.getLogger().info("""
\n /$$$$$$$$ /$$ /$$ /$$ /$$ /$$ \s
Expand All @@ -202,42 +120,24 @@ public void onInitialize() {

LogUtils.getLogger().info("[ThunderHack] Init time: " + (System.currentTimeMillis() - initTime) + " ms.");
initTime = System.currentTimeMillis();
}

public static void syncVersion() {
try {
if (!new BufferedReader(new InputStreamReader(new URL("https://raw.githubusercontent.com/Pan4ur/THRecodeUtil/main/syncVersionBeta.txt").openStream())).readLine().equals(VERSION))
isOutdated = true;
} catch (Exception ignored) {
}
}
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
if (ModuleManager.unHook.isEnabled()) ModuleManager.unHook.disable();

public static void syncContributors() {
try {
URL list = new URL("https://raw.githubusercontent.com/Pan4ur/THRecodeUtil/main/thTeam.txt");
BufferedReader in = new BufferedReader(new InputStreamReader(list.openStream(), StandardCharsets.UTF_8));
String inputLine;
int i = 0;
while ((inputLine = in.readLine()) != null) {
contributors[i] = inputLine.trim();
i++;
}
in.close();
} catch (Exception e) {
e.printStackTrace();
}
friendManager.saveFriends();
configManager.save(configManager.getCurrentConfig());
wayPointManager.saveWayPoints();
macroManager.saveMacro();
proxyManager.saveProxies();
addonManager.shutDown();
}));
}

public static boolean isFuturePresent() {
return !FabricLoader.getInstance().getModContainer("future").isEmpty();
}

public enum KeyListening {
ThunderGui,
ClickGui,
Search,
Sliders,
Strings
ThunderGui, ClickGui, Search, Sliders, Strings
}
}

}
5 changes: 3 additions & 2 deletions src/main/java/thunder/hack/cmd/impl/AddonsCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.minecraft.command.CommandSource;
import thunder.hack.ThunderHack;
import thunder.hack.api.IAddon;
import thunder.hack.cmd.Command;
import thunder.hack.core.impl.AddonManager;
Expand All @@ -20,10 +21,10 @@ public AddonsCommand() {
@Override
public void executeBuild(LiteralArgumentBuilder<CommandSource> builder) {
builder.executes(context -> {
List<IAddon> sortedAddons = AddonManager.getAddons().stream()
List<IAddon> sortedAddons = ThunderHack.addonManager.getAddons().stream()
.filter(Objects::nonNull)
.sorted(Comparator.comparing(IAddon::getName))
.collect(Collectors.toList());
.toList();

if (sortedAddons.isEmpty()) {
sendMessage("No addons installed.");
Expand Down
36 changes: 36 additions & 0 deletions src/main/java/thunder/hack/cmd/impl/GamemodeCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package thunder.hack.cmd.impl;

import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.minecraft.command.CommandSource;
import net.minecraft.world.GameMode;
import thunder.hack.cmd.Command;

import static com.mojang.brigadier.Command.SINGLE_SUCCESS;

public class GamemodeCommand extends Command {
public GamemodeCommand() {
super("gamemode", "gm");
}

@Override
public void executeBuild(LiteralArgumentBuilder<CommandSource> builder) {

builder.then(arg("mode", StringArgumentType.greedyString()).executes(context -> {
final String mode = context.getArgument("mode", String.class);

switch (mode) {
case "survival", "0":
mc.interactionManager.setGameMode(GameMode.SURVIVAL);
case "creative", "1":
mc.interactionManager.setGameMode(GameMode.CREATIVE);
case "spectator", "2":
mc.interactionManager.setGameMode(GameMode.SPECTATOR);
case "adventure", "3":
mc.interactionManager.setGameMode(GameMode.ADVENTURE);
}

return SINGLE_SUCCESS;
}));
}
}
4 changes: 2 additions & 2 deletions src/main/java/thunder/hack/core/Core.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void onTick(PlayerUpdateEvent event) {
});

if(autoSave.every(600000)) {
FriendManager.saveFriends();
ThunderHack.friendManager.saveFriends();
ThunderHack.configManager.save(ThunderHack.configManager.getCurrentConfig());
ThunderHack.wayPointManager.saveWayPoints();
ThunderHack.macroManager.saveMacro();
Expand Down Expand Up @@ -142,7 +142,7 @@ public void onPacketReceive(PacketEvent.Receive e) {
setBackTimer.reset();

if(autoSave.every(200000)) {
FriendManager.saveFriends();
ThunderHack.friendManager.saveFriends();
ThunderHack.configManager.save(ThunderHack.configManager.getCurrentConfig());
ThunderHack.wayPointManager.saveWayPoints();
ThunderHack.macroManager.saveMacro();
Expand Down
Loading

0 comments on commit c4433a6

Please sign in to comment.