ForgeEvents.onEvent(
    'net.minecraftforge.event.entity.player.PlayerWakeUpEvent',
    event => {
        if (event.entity.level.isClientSide()) return
        global.wakeup(event)
    }
)

/**
 * @param {Internal.PlayerWakeUpEvent} event
 */
global.wakeup = event => {
    const player = event.entity
    if (!player.isPlayer()) return

    const server = player.level.server
    if (!server) return
    server.runCommandSilent(`scoreboard players reset ${player.username} sleeping`)
    server.runCommandSilent(`execute in minecraft:overworld run time set 23961`)
    server.runCommandSilent(`execute in minecraft:overworld run weather clear`)
}
