ServerEvents.commandRegistry(event => {
    const { commands: Commands, arguments: Arguments } = event;
    event.register(
        Commands.literal('checkpoint')
            .executes(ctx => {
                const player = ctx.source.player;
                if (!player.onGround()) {
                    player.setStatusMessage(Text.red('✖ You cannot set a checkpoint in the air!'));
                    player.playSound('minecraft:entity.villager.no', 0.5, 1.0);
                    return 0;
                }
                const px = Math.floor(player.x);
                const py = Math.floor(player.y+1);
                const pz = Math.floor(player.z);
                player.server.runCommandSilent(`spawnpoint ${player.username} ${px} ${py} ${pz}`);
                player.setStatusMessage(Text.green('✔ Checkpoint Set!'));
                player.playSound('minecraft:entity.experience_orb.pickup', 0.5, 1.0);

                return 1;
            })
    );
});