Skip to content

Commit

Permalink
[6.2.0] ConfigurationSection#getStringColored 函数不再直接抛出异常
Browse files Browse the repository at this point in the history
  • Loading branch information
Bkm016 committed Oct 29, 2024
1 parent 6c255f1 commit 40b1d1c
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import taboolib.module.chat.colored
* @return 上色后的文本
*/
fun ConfigurationSection.getStringColored(node: String): String? {
return runCatching { getString(node)?.colored() }.getOrElse { error("missing chat module (install(\"module-chat\"))") }
val string = getString(node) ?: return null
return runCatching { string.colored() }.getOrNull()
}

/**
Expand All @@ -20,5 +21,6 @@ fun ConfigurationSection.getStringColored(node: String): String? {
* @return 上色后的文本
*/
fun ConfigurationSection.getStringListColored(node: String): List<String> {
return getStringList(node).map { it.colored() }
val stringList = getStringList(node)
return runCatching { stringList.map { it.colored() } }.getOrElse { stringList }
}

0 comments on commit 40b1d1c

Please sign in to comment.