fix copy not working in chomens format that everyone uses.,,.
This commit is contained in:
parent
3d511788a3
commit
83671e103e
1 changed files with 8 additions and 13 deletions
|
@ -44,8 +44,10 @@ public class CustomChat {
|
|||
|
||||
final LegacyComponentSerializer serializer = LegacyComponentSerializer.legacyAmpersand();
|
||||
|
||||
final String randomized = String.valueOf(Math.random());
|
||||
|
||||
final Component deserialized = serializer.deserialize(message);
|
||||
final String messageWithColor = GsonComponentSerializer.gson().serialize(deserialized);
|
||||
final String messageWithColor = GsonComponentSerializer.gson().serialize(deserialized).replace("MESSAGE", randomized);
|
||||
|
||||
try {
|
||||
// final MutablePlayerListEntry entry = Players.INSTANCE.getEntry(client.getNetworkHandler().getProfile().getId());
|
||||
|
@ -59,18 +61,11 @@ public class CustomChat {
|
|||
String sanitizedFormat = format
|
||||
// .replace("\"PREFIX\"", prefix)
|
||||
// .replace("\"DISPLAYNAME\"", displayName)
|
||||
.replace("USERNAME", username);
|
||||
// these 4 lines are toooooo ohio code
|
||||
if (
|
||||
sanitizedFormat.contains("{\"text\":\"MESSAGE\"}") ||
|
||||
sanitizedFormat.contains("\"extra\":[\"MESSAGE\"],\"color\":")
|
||||
) {
|
||||
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
|
||||
}
|
||||
.replace("USERNAME", username)
|
||||
.replace("{\"text\":\"MESSAGE\"}", messageWithColor)
|
||||
.replace("\"extra\":[\"MESSAGE\"],\"color\":", "\"extra\":[" + messageWithColor + "],\"color\":")
|
||||
.replace("MESSAGE", sanitizedMessage.replaceAll("&.", "")) // TODO: make this not use regex
|
||||
.replace(randomized, "MESSAGE"); // ohio ohio
|
||||
|
||||
CommandCore.INSTANCE.run("minecraft:tellraw @a " + sanitizedFormat);
|
||||
} catch (Exception e) {
|
||||
|
|
Loading…
Reference in a new issue