Rename AnsiMessageBuilder.builder to create

This commit is contained in:
Karlatemp 2020-11-28 21:50:26 +08:00
parent 480666e3f0
commit 04c1d951aa
No known key found for this signature in database
GPG Key ID: 21FBDDF664FF06F8

View File

@ -30,7 +30,7 @@ public open class AnsiMessageBuilder public constructor(
* @param code Ansi 操作码 * @param code Ansi 操作码
* *
* @see from * @see from
* @see builder * @see create
*/ */
public open fun ansi(code: String): AnsiMessageBuilder = append(code) public open fun ansi(code: String): AnsiMessageBuilder = append(code)
@ -142,7 +142,7 @@ public open class AnsiMessageBuilder public constructor(
*/ */
@JvmStatic @JvmStatic
@JvmOverloads @JvmOverloads
public fun builder( public fun create(
capacity: Int = 16, capacity: Int = 16,
noAnsi: Boolean = false noAnsi: Boolean = false
): AnsiMessageBuilder = from(StringBuilder(capacity), noAnsi) ): AnsiMessageBuilder = from(StringBuilder(capacity), noAnsi)
@ -195,7 +195,7 @@ public fun AnsiMessageBuilder(capacity: Int = 16): AnsiMessageBuilder = AnsiMess
public inline fun buildAnsiMessage( public inline fun buildAnsiMessage(
capacity: Int = 16, capacity: Int = 16,
action: AnsiMessageBuilder.() -> Unit action: AnsiMessageBuilder.() -> Unit
): String = AnsiMessageBuilder.builder(capacity, false).apply(action).toString() ): String = AnsiMessageBuilder.create(capacity, false).apply(action).toString()
// 不在 top-level 使用者会得到 Internal error: Couldn't inline sendAnsiMessage // 不在 top-level 使用者会得到 Internal error: Couldn't inline sendAnsiMessage
@ -209,7 +209,7 @@ public suspend inline fun CommandSender.sendAnsiMessage(
builder: AnsiMessageBuilder.() -> Unit builder: AnsiMessageBuilder.() -> Unit
) { ) {
sendMessage( sendMessage(
AnsiMessageBuilder.builder(capacity, noAnsi = !AnsiMessageBuilder.isAnsiSupported(this)) AnsiMessageBuilder.create(capacity, noAnsi = !AnsiMessageBuilder.isAnsiSupported(this))
.apply(builder) .apply(builder)
.toString() .toString()
) )