This commit is contained in:
Aust1n46 2023-02-09 18:33:15 -06:00
commit d7d66e1786

View File

@ -68,10 +68,9 @@ public class Format {
*/ */
public static String convertToJson(MineverseChatPlayer sender, String format, String chat) { public static String convertToJson(MineverseChatPlayer sender, String format, String chat) {
JsonFormat JSONformat = JsonFormat.getJsonFormat(sender.getJsonFormat()); JsonFormat JSONformat = JsonFormat.getJsonFormat(sender.getJsonFormat());
String f = escapeJsonChars(format);
String c = escapeJsonChars(chat); String c = escapeJsonChars(chat);
String json = "[\"\",{\"text\":\"\",\"extra\":["; String json = "[\"\",{\"text\":\"\",\"extra\":[";
json += convertPlaceholders(f, JSONformat, sender); json += convertPlaceholders(format, JSONformat, sender);
json += "]}"; json += "]}";
json += "," + convertLinks(c); json += "," + convertLinks(c);
json += "]"; json += "]";
@ -111,8 +110,8 @@ public class Format {
indexStart = matcher.start(); indexStart = matcher.start();
indexEnd = matcher.end(); indexEnd = matcher.end();
placeholder = remaining.substring(indexStart, indexEnd); placeholder = remaining.substring(indexStart, indexEnd);
formattedPlaceholder = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), placeholder)); formattedPlaceholder = escapeJsonChars(Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), placeholder)));
temp += convertToJsonColors(lastCode + remaining.substring(0, indexStart)) + ","; temp += convertToJsonColors(escapeJsonChars(lastCode + remaining.substring(0, indexStart))) + ",";
lastCode = getLastCode(lastCode + remaining.substring(0, indexStart)); lastCode = getLastCode(lastCode + remaining.substring(0, indexStart));
boolean placeholderHasJsonAttribute = false; boolean placeholderHasJsonAttribute = false;
for (JsonAttribute jsonAttribute : format.getJsonAttributes()) { for (JsonAttribute jsonAttribute : format.getJsonAttributes()) {
@ -123,8 +122,8 @@ public class Format {
} }
final String hoverText; final String hoverText;
if(!hover.isEmpty()) { if(!hover.isEmpty()) {
hoverText = Format.FormatStringAll( hoverText = escapeJsonChars(Format.FormatStringAll(
PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), hover.substring(0, hover.length() - 1))); PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), hover.substring(0, hover.length() - 1))));
} else { } else {
hoverText = StringUtils.EMPTY; hoverText = StringUtils.EMPTY;
} }
@ -133,8 +132,8 @@ public class Format {
if (clickAction == ClickAction.NONE) { if (clickAction == ClickAction.NONE) {
actionJson = StringUtils.EMPTY; actionJson = StringUtils.EMPTY;
} else { } else {
final String clickText = Format.FormatStringAll( final String clickText = escapeJsonChars(Format.FormatStringAll(
PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), jsonAttribute.getClickText())); PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), jsonAttribute.getClickText())));
actionJson = ",\"clickEvent\":{\"action\":\"" + jsonAttribute.getClickAction().toString() + "\",\"value\":\"" + clickText actionJson = ",\"clickEvent\":{\"action\":\"" + jsonAttribute.getClickAction().toString() + "\",\"value\":\"" + clickText
+ "\"}"; + "\"}";
} }