Java Code Examples for com.nukkitx.protocol.bedrock.packet.PlayerListPacket#setAction()

The following examples show how to use com.nukkitx.protocol.bedrock.packet.PlayerListPacket#setAction() . 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_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 2
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 3
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 4
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 5
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 6
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 7
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 8
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)));
        }
    }
}