feat: added .done() to handle config popping

This commit is contained in:
əlemi 2023-02-13 01:21:04 +01:00
parent 75e627c0cc
commit 1091f35cb7
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 16 additions and 21 deletions

View file

@ -59,29 +59,19 @@ public class BoSCoVicino {
// load and register mods
BoSCoVicino.mods = new ArrayList<Module>();
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
ForgeConfigSpec.Builder cfg = new ForgeConfigSpec.Builder();
CommandDispatcher<CommandSource> 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");

View file

@ -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?