diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/StatusSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/StatusSessionHandler.java index 4f38ffb44..0916d4aea 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/StatusSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/StatusSessionHandler.java @@ -69,7 +69,11 @@ public class StatusSessionHandler implements MinecraftSessionHandler { ProxyPingEvent event = new ProxyPingEvent(inboundWrapper, initialPing); server.getEventManager().fire(event) .thenRunAsync( - () -> connection.write(new StatusResponse(VelocityServer.GSON.toJson(event.getPing()))), + () -> { + StringBuilder json = new StringBuilder(); + VelocityServer.GSON.toJson(event.getPing(), json); + connection.write(new StatusResponse(json)); + }, connection.eventLoop()); return true; } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/ProtocolUtils.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/ProtocolUtils.java index 6b50392da..907a8640f 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/ProtocolUtils.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/ProtocolUtils.java @@ -88,7 +88,7 @@ public enum ProtocolUtils { * @param buf the buffer to write to * @param str the string to write */ - public static void writeString(ByteBuf buf, String str) { + public static void writeString(ByteBuf buf, CharSequence str) { int size = ByteBufUtil.utf8Bytes(str); writeVarInt(buf, size); ByteBufUtil.writeUtf8(buf, str); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/StatusResponse.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/StatusResponse.java index 84493513d..df0d856cc 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/StatusResponse.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/StatusResponse.java @@ -9,12 +9,12 @@ import org.checkerframework.checker.nullness.qual.Nullable; public class StatusResponse implements MinecraftPacket { - private @Nullable String status; + private @Nullable CharSequence status; public StatusResponse() { } - public StatusResponse(String status) { + public StatusResponse(CharSequence status) { this.status = status; } @@ -22,7 +22,7 @@ public class StatusResponse implements MinecraftPacket { if (status == null) { throw new IllegalStateException("Status is not specified"); } - return status; + return status.toString(); } @Override