public final ChannelBuffer getArchivePacketData(int indexId, int archiveId,
			boolean priority) {

		byte[] archive = indexId == 255 ? Cache.STORE.getIndex255()
				.getArchiveData(archiveId) : Cache.STORE.getIndexes()[indexId]
				.getMainFile().getArchiveData(archiveId);
		if (archive == null || !priority)
			return null;
		int compression = archive[0] & 0xff;
		int length = ((archive[1] & 0xff) << 24) + ((archive[2] & 0xff) << 16)
				+ ((archive[3] & 0xff) << 8) + (archive[4] & 0xff);
		int settings = compression;
		if (!priority)
			settings |= 0x80;

		System.out.println(" " + indexId + " " + archiveId);

		ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
		buffer.writeByte(indexId);
		buffer.writeInt(archiveId);
		buffer.writeByte(settings);
		buffer.writeInt(length);
		int realLength = compression != 0 ? length + 4 : length;
		for (int index = 5; index < realLength + 5; index++) {
			if (buffer.writerIndex() % 512 == 0) {
				buffer.writeByte(255);
			}
			buffer.writeByte(archive[index]);
		}

		int v = encryptionValue;
		if (v != 0) {
			for (int i = 0; i < buffer.arrayOffset(); i++)
				buffer.setByte(i, buffer.getByte(i) ^ v);
		}
		return buffer;
	}