com.nukkitx.protocol.bedrock.packet.PlayerListPacket Java Examples

The following examples show how to use com.nukkitx.protocol.bedrock.packet.PlayerListPacket. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlayerListSerializer_v340.java    From Protocol with Apache License 2.0 6 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, PlayerListPacket packet) {
    PlayerListPacket.Action action = Action.values()[buffer.readUnsignedByte()];
    packet.setAction(action);
    int length = VarInts.readUnsignedInt(buffer);

    for (int i = 0; i < length; i++) {
        Entry entry = new Entry(BedrockUtils.readUuid(buffer));

        if (action == PlayerListPacket.Action.ADD) {
            entry.setEntityId(VarInts.readLong(buffer));
            entry.setName(BedrockUtils.readString(buffer));
            String skinId = BedrockUtils.readString(buffer);
            ImageData skinData = ImageData.of(BedrockUtils.readByteArray(buffer));
            ImageData capeData = ImageData.of(64, 32, BedrockUtils.readByteArray(buffer));
            String geometryName = BedrockUtils.readString(buffer);
            String geometryData = BedrockUtils.readString(buffer);
            entry.setSkin(SerializedSkin.of(skinId, skinData, capeData, geometryName, geometryData, false));
            entry.setXuid(BedrockUtils.readString(buffer));
            entry.setPlatformChatId(BedrockUtils.readString(buffer));
        }
        packet.getEntries().add(entry);
    }
}
 
Example #2
Source File: PlayerListSerializer_v291.java    From Protocol with Apache License 2.0 6 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, PlayerListPacket packet) {
    PlayerListPacket.Action action = PlayerListPacket.Action.values()[buffer.readUnsignedByte()];
    packet.setAction(action);
    int length = VarInts.readUnsignedInt(buffer);

    for (int i = 0; i < length; i++) {
        Entry entry = new Entry(BedrockUtils.readUuid(buffer));

        if (action == Action.ADD) {
            entry.setEntityId(VarInts.readLong(buffer));
            entry.setName(BedrockUtils.readString(buffer));
            String skinId = BedrockUtils.readString(buffer);
            ImageData skinData = ImageData.of(BedrockUtils.readByteArray(buffer));
            ImageData capeData = ImageData.of(64, 32, BedrockUtils.readByteArray(buffer));
            String geometryName = BedrockUtils.readString(buffer);
            String geometryData = BedrockUtils.readString(buffer);
            entry.setSkin(SerializedSkin.of(skinId, skinData, capeData, geometryName, geometryData, false));
            entry.setXuid(BedrockUtils.readString(buffer));
            entry.setPlatformChatId(BedrockUtils.readString(buffer));
        }
        packet.getEntries().add(entry);
    }
}
 
Example #3
Source File: PlayerListSerializer_v291.java    From Protocol with Apache License 2.0 6 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, PlayerListPacket packet) {
    buffer.writeByte(packet.getAction().ordinal());
    VarInts.writeUnsignedInt(buffer, packet.getEntries().size());

    for (Entry entry : packet.getEntries()) {
        BedrockUtils.writeUuid(buffer, entry.getUuid());

        if (packet.getAction() == Action.ADD) {
            VarInts.writeLong(buffer, entry.getEntityId());
            BedrockUtils.writeString(buffer, entry.getName());
            SerializedSkin skin = entry.getSkin();
            BedrockUtils.writeString(buffer, skin.getSkinId());
            skin.getSkinData().checkLegacySkinSize();
            BedrockUtils.writeByteArray(buffer, skin.getSkinData().getImage());
            skin.getCapeData().checkLegacyCapeSize();
            BedrockUtils.writeByteArray(buffer, skin.getCapeData().getImage());
            BedrockUtils.writeString(buffer, skin.getGeometryName());
            BedrockUtils.writeString(buffer, skin.getGeometryData());
            BedrockUtils.writeString(buffer, entry.getXuid());
            BedrockUtils.writeString(buffer, entry.getPlatformChatId());
        }
    }
}
 
Example #4
Source File: PlayerListSerializer_v332.java    From Protocol with Apache License 2.0 6 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, PlayerListPacket packet) {
    Action action = Action.values()[buffer.readUnsignedByte()];
    packet.setAction(action);
    int length = VarInts.readUnsignedInt(buffer);

    for (int i = 0; i < length; i++) {
        Entry entry = new Entry(BedrockUtils.readUuid(buffer));

        if (action == Action.ADD) {
            entry.setEntityId(VarInts.readLong(buffer));
            entry.setName(BedrockUtils.readString(buffer));
            String skinId = BedrockUtils.readString(buffer);
            ImageData skinData = ImageData.of(BedrockUtils.readByteArray(buffer));
            ImageData capeData = ImageData.of(64, 32, BedrockUtils.readByteArray(buffer));
            String geometryName = BedrockUtils.readString(buffer);
            String geometryData = BedrockUtils.readString(buffer);
            entry.setSkin(SerializedSkin.of(skinId, skinData, capeData, geometryName, geometryData, false));
            entry.setXuid(BedrockUtils.readString(buffer));
            entry.setPlatformChatId(BedrockUtils.readString(buffer));
        }
        packet.getEntries().add(entry);
    }
}
 
Example #5
Source File: PlayerListSerializer_v332.java    From Protocol with Apache License 2.0 6 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, PlayerListPacket packet) {
    buffer.writeByte(packet.getAction().ordinal());
    VarInts.writeUnsignedInt(buffer, packet.getEntries().size());

    for (Entry entry : packet.getEntries()) {
        BedrockUtils.writeUuid(buffer, entry.getUuid());

        if (packet.getAction() == PlayerListPacket.Action.ADD) {
            VarInts.writeLong(buffer, entry.getEntityId());
            BedrockUtils.writeString(buffer, entry.getName());
            SerializedSkin skin = entry.getSkin();
            BedrockUtils.writeString(buffer, skin.getSkinId());
            skin.getSkinData().checkLegacySkinSize();
            BedrockUtils.writeByteArray(buffer, skin.getSkinData().getImage());
            skin.getCapeData().checkLegacyCapeSize();
            BedrockUtils.writeByteArray(buffer, skin.getCapeData().getImage());
            BedrockUtils.writeString(buffer, skin.getGeometryName());
            BedrockUtils.writeString(buffer, skin.getGeometryData());
            BedrockUtils.writeString(buffer, entry.getXuid());
            BedrockUtils.writeString(buffer, entry.getPlatformChatId());
        }
    }
}
 
Example #6
Source File: PlayerListSerializer_v361.java    From Protocol with Apache License 2.0 6 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, PlayerListPacket packet) {
    Action action = Action.values()[buffer.readUnsignedByte()];
    packet.setAction(action);
    int length = VarInts.readUnsignedInt(buffer);

    for (int i = 0; i < length; i++) {
        Entry entry = new Entry(BedrockUtils.readUuid(buffer));

        if (action == Action.ADD) {
            entry.setEntityId(VarInts.readLong(buffer));
            entry.setName(BedrockUtils.readString(buffer));
            String skinId = BedrockUtils.readString(buffer);
            ImageData skinData = ImageData.of(BedrockUtils.readByteArray(buffer));
            ImageData capeData = ImageData.of(64, 32, BedrockUtils.readByteArray(buffer));
            String geometryName = BedrockUtils.readString(buffer);
            String geometryData = BedrockUtils.readString(buffer);
            entry.setSkin(SerializedSkin.of(skinId, skinData, capeData, geometryName, geometryData, false));
            entry.setXuid(BedrockUtils.readString(buffer));
            entry.setPlatformChatId(BedrockUtils.readString(buffer));
        }
        packet.getEntries().add(entry);
    }
}
 
Example #7
Source File: PlayerListSerializer_v361.java    From Protocol with Apache License 2.0 6 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, PlayerListPacket packet) {
    buffer.writeByte(packet.getAction().ordinal());
    VarInts.writeUnsignedInt(buffer, packet.getEntries().size());

    for (Entry entry : packet.getEntries()) {
        BedrockUtils.writeUuid(buffer, entry.getUuid());

        if (packet.getAction() == Action.ADD) {
            VarInts.writeLong(buffer, entry.getEntityId());
            BedrockUtils.writeString(buffer, entry.getName());
            SerializedSkin skin = entry.getSkin();
            BedrockUtils.writeString(buffer, skin.getSkinId());
            skin.getSkinData().checkLegacySkinSize();
            BedrockUtils.writeByteArray(buffer, skin.getSkinData().getImage());
            skin.getCapeData().checkLegacyCapeSize();
            BedrockUtils.writeByteArray(buffer, skin.getCapeData().getImage());
            BedrockUtils.writeString(buffer, skin.getGeometryName());
            BedrockUtils.writeString(buffer, skin.getGeometryData());
            BedrockUtils.writeString(buffer, entry.getXuid());
            BedrockUtils.writeString(buffer, entry.getPlatformChatId());
        }
    }
}
 
Example #8
Source File: PlayerListSerializer_v313.java    From Protocol with Apache License 2.0 6 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, PlayerListPacket packet) {
    PlayerListPacket.Action action = PlayerListPacket.Action.values()[buffer.readUnsignedByte()];
    packet.setAction(action);
    int length = VarInts.readUnsignedInt(buffer);

    for (int i = 0; i < length; i++) {
        Entry entry = new Entry(BedrockUtils.readUuid(buffer));

        if (action == PlayerListPacket.Action.ADD) {
            entry.setEntityId(VarInts.readLong(buffer));
            entry.setName(BedrockUtils.readString(buffer));
            String skinId = BedrockUtils.readString(buffer);
            ImageData skinData = ImageData.of(BedrockUtils.readByteArray(buffer));
            ImageData capeData = ImageData.of(64, 32, BedrockUtils.readByteArray(buffer));
            String geometryName = BedrockUtils.readString(buffer);
            String geometryData = BedrockUtils.readString(buffer);
            entry.setSkin(SerializedSkin.of(skinId, skinData, capeData, geometryName, geometryData, false));
            entry.setXuid(BedrockUtils.readString(buffer));
            entry.setPlatformChatId(BedrockUtils.readString(buffer));
        }
        packet.getEntries().add(entry);
    }
}
 
Example #9
Source File: PlayerListSerializer_v313.java    From Protocol with Apache License 2.0 6 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, PlayerListPacket packet) {
    buffer.writeByte(packet.getAction().ordinal());
    VarInts.writeUnsignedInt(buffer, packet.getEntries().size());

    for (Entry entry : packet.getEntries()) {
        BedrockUtils.writeUuid(buffer, entry.getUuid());

        if (packet.getAction() == PlayerListPacket.Action.ADD) {
            VarInts.writeLong(buffer, entry.getEntityId());
            BedrockUtils.writeString(buffer, entry.getName());
            SerializedSkin skin = entry.getSkin();
            BedrockUtils.writeString(buffer, skin.getSkinId());
            skin.getSkinData().checkLegacySkinSize();
            BedrockUtils.writeByteArray(buffer, skin.getSkinData().getImage());
            skin.getCapeData().checkLegacyCapeSize();
            BedrockUtils.writeByteArray(buffer, skin.getCapeData().getImage());
            BedrockUtils.writeString(buffer, skin.getGeometryName());
            BedrockUtils.writeString(buffer, skin.getGeometryData());
            BedrockUtils.writeString(buffer, entry.getXuid());
            BedrockUtils.writeString(buffer, entry.getPlatformChatId());
        }
    }
}
 
Example #10
Source File: SkinUtils.java    From Geyser with MIT License 6 votes vote down vote up
public static PlayerListPacket.Entry buildCachedEntry(GameProfile profile, long geyserId) {
    GameProfileData data = GameProfileData.from(profile);
    SkinProvider.Cape cape = SkinProvider.getCachedCape(data.getCapeUrl());

    SkinProvider.SkinGeometry geometry = SkinProvider.SkinGeometry.getLegacy(data.isAlex());

    return buildEntryManually(
            profile.getId(),
            profile.getName(),
            geyserId,
            profile.getIdAsString(),
            SkinProvider.getCachedSkin(profile.getId()).getSkinData(),
            cape.getCapeId(),
            cape.getCapeData(),
            geometry.getGeometryName(),
            geometry.getGeometryData()
    );
}
 
Example #11
Source File: PlayerListSerializer_v340.java    From Protocol with Apache License 2.0 6 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, PlayerListPacket packet) {
    buffer.writeByte(packet.getAction().ordinal());
    VarInts.writeUnsignedInt(buffer, packet.getEntries().size());

    for (Entry entry : packet.getEntries()) {
        BedrockUtils.writeUuid(buffer, entry.getUuid());

        if (packet.getAction() == PlayerListPacket.Action.ADD) {
            VarInts.writeLong(buffer, entry.getEntityId());
            BedrockUtils.writeString(buffer, entry.getName());
            SerializedSkin skin = entry.getSkin();
            BedrockUtils.writeString(buffer, skin.getSkinId());
            skin.getSkinData().checkLegacySkinSize();
            BedrockUtils.writeByteArray(buffer, skin.getSkinData().getImage());
            skin.getCapeData().checkLegacyCapeSize();
            BedrockUtils.writeByteArray(buffer, skin.getCapeData().getImage());
            BedrockUtils.writeString(buffer, skin.getGeometryName());
            BedrockUtils.writeString(buffer, skin.getGeometryData());
            BedrockUtils.writeString(buffer, entry.getXuid());
            BedrockUtils.writeString(buffer, entry.getPlatformChatId());
        }
    }
}
 
Example #12
Source File: PlayerListSerializer_v388.java    From Protocol with Apache License 2.0 6 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, PlayerListPacket packet) {
    Action action = Action.values()[buffer.readUnsignedByte()];
    packet.setAction(action);
    int length = VarInts.readUnsignedInt(buffer);

    for (int i = 0; i < length; i++) {
        Entry entry = new Entry(BedrockUtils.readUuid(buffer));

        if (action == PlayerListPacket.Action.ADD) {
            entry.setEntityId(VarInts.readLong(buffer));
            entry.setName(BedrockUtils.readString(buffer));
            entry.setXuid(BedrockUtils.readString(buffer));
            entry.setPlatformChatId(BedrockUtils.readString(buffer));
            entry.setBuildPlatform(buffer.readIntLE());
            entry.setSkin(BedrockUtils.readSkin(buffer));
            entry.setTeacher(buffer.readBoolean());
            entry.setHost(buffer.readBoolean());
        }
        packet.getEntries().add(entry);
    }
}
 
Example #13
Source File: PlayerListSerializer_v388.java    From Protocol with Apache License 2.0 6 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, PlayerListPacket packet) {
    buffer.writeByte(packet.getAction().ordinal());
    VarInts.writeUnsignedInt(buffer, packet.getEntries().size());

    for (Entry entry : packet.getEntries()) {
        BedrockUtils.writeUuid(buffer, entry.getUuid());

        if (packet.getAction() == Action.ADD) {
            VarInts.writeLong(buffer, entry.getEntityId());
            BedrockUtils.writeString(buffer, entry.getName());
            BedrockUtils.writeString(buffer, entry.getXuid());
            BedrockUtils.writeString(buffer, entry.getPlatformChatId());
            buffer.writeIntLE(entry.getBuildPlatform());
            BedrockUtils.writeSkin(buffer, entry.getSkin());
            buffer.writeBoolean(entry.isTeacher());
            buffer.writeBoolean(entry.isHost());
        }
    }
}
 
Example #14
Source File: PlayerListSerializer_v354.java    From Protocol with Apache License 2.0 6 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, PlayerListPacket packet) {
    Action action = PlayerListPacket.Action.values()[buffer.readUnsignedByte()];
    packet.setAction(action);
    int length = VarInts.readUnsignedInt(buffer);

    for (int i = 0; i < length; i++) {
        Entry entry = new Entry(BedrockUtils.readUuid(buffer));

        if (action == PlayerListPacket.Action.ADD) {
            entry.setEntityId(VarInts.readLong(buffer));
            entry.setName(BedrockUtils.readString(buffer));
            String skinId = BedrockUtils.readString(buffer);
            ImageData skinData = ImageData.of(BedrockUtils.readByteArray(buffer));
            ImageData capeData = ImageData.of(64, 32, BedrockUtils.readByteArray(buffer));
            String geometryName = BedrockUtils.readString(buffer);
            String geometryData = BedrockUtils.readString(buffer);
            entry.setSkin(SerializedSkin.of(skinId, skinData, capeData, geometryName, geometryData, false));
            entry.setXuid(BedrockUtils.readString(buffer));
            entry.setPlatformChatId(BedrockUtils.readString(buffer));
        }
        packet.getEntries().add(entry);
    }
}
 
Example #15
Source File: PlayerListSerializer_v354.java    From Protocol with Apache License 2.0 6 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, PlayerListPacket packet) {
    buffer.writeByte(packet.getAction().ordinal());
    VarInts.writeUnsignedInt(buffer, packet.getEntries().size());

    for (Entry entry : packet.getEntries()) {
        BedrockUtils.writeUuid(buffer, entry.getUuid());

        if (packet.getAction() == PlayerListPacket.Action.ADD) {
            VarInts.writeLong(buffer, entry.getEntityId());
            BedrockUtils.writeString(buffer, entry.getName());
            SerializedSkin skin = entry.getSkin();
            BedrockUtils.writeString(buffer, skin.getSkinId());
            skin.getSkinData().checkLegacySkinSize();
            BedrockUtils.writeByteArray(buffer, skin.getSkinData().getImage());
            skin.getCapeData().checkLegacyCapeSize();
            BedrockUtils.writeByteArray(buffer, skin.getCapeData().getImage());
            BedrockUtils.writeString(buffer, skin.getGeometryName());
            BedrockUtils.writeString(buffer, skin.getGeometryData());
            BedrockUtils.writeString(buffer, entry.getXuid());
            BedrockUtils.writeString(buffer, entry.getPlatformChatId());
        }
    }
}
 
Example #16
Source File: SkinUtils.java    From Geyser with MIT License 6 votes vote down vote up
public static PlayerListPacket.Entry buildEntryManually(UUID uuid, String username, long geyserId,
                                                        String skinId, byte[] skinData,
                                                        String capeId, byte[] capeData,
                                                        String geometryName, String geometryData) {
    SerializedSkin serializedSkin = SerializedSkin.of(
            skinId, geometryName, ImageData.of(skinData), Collections.emptyList(),
            ImageData.of(capeData), geometryData, "", true, false, !capeId.equals(SkinProvider.EMPTY_CAPE.getCapeId()), capeId, uuid.toString()
    );

    PlayerListPacket.Entry entry = new PlayerListPacket.Entry(uuid);
    entry.setName(username);
    entry.setEntityId(geyserId);
    entry.setSkin(serializedSkin);
    entry.setXuid("");
    entry.setPlatformChatId("");
    entry.setTeacher(false);
    return entry;
}
 
Example #17
Source File: PlayerListSerializer_v390.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, PlayerListPacket packet) {
    Action action = Action.values()[buffer.readUnsignedByte()];
    packet.setAction(action);
    int length = VarInts.readUnsignedInt(buffer);

    if (action == Action.ADD) {
        for (int i = 0; i < length; i++) {
            Entry entry = new Entry(BedrockUtils.readUuid(buffer));
            entry.setEntityId(VarInts.readLong(buffer));
            entry.setName(BedrockUtils.readString(buffer));
            entry.setXuid(BedrockUtils.readString(buffer));
            entry.setPlatformChatId(BedrockUtils.readString(buffer));
            entry.setBuildPlatform(buffer.readIntLE());
            entry.setSkin(BedrockUtils_v390.readSkin(buffer));
            entry.setTeacher(buffer.readBoolean());
            entry.setHost(buffer.readBoolean());
            packet.getEntries().add(entry);
        }

        for (int i = 0; i < length; i++) {
            packet.getEntries().get(i).setTrustedSkin(buffer.readBoolean());
        }
    } else {
        for (int i = 0; i < length; i++) {
            packet.getEntries().add(new Entry(BedrockUtils.readUuid(buffer)));
        }
    }
}
 
Example #18
Source File: SkinUtils.java    From Geyser with MIT License 5 votes vote down vote up
public static PlayerListPacket.Entry buildDefaultEntry(GameProfile profile, long geyserId) {
    return buildEntryManually(
            profile.getId(),
            profile.getName(),
            geyserId,
            profile.getIdAsString(),
            SkinProvider.STEVE_SKIN,
            SkinProvider.EMPTY_CAPE.getCapeId(),
            SkinProvider.EMPTY_CAPE.getCapeData(),
            SkinProvider.EMPTY_GEOMETRY.getGeometryName(),
            SkinProvider.EMPTY_GEOMETRY.getGeometryData()
    );
}