PlayerListHeaderAndFooterPacket
This commit is contained in:
@@ -61,7 +61,8 @@ public enum State {
|
|||||||
PlayerAbilitiesPacket.class,0x2C,
|
PlayerAbilitiesPacket.class,0x2C,
|
||||||
PlayerListItemPacket.class,0x2E,
|
PlayerListItemPacket.class,0x2E,
|
||||||
SPlayerPositionAndLookPacket.class, 0x2F,
|
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>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @see <a href="https://wiki.vg/index.php?title=Protocol&oldid=14204#Player_List_Item">Player List Item</a>
|
* @see <a href="https://wiki.vg/index.php?title=Protocol&oldid=14204#Player_List_Item">Player List Item</a>
|
||||||
|
* @see PlayerListHeaderAndFooterPacket
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class PlayerListItemPacket implements ServerSidePacket {
|
public class PlayerListItemPacket implements ServerSidePacket {
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import mc.protocol.api.ConnectionContext;
|
|||||||
import mc.protocol.model.Location;
|
import mc.protocol.model.Location;
|
||||||
import mc.protocol.model.Look;
|
import mc.protocol.model.Look;
|
||||||
import mc.protocol.model.ServerInfo;
|
import mc.protocol.model.ServerInfo;
|
||||||
|
import mc.protocol.model.text.Text;
|
||||||
|
import mc.protocol.model.text.TextColor;
|
||||||
import mc.protocol.packets.PingPacket;
|
import mc.protocol.packets.PingPacket;
|
||||||
import mc.protocol.packets.client.HandshakePacket;
|
import mc.protocol.packets.client.HandshakePacket;
|
||||||
import mc.protocol.packets.client.LoginStartPacket;
|
import mc.protocol.packets.client.LoginStartPacket;
|
||||||
@@ -139,7 +141,20 @@ public class PacketHandler {
|
|||||||
.hasDisplayName(false)
|
.hasDisplayName(false)
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
context.sendNow(playerListItemPacket);
|
context.send(playerListItemPacket);
|
||||||
|
|
||||||
|
var playerListHeaderAndFooterPacket = new PlayerListHeaderAndFooterPacket();
|
||||||
|
playerListHeaderAndFooterPacket.setHeader(Text.builder()
|
||||||
|
.append("") //TODO bug component
|
||||||
|
.append(Text.of(TextColor.GREEN, "==="))
|
||||||
|
.append(Text.of(TextColor.RED, " MC-PROJECT "))
|
||||||
|
.append(Text.of(TextColor.GREEN, "==="))
|
||||||
|
.build());
|
||||||
|
playerListHeaderAndFooterPacket.setFoother(Text.of(TextColor.GRAY, "develop by DmitriyMX"));
|
||||||
|
|
||||||
|
context.send(playerListHeaderAndFooterPacket);
|
||||||
|
|
||||||
|
context.flushSending();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String faviconToBase64(Path iconPath) {
|
private static String faviconToBase64(Path iconPath) {
|
||||||
|
|||||||
Reference in New Issue
Block a user