|
17 | 17 |
|
18 | 18 | package com.lambda.module |
19 | 19 |
|
| 20 | +import com.lambda.Lambda |
20 | 21 | import com.lambda.command.LambdaCommand |
21 | 22 | import com.lambda.config.AbstractSetting |
22 | 23 | import com.lambda.config.Configurable |
@@ -116,26 +117,28 @@ abstract class Module( |
116 | 117 | ) : Nameable, Muteable, Configurable(ModuleConfig) { |
117 | 118 | private val isEnabledSetting = setting("Enabled", enabledByDefault) { false } |
118 | 119 | val keybindSetting = setting("Keybind", defaultKeybind) { false } |
| 120 | + val disableOnReleaseSetting = setting("Disable On Release", false) { false } |
119 | 121 |
|
120 | 122 | open val isVisible: Boolean = true |
121 | 123 |
|
122 | 124 | var isEnabled by isEnabledSetting |
123 | 125 | val isDisabled get() = !isEnabled |
124 | 126 |
|
125 | 127 | val keybind by keybindSetting |
| 128 | + val disableOnRelease by disableOnReleaseSetting |
126 | 129 |
|
127 | 130 | override val isMuted: Boolean |
128 | 131 | get() = !isEnabled && !alwaysListening |
129 | 132 |
|
130 | 133 | init { |
131 | 134 | listen<KeyboardEvent.Press>(alwaysListen = true) { event -> |
132 | | - if (mc.options.commandKey.isPressed) return@listen |
133 | | - if (!event.isPressed) return@listen |
| 135 | + if (Lambda.mc.options.commandKey.isPressed) return@listen |
134 | 136 | if (keybind == KeyCode.UNBOUND) return@listen |
135 | 137 | if (event.translated != keybind) return@listen |
136 | | - if (mc.currentScreen != null) return@listen |
| 138 | + if (Lambda.mc.currentScreen != null) return@listen |
137 | 139 |
|
138 | | - toggle() |
| 140 | + if (event.isPressed) toggle() |
| 141 | + else if (event.isReleased && disableOnRelease) disable() |
139 | 142 | } |
140 | 143 |
|
141 | 144 | onEnable { LambdaSound.MODULE_ON.play() } |
|
0 commit comments