mirror of
https://github.com/xiaozhou233/OrangeX-Client.git
synced 2026-12-05 13:05:52 +08:00
Fix: setEnable logic
This commit is contained in:
1 parent
8a806a02e1
commit
572a3535bd
1 file changed
+8
-10
@@ -47,19 +47,17 @@ public class Module {
|
||||
public void setEnabled(boolean setEnabled) {
|
||||
if (this.enabled == setEnabled) return;
|
||||
|
||||
if (setEnabled) {
|
||||
try {
|
||||
OrangeX.getInstance().getEventBus().register(this);
|
||||
} catch (Exception e) {
|
||||
this.enabled = setEnabled;
|
||||
|
||||
if (this.enabled) {
|
||||
if (OrangeX.getInstance().getEventBus().isRegistered(this))
|
||||
return;
|
||||
}
|
||||
this.enabled = true;
|
||||
try { OrangeX.getInstance().getEventBus().register(this); } catch (Exception ignored) {}
|
||||
onEnable();
|
||||
} else {
|
||||
try {
|
||||
OrangeX.getInstance().getEventBus().unregister(this);
|
||||
} catch (Exception ignored) {}
|
||||
this.enabled = false;
|
||||
if (!OrangeX.getInstance().getEventBus().isRegistered(this))
|
||||
return;
|
||||
try { OrangeX.getInstance().getEventBus().unregister(this); } catch (Exception ignored) {}
|
||||
onDisable();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user