From 41a840c2623b616607852c9e1343c662a4143216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=91?= Date: Sun, 20 Oct 2024 00:22:04 +0800 Subject: [PATCH] =?UTF-8?q?[6.2.0]=20=E8=B0=83=E6=95=B4=20StringBar=20?= =?UTF-8?q?=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/kotlin/taboolib/common/util/StringBar.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common-util/src/main/kotlin/taboolib/common/util/StringBar.kt b/common-util/src/main/kotlin/taboolib/common/util/StringBar.kt index e0e13c7cc..ca33006ff 100644 --- a/common-util/src/main/kotlin/taboolib/common/util/StringBar.kt +++ b/common-util/src/main/kotlin/taboolib/common/util/StringBar.kt @@ -15,7 +15,7 @@ package taboolib.common.util * * 你还可以使用 builder 参数来进一步自定义每个字符的显示: * ``` - * val coloredBar = buildBarWith("0(#)9", 0.6, 20) { code -> + * val coloredBar = buildBarWith("0(#)9", 0.6, 20) { _, code -> * when (code) { * "0", "9" -> code.red() * "#" -> code.green() @@ -34,7 +34,7 @@ package taboolib.common.util * 默认为 { it },即直接返回原字符 * @return 构建好的 Bar 字符串 */ -fun buildStringBarWith(template: String, value: Double, length: Int, reverse: Boolean = false, builder: (code: String) -> String = { it }): String { +fun buildStringBarWith(template: String, value: Double, length: Int, reverse: Boolean = false, builder: (index: Int, code: String) -> String = { _, code -> code }): String { val (prefix, body, suffix) = parseTemplate(template) return buildStringBar(value, length, reverse) { index, state -> val code = if (state) { @@ -49,7 +49,7 @@ fun buildStringBarWith(template: String, value: Double, length: Int, reverse: Bo } else { " " } - builder(code) + builder(index, code) } }