feat: pass UUID placeholder to CustomChat

This commit is contained in:
amyavi 2024-12-31 02:12:26 -03:00
parent c61773fb73
commit fc4e2d2ccc
No known key found for this signature in database
2 changed files with 2 additions and 6 deletions

View file

@ -4,8 +4,6 @@ import com.google.common.hash.Hashing;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import land.chipmunk.chipmunkmod.ChipmunkMod; import land.chipmunk.chipmunkmod.ChipmunkMod;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
@ -13,13 +11,10 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.text.Text;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class CustomChat { public class CustomChat {
private final MinecraftClient client; private final MinecraftClient client;
@ -127,6 +122,7 @@ public class CustomChat {
// .replace("\"PREFIX\"", prefix) // .replace("\"PREFIX\"", prefix)
// .replace("\"DISPLAYNAME\"", displayName) // .replace("\"DISPLAYNAME\"", displayName)
.replace("USERNAME", username) .replace("USERNAME", username)
.replace("UUID", player.getUuidAsString())
.replace("HASH", hash) .replace("HASH", hash)
.replace("{\"text\":\"MESSAGE\"}", messageWithColor) .replace("{\"text\":\"MESSAGE\"}", messageWithColor)
.replace("\"extra\":[\"MESSAGE\"],\"color\":", "\"extra\":[" + messageWithColor + "],\"color\":") .replace("\"extra\":[\"MESSAGE\"],\"color\":", "\"extra\":[" + messageWithColor + "],\"color\":")

View file

@ -26,7 +26,7 @@
"translate": "chat.type.text", "translate": "chat.type.text",
"with": [ "with": [
{ {
"selector": "USERNAME" "selector": "UUID"
}, },
{ {
"text": "MESSAGE" "text": "MESSAGE"