Hello bro!. Out of curiosity I have seen that you use world.setTime(0)
to make it through the night. if you want something more natural in that event you can use "event.setUseBed(BedEnterResult.ALLOW)" and the player will be able to sleep like normal!