fix copy not working in chomens format that everyone uses.,,.

This commit is contained in:
Chayapak 2023-05-07 08:04:17 +07:00
parent 3d511788a3
commit 83671e103e

View file

@ -44,8 +44,10 @@ public class CustomChat {
final LegacyComponentSerializer serializer = LegacyComponentSerializer.legacyAmpersand(); final LegacyComponentSerializer serializer = LegacyComponentSerializer.legacyAmpersand();
final String randomized = String.valueOf(Math.random());
final Component deserialized = serializer.deserialize(message); final Component deserialized = serializer.deserialize(message);
final String messageWithColor = GsonComponentSerializer.gson().serialize(deserialized); final String messageWithColor = GsonComponentSerializer.gson().serialize(deserialized).replace("MESSAGE", randomized);
try { try {
// final MutablePlayerListEntry entry = Players.INSTANCE.getEntry(client.getNetworkHandler().getProfile().getId()); // final MutablePlayerListEntry entry = Players.INSTANCE.getEntry(client.getNetworkHandler().getProfile().getId());
@ -59,18 +61,11 @@ public class CustomChat {
String sanitizedFormat = format String sanitizedFormat = format
// .replace("\"PREFIX\"", prefix) // .replace("\"PREFIX\"", prefix)
// .replace("\"DISPLAYNAME\"", displayName) // .replace("\"DISPLAYNAME\"", displayName)
.replace("USERNAME", username); .replace("USERNAME", username)
// these 4 lines are toooooo ohio code .replace("{\"text\":\"MESSAGE\"}", messageWithColor)
if ( .replace("\"extra\":[\"MESSAGE\"],\"color\":", "\"extra\":[" + messageWithColor + "],\"color\":")
sanitizedFormat.contains("{\"text\":\"MESSAGE\"}") || .replace("MESSAGE", sanitizedMessage.replaceAll("&.", "")) // TODO: make this not use regex
sanitizedFormat.contains("\"extra\":[\"MESSAGE\"],\"color\":") .replace(randomized, "MESSAGE"); // ohio ohio
) {
sanitizedFormat = sanitizedFormat
.replace("{\"text\":\"MESSAGE\"}", messageWithColor)
.replace("\"extra\":[\"MESSAGE\"],\"color\":", "\"extra\":[" + messageWithColor + "],\"color\":");
} else {
sanitizedFormat = sanitizedFormat.replace("MESSAGE", sanitizedMessage.replaceAll("&.", "")); // TODO: make this not use regex
}
CommandCore.INSTANCE.run("minecraft:tellraw @a " + sanitizedFormat); CommandCore.INSTANCE.run("minecraft:tellraw @a " + sanitizedFormat);
} catch (Exception e) { } catch (Exception e) {