Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-23 23:00:13 +01:00
Fix item hover event for 1.12 players
Dieser Commit ist enthalten in:
Ursprung
98a8f7f072
Commit
ee54e153bf
@ -3,6 +3,7 @@ package us.myles.ViaVersion.protocols.protocol1_12to1_11_1;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
@ -20,23 +21,30 @@ public class ChatItemRewriter {
|
||||
if (hoverEvent.has("action") && hoverEvent.has("value")) {
|
||||
String type = hoverEvent.get("action").getAsString();
|
||||
if (type.equals("show_item") || type.equals("show_entity")) {
|
||||
if (hoverEvent.get("value").isJsonPrimitive()) {
|
||||
if (hoverEvent.get("value").getAsJsonPrimitive().isString()) {
|
||||
String value = hoverEvent.get("value").getAsString();
|
||||
value = indexRemoval.matcher(value).replaceAll("");
|
||||
hoverEvent.addProperty("value", value);
|
||||
JsonElement value = hoverEvent.get("value");
|
||||
|
||||
if (value.isJsonPrimitive() && value.getAsJsonPrimitive().isString()) {
|
||||
String newValue = indexRemoval.matcher(value.getAsString()).replaceAll("");
|
||||
hoverEvent.addProperty("value", newValue);
|
||||
} 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));
|
||||
}
|
||||
}
|
||||
|
||||
hoverEvent.add("value", newArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (obj.has("extra")) {
|
||||
toClient(obj.get("extra"), user);
|
||||
}
|
||||
} else if (obj.has("extra")) {
|
||||
toClient(obj.get("extra"), user);
|
||||
}
|
||||
}
|
||||
if (element instanceof JsonArray) {
|
||||
} else if (element instanceof JsonArray) {
|
||||
JsonArray array = (JsonArray) element;
|
||||
for (JsonElement value : array) {
|
||||
toClient(value, user);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren