Fixed issue with experimental VentureChatBungee setting from DiscordSRV.

Created helper method for escaping JSON chars.
This commit is contained in:
Aust1n46 2021-02-19 17:43:24 -06:00
parent 87b49cec2b
commit 2ec0439581

View File

@ -53,8 +53,8 @@ public class Format {
*/
public static String convertToJson(MineverseChatPlayer sender, String format, String chat) {
JsonFormat JSONformat = MineverseChat.jfInfo.getJsonFormat(sender.getJsonFormat());
String f = format.replace("\\", "\\\\").replace("\"", "\\\"");
String c = chat.replace("\\", "\\\\").replace("\"", "\\\"");
String f = escapeJsonChars(format);
String c = escapeJsonChars(chat);
String json = "[\"\",{\"text\":\"\",\"extra\":[";
String prefix = "";
String suffix = "";
@ -426,12 +426,17 @@ public class Format {
}
public static String convertPlainTextToJson(String s, boolean convertURL) {
s = escapeJsonChars(s);
if (convertURL) {
return "[" + Format.convertLinks(s) + "]";
} else {
return "[" + convertToJsonColors(DEFAULT_COLOR_CODE + s) + "]";
}
}
private static String escapeJsonChars(String s) {
return s.replace("\\", "\\\\").replace("\"", "\\\"");
}
public static String formatModerationGUI(String json, Player player, String sender, String channelName, int hash) {
if (player.hasPermission("venturechat.gui")) {