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: command binds/autoDisable list page #5615

Merged
merged 3 commits into from
Feb 14, 2025
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 @@ -73,7 +73,7 @@ class Command(
}

fun result(key: String, vararg args: Any): MutableText {
return translation("$translationBaseKey.result.$key", *args)
return translation("$translationBaseKey.result.$key", args = args)
}

fun resultWithTree(key: String, vararg args: Any): MutableText {
Expand All @@ -84,10 +84,10 @@ class Command(
parentCommand = parentCommand.parentCommand
}

return parentCommand!!.result(key, *args)
return parentCommand!!.result(key, args = args)
}

return translation("$translationBaseKey.result.$key", *args)
return translation("$translationBaseKey.result.$key", args = args)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,9 @@ object CommandBinds : CommandFactory {
.build()
)
.handler { command, args ->
val page = if (args.size > 1) {
args[0] as Int
} else {
1
}.coerceAtLeast(1)

val bindings = ModuleManager.sortedBy { it.name }
.filter { !it.bind.isUnbound }
val page = (args.firstOrNull() as? Int ?: 1).coerceAtLeast(1)

val bindings = ModuleManager.filter { !it.bind.isUnbound }

if (bindings.isEmpty()) {
throw CommandException(command.result("noBindings"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,7 @@ object CommandAutoDisable : CommandFactory {
.build()
)
.handler { command, args ->
val page = if (args.size > 1) {
args[0] as Int
} else {
1
}.coerceAtLeast(1)
val page = (args.firstOrNull() as? Int ?: 1).coerceAtLeast(1)

val modules = ModuleAutoDisable.listOfModules.sortedBy { it.name }

Expand Down Expand Up @@ -129,7 +125,7 @@ object CommandAutoDisable : CommandFactory {
.begin<String>("module")
.verifiedBy(ParameterBuilder.STRING_VALIDATOR)
.autocompletedWith { begin, _ ->
ModuleAutoDisable.listOfModules.map { it.name }.toList().filter { it.startsWith(begin) }
ModuleAutoDisable.listOfModules.mapNotNull { it.name.takeIf { n -> n.startsWith(begin) } }
}
.required()
.build()
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/resources/liquidbounce/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"liquidbounce.command.binds.subcommand.list.result.bindings": "快捷键",
"liquidbounce.command.binds.subcommand.list.result.noBindings": "未找到任何快捷键。",
"liquidbounce.command.binds.subcommand.list.result.page": "页数: %s",
"liquidbounce.command.binds.subcommand.list.result.pageNumberTooLarge": "你输入的页数过大,一共有 %d 页。",
"liquidbounce.command.binds.subcommand.list.result.pageNumberTooLarge": "你输入的页数过大,一共有 %s 页。",
"liquidbounce.command.binds.subcommand.remove.description": "移除快捷键。",
"liquidbounce.command.binds.subcommand.remove.parameter.name.description": "模块名。",
"liquidbounce.command.binds.subcommand.remove.result.bindRemoved": "已移除模块 \"%s\" 的快捷键。",
Expand Down
Loading