Skip to content

Commit 0078ead

Browse files
committed
Update ChatTimestamp.kt
1 parent e600909 commit 0078ead

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import com.lambda.util.text.buildText
2929
import com.lambda.util.text.literal
3030
import com.lambda.util.text.styled
3131
import com.lambda.util.text.text
32+
import net.minecraft.util.Formatting
3233
import java.awt.Color
3334
import java.time.LocalDateTime
3435
import java.time.ZoneId
@@ -40,18 +41,23 @@ object ChatTimestamp : Module(
4041
description = "Displays the time a message was sent next to it",
4142
tag = ModuleTag.CHAT,
4243
) {
44+
var color: Formatting by setting("Color", Formatting.GRAY)
45+
.onValueChange { from, to -> if (to.colorIndex !in 0..15) color = from }
46+
47+
val javaColor: Color get() = Color(color.colorValue!! and 16777215)
48+
4349
val formatter = FormatterSettings(this).apply { applyEdits { hide(::localeEnum, ::sep, ::customSep, ::group, ::floatingPrecision); editTyped(::timeFormat) { defaultValue(FormatterConfig.Time.IsoLocalTime) } } }
4450

4551
private val currentTime get() =
4652
ZonedDateTime.of(LocalDateTime.now(), ZoneId.systemDefault())
47-
.truncatedTo(ChronoUnit.MINUTES)
53+
.truncatedTo(ChronoUnit.SECONDS)
4854

4955
init {
5056
listen<ChatEvent.Receive> {
5157
it.message = buildText {
5258
text(it.message)
5359
literal(" ")
54-
styled(Color.GRAY, italic = true) { literal(currentTime.format(formatter)) }
60+
styled(javaColor, italic = true) { literal(currentTime.format(formatter)) }
5561
}
5662
}
5763
}

0 commit comments

Comments
 (0)