import {
    world,
    system
} from "@minecraft/server";

const allScores = [
    'lethalAbsorp',
    'lethalStun',
    'musicT'
];

world.afterEvents.worldInitialize.subscribe(e => {

    for (const score of allScores) {
        if (!world.scoreboard.getObjective(score)) {
            world.scoreboard.addObjective(score)
        }
    }
});

world.afterEvents.playerSpawn.subscribe(e => {
    let player = e.player;
    if (e.initialSpawn === false) return;

    player.removeTag("dragons:music_playing");

    for (const score of allScores) {
        world.scoreboard.getObjective(score).addScore(player, 0);


        system.runTimeout(() => {
            player.addTag('aly:dragons_enabled');
        }, 10);
        // Aly advancements compatibility 

    }
});
