feat: some initial work on Abstract Module
This commit is contained in:
parent
dd5bb2205b
commit
d497c1d976
1 changed files with 17 additions and 4 deletions
|
@ -22,12 +22,10 @@ public abstract class Module {
|
||||||
|
|
||||||
public final String name;
|
public final String name;
|
||||||
public final Group group;
|
public final Group group;
|
||||||
public final ForgeConfigSpec.ConfigValue<Boolean> enabled;
|
|
||||||
|
|
||||||
protected Module(String name, Group group, ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
|
protected ForgeConfigSpec.ConfigValue<Boolean> enabled;
|
||||||
this.name = name;
|
|
||||||
this.group = group;
|
|
||||||
|
|
||||||
|
public void initialize(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
|
||||||
builder.push(this.name.toLowerCase());
|
builder.push(this.name.toLowerCase());
|
||||||
this.enabled = builder
|
this.enabled = builder
|
||||||
.comment(String.format("Enables %s", this.name))
|
.comment(String.format("Enables %s", this.name))
|
||||||
|
@ -60,6 +58,21 @@ public abstract class Module {
|
||||||
return 1;
|
return 1;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.register(builder, dispatcher);
|
||||||
|
|
||||||
|
builder.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void register(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher);
|
||||||
|
|
||||||
|
protected Module(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
|
||||||
|
// TODO can this be done in a less magic way?
|
||||||
|
String[] pkg = this.getClass().getPackage().getName().split(".");
|
||||||
|
this.group = Group.valueOf(pkg[pkg.length-1].toUpperCase());
|
||||||
|
this.name = this.getClass().getName();
|
||||||
|
|
||||||
|
this.initialize(builder, dispatcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Module done(ForgeConfigSpec.Builder builder) {
|
public Module done(ForgeConfigSpec.Builder builder) {
|
||||||
|
|
Loading…
Reference in a new issue