PlayerListHeaderAndFooterPacket
This commit is contained in:
@@ -61,7 +61,8 @@ public enum State {
|
||||
PlayerAbilitiesPacket.class,0x2C,
|
||||
PlayerListItemPacket.class,0x2E,
|
||||
SPlayerPositionAndLookPacket.class, 0x2F,
|
||||
SpawnPositionPacket.class, 0x46
|
||||
SpawnPositionPacket.class, 0x46,
|
||||
PlayerListHeaderAndFooterPacket.class,0x4A
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package mc.protocol.packets.server;
|
||||
|
||||
import lombok.Data;
|
||||
import mc.protocol.io.NetByteBuf;
|
||||
import mc.protocol.model.text.Text;
|
||||
import mc.protocol.packets.ServerSidePacket;
|
||||
import mc.protocol.serializer.TextSerializer;
|
||||
|
||||
/**
|
||||
* Установка текста для "шапки" и "подвала" Tab-листа.
|
||||
*
|
||||
* <p>Структура пакета</p>
|
||||
* <pre>
|
||||
* | FIELD | TYPE | NOTES |
|
||||
* |--------|------|-------|
|
||||
* | Header | Text | |
|
||||
* | Footer | Text | |
|
||||
* </pre>
|
||||
*
|
||||
* <p>Для удаления "шапки" и/или "подвала", нужно отправить следующий {@link Text} компонент:</p>
|
||||
* <pre>
|
||||
* {"translate":""}
|
||||
* </pre>
|
||||
*
|
||||
* @see <a href="https://wiki.vg/index.php?title=Protocol&oldid=14204#Player_List_Header_And_Footer">Player List Header And Footer</a>
|
||||
* @see PlayerListItemPacket
|
||||
*/
|
||||
@Data
|
||||
public class PlayerListHeaderAndFooterPacket implements ServerSidePacket {
|
||||
|
||||
private static final String REMOVE_COMPONENT = "{\"translate\":\"\"}";
|
||||
|
||||
private Text header;
|
||||
private Text foother;
|
||||
|
||||
@Override
|
||||
public void writeSelf(NetByteBuf netByteBuf) {
|
||||
if (this.header == null) {
|
||||
netByteBuf.writeString(REMOVE_COMPONENT);
|
||||
} else {
|
||||
netByteBuf.writeString(TextSerializer.toJsonObject(this.header).toString());
|
||||
}
|
||||
|
||||
if (this.foother == null) {
|
||||
netByteBuf.writeString(REMOVE_COMPONENT);
|
||||
} else {
|
||||
netByteBuf.writeString(TextSerializer.toJsonObject(this.foother).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,6 +60,7 @@ import java.util.function.BiConsumer;
|
||||
* </pre>
|
||||
*
|
||||
* @see <a href="https://wiki.vg/index.php?title=Protocol&oldid=14204#Player_List_Item">Player List Item</a>
|
||||
* @see PlayerListHeaderAndFooterPacket
|
||||
*/
|
||||
@Data
|
||||
public class PlayerListItemPacket implements ServerSidePacket {
|
||||
|
||||
Reference in New Issue
Block a user