aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/util/textutil.kt
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-10-30 16:35:19 +0100
committerLinnea Gräf <nea@nea.moe>2024-10-30 16:35:19 +0100
commitc9c25b61560e6fb4e1ba2dfb1d5cc61b0ec9ddab (patch)
treefa13364bf64a70e93969992069e12865fb24ca09 /src/main/kotlin/util/textutil.kt
parentc38dcee2c5f483ef5990ae9204355e1bc3c2bf74 (diff)
downloadFirmament-c9c25b61560e6fb4e1ba2dfb1d5cc61b0ec9ddab.tar.gz
Firmament-c9c25b61560e6fb4e1ba2dfb1d5cc61b0ec9ddab.tar.bz2
Firmament-c9c25b61560e6fb4e1ba2dfb1d5cc61b0ec9ddab.zip
Add warning for missing REI
Diffstat (limited to 'src/main/kotlin/util/textutil.kt')
-rw-r--r--src/main/kotlin/util/textutil.kt26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/main/kotlin/util/textutil.kt b/src/main/kotlin/util/textutil.kt
index 252f708..a6a7e87 100644
--- a/src/main/kotlin/util/textutil.kt
+++ b/src/main/kotlin/util/textutil.kt
@@ -1,5 +1,6 @@
package moe.nea.firmament.util
+import net.minecraft.text.ClickEvent
import net.minecraft.text.MutableText
import net.minecraft.text.PlainTextContent
import net.minecraft.text.Text
@@ -119,7 +120,30 @@ fun Text.iterator(): Sequence<Text> {
fun Text.allSiblings(): List<Text> = listOf(this) + siblings.flatMap { it.allSiblings() }
-fun MutableText.withColor(formatting: Formatting) = this.styled { it.withColor(formatting).withItalic(false) }
+fun MutableText.withColor(formatting: Formatting): MutableText = this.styled {
+ it.withColor(formatting)
+ .withItalic(false)
+ .withBold(false)
+}
+
+fun MutableText.blue() = withColor(Formatting.BLUE)
+fun MutableText.aqua() = withColor(Formatting.AQUA)
+fun MutableText.lime() = withColor(Formatting.GREEN)
+fun MutableText.darkGreen() = withColor(Formatting.DARK_GREEN)
+fun MutableText.yellow() = withColor(Formatting.YELLOW)
+fun MutableText.grey() = withColor(Formatting.GRAY)
+fun MutableText.red() = withColor(Formatting.RED)
+fun MutableText.white() = withColor(Formatting.WHITE)
+fun MutableText.bold(): MutableText = styled { it.withBold(true) }
+
+
+fun MutableText.clickCommand(command: String): MutableText {
+ require(command.startsWith("/"))
+ return this.styled {
+ it.withClickEvent(ClickEvent(ClickEvent.Action.RUN_COMMAND,
+ "/firm disablereiwarning"))
+ }
+}
fun Text.transformEachRecursively(function: (Text) -> Text): Text {
val c = this.content