3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-19 14:30:16 +01:00

Fix legacy hover deserialization, add snapshot suffix to version

Dieser Commit ist enthalten in:
KennyTV 2021-05-14 10:59:43 +02:00
Ursprung 7b5b79f510
Commit 84c064fc11
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
3 geänderte Dateien mit 13 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -8,7 +8,7 @@ plugins {
allprojects {
group = "com.viaversion"
version = "4.0.0-21w19a"
version = "4.0.0-21w19a-SNAPSHOT"
description = "Allow newer clients to join older server versions."
}

Datei anzeigen

@ -23,11 +23,13 @@ import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.libs.kyori.adventure.text.Component;
import com.viaversion.viaversion.libs.kyori.adventure.text.format.TextDecoration;
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.legacyimpl.NBTLegacyHoverEventSerializer;
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.ComponentRewriter1_13;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
public class ChatRewriter {
public final class ChatRewriter {
public static final GsonComponentSerializer HOVER_GSON_SERIALIZER = GsonComponentSerializer.builder().emitLegacyHoverEvent().legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.get()).build();
private static final ComponentRewriter COMPONENT_REWRITER = new ComponentRewriter1_13();
public static String legacyTextToJsonString(String message, boolean itemData) {
@ -52,7 +54,7 @@ public class ChatRewriter {
public static String jsonToLegacyText(String value) {
try {
Component component = GsonComponentSerializer.gson().deserialize(value);
Component component = HOVER_GSON_SERIALIZER.deserialize(value);
return LegacyComponentSerializer.legacySection().serialize(component);
} catch (Exception e) {
Via.getPlatform().getLogger().warning("Error converting json text to legacy: " + value);

Datei anzeigen

@ -27,9 +27,10 @@ velocity = "1.1.0-SNAPSHOT"
[libraries]
adventure-api = { group = "net.kyori", name = "adventure-api", version.ref = "adventure" }
adventure-text-serializer-gson = { group = "net.kyori", name = "adventure-text-serializer-gson", version.ref = "adventure" }
adventure-text-serializer-legacy = { group = "net.kyori", name = "adventure-text-serializer-legacy", version.ref = "adventure" }
adventureApi = { group = "net.kyori", name = "adventure-api", version.ref = "adventure" }
adventureTextSerializerGson = { group = "net.kyori", name = "adventure-text-serializer-gson", version.ref = "adventure" }
adventureTextSerializerGsonLegacy = { group = "net.kyori", name = "adventure-text-serializer-gson-legacy-impl", version.ref = "adventure" }
adventureTextSerializerLegacy = { group = "net.kyori", name = "adventure-text-serializer-legacy", version.ref = "adventure" }
gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" }
fastutil = { group = "it.unimi.dsi", name = "fastutil", version.ref = "fastutil" }
@ -40,8 +41,8 @@ netty = { group = "io.netty", name = "netty-all", version.ref = "netty" }
guava = { group = "com.google.guava", name = "guava", version.ref = "guava" }
snakeYaml = { group = "org.yaml", name = "snakeyaml", version.ref = "snakeYaml" }
jupiter-api = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "junit" }
jupiter-engine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", version.ref = "junit" }
jupiterApi = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "junit" }
jupiterEngine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", version.ref = "junit" }
checkerQual = { group = "org.checkerframework", name = "checker-qual", version.ref = "checkerQual" }
paper = { group = "com.destroystokyo.paper", name = "paper-api", version.ref = "paper" }
@ -54,5 +55,5 @@ velocity = { group = "com.velocitypowered", name = "velocity-api", version.ref =
[bundles]
adventure = ["adventure-api", "adventure-text-serializer-gson", "adventure-text-serializer-legacy"]
junit = ["jupiter-api", "jupiter-engine"]
adventure = ["adventureApi", "adventureTextSerializerGson", "adventureTextSerializerGsonLegacy", "adventureTextSerializerLegacy"]
junit = ["jupiterApi", "jupiterEngine"]