diff --git a/src/main/java/land/chipmunk/chipmunkmod/modules/CustomChat.java b/src/main/java/land/chipmunk/chipmunkmod/modules/CustomChat.java index 9731ffc..1983853 100644 --- a/src/main/java/land/chipmunk/chipmunkmod/modules/CustomChat.java +++ b/src/main/java/land/chipmunk/chipmunkmod/modules/CustomChat.java @@ -56,16 +56,21 @@ public class CustomChat { // final String displayName = GsonComponentSerializer.gson().serialize(Component.join(JoinConfiguration.separator(Component.empty()), displayNameComponent.children().get(1))); // TODO: make this code not ohio code.,., - final String sanitizedFormat = format + String sanitizedFormat = format // .replace("\"PREFIX\"", prefix) // .replace("\"DISPLAYNAME\"", displayName) - .replace("USERNAME", username) - - // these 2 lines are toooooo ohio code - .replace("{\"text\":\"MESSAGE\"}", messageWithColor) - .replace("\"extra\":[\"MESSAGE\"],\"color\":", "\"extra\":[" + messageWithColor + "],\"color\":") - - .replace("MESSAGE", sanitizedMessage.replaceAll("&.", "")); // TODO: make this not use regex + .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 + } CommandCore.INSTANCE.run("minecraft:tellraw @a " + sanitizedFormat); } catch (Exception e) {