From cfe0d806a1db9b8bcadbd4fa5035d91ecb6811b4 Mon Sep 17 00:00:00 2001 From: Josh Date: Mon, 1 May 2023 09:32:18 +0100 Subject: [PATCH] Add date on hover to actionlog (#3597) --- .../main/java/me/lucko/luckperms/common/locale/Message.java | 6 ++++++ common/src/main/resources/luckperms_en.properties | 1 + 2 files changed, 7 insertions(+) diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/Message.java b/common/src/main/java/me/lucko/luckperms/common/locale/Message.java index 74fee43d5..5a1ea2489 100644 --- a/common/src/main/java/me/lucko/luckperms/common/locale/Message.java +++ b/common/src/main/java/me/lucko/luckperms/common/locale/Message.java @@ -55,6 +55,8 @@ import net.luckperms.api.util.Tristate; import java.time.Duration; import java.time.Instant; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -88,6 +90,9 @@ import static net.kyori.adventure.text.format.TextDecoration.BOLD; */ public interface Message { + static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd '@' HH:mm:ss") + .withZone(ZoneId.systemDefault()); + TextComponent OPEN_BRACKET = Component.text('('); TextComponent CLOSE_BRACKET = Component.text(')'); TextComponent FULL_STOP = Component.text('.'); @@ -3717,6 +3722,7 @@ public interface Message { .color(GRAY) .key("luckperms.duration.since") .args(DurationFormatter.CONCISE_LOW_ACCURACY.format(action.getDurationSince())) + .hoverEvent(HoverEvent.showText(text().append(translatable("luckperms.duration.date", GRAY)).append(text(": ", GRAY)).append(text(DATE_FORMAT.format(action.getTimestamp()), AQUA)))) ) .append(CLOSE_BRACKET) ) diff --git a/common/src/main/resources/luckperms_en.properties b/common/src/main/resources/luckperms_en.properties index c8668e2ac..8939215fe 100644 --- a/common/src/main/resources/luckperms_en.properties +++ b/common/src/main/resources/luckperms_en.properties @@ -54,6 +54,7 @@ luckperms.duration.unit.seconds.plural={0} seconds luckperms.duration.unit.seconds.singular={0} second luckperms.duration.unit.seconds.short={0}s luckperms.duration.since={0} ago +luckperms.duration.date=Date luckperms.command.misc.invalid-code=Invalid code luckperms.command.misc.response-code-key=response code luckperms.command.misc.error-message-key=message