From 117f52583be389909a694afa466cf1460a6c65d5 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+chomens@users.noreply.github.com> Date: Thu, 24 Apr 2025 11:55:02 +0700 Subject: [PATCH] refactor: change custom chat default format (not tested but should work) --- .../chipmunkmod/config/Configuration.java | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/main/java/land/chipmunk/chipmunkmod/config/Configuration.java b/src/main/java/land/chipmunk/chipmunkmod/config/Configuration.java index cbc0d34..6123ec0 100644 --- a/src/main/java/land/chipmunk/chipmunkmod/config/Configuration.java +++ b/src/main/java/land/chipmunk/chipmunkmod/config/Configuration.java @@ -1,6 +1,9 @@ package land.chipmunk.chipmunkmod.config; import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.event.ClickEvent; +import net.kyori.adventure.text.event.HoverEvent; +import net.kyori.adventure.text.format.NamedTextColor; import net.minecraft.util.math.BlockBox; import net.minecraft.util.math.BlockPos; import org.jetbrains.annotations.NotNull; @@ -77,9 +80,33 @@ public class Configuration { @ConfigSerializable public static class CustomChat { public @NotNull Component format = - Component.translatable("chat.type.text", - Component.selector("@s"), - Component.text("MESSAGE") - ); + // chipmunk's custom chat format + // §8[§7Chat§8] §aUSERNAME§8 › §7MESSAGE + // but with `Chat` replaced with `ChipmunkMod` + // and click events and hover events added + Component + .translatable("[%s] %s › %s", NamedTextColor.DARK_GRAY, + Component.text("ChipmunkMod", NamedTextColor.GREEN) + .hoverEvent( + HoverEvent.showText( + Component.text( + "Click here to open the ChipmunkMod source code (chayapak's fork)", + NamedTextColor.GREEN + ) + ) + ) + .clickEvent(ClickEvent.openUrl("https://code.chipmunk.land/ChomeNS/chipmunkmod")), + Component.selector("@s").color(NamedTextColor.GREEN), + Component.text("MESSAGE", NamedTextColor.GRAY) + .hoverEvent( + HoverEvent.showText( + Component.text( + "Click here to copy the message to your clipboard", + NamedTextColor.GREEN + ) + ) + ) + .clickEvent(ClickEvent.copyToClipboard("MESSAGE")) + ); } }