fix: null ptr, activemodules, service

modManager must be set during ModManager initialization. moved that part
into a separate method. Activemodules had the check inverted. Abstract
classes cannot be loaded (and thus should not be annotated)
This commit is contained in:
əlemi 2023-03-01 01:00:04 +01:00
parent 930ccf34c7
commit f4889c1ce2
Signed by: alemi
GPG key ID: A4895B84D311642C
4 changed files with 4 additions and 4 deletions

View file

@ -47,6 +47,7 @@ public class BoSCoVicino implements ICommons {
CommandDispatcher<CommandSource> dp = this.dispatcher; CommandDispatcher<CommandSource> dp = this.dispatcher;
BoSCoVicino.modManager = new ModManager(cfg, dp); BoSCoVicino.modManager = new ModManager(cfg, dp);
BoSCoVicino.modManager.load();
BoSCoVicino.spec = cfg.build(); BoSCoVicino.spec = cfg.build();

View file

@ -8,11 +8,8 @@ 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

@ -19,7 +19,7 @@ public class ActiveModules extends HudModule implements ICommons {
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().equalsIgnoreCase("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

@ -23,7 +23,9 @@ public class ModManager {
this.dispatcher = Optional.of(dispatcher); this.dispatcher = Optional.of(dispatcher);
this.mods = new HashSet<>(); this.mods = new HashSet<>();
this.categories = new HashSet<>(); this.categories = new HashSet<>();
}
public void load() {
for (ILoadable module : ServiceLoader.load(ILoadable.class)) { for (ILoadable module : ServiceLoader.load(ILoadable.class)) {
if(module instanceof IModule) { if(module instanceof IModule) {
IModule mod = (IModule) module; IModule mod = (IModule) module;