Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing handling of text components in 1.11.1>1.12 chat item rewriter #3662

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -42,13 +42,31 @@ public static void toClient(JsonElement element, UserConnection user) {
if (value.isJsonPrimitive() && value.getAsJsonPrimitive().isString()) {
String newValue = indexRemoval.matcher(value.getAsString()).replaceAll("");
hoverEvent.addProperty("value", newValue);
} else if (value.isJsonObject() && value.getAsJsonObject().has("text")) {
JsonObject newObject = (JsonObject) value;
JsonElement textElement = newObject.get("text");

if (textElement.isJsonPrimitive() && textElement.getAsJsonPrimitive().isString()) {
String newValue = indexRemoval.matcher(textElement.getAsString()).replaceAll("");
newObject.addProperty("text", newValue);
hoverEvent.add("value", newObject);
}
} else if (value.isJsonArray()) {
JsonArray newArray = new JsonArray();

for (JsonElement valueElement : value.getAsJsonArray()) {
if (valueElement.isJsonPrimitive() && valueElement.getAsJsonPrimitive().isString()) {
String newValue = indexRemoval.matcher(valueElement.getAsString()).replaceAll("");
newArray.add(new JsonPrimitive(newValue));
} else if (valueElement.isJsonObject() && valueElement.getAsJsonObject().has("text")) {
JsonObject newObject = (JsonObject) valueElement;
JsonElement textElement = newObject.get("text");

if (textElement.isJsonPrimitive() && textElement.getAsJsonPrimitive().isString()) {
String newValue = indexRemoval.matcher(textElement.getAsString()).replaceAll("");
newObject.addProperty("text", newValue);
newArray.add(newObject);
}
}
}

Expand Down