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

const scoreboard = world.scoreboard;

/**
 * Class for .
 *
 * @class
 */
export class Jigcs {

    static OBJ_ID = "mythicus_warpstones:jig_computer.addon_stats";
    static SCORE_ID = "mythicus_warpstones:";
    static OBJ = scoreboard.getObjective("mythicus_warpstones:jig_computer.addon_stats");

    /**
     * Initializes scoreboard objective and all relevant scores.
     *
    */
    static globalInit() {
        if (Jigcs.OBJ) return;

        Jigcs.init();

        Jigcs.set("created", 0);
        Jigcs.set("active", 0);
        Jigcs.set("overworld", 0);
        Jigcs.set("nether", 0);
        Jigcs.set("the_end", 0);
    }

    /**
     * Initializes scoreboard objective.
     *
    */
    static init() {
        if (Jigcs.OBJ) return;

        scoreboard.addObjective(Jigcs.OBJ_ID);
        Jigcs.OBJ = scoreboard.getObjective(Jigcs.OBJ_ID);
    }
    /**
     * Adds to the scoreboard value of this id.
     *
     * @param {String} id - Identifier of scoreboard participant.
     * @param {BigInteger} x - Number to add or subtract.
    */
    static add(id, x) {
        if (!Jigcs.OBJ) Jigcs.init();

        Jigcs.OBJ.addScore(Jigcs.SCORE_ID + id, x);
    }
    /**
     * Sets the scoreboard value of this id.
     *
     * @param {String} id - Identifier of scoreboard participant.
     * @param {BigInteger} x - Number to set.
    */
    static set(id, x) {
        if (!Jigcs.OBJ) Jigcs.init();

        Jigcs.OBJ.setScore(Jigcs.SCORE_ID + id, x);
    }

}

Jigcs.globalInit();