Converter
Converter とは
Section titled “Converter とは”Converter は CoordinateComponent の座標集合を視覚的な文字列に変換するユーティリティオブジェクトです。
デバッグやログ出力時にレシピの形状を確認するために利用できます。
getComponentsShapeString()
Section titled “getComponentsShapeString()”座標の集合を ASCII アートの形式で文字列に変換します。
@JvmStaticfun getComponentsShapeString( list: Collection<CoordinateComponent>, existsSlotChar: Char = '#', notExistsSlotChar: Char = '_'): String| パラメータ | デフォルト | 概要 |
|---|---|---|
list | — | 座標のコレクション |
existsSlotChar | '#' | 座標が存在するスロットに使用する文字 |
notExistsSlotChar | '_' | 座標が存在しないスロットに使用する文字 |
import io.github.sakaki_aruka.customcrafter.impl.util.Converter
// 3x3 の塗りつぶしval filled = CoordinateComponent.squareFill(3)println(Converter.getComponentsShapeString(filled))// ###// ###// ###
// 3x3 の枠線val frame = CoordinateComponent.square(3)println(Converter.getComponentsShapeString(frame))// ###// #_#// ###
// カスタム文字println(Converter.getComponentsShapeString(filled, existsSlotChar = 'O', notExistsSlotChar = '.'))// OOO// OOO// OOOString.toComponent()
Section titled “String.toComponent()”String を net.kyori.adventure.text.Component に変換する拡張関数です。
MiniMessage 形式のテキストをサポートします。
fun String.toComponent(): Componentimport io.github.sakaki_aruka.customcrafter.impl.util.Converter.toComponent
val component = "<aqua>カスタムクラフター</aqua>".toComponent()player.sendMessage(component)