feat: added onEnabled/onDisabled callbacks
This commit is contained in:
parent
6a9df35f40
commit
27c30423de
1 changed files with 8 additions and 3 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue