Search in sources :

Example 1 with SendPlayerToServerPacket

use of io.gomint.proxprox.network.tcp.protocol.SendPlayerToServerPacket in project ProxProx by GoMint.

the class Decoder method decode.

@Override
protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf buf, List<Object> objects) throws Exception {
    if (buf instanceof EmptyByteBuf) {
        // The Channel has disconnected and this is the last message we got. R.I.P. connection
        return;
    }
    byte packetId = buf.readByte();
    switch(packetId) {
        case 1:
            WrappedMCPEPacket wrappedMCPEPacket = new WrappedMCPEPacket();
            wrappedMCPEPacket.read(buf);
            objects.add(wrappedMCPEPacket);
            break;
        case 2:
            UpdatePingPacket updatePingPacket = new UpdatePingPacket();
            updatePingPacket.read(buf);
            objects.add(updatePingPacket);
            break;
        case 3:
            SendPlayerToServerPacket sendPlayerToServerPacket = new SendPlayerToServerPacket();
            sendPlayerToServerPacket.read(buf);
            objects.add(sendPlayerToServerPacket);
            break;
        default:
            break;
    }
}
Also used : SendPlayerToServerPacket(io.gomint.proxprox.network.tcp.protocol.SendPlayerToServerPacket) UpdatePingPacket(io.gomint.proxprox.network.tcp.protocol.UpdatePingPacket) EmptyByteBuf(io.netty.buffer.EmptyByteBuf) WrappedMCPEPacket(io.gomint.proxprox.network.tcp.protocol.WrappedMCPEPacket)

Aggregations

SendPlayerToServerPacket (io.gomint.proxprox.network.tcp.protocol.SendPlayerToServerPacket)1 UpdatePingPacket (io.gomint.proxprox.network.tcp.protocol.UpdatePingPacket)1 WrappedMCPEPacket (io.gomint.proxprox.network.tcp.protocol.WrappedMCPEPacket)1 EmptyByteBuf (io.netty.buffer.EmptyByteBuf)1