refactor: change custom chat default format (not tested but should work)

This commit is contained in:
Chayapak Supasakul 2025-04-24 11:55:02 +07:00
parent 2f7b1268c6
commit 117f52583b
Signed by: ChomeNS
SSH key fingerprint: SHA256:0YoxhdyXsgbc0nfeB2N6FYE60mxMU7DS4uCUMaw2mvA

View file

@ -1,6 +1,9 @@
package land.chipmunk.chipmunkmod.config; package land.chipmunk.chipmunkmod.config;
import net.kyori.adventure.text.Component; 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.BlockBox;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -77,9 +80,33 @@ public class Configuration {
@ConfigSerializable @ConfigSerializable
public static class CustomChat { public static class CustomChat {
public @NotNull Component format = public @NotNull Component format =
Component.translatable("chat.type.text", // chipmunk's custom chat format
Component.selector("@s"), // §8[§7Chat§8] §aUSERNAME§8 §7MESSAGE
Component.text("MESSAGE") // 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"))
);
} }
} }