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) {