The party encounters the BBEG, they quickly burn through their legendary resistances, and the monk burns a ki point to do stunning strike.
The BBEG fails his roll, and is stunned before he has a chance to do much of anything. They're stunned until the end of the monks next turn. The turn of the BBEG comes along, and as they are unable to take actions, they instead ready their action to trigger a spell attack once they are no longer stunned.
The monk's turn comes, they attempt to stun once more and fail, after the monk's turn ends the BBEG's action triggers and they fire off a spell. A few people later and their turn comes up again, and they fire off another spell.
I'm curious as to whether this is allowed under the current rules. Is a creature able to ready an action while stunned?