Skip to content

Commit

Permalink
[6.2.0] 调整 AppConsole#sendMessage 逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
Bkm016 committed Oct 23, 2024
1 parent c808f9c commit 30e5379
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,30 @@ object AppConsole : SimpleTerminalConsole(), ProxyCommandSender {
override fun sendMessage(message: String) {
// 移除颜色代码
if (message.contains("§")) {
info(message.replace("§[0-9a-fA-F]", ""))
info(stripColor(message))
} else {
info(message)
}
}

fun stripColor(message: String): String {
val filteredMessage = StringBuilder()
var skip = false
for (char in message) {
if (char == '§') {
skip = true
} else if (skip) {
// 判断 § 后面的东西
if (char.isLetterOrDigit()) {
skip = false
} else {
filteredMessage.append('§').append(char)
skip = false
}
} else {
filteredMessage.append(char)
}
}
return filteredMessage.toString()
}
}

0 comments on commit 30e5379

Please sign in to comment.