Skip to content

Commit

Permalink
Display in the module screen which addon it came from. (#4947)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wide-Cat authored Oct 11, 2024
1 parent ac96267 commit 4696ec1
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public void onInitializeClient() {
AddonManager.init();

// Register event handlers
EVENT_BUS.registerLambdaFactory(ADDON.getPackage() , (lookupInMethod, klass) -> (MethodHandles.Lookup) lookupInMethod.invoke(null, klass, MethodHandles.lookup()));
AddonManager.ADDONS.forEach(addon -> {
try {
EVENT_BUS.registerLambdaFactory(addon.getPackage(), (lookupInMethod, klass) -> (MethodHandles.Lookup) lookupInMethod.invoke(null, klass, MethodHandles.lookup()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public String getCommit() {
for (Person author : metadata.getAuthors()) {
MeteorClient.ADDON.authors[i++] = author.getName();
}

ADDONS.add(MeteorClient.ADDON);
}

// Addons
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package meteordevelopment.meteorclient.gui.screens;

import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.events.meteor.ActiveModulesChangedEvent;
import meteordevelopment.meteorclient.events.meteor.ModuleBindChangedEvent;
import meteordevelopment.meteorclient.gui.GuiTheme;
Expand Down Expand Up @@ -93,12 +94,17 @@ public void initWidgets() {
// Bottom
WHorizontalList bottom = add(theme.horizontalList()).expandX().widget();

// Active
// Active
bottom.add(theme.label("Active: "));
active = bottom.add(theme.checkbox(module.isActive())).expandCellX().widget();
active.action = () -> {
if (module.isActive() != active.checked) module.toggle();
};

if (module.addon != null && module.addon != MeteorClient.ADDON) {
bottom.add(theme.label("From: ")).right().widget();
bottom.add(theme.label(module.addon.name).color(theme.textSecondaryColor())).right().widget();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
package meteordevelopment.meteorclient.systems.modules;

import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.addons.AddonManager;
import meteordevelopment.meteorclient.addons.MeteorAddon;
import meteordevelopment.meteorclient.gui.GuiTheme;
import meteordevelopment.meteorclient.gui.widgets.WWidget;
import meteordevelopment.meteorclient.settings.Settings;
Expand Down Expand Up @@ -33,6 +35,7 @@ public abstract class Module implements ISerializable<Module>, Comparable<Module
public final String description;
public final Color color;

public final MeteorAddon addon;
public final Settings settings = new Settings();

private boolean active;
Expand All @@ -53,6 +56,16 @@ public Module(Category category, String name, String description) {
this.title = Utils.nameToTitle(name);
this.description = description;
this.color = Color.fromHsv(Utils.random(0.0, 360.0), 0.35, 1);

String classname = this.getClass().getName();
for (MeteorAddon addon : AddonManager.ADDONS) {
if (classname.startsWith(addon.getPackage())) {
this.addon = addon;
return;
}
}

this.addon = null;
}

public WWidget getWidget(GuiTheme theme) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

package meteordevelopment.meteorclient.utils;

import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.addons.AddonManager;
import meteordevelopment.meteorclient.addons.MeteorAddon;
import org.reflections.Reflections;
Expand All @@ -24,8 +23,6 @@ private ReflectInit() {
}

public static void registerPackages() {
add(MeteorClient.ADDON);

for (MeteorAddon addon : AddonManager.ADDONS) {
try {
add(addon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ private TitleScreenCredits() {

private static void init() {
// Add addons
add(MeteorClient.ADDON);
for (MeteorAddon addon : AddonManager.ADDONS) add(addon);

// Sort by width (Meteor always first)
Expand Down

0 comments on commit 4696ec1

Please sign in to comment.