diff --git a/api/src/main/java/com/velocitypowered/api/proxy/Player.java b/api/src/main/java/com/velocitypowered/api/proxy/Player.java index e1be76ee6..e90a34c13 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/Player.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/Player.java @@ -60,8 +60,13 @@ public interface Player extends CommandSource, InboundConnection, ChannelMessage * @param header component with header * @param footer component with footer */ - void setHeaderAndFooter(@NonNull Component header, @NonNull Component footer); - + void setHeaderAndFooter(Component header, Component footer); + + /** + * Clears a header and footer for the player + */ + void clearHeaderAndFooter(); + /** * Disconnects the player with the reason * @param reason component with the reason diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java index ac65b4571..91c88ce8b 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java @@ -144,6 +144,11 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { connection.write(HeaderAndFooter.create(header, footer)); } + @Override + public void clearHeaderAndFooter() { + connection.write(HeaderAndFooter.reset()); + } + @Override public void disconnect(Component reason) { connection.closeWith(Disconnect.create(reason)); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/HeaderAndFooter.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/HeaderAndFooter.java index 2b3141cb1..35c75af30 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/HeaderAndFooter.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/HeaderAndFooter.java @@ -11,6 +11,8 @@ import net.kyori.text.serializer.ComponentSerializers; public class HeaderAndFooter implements MinecraftPacket { + private static final HeaderAndFooter RESET = new HeaderAndFooter("{\"translate\":\"\"}", "{\"translate\":\"\"}"); + private String header; private String footer; @@ -40,7 +42,7 @@ public class HeaderAndFooter implements MinecraftPacket { @Override public void decode(ByteBuf buf, Direction direction, int protocolVersion) { - // We dont handle this packet from backend + throw new UnsupportedOperationException("Decode is not implemented"); } @Override @@ -54,4 +56,7 @@ public class HeaderAndFooter implements MinecraftPacket { return new HeaderAndFooter(json.serialize(header), json.serialize(footer)); } + public static HeaderAndFooter reset() { + return RESET; + } }