diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/ftbsc/bscv/modules/AbstractModule.java | 2 | ||||
-rw-r--r-- | src/main/java/ftbsc/bscv/system/ModManager.java | 19 |
2 files changed, 13 insertions, 8 deletions
diff --git a/src/main/java/ftbsc/bscv/modules/AbstractModule.java b/src/main/java/ftbsc/bscv/modules/AbstractModule.java index 7e6d2a6..a7f4b04 100644 --- a/src/main/java/ftbsc/bscv/modules/AbstractModule.java +++ b/src/main/java/ftbsc/bscv/modules/AbstractModule.java @@ -68,8 +68,6 @@ public abstract class AbstractModule implements IModule<AbstractModule.Group> { return 1; }) ); - - this.getConfigBuilder().pop(); } protected void onEnabled() {} diff --git a/src/main/java/ftbsc/bscv/system/ModManager.java b/src/main/java/ftbsc/bscv/system/ModManager.java index ea64b0c..d5ce124 100644 --- a/src/main/java/ftbsc/bscv/system/ModManager.java +++ b/src/main/java/ftbsc/bscv/system/ModManager.java @@ -14,29 +14,36 @@ import net.minecraft.command.CommandSource; import net.minecraftforge.common.ForgeConfigSpec; import java.util.HashSet; +import java.util.Optional; import java.util.Set; public class ModManager { - private final ForgeConfigSpec.Builder cfgBuilder; - private final CommandDispatcher<CommandSource> dispatcher; + private Optional<ForgeConfigSpec.Builder> cfgBuilder; + private Optional<CommandDispatcher<CommandSource>> dispatcher; public final Set<IModule<? extends Enum<?>> > mods; public ModManager(ForgeConfigSpec.Builder cfgBuilder, CommandDispatcher<CommandSource> dispatcher) { - this.cfgBuilder = cfgBuilder; - this.dispatcher = dispatcher; + this.cfgBuilder = Optional.of(cfgBuilder); + this.dispatcher = Optional.of(dispatcher); this.mods = new HashSet<>(); } public void registerMod(IModule<? extends Enum<?>> mod) { this.mods.add(mod); + this.cfgBuilder.get().pop(); // TODO solved by AutoService, soon TM + } + + public void finalize() { + this.cfgBuilder = Optional.empty(); + this.dispatcher = Optional.empty(); } public ForgeConfigSpec.Builder getCfgBuilder() { - return cfgBuilder; + return cfgBuilder.get(); } public CommandDispatcher<CommandSource> getDispatcher() { - return dispatcher; + return dispatcher.get(); } } |