Skip to content

Commit 3bb8607

Browse files
committed
chore: some code improvements
1 parent e9bf9ec commit 3bb8607

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

src/main/kotlin/de/fruxz/stacked/extension/ComponentCollection.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ fun <T : ComponentLike> Iterable<T>.joinToComponent(spliterator: ComponentLike,
4242
}
4343

4444
/**
45-
* This function splits every line of the component to its
45+
* This computational value splits every line of the component to its
4646
* own component.
4747
* This is useful if you need the specific lines of the component,
4848
* like adding a prefix to each line.
4949
* @return A list of components, each representing a line of the original component
5050
* @author Fruxz
5151
* @since 1.0
5252
*/
53-
fun <T : ComponentLike> T.lines(): List<Component> =
54-
(asComponent().children().takeIf { it.isNotEmpty() } ?: listOf(asComponent()))
53+
val <T : ComponentLike> T.lines: List<Component>
54+
get() = (asComponent().children().takeIf { it.isNotEmpty() } ?: listOf(asComponent()))
5555
.splitBy { it == Component.newline() }
5656
.map { it.joinToComponent() }

src/main/kotlin/de/fruxz/stacked/extension/ComponentContent.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ package de.fruxz.stacked.extension
22

33
import net.kyori.adventure.text.ComponentLike
44

5-
fun ComponentLike.content() = asPlainString
5+
val ComponentLike.content get() = asPlainString
66

7-
fun ComponentLike.isBlank() = content().isBlank()
7+
val ComponentLike.isBlank get() = content.isBlank()
88

9-
fun ComponentLike.isNotBlank() = content().isNotBlank()
9+
val ComponentLike.isNotBlank get() = content.isNotBlank()
1010

11-
fun ComponentLike.isEmpty() = content().isEmpty()
11+
val ComponentLike.isEmpty get() = content.isEmpty()
1212

13-
fun ComponentLike.isNotEmpty() = content().isNotEmpty()
13+
val ComponentLike.isNotEmpty get() = content.isNotEmpty()

src/main/kotlin/de/fruxz/stacked/extension/TextColor.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@ import net.kyori.adventure.text.format.NamedTextColor
55
import net.kyori.adventure.text.format.StyleSetter
66
import net.kyori.adventure.text.format.TextColor
77
import de.fruxz.ascend.tool.color.Color as AscendColor
8+
import java.awt.Color as AwtColor
89

910
@Stacked
1011
infix fun <T : StyleSetter<T>> T.dye(color: TextColor) = color(color)
1112

1213
@Stacked
1314
infix fun <T : StyleSetter<T>> T.dye(color: AscendColor) = this dye color.asKotlinColor()
1415

16+
@Stacked
17+
infix fun <T : StyleSetter<T>> T.dye(color: AwtColor) = this dye TextColor.color(color.rgb)
18+
1519
fun <T : StyleSetter<T>> T.dyeBlack() = this dye NamedTextColor.BLACK
1620

1721
fun <T : StyleSetter<T>> T.dyeDarkBlue() = this dye NamedTextColor.DARK_BLUE

0 commit comments

Comments
 (0)