fix: optional builder/dispatcher, moved cfg.pop
This commit is contained in:
parent
c833568c4b
commit
e3af53002f
2 changed files with 13 additions and 8 deletions
|
@ -68,8 +68,6 @@ public abstract class AbstractModule implements IModule<AbstractModule.Group> {
|
|||
return 1;
|
||||
})
|
||||
);
|
||||
|
||||
this.getConfigBuilder().pop();
|
||||
}
|
||||
|
||||
protected void onEnabled() {}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue