diff options
author | alemidev <me@alemi.dev> | 2023-01-29 00:03:15 +0100 |
---|---|---|
committer | alemidev <me@alemi.dev> | 2023-01-29 00:03:15 +0100 |
commit | 27c30423de8b564539ac43a5fbea97de6ed2e4f8 (patch) | |
tree | e9fde297c4fa61c53610a813e6e6f5066884e995 | |
parent | 6a9df35f400eb1e31c574d1418b0772246b5870f (diff) |
feat: added onEnabled/onDisabled callbacks
-rw-r--r-- | src/main/java/co/fantabos/bscv/Module.java | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/main/java/co/fantabos/bscv/Module.java b/src/main/java/co/fantabos/bscv/Module.java index 295d6a8..dad3d56 100644 --- a/src/main/java/co/fantabos/bscv/Module.java +++ b/src/main/java/co/fantabos/bscv/Module.java @@ -41,18 +41,23 @@ public abstract class Module { ); } - public void toggle() { + protected void onEnabled() {} + protected void onDisabled() {} + + public final void toggle() { if (this.enabled.get()) this.disable(); else this.enable(); } - public void enable() { + public final void enable() { MinecraftForge.EVENT_BUS.register(this); this.enabled.set(true); + this.onEnabled(); } - public void disable() { + public final void disable() { MinecraftForge.EVENT_BUS.unregister(this); this.enabled.set(false); + this.onDisabled(); } } |