add method to clear header and footer

This commit is contained in:
Leymooo
2018-08-25 04:45:10 +03:00
parent 1f8c8dcd94
commit d65e4ed296
3 changed files with 18 additions and 3 deletions

View File

@@ -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));

View File

@@ -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;
}
}