import FSLocalizedString from "./FSLocalizedString";
export default class FSXPHelper {
    static getXP(player) {
        return player.getTotalXp();
    }
    static doesPlayerHaveEnoughXP(player, xp, outputNotEnoughXP = false, removeIfSo = false) {
        if (player.getTotalXp() >= xp) {
            if (removeIfSo) {
                FSXPHelper.removeXP(player, xp);
            }
            return true;
        }
        if (outputNotEnoughXP) {
            FSXPHelper.outputNotEnoughXP(player, xp);
        }
        return false;
    }
    static removeXP(player, xp) {
        let totalXP = player.getTotalXp();
        const currentLevel = player.level;
        if (totalXP < xp) {
            return false;
        }
        totalXP -= xp;
        player.sendMessage({
            rawtext: [{ text: "§a[!] " }, { translate: FSLocalizedString.localize("removed_xp", "You were charged %1 XP.", "Success message for removing XP from a player"), with: [`${Math.abs(xp)}`] }]
        });
        player.addExperience(-player.getTotalXp());
        player.addLevels(-player.level);
        player.addExperience(totalXP);
        const newLevel = player.level;
        if (newLevel < currentLevel) {
            const levelsLost = currentLevel - newLevel;
            player.sendMessage({
                rawtext: [{ text: "§a[!] " }, { translate: FSLocalizedString.localize("level_down", "You leveled down to level %1 (-%2 levels).", "Success message for leveling down"), with: [`${newLevel}`, `${Math.abs(levelsLost)}`] }]
            });
        }
        return true;
    }
    static outputNotEnoughXP(player, xp) {
        player.sendMessage({
            rawtext: [
                { text: "§c[!] " },
                {
                    translate: FSLocalizedString.localize("ui.buy_security_chips.error.not_enough_xp", "You do not have enough XP to buy a Security Chip!", "Error message for not having enough XP to buy a security chip")
                }
            ]
        });
        player.sendMessage({
            rawtext: [
                { text: "§7[TIP] " },
                {
                    translate: FSLocalizedString.localize("ui.buy_security_chips.error.tip", "Earn XP (experience points) by mining ores, smelting items, killing mobs, and fishing. You can also gain XP by breeding animals, cooking food, and trading with villagers.", "Hint to show how to get XP")
                }
            ]
        });
        player.playSound("fs.sbunk.chat_ping");
    }
}

//# sourceMappingURL=../../../../_SBUNK_BPDebug/fs_sbunk/fs/FSXPHelper.js.map
