Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sync on bind #4519

Merged
merged 1 commit into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import net.ccbluex.liquidbounce.features.command.builder.CommandBuilder
import net.ccbluex.liquidbounce.features.command.builder.ParameterBuilder
import net.ccbluex.liquidbounce.features.command.builder.moduleParameter
import net.ccbluex.liquidbounce.features.module.ModuleManager
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleClickGui
import net.ccbluex.liquidbounce.utils.client.*
import net.ccbluex.liquidbounce.utils.input.keyList
import net.ccbluex.liquidbounce.utils.input.mouseList
Expand Down Expand Up @@ -58,12 +59,14 @@ object CommandBind {

if (keyName.equals("none", true)) {
module.bind.unbind()
ModuleClickGui.sync()
chat(regular(command.result("moduleUnbound", variable(module.name))))
return@handler
}

runCatching {
module.bind.bind(keyName)
ModuleClickGui.sync()
}.onSuccess {
chat(regular(command.result("moduleBound", variable(module.name), variable(module.bind.keyName))))
}.onFailure {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import net.ccbluex.liquidbounce.features.command.builder.ParameterBuilder
import net.ccbluex.liquidbounce.features.command.builder.moduleParameter
import net.ccbluex.liquidbounce.features.command.builder.pageParameter
import net.ccbluex.liquidbounce.features.module.ModuleManager
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleClickGui
import net.ccbluex.liquidbounce.utils.client.*
import net.ccbluex.liquidbounce.utils.input.inputByName
import net.ccbluex.liquidbounce.utils.input.keyList
Expand Down Expand Up @@ -73,7 +74,8 @@ object CommandBinds {
throw CommandException(command.result("unknownKey"))
}

module.bind.boundKey = bindKey
module.bind.bind(bindKey)
ModuleClickGui.sync()
chat(regular(command.result("moduleBound", variable(module.name),
variable(module.bind.keyName))))
}
Expand All @@ -97,6 +99,7 @@ object CommandBinds {
}

module.bind.unbind()
ModuleClickGui.sync()
chat(regular(command.result("bindRemoved", variable(module.name))))
}
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ data class InputBind(
this.boundKey = inputByName(name)
}

/**
* Binds to the given input type and code.
*/
fun bind(key: InputUtil.Key) {
this.boundKey = key
}

/**
* Unbinds the key by setting it to UNKNOWN_KEY.
*/
Expand Down
Loading