[fix] Bug with ChatTimeStamp and added separator options

Signed-off-by: Dominika <sokolov.dominika@gmail.com>
This commit is contained in:
Dominika 2021-01-07 21:52:13 -05:00
parent cbaee402d7
commit ebd4b9cd1b
No known key found for this signature in database
GPG Key ID: B4A5A6DCA70F861F
2 changed files with 18 additions and 5 deletions

View File

@ -7,6 +7,7 @@ import me.zeroeightsix.kami.util.color.EnumTextColor
import me.zeroeightsix.kami.util.text.format
import net.minecraft.util.text.TextComponentString
import net.minecraftforge.client.event.ClientChatReceivedEvent
import org.kamiblue.commons.interfaces.DisplayEnum
import org.kamiblue.event.listener.listener
object ChatTimestamp : Module(
@ -15,9 +16,10 @@ object ChatTimestamp : Module(
description = "Shows the time a message was sent beside the message",
showOnArray = false
) {
private val color = setting("Color", EnumTextColor.GRAY)
private val timeFormat = setting("TimeFormat", TimeUtils.TimeFormat.HHMM)
private val timeUnit = setting("TimeUnit", TimeUtils.TimeUnit.H12)
private val color by setting("Color", EnumTextColor.GRAY)
private val separator by setting("Separator", Separator.ARROWS)
private val timeFormat by setting("TimeFormat", TimeUtils.TimeFormat.HHMM)
private val timeUnit by setting("TimeUnit", TimeUtils.TimeUnit.H12)
init {
listener<ClientChatReceivedEvent> {
@ -27,5 +29,14 @@ object ChatTimestamp : Module(
}
val formattedTime: String
get() = "<${color.value format TimeUtils.getTime(timeFormat.value, timeUnit.value)}>"
get() = "${separator.left}${color format TimeUtils.getTime(timeFormat, timeUnit)}${separator.right} "
@Suppress("unused")
private enum class Separator(override val displayName: String, val left: String, val right: String) : DisplayEnum {
ARROWS("< >", "<", ">"),
SQUARE_BRACKETS("[ ]", "[", "]"),
CURLY_BRACKETS("{ }", "{", "}"),
ROUND_BRACKETS("( )", "(", ")"),
NONE("None", "", "")
}
}

View File

@ -19,5 +19,7 @@ enum class EnumTextColor(val textFormatting: TextFormatting) {
RED(TextFormatting.RED),
LIGHT_PURPLE(TextFormatting.LIGHT_PURPLE),
YELLOW(TextFormatting.YELLOW),
WHITE(TextFormatting.WHITE)
WHITE(TextFormatting.WHITE);
override fun toString(): String = this.textFormatting.toString()
}