This commit is contained in:
Chayapak 2023-05-05 16:06:29 +07:00
parent cb2fd9401e
commit ea460eed12

View file

@ -2,13 +2,10 @@ package land.chipmunk.chipmunkmod.modules;
import com.google.gson.JsonElement;
import land.chipmunk.chipmunkmod.ChipmunkMod;
import land.chipmunk.chipmunkmod.data.MutablePlayerListEntry;
import lombok.Getter;
import lombok.Setter;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.JoinConfiguration;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
@ -45,24 +42,17 @@ public class CustomChat {
try {
// final MutablePlayerListEntry entry = Players.INSTANCE.getEntry(client.getNetworkHandler().getProfile().getId());
//
// final Component displayNameComponent = entry.displayName().asComponent();
// final String prefix = GsonComponentSerializer.gson().serialize(Component.join(JoinConfiguration.separator(Component.empty()), displayNameComponent.children().get(0)));
// final String displayName = GsonComponentSerializer.gson().serialize(Component.join(JoinConfiguration.separator(Component.empty()), displayNameComponent.children().get(1)));
String sanitizedFormat;
try {
sanitizedFormat = format
final String sanitizedFormat = format
// .replace("\"PREFIX\"", prefix)
// .replace("\"DISPLAYNAME\"", displayName)
.replace("USERNAME", username)
.replace("MESSAGE", sanitizedMessage);
} catch (Exception e) {
sanitizedFormat = format
.replace("USERNAME", username)
.replace("MESSAGE", sanitizedMessage);
}
.replace("USERNAME", username)
.replace("MESSAGE", sanitizedMessage);
CommandCore.INSTANCE.run("minecraft:tellraw @a " + sanitizedFormat);
} catch (Exception e) {