Skip to content

Commit ab17179

Browse files
feature: add color conversion properties
Add additional getter-properties to transform awt colors into adventure TextColors and vice versa. A rewrite of the #119 PR, made by @ InvalidJoker Co-authored-by: InvalidJoker <83445245+InvalidJoker@users.noreply.github.com>
1 parent 2d02ccf commit ab17179

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package dev.fruxz.stacked.extension
2+
3+
import net.kyori.adventure.text.format.TextColor
4+
import java.awt.Color as AwtColor
5+
6+
val TextColor.asAwtColor: AwtColor
7+
get() = AwtColor(this.value())
8+
9+
val AwtColor.asTextColor: TextColor
10+
get() = TextColor.color(this.rgb)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import java.awt.Color as AwtColor
1010
infix fun <T : StyleSetter<T>> T.dye(color: TextColor) = color(color)
1111

1212
@Stacked
13-
infix fun <T : StyleSetter<T>> T.dye(color: AwtColor) = this dye TextColor.color(color.rgb)
13+
infix fun <T : StyleSetter<T>> T.dye(color: AwtColor) = this dye color.asTextColor
1414

1515
fun <T : StyleSetter<T>> T.dyeBlack() = this dye NamedTextColor.BLACK
1616

0 commit comments

Comments
 (0)