From ebd4b9cd1b47687b7984d5b0fcf3da43e735a262 Mon Sep 17 00:00:00 2001 From: Dominika Date: Thu, 7 Jan 2021 21:52:13 -0500 Subject: [PATCH] [fix] Bug with ChatTimeStamp and added separator options Signed-off-by: Dominika --- .../kami/module/modules/chat/ChatTimestamp.kt | 19 +++++++++++++++---- .../kami/util/color/EnumTextColor.kt | 4 +++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/main/java/me/zeroeightsix/kami/module/modules/chat/ChatTimestamp.kt b/src/main/java/me/zeroeightsix/kami/module/modules/chat/ChatTimestamp.kt index 2709a4d67..454b87e3a 100644 --- a/src/main/java/me/zeroeightsix/kami/module/modules/chat/ChatTimestamp.kt +++ b/src/main/java/me/zeroeightsix/kami/module/modules/chat/ChatTimestamp.kt @@ -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 { @@ -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", "", "") + } } \ No newline at end of file diff --git a/src/main/java/me/zeroeightsix/kami/util/color/EnumTextColor.kt b/src/main/java/me/zeroeightsix/kami/util/color/EnumTextColor.kt index 845666226..f2c63044b 100644 --- a/src/main/java/me/zeroeightsix/kami/util/color/EnumTextColor.kt +++ b/src/main/java/me/zeroeightsix/kami/util/color/EnumTextColor.kt @@ -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() } \ No newline at end of file