Skip to content
This repository was archived by the owner on Feb 19, 2019. It is now read-only.

Commit 0e02d25

Browse files
committed
Module Mode event listener fix
1 parent a1d69e6 commit 0e02d25

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/main/java/clientapi/module/Module.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ private void checkModes() {
270270

271271
@Override
272272
public final void setState(boolean state) {
273-
if (state == this.state) return;
273+
if (state == this.state)
274+
return;
274275

275276
ModuleStateEvent event = new ModuleStateEvent(this, state);
276277
ClientAPI.EVENT_BUS.post(event);

src/main/java/clientapi/module/ModuleMode.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package clientapi.module;
1818

19+
import clientapi.ClientAPI;
1920
import clientapi.util.io.Keybind;
2021
import clientapi.value.holder.ValueHolder;
2122

@@ -60,9 +61,17 @@ public ModuleMode(T parent, String name, String description) {
6061
}
6162

6263
@Override
63-
public void setState(boolean state) {
64+
public final void setState(boolean state) {
6465
parent.setState(state);
6566
parent.setMode(this);
67+
68+
if (state) {
69+
onEnable();
70+
ClientAPI.EVENT_BUS.subscribe(this);
71+
} else {
72+
ClientAPI.EVENT_BUS.unsubscribe(this);
73+
onDisable();
74+
}
6675
}
6776

6877
/**

0 commit comments

Comments
 (0)