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

function getScore(objectiveName, player) {
    return world.scoreboard.getObjective(objectiveName)?.getScore(player.scoreboardIdentity);
}

world.afterEvents.itemUse.subscribe((event) => {
    if (event.itemStack.typeId == "zk:voidsdemise") {
        const player = event.source;
        let cd = getScore('voidsdcd', player);

        if (cd >= 500) {
            player.runCommand("function chaoscleaver/voidsdemise");
        }
        else if (cd < 500) {
            player.runCommand("function chaoscleaver/ccfr");
        }
    }
});