Skip to content

Commit 08a42b3

Browse files
committed
Replace home-made legacy hover event serializer with Adventure's implementation
This technically can break backwards compatibility, but this seems to be very unlikely to be the practice in reality. (The Velocity implementation probably wasn't correct, anyway.)
1 parent dc40e16 commit 08a42b3

File tree

4 files changed

+7
-130
lines changed

4 files changed

+7
-130
lines changed

gradle/libs.versions.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ spotless = "com.diffplug.spotless:6.25.0"
1212

1313
[libraries]
1414
adventure-bom = "net.kyori:adventure-bom:4.17.0"
15-
adventure-facet = "net.kyori:adventure-platform-facet:4.3.2"
15+
adventure-text-serializer-json-legacy-impl = "net.kyori:adventure-text-serializer-json-legacy-impl:4.17.0"
16+
adventure-facet = "net.kyori:adventure-platform-facet:4.3.4"
1617
asm = "org.ow2.asm:asm:9.6"
1718
auto-service = "com.google.auto.service:auto-service:1.0.1"
1819
auto-service-annotations = "com.google.auto.service:auto-service-annotations:1.0.1"

proxy/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ dependencies {
127127
runtimeOnly(libs.disruptor)
128128
implementation(libs.fastutil)
129129
implementation(platform(libs.adventure.bom))
130-
implementation("net.kyori:adventure-nbt")
130+
implementation(libs.adventure.text.serializer.json.legacy.impl)
131131
implementation(libs.adventure.facet)
132132
implementation(libs.completablefutures)
133133
implementation(libs.nightconfig)

proxy/src/main/java/com/velocitypowered/proxy/protocol/ProtocolUtils.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import com.velocitypowered.api.util.GameProfile;
2626
import com.velocitypowered.proxy.crypto.IdentifiedKeyImpl;
2727
import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder;
28-
import com.velocitypowered.proxy.protocol.util.VelocityLegacyHoverEventSerializer;
2928
import com.velocitypowered.proxy.util.except.QuietDecoderException;
3029
import io.netty.buffer.ByteBuf;
3130
import io.netty.buffer.ByteBufInputStream;
@@ -47,6 +46,7 @@
4746
import net.kyori.adventure.nbt.CompoundBinaryTag;
4847
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
4948
import net.kyori.adventure.text.serializer.json.JSONOptions;
49+
import net.kyori.adventure.text.serializer.json.legacyimpl.NBTLegacyHoverEventSerializer;
5050
import net.kyori.option.OptionState;
5151

5252
/**
@@ -58,8 +58,7 @@ public enum ProtocolUtils {
5858
private static final GsonComponentSerializer PRE_1_16_SERIALIZER =
5959
GsonComponentSerializer.builder()
6060
.downsampleColors()
61-
.emitLegacyHoverEvent()
62-
.legacyHoverEventSerializer(VelocityLegacyHoverEventSerializer.INSTANCE)
61+
.legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.get())
6362
.options(
6463
OptionState.optionState()
6564
// before 1.16
@@ -74,7 +73,7 @@ public enum ProtocolUtils {
7473
.build();
7574
private static final GsonComponentSerializer PRE_1_20_3_SERIALIZER =
7675
GsonComponentSerializer.builder()
77-
.legacyHoverEventSerializer(VelocityLegacyHoverEventSerializer.INSTANCE)
76+
.legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.get())
7877
.options(
7978
OptionState.optionState()
8079
// after 1.16
@@ -89,7 +88,7 @@ public enum ProtocolUtils {
8988
.build();
9089
private static final GsonComponentSerializer MODERN_SERIALIZER =
9190
GsonComponentSerializer.builder()
92-
.legacyHoverEventSerializer(VelocityLegacyHoverEventSerializer.INSTANCE)
91+
.legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.get())
9392
.options(
9493
OptionState.optionState()
9594
// after 1.16

proxy/src/main/java/com/velocitypowered/proxy/protocol/util/VelocityLegacyHoverEventSerializer.java

-123
This file was deleted.

0 commit comments

Comments
 (0)