feat: implemented auto service for modules

This commit is contained in:
ftbsc 2023-02-28 23:00:03 +01:00
parent e82f1cc5e6
commit 930ccf34c7
24 changed files with 82 additions and 75 deletions

View file

@ -92,9 +92,11 @@ dependencies {
minecraft "net.minecraftforge:forge:${minecraftVersion}-${forgeVersion}" minecraft "net.minecraftforge:forge:${minecraftVersion}-${forgeVersion}"
implementation 'ftbsc:lll:0.2.2' implementation 'ftbsc:lll:0.2.2'
implementation 'ftbsc.lll:processor:0.1.1' implementation 'ftbsc.lll:processor:0.1.1'
implementation 'com.google.auto.service:auto-service-annotations:1.0.1'
annotationProcessor 'com.squareup:javapoet:1.13.0' annotationProcessor 'com.squareup:javapoet:1.13.0'
annotationProcessor 'ftbsc:lll:0.2.2' annotationProcessor 'ftbsc:lll:0.2.2'
annotationProcessor 'ftbsc.lll:processor:0.1.1' annotationProcessor 'ftbsc.lll:processor:0.1.1'
annotationProcessor 'com.google.auto.service:auto-service:1.0.1'
} }
jar { jar {

View file

@ -28,12 +28,6 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import ftbsc.bscv.modules.vision.*;
import ftbsc.bscv.modules.motion.*;
import ftbsc.bscv.modules.self.*;
import ftbsc.bscv.modules.hud.*;
import ftbsc.bscv.modules.defense.*;
@Mod("bscv") @Mod("bscv")
public class BoSCoVicino implements ICommons { public class BoSCoVicino implements ICommons {
public static String MOD_ID = "bscv"; public static String MOD_ID = "bscv";
@ -52,24 +46,7 @@ public class BoSCoVicino implements ICommons {
ForgeConfigSpec.Builder cfg = new ForgeConfigSpec.Builder(); ForgeConfigSpec.Builder cfg = new ForgeConfigSpec.Builder();
CommandDispatcher<CommandSource> dp = this.dispatcher; CommandDispatcher<CommandSource> dp = this.dispatcher;
this.modManager = new ModManager(cfg, dp); BoSCoVicino.modManager = new ModManager(cfg, dp);
this.modManager.registerMod(new AutoDisconnect());
this.modManager.registerMod(new ActiveModules());
this.modManager.registerMod(new VanillaFlight());
this.modManager.registerMod(new FastInteract());
this.modManager.registerMod(new InfoDisplay());
this.modManager.registerMod(new Coordinates());
this.modManager.registerMod(new EntityList());
this.modManager.registerMod(new PlayerList());
this.modManager.registerMod(new Fullbright());
this.modManager.registerMod(new AntiHunger());
this.modManager.registerMod(new PortalGui());
this.modManager.registerMod(new AutoFish());
this.modManager.registerMod(new AutoTool());
this.modManager.registerMod(new Freecam());
this.modManager.registerMod(new BoatFly());
this.modManager.registerMod(new Aura());
BoSCoVicino.spec = cfg.build(); BoSCoVicino.spec = cfg.build();
@ -90,7 +67,7 @@ public class BoSCoVicino implements ICommons {
private void clientSetup(final FMLClientSetupEvent event) { private void clientSetup(final FMLClientSetupEvent event) {
LOGGER.info("Initializing modules"); LOGGER.info("Initializing modules");
for (IModule<?> m : modManager.mods) { for (IModule m : modManager.mods) {
if (m.isEnabled()) m.enable(); if (m.isEnabled()) m.enable();
} }
@ -127,7 +104,7 @@ public class BoSCoVicino implements ICommons {
dispatcher.register( dispatcher.register(
Commands.literal("toggle-all") Commands.literal("toggle-all")
.executes(ctx -> { .executes(ctx -> {
for (IModule<?> mod : modManager.mods) { for (IModule mod : modManager.mods) {
if (mod.isEnabled()) { if (mod.isEnabled()) {
mod.disable(); mod.disable();
mod.enable(); mod.enable();

View file

@ -3,8 +3,8 @@ package ftbsc.bscv.api;
import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
public interface IModule<T extends Enum<T>> extends ICommand { public interface IModule extends ICommand {
T getGroup(); String getGroup();
ForgeConfigSpec.Builder getConfigBuilder(); ForgeConfigSpec.Builder getConfigBuilder();

View file

@ -5,7 +5,6 @@ import com.mojang.brigadier.arguments.BoolArgumentType;
import ftbsc.bscv.BoSCoVicino; import ftbsc.bscv.BoSCoVicino;
import ftbsc.bscv.api.IModule; import ftbsc.bscv.api.IModule;
import ftbsc.bscv.system.ModManager;
import net.minecraft.command.CommandSource; import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands; import net.minecraft.command.Commands;
import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec;
@ -13,16 +12,7 @@ import net.minecraftforge.common.MinecraftForge;
import static ftbsc.bscv.BoSCoVicino.log; import static ftbsc.bscv.BoSCoVicino.log;
public abstract class AbstractModule implements IModule<AbstractModule.Group> { public abstract class AbstractModule implements IModule {
public enum Group {
SELF,
HUD,
BUILD,
DEFENSE,
VISION,
MOTION,
}
protected ForgeConfigSpec.ConfigValue<Boolean> enabled; protected ForgeConfigSpec.ConfigValue<Boolean> enabled;
@Override @Override
@ -31,9 +21,9 @@ public abstract class AbstractModule implements IModule<AbstractModule.Group> {
} }
@Override @Override
public Group getGroup() { public String getGroup() {
String[] pkg = this.getClass().getPackage().getName().split("\\."); String[] pkg = this.getClass().getPackage().getName().split("\\.");
return Group.valueOf(pkg[pkg.length - 1].toUpperCase()); return pkg[pkg.length - 1].toUpperCase();
} }
@Override @Override

View file

@ -1,11 +1,8 @@
package ftbsc.bscv.modules; package ftbsc.bscv.modules;
import com.mojang.brigadier.CommandDispatcher;
import ftbsc.bscv.ICommons; import ftbsc.bscv.ICommons;
import ftbsc.bscv.tools.Anchor; import ftbsc.bscv.tools.Anchor;
import ftbsc.bscv.tools.Setting; import ftbsc.bscv.tools.Setting;
import net.minecraft.command.CommandSource;
import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec;
public abstract class HudModule extends AbstractModule { public abstract class HudModule extends AbstractModule {
@ -16,8 +13,8 @@ public abstract class HudModule extends AbstractModule {
public final ForgeConfigSpec.ConfigValue<Anchor> anchor; public final ForgeConfigSpec.ConfigValue<Anchor> anchor;
@Override @Override
public Group getGroup() { public String getGroup() {
return Group.HUD; return "HUD";
} }
protected HudModule() { protected HudModule() {

View file

@ -1,19 +1,18 @@
package ftbsc.bscv.modules; package ftbsc.bscv.modules;
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.client.settings.KeyBinding; import net.minecraft.client.settings.KeyBinding;
import net.minecraft.client.util.InputMappings; import net.minecraft.client.util.InputMappings;
import net.minecraft.command.CommandSource;
import net.minecraftforge.client.event.InputEvent; import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.client.registry.ClientRegistry;
import ftbsc.bscv.BoSCoVicino; import ftbsc.bscv.BoSCoVicino;
import ftbsc.bscv.api.ILoadable;
import com.google.auto.service.AutoService;
// TODO rename // TODO rename
@AutoService(ILoadable.class)
public abstract class QuickModule extends AbstractModule { public abstract class QuickModule extends AbstractModule {
public static final int UNBOUND = InputMappings.UNKNOWN.getValue(); public static final int UNBOUND = InputMappings.UNKNOWN.getValue();

View file

@ -9,7 +9,10 @@ import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.TickEvent.Phase; import net.minecraftforge.event.TickEvent.Phase;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import ftbsc.bscv.api.ILoadable;
import com.google.auto.service.AutoService;
@AutoService(ILoadable.class)
public class Aura extends QuickModule implements ICommons { public class Aura extends QuickModule implements ICommons {
@Override @Override

View file

@ -9,14 +9,17 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import static ftbsc.bscv.tools.Text.TextBuilder; import static ftbsc.bscv.tools.Text.TextBuilder;
import ftbsc.bscv.api.ILoadable;
import com.google.auto.service.AutoService;
@AutoService(ILoadable.class)
public class ActiveModules extends HudModule implements ICommons { public class ActiveModules extends HudModule implements ICommons {
@SubscribeEvent @SubscribeEvent
public void onRenderOverlay(RenderGameOverlayEvent event) { public void onRenderOverlay(RenderGameOverlayEvent event) {
if (event.getType() == ElementType.TEXT) { if (event.getType() == ElementType.TEXT) {
int offset = 0; int offset = 0;
for (IModule<?> m : BoSCoVicino.modManager.mods) { for (IModule m : BoSCoVicino.modManager.mods) {
if (m.isEnabled() && m.getGroup() != Group.HUD) { if (m.isEnabled() && m.getGroup().equalsIgnoreCase("HUD")) {
TextBuilder() TextBuilder()
.txt(String.format("%s <", m.getName())) .txt(String.format("%s <", m.getName()))
.anchor(this.anchor.get()) .anchor(this.anchor.get())

View file

@ -1,18 +1,19 @@
package ftbsc.bscv.modules.hud; package ftbsc.bscv.modules.hud;
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.command.CommandSource;
import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.math.vector.Vector3d;
import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import static ftbsc.bscv.tools.Text.TextBuilder; import static ftbsc.bscv.tools.Text.TextBuilder;
import com.google.auto.service.AutoService;
import ftbsc.bscv.ICommons; import ftbsc.bscv.ICommons;
import ftbsc.bscv.modules.HudModule; import ftbsc.bscv.modules.HudModule;
import ftbsc.bscv.api.ILoadable;
@AutoService(ILoadable.class)
public class Coordinates extends HudModule implements ICommons { public class Coordinates extends HudModule implements ICommons {
@SubscribeEvent @SubscribeEvent
public void onRenderOverlay(RenderGameOverlayEvent event) { public void onRenderOverlay(RenderGameOverlayEvent event) {

View file

@ -21,7 +21,10 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import ftbsc.bscv.api.ILoadable;
import com.google.auto.service.AutoService;
@AutoService(ILoadable.class)
public class EntityList extends HudModule implements ICommons { public class EntityList extends HudModule implements ICommons {
public final ForgeConfigSpec.ConfigValue<String> search; public final ForgeConfigSpec.ConfigValue<String> search;

View file

@ -20,7 +20,10 @@ import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.TickEvent.Phase; import net.minecraftforge.event.TickEvent.Phase;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import ftbsc.bscv.api.ILoadable;
import com.google.auto.service.AutoService;
@AutoService(ILoadable.class)
public class InfoDisplay extends HudModule implements ICommons { public class InfoDisplay extends HudModule implements ICommons {
private Vector3d last_position = new Vector3d(0.0, 0.0, 0.0); private Vector3d last_position = new Vector3d(0.0, 0.0, 0.0);

View file

@ -13,7 +13,10 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import ftbsc.bscv.api.ILoadable;
import com.google.auto.service.AutoService;
@AutoService(ILoadable.class)
public class PlayerList extends HudModule implements ICommons { public class PlayerList extends HudModule implements ICommons {
@SubscribeEvent @SubscribeEvent

View file

@ -1,12 +1,12 @@
package ftbsc.bscv.modules.motion; package ftbsc.bscv.modules.motion;
import com.mojang.brigadier.CommandDispatcher; import com.google.auto.service.AutoService;
import ftbsc.bscv.ICommons; import ftbsc.bscv.ICommons;
import ftbsc.bscv.api.ILoadable;
import ftbsc.bscv.events.BoatEvent; import ftbsc.bscv.events.BoatEvent;
import ftbsc.bscv.modules.AbstractModule; import ftbsc.bscv.modules.AbstractModule;
import ftbsc.bscv.tools.Keyboard; import ftbsc.bscv.tools.Keyboard;
import ftbsc.bscv.tools.Setting; import ftbsc.bscv.tools.Setting;
import net.minecraft.command.CommandSource;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec;
@ -14,6 +14,7 @@ import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.TickEvent.Phase; import net.minecraftforge.event.TickEvent.Phase;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
@AutoService(ILoadable.class)
public class BoatFly extends AbstractModule implements ICommons { public class BoatFly extends AbstractModule implements ICommons {
public final ForgeConfigSpec.ConfigValue<Double> speed; public final ForgeConfigSpec.ConfigValue<Double> speed;

View file

@ -14,7 +14,10 @@ import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.TickEvent.Phase; import net.minecraftforge.event.TickEvent.Phase;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import ftbsc.bscv.api.ILoadable;
import com.google.auto.service.AutoService;
@AutoService(ILoadable.class)
public class VanillaFlight extends QuickModule implements ICommons { public class VanillaFlight extends QuickModule implements ICommons {
@Override @Override

View file

@ -9,7 +9,10 @@ import net.minecraft.network.play.client.CPlayerPacket;
import net.minecraft.network.play.client.CEntityActionPacket.Action; import net.minecraft.network.play.client.CEntityActionPacket.Action;
import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import ftbsc.bscv.api.ILoadable;
import com.google.auto.service.AutoService;
@AutoService(ILoadable.class)
public class AntiHunger extends AbstractModule implements ICommons { public class AntiHunger extends AbstractModule implements ICommons {
public final ForgeConfigSpec.ConfigValue<Boolean> sprint; public final ForgeConfigSpec.ConfigValue<Boolean> sprint;

View file

@ -12,7 +12,10 @@ import net.minecraft.network.play.server.SUpdateHealthPacket;
import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import ftbsc.bscv.api.ILoadable;
import com.google.auto.service.AutoService;
@AutoService(ILoadable.class)
public class AutoDisconnect extends AbstractModule implements ICommons { public class AutoDisconnect extends AbstractModule implements ICommons {
public final ForgeConfigSpec.ConfigValue<Double> threshold; public final ForgeConfigSpec.ConfigValue<Double> threshold;

View file

@ -10,7 +10,10 @@ import net.minecraft.util.Hand;
import net.minecraft.util.SoundEvents; import net.minecraft.util.SoundEvents;
import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import ftbsc.bscv.api.ILoadable;
import com.google.auto.service.AutoService;
@AutoService(ILoadable.class)
public class AutoFish extends AbstractModule implements ICommons { public class AutoFish extends AbstractModule implements ICommons {
public final ForgeConfigSpec.ConfigValue<Boolean> recast; public final ForgeConfigSpec.ConfigValue<Boolean> recast;

View file

@ -13,7 +13,10 @@ import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraftforge.client.event.InputEvent; import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import ftbsc.bscv.api.ILoadable;
import com.google.auto.service.AutoService;
@AutoService(ILoadable.class)
public class AutoTool extends AbstractModule implements ICommons { public class AutoTool extends AbstractModule implements ICommons {
public final ForgeConfigSpec.ConfigValue<Integer> limit; public final ForgeConfigSpec.ConfigValue<Integer> limit;

View file

@ -13,7 +13,10 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
import ftbsc.bscv.modules.QuickModule; import ftbsc.bscv.modules.QuickModule;
import ftbsc.bscv.ICommons; import ftbsc.bscv.ICommons;
import ftbsc.bscv.api.ILoadable;
import com.google.auto.service.AutoService;
@AutoService(ILoadable.class)
public class FastInteract extends QuickModule implements ICommons { public class FastInteract extends QuickModule implements ICommons {
@Override @Override
protected int getDefaultKey() { protected int getDefaultKey() {

View file

@ -17,7 +17,10 @@ import net.minecraft.world.GameType;
import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import ftbsc.bscv.api.ILoadable;
import com.google.auto.service.AutoService;
@AutoService(ILoadable.class)
public class Freecam extends QuickModule implements ICommons { public class Freecam extends QuickModule implements ICommons {
public final ForgeConfigSpec.ConfigValue<Boolean> log; public final ForgeConfigSpec.ConfigValue<Boolean> log;

View file

@ -4,7 +4,10 @@ import ftbsc.bscv.ICommons;
import ftbsc.bscv.modules.AbstractModule; import ftbsc.bscv.modules.AbstractModule;
import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import ftbsc.bscv.api.ILoadable;
import com.google.auto.service.AutoService;
@AutoService(ILoadable.class)
public class PortalGui extends AbstractModule implements ICommons { public class PortalGui extends AbstractModule implements ICommons {
@SubscribeEvent @SubscribeEvent

View file

@ -8,7 +8,10 @@ import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import ftbsc.bscv.api.ILoadable;
import com.google.auto.service.AutoService;
@AutoService(ILoadable.class)
public class Fullbright extends QuickModule implements ICommons { public class Fullbright extends QuickModule implements ICommons {
@Override @Override
protected int getDefaultKey() { protected int getDefaultKey() {

View file

@ -1,38 +1,38 @@
package ftbsc.bscv.system; package ftbsc.bscv.system;
import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.CommandDispatcher;
import ftbsc.bscv.BoSCoVicino; import ftbsc.bscv.api.ILoadable;
import ftbsc.bscv.api.IModule; import ftbsc.bscv.api.IModule;
import ftbsc.bscv.modules.AbstractModule;
import ftbsc.bscv.modules.defense.Aura;
import ftbsc.bscv.modules.hud.*;
import ftbsc.bscv.modules.motion.BoatFly;
import ftbsc.bscv.modules.motion.VanillaFlight;
import ftbsc.bscv.modules.self.*;
import ftbsc.bscv.modules.vision.Fullbright;
import net.minecraft.command.CommandSource; import net.minecraft.command.CommandSource;
import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec;
import java.util.HashSet; import java.util.HashSet;
import java.util.Optional; import java.util.Optional;
import java.util.ServiceLoader;
import java.util.Set; import java.util.Set;
public class ModManager { public class ModManager {
private Optional<ForgeConfigSpec.Builder> cfgBuilder; private Optional<ForgeConfigSpec.Builder> cfgBuilder;
private Optional<CommandDispatcher<CommandSource>> dispatcher; private Optional<CommandDispatcher<CommandSource>> dispatcher;
public final Set<IModule<? extends Enum<?>> > mods; public final Set<IModule> mods;
public final Set<String> categories;
public ModManager(ForgeConfigSpec.Builder cfgBuilder, CommandDispatcher<CommandSource> dispatcher) { public ModManager(ForgeConfigSpec.Builder cfgBuilder, CommandDispatcher<CommandSource> dispatcher) {
this.cfgBuilder = Optional.of(cfgBuilder); this.cfgBuilder = Optional.of(cfgBuilder);
this.dispatcher = Optional.of(dispatcher); this.dispatcher = Optional.of(dispatcher);
this.mods = new HashSet<>(); this.mods = new HashSet<>();
} this.categories = new HashSet<>();
public void registerMod(IModule<? extends Enum<?>> mod) { for (ILoadable module : ServiceLoader.load(ILoadable.class)) {
if(module instanceof IModule) {
IModule mod = (IModule) module;
this.mods.add(mod); this.mods.add(mod);
this.categories.add(mod.getGroup());
this.cfgBuilder.get().pop(); // TODO solved by AutoService, soon TM this.cfgBuilder.get().pop(); // TODO solved by AutoService, soon TM
} }
}
}
public void finalize() { public void finalize() {
this.cfgBuilder = Optional.empty(); this.cfgBuilder = Optional.empty();

View file

@ -4,7 +4,6 @@ import static ftbsc.bscv.BoSCoVicino.log;
import java.util.Optional; import java.util.Optional;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.ArgumentType; import com.mojang.brigadier.arguments.ArgumentType;
import com.mojang.brigadier.arguments.BoolArgumentType; import com.mojang.brigadier.arguments.BoolArgumentType;
import com.mojang.brigadier.arguments.DoubleArgumentType; import com.mojang.brigadier.arguments.DoubleArgumentType;
@ -12,7 +11,6 @@ import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.arguments.StringArgumentType;
import ftbsc.bscv.api.IModule; import ftbsc.bscv.api.IModule;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands; import net.minecraft.command.Commands;
import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.server.command.EnumArgument; import net.minecraftforge.server.command.EnumArgument;
@ -51,7 +49,7 @@ public abstract class Setting<T> {
abstract Class<T> clazz(); abstract Class<T> clazz();
public ForgeConfigSpec.ConfigValue<T> build(IModule<?> module) { public ForgeConfigSpec.ConfigValue<T> build(IModule module) {
ForgeConfigSpec.ConfigValue<T> conf = this.value(module.getConfigBuilder()); ForgeConfigSpec.ConfigValue<T> conf = this.value(module.getConfigBuilder());
module.getDispatcher().register( module.getDispatcher().register(