I'm wondering if it's possible to prevent a player from leaving the bed once he gets in it. I want to count how many times a player slept in a bed in a Minecraft map. I made a scoreboard with it:
/scoreboard objectives add sleepingInBed stat.sleepInBed
The problem is that a player can quit the bed when the night isn't over. The score goes up every time the player tries to sleep in it. Is there a solution for this?