summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/co/fantabos/bscv/Module.java45
-rw-r--r--src/main/java/co/fantabos/bscv/modules/Fullbright.java7
2 files changed, 51 insertions, 1 deletions
diff --git a/src/main/java/co/fantabos/bscv/Module.java b/src/main/java/co/fantabos/bscv/Module.java
index adb5297..620ece2 100644
--- a/src/main/java/co/fantabos/bscv/Module.java
+++ b/src/main/java/co/fantabos/bscv/Module.java
@@ -1,6 +1,7 @@
package co.fantabos.bscv;
import com.mojang.brigadier.CommandDispatcher;
+import com.mojang.brigadier.arguments.ArgumentType;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
@@ -39,9 +40,49 @@ public abstract class Module {
return 1;
})
)
+ .executes(ctx -> {
+ log(String.format("=[ %s ]%s", this.name, this.enabled.get() ? "+" : ""));
+ // TODO: print all mod options!
+ return 1;
+ })
);
}
+ public <T> ForgeConfigSpec.ConfigValue<T> option(
+ String name,
+ String comment,
+ T fallback,
+ ArgumentType<T> argument,
+ Class<T> clazz,
+ ForgeConfigSpec.Builder builder,
+ CommandDispatcher<CommandSource> dispatcher
+ ) {
+ ForgeConfigSpec.ConfigValue<T> conf = builder
+ .comment(comment)
+ .define(name, fallback);
+
+ dispatcher.register(
+ Commands.literal(this.name.toLowerCase())
+ .then(
+ Commands.literal(name)
+ .then(
+ Commands.argument(name, argument)
+ .executes( ctx -> {
+ conf.set(ctx.getArgument(name, clazz));
+ conf.save();
+ log(String.format("> %s -> %s", name, conf.get().toString()));
+ return 1;
+ }))
+ .executes(ctx -> {
+ log(String.format("> %s: %s", name, conf.get().toString()));
+ return 1;
+ })
+ )
+ );
+
+ return conf;
+ }
+
protected void onEnabled() {}
protected void onDisabled() {}
@@ -53,14 +94,18 @@ public abstract class Module {
public final void enable() {
MinecraftForge.EVENT_BUS.register(this);
this.enabled.set(true);
+ this.enabled.save();
this.onEnabled();
log(String.format("%s enabled", this.name));
+ BoSCoVicino.LOGGER.info(String.format("%s enabled", this.name));
}
public final void disable() {
MinecraftForge.EVENT_BUS.unregister(this);
this.enabled.set(false);
+ this.enabled.save();
this.onDisabled();
log(String.format("%s disabled", this.name));
+ BoSCoVicino.LOGGER.info(String.format("%s disabled", this.name));
}
}
diff --git a/src/main/java/co/fantabos/bscv/modules/Fullbright.java b/src/main/java/co/fantabos/bscv/modules/Fullbright.java
index d518448..5c2ce5f 100644
--- a/src/main/java/co/fantabos/bscv/modules/Fullbright.java
+++ b/src/main/java/co/fantabos/bscv/modules/Fullbright.java
@@ -1,6 +1,7 @@
package co.fantabos.bscv.modules;
import com.mojang.brigadier.CommandDispatcher;
+import com.mojang.brigadier.arguments.StringArgumentType;
import net.minecraft.command.CommandSource;
import net.minecraft.potion.Effect;
@@ -19,7 +20,11 @@ public class Fullbright extends Module {
public Fullbright(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
super("Fullbright", Group.VISION, builder, dispatcher);
- this.mode = builder.comment("either potion or gamma").define("mode", "potion");
+ this.mode = this.option(
+ "mode", "either potion or gamma", "potion",
+ StringArgumentType.string(), String.class,
+ builder, dispatcher
+ );
}
@SubscribeEvent