From c833568c4b9dabc690bb4c962058da0e9e0c455b Mon Sep 17 00:00:00 2001 From: ftbsc Date: Tue, 28 Feb 2023 21:49:37 +0100 Subject: [PATCH] feat: defaults for toggle/enable/disable --- src/main/java/ftbsc/bscv/api/IModule.java | 15 ++++++++++++--- 1 file 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> 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(); }