fix: bind command unbind and key not found (#4247)

These cases were not really handled before, now it works as expected with formatted messages.
This commit is contained in:
1zuna
2024-10-25 20:10:13 +00:00
committed by GitHub
parent efba89fa3c
commit 78fed50920
2 changed files with 16 additions and 2 deletions

View File

@@ -56,8 +56,20 @@ object CommandBind {
val module = ModuleManager.find { it.name.equals(name, true) }
?: throw CommandException(command.result("moduleNotFound", name))
module.bind.bind(keyName)
chat(regular(command.result("moduleBound", variable(module.name), variable(module.bind.keyName))))
if (keyName.equals("none", true)) {
module.bind.unbind()
chat(regular(command.result("moduleUnbound", variable(module.name))))
return@handler
}
runCatching {
module.bind.bind(keyName)
}.onSuccess {
chat(regular(command.result("moduleBound", variable(module.name), variable(module.bind.keyName))))
}.onFailure {
chat(markAsError(command.result("keyNotFound", variable(keyName))))
}
}
.build()
}

View File

@@ -4,7 +4,9 @@
"liquidbounce.command.bind.parameter.key.description": "Key to which the module should be bound.",
"liquidbounce.command.bind.parameter.name.description": "Name of the module.",
"liquidbounce.command.bind.result.moduleBound": "Bound module \"%s\" to key \"%s\".",
"liquidbounce.command.bind.result.moduleUnbound": "Unbound module \"%s\".",
"liquidbounce.command.bind.result.moduleNotFound": "Module \"%s\" was not found.",
"liquidbounce.command.bind.result.keyNotFound": "Key \"%s\" was not found.",
"liquidbounce.command.binds.description": "Binds a module to a key.",
"liquidbounce.command.binds.subcommand.add.description": "Adds a new bind.",
"liquidbounce.command.binds.subcommand.add.parameter.key.description": "Key to which the module should be bound.",