summaryrefslogtreecommitdiff
path: root/src/main/java/ftbsc
diff options
context:
space:
mode:
author alemi <me@alemi.dev>2023-02-13 01:21:04 +0100
committer alemi <me@alemi.dev>2023-02-13 01:21:04 +0100
commit1091f35cb72f84f1fd1e32277a3182cd8c84794e (patch)
tree7100a46bdb4f6ed3f40b3e5813ba2a2231620f87 /src/main/java/ftbsc
parent75e627c0cca16ddb91b28b151358b1e3c42367ef (diff)
feat: added .done() to handle config popping
Diffstat (limited to 'src/main/java/ftbsc')
-rw-r--r--src/main/java/ftbsc/bscv/BoSCoVicino.java36
-rw-r--r--src/main/java/ftbsc/bscv/module/Module.java5
2 files changed, 18 insertions, 23 deletions
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<Module>();
- ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
-
- // 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 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();
+ ForgeConfigSpec.Builder cfg = new ForgeConfigSpec.Builder();
+ CommandDispatcher<CommandSource> dp = this.dispatcher;
+
+ 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.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?