diff --git a/src/main/java/ftbsc/bscv/BoSCoVicino.java b/src/main/java/ftbsc/bscv/BoSCoVicino.java index 5ea29b1..9a69620 100644 --- a/src/main/java/ftbsc/bscv/BoSCoVicino.java +++ b/src/main/java/ftbsc/bscv/BoSCoVicino.java @@ -59,29 +59,19 @@ public class BoSCoVicino { // load and register mods BoSCoVicino.mods = new ArrayList(); - ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder(); + ForgeConfigSpec.Builder cfg = new ForgeConfigSpec.Builder(); + CommandDispatcher dp = this.dispatcher; - // TODO also push! - // modules cannot easily pop from their builder, but here we can't easily get - // the module name yet. We should push and pop the builder ourselves and not - // bother the modules themselves. + BoSCoVicino.mods.add(new ActiveModules(cfg, dp).done(cfg)); + BoSCoVicino.mods.add(new VanillaFlight(cfg, dp).done(cfg)); + BoSCoVicino.mods.add(new FastInteract(cfg, dp).done(cfg)); + BoSCoVicino.mods.add(new InfoDisplay(cfg, dp).done(cfg)); + BoSCoVicino.mods.add(new Coordinates(cfg, dp).done(cfg)); + BoSCoVicino.mods.add(new EntityList(cfg, dp).done(cfg)); + BoSCoVicino.mods.add(new Fullbright(cfg, dp).done(cfg)); + BoSCoVicino.mods.add(new Freecam(cfg, dp).done(cfg)); - BoSCoVicino.mods.add(new Fullbright(builder, this.dispatcher)); - builder.pop(); - BoSCoVicino.mods.add(new VanillaFlight(builder, this.dispatcher)); - builder.pop(); - BoSCoVicino.mods.add(new FastInteract(builder, this.dispatcher)); - builder.pop(); - BoSCoVicino.mods.add(new InfoDisplay(builder, this.dispatcher)); - builder.pop(); - BoSCoVicino.mods.add(new Coordinates(builder, this.dispatcher)); - builder.pop(); - BoSCoVicino.mods.add(new EntityList(builder, this.dispatcher)); - builder.pop(); - BoSCoVicino.mods.add(new ActiveModules(builder, this.dispatcher)); - builder.pop(); - - BoSCoVicino.spec = builder.build(); + BoSCoVicino.spec = cfg.build(); // register config handler ModLoadingContext.get().registerConfig(Type.CLIENT, spec, "bscv.toml"); diff --git a/src/main/java/ftbsc/bscv/module/Module.java b/src/main/java/ftbsc/bscv/module/Module.java index d5ba285..84153a7 100644 --- a/src/main/java/ftbsc/bscv/module/Module.java +++ b/src/main/java/ftbsc/bscv/module/Module.java @@ -51,6 +51,11 @@ public abstract class Module { ); } + public Module done(ForgeConfigSpec.Builder builder) { + builder.pop(); + return this; + } + // TODO can I merge these two option into one? Maybe redo with builder pattern?