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))); // final String displayName = GsonComponentSerializer.gson().serialize(Component.join(JoinConfiguration.separator(Component.empty()), displayNameComponent.children().get(1)));
// TODO: make this code not ohio code.,., // TODO: make this code not ohio code.,.,
final String sanitizedFormat = format String sanitizedFormat = format
// .replace("\"PREFIX\"", prefix) // .replace("\"PREFIX\"", prefix)
// .replace("\"DISPLAYNAME\"", displayName) // .replace("\"DISPLAYNAME\"", displayName)
.replace("USERNAME", username) .replace("USERNAME", username);
// these 4 lines are toooooo ohio code
// these 2 lines are toooooo ohio code if (
sanitizedFormat.contains("{\"text\":\"MESSAGE\"}") ||
sanitizedFormat.contains("\"extra\":[\"MESSAGE\"],\"color\":")
) {
sanitizedFormat = sanitizedFormat
.replace("{\"text\":\"MESSAGE\"}", messageWithColor) .replace("{\"text\":\"MESSAGE\"}", messageWithColor)
.replace("\"extra\":[\"MESSAGE\"],\"color\":", "\"extra\":[" + messageWithColor + "],\"color\":") .replace("\"extra\":[\"MESSAGE\"],\"color\":", "\"extra\":[" + messageWithColor + "],\"color\":");
} else {
.replace("MESSAGE", sanitizedMessage.replaceAll("&.", "")); // TODO: make this not use regex sanitizedFormat = sanitizedFormat.replace("MESSAGE", sanitizedMessage.replaceAll("&.", "")); // TODO: make this not use regex
}
CommandCore.INSTANCE.run("minecraft:tellraw @a " + sanitizedFormat); CommandCore.INSTANCE.run("minecraft:tellraw @a " + sanitizedFormat);
} catch (Exception e) { } catch (Exception e) {