summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author ftbsc <dev@fantabos.co>2023-02-28 21:49:37 +0100
committer ftbsc <dev@fantabos.co>2023-02-28 21:49:37 +0100
commitc833568c4b9dabc690bb4c962058da0e9e0c455b (patch)
tree3ee5fbacb47bcbee0b8815f7ef0d374ba3400e53
parent4359e3d285774ced2ebd8662b82f8b5c41fb51a9 (diff)
feat: defaults for toggle/enable/disable
-rw-r--r--src/main/java/ftbsc/bscv/api/IModule.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/main/java/ftbsc/bscv/api/IModule.java b/src/main/java/ftbsc/bscv/api/IModule.java
index a6a6d12..e075aa6 100644
--- a/src/main/java/ftbsc/bscv/api/IModule.java
+++ b/src/main/java/ftbsc/bscv/api/IModule.java
@@ -1,17 +1,26 @@
package ftbsc.bscv.api;
import net.minecraftforge.common.ForgeConfigSpec;
+import net.minecraftforge.common.MinecraftForge;
public interface IModule<T extends Enum<T>> extends ICommand {
T getGroup();
ForgeConfigSpec.Builder getConfigBuilder();
- void toggle();
+ default void toggle() {
+ if(this.isEnabled())
+ this.disable();
+ else this.enable();
+ }
- void enable();
+ default void enable() {
+ MinecraftForge.EVENT_BUS.register(this);
+ }
- void disable();
+ default void disable() {
+ MinecraftForge.EVENT_BUS.register(this);
+ }
boolean isEnabled();
}