@@ -35,10 +35,10 @@ var plainAdventureSerializer: ComponentSerializer<Component, TextComponent, Stri
3535 * @author Fruxz
3636 * @since 1.0
3737 */
38- var miniMessageSerializer: ComponentSerializer < Component , Component , String > =
38+ var miniMessageSerializer: OpenMiniMessageSerializer =
3939 MiniMessage .miniMessage()
4040
41- var strictMiniMessageSerializer: ComponentSerializer < Component , Component , String > =
41+ var strictMiniMessageSerializer: OpenMiniMessageSerializer =
4242 MiniMessage .builder().strict(true ).build()
4343
4444/* *
@@ -103,8 +103,11 @@ val Iterable<String>.asComponents: List<TextComponent>
103103val ComponentLike .asStyledString: String
104104 get() = strictMiniMessageSerializer.serialize(asComponent())
105105
106- fun ComponentLike.asStyledString (strict : Boolean = true) =
107- strict.switch(asStyledString, miniMessageSerializer.serialize(asComponent()))
106+ fun ComponentLike.asStyledString (
107+ serializer : OpenMiniMessageSerializer = strictMiniMessageSerializer,
108+ strict : Boolean = true
109+ ) =
110+ strict.switch(asStyledString, serializer.serialize(asComponent()))
108111
109112/* *
110113 * This computational value converts this [String] into a [TextComponent]
@@ -118,8 +121,12 @@ fun ComponentLike.asStyledString(strict: Boolean = true) =
118121val String .asStyledComponent: TextComponent
119122 get() = Component .text().append(miniMessageSerializer.deserializeOr(this , Component .empty())!! ).build()
120123
121- inline fun String.asStyledComponent (builder : StackedBuilder .() -> Unit ) =
122- StackedBuilder (Component .text().append(asStyledComponent)).apply (builder).build()
124+ inline fun String.asStyledComponent (
125+ serializer : OpenMiniMessageSerializer = miniMessageSerializer,
126+ builder : StackedBuilder .() -> Unit = { },
127+ ) = StackedBuilder (Component .text().append(serializer.deserializeOr(this , Component .empty())!! ))
128+ .apply (builder)
129+ .build()
123130
124131/* *
125132 * This computational value converts this [String] into a [TextComponent]
@@ -133,6 +140,10 @@ inline fun String.asStyledComponent(builder: StackedBuilder.() -> Unit) =
133140val String .asStyledComponents: List <TextComponent >
134141 get() = this .lines().asStyledComponents
135142
143+ fun String.asStyledComponents (
144+ serializer : OpenMiniMessageSerializer = miniMessageSerializer,
145+ ): List <TextComponent > = this .lines().asStyledComponents(serializer)
146+
136147/* *
137148 * This computational value converts this [Iterable] into a [TextComponent]
138149 * list (every entry represents a line) by using the [MiniMessage], provided by the
@@ -143,4 +154,8 @@ val String.asStyledComponents: List<TextComponent>
143154 * @since 1.0
144155 */
145156val Iterable <String >.asStyledComponents: List <TextComponent >
146- get() = map { it.asStyledComponent }
157+ get() = map { it.asStyledComponent }
158+
159+ fun Iterable<String>.asStyledComponents (
160+ serializer : OpenMiniMessageSerializer = miniMessageSerializer,
161+ ): List <TextComponent > = map { it.asStyledComponent(serializer) }
0 commit comments