fix MESSAGE exploit !!!

This commit is contained in:
Chayapak 2023-05-07 07:35:20 +07:00
parent 82a0d8e31f
commit 3d511788a3

View file

@ -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("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\":")
.replace("MESSAGE", sanitizedMessage.replaceAll("&.", "")); // TODO: make this not use regex
.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) {