From 83671e103ea83e76827a68673a5fc245af1fac5e Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Sun, 7 May 2023 08:04:17 +0700 Subject: [PATCH] fix copy not working in chomens format that everyone uses.,,. --- .../chipmunkmod/modules/CustomChat.java | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/main/java/land/chipmunk/chipmunkmod/modules/CustomChat.java b/src/main/java/land/chipmunk/chipmunkmod/modules/CustomChat.java index 1983853..ddf94ab 100644 --- a/src/main/java/land/chipmunk/chipmunkmod/modules/CustomChat.java +++ b/src/main/java/land/chipmunk/chipmunkmod/modules/CustomChat.java @@ -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) {