// Autogenerated via generator.py

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

    const TAG_CLAIMING_REWARDS = 'oct_plev_claiming_rewards'
    const TAG_REWARD_CLAIMED_1 = 'oct_plev_reward_claimed_1'
		const TAG_REWARD_CLAIMED_5 = 'oct_plev_reward_claimed_5'
		const TAG_REWARD_CLAIMED_10 = 'oct_plev_reward_claimed_10'
		const TAG_REWARD_CLAIMED_15 = 'oct_plev_reward_claimed_15'
		const TAG_REWARD_CLAIMED_20 = 'oct_plev_reward_claimed_20'
		const TAG_REWARD_CLAIMED_25 = 'oct_plev_reward_claimed_25'
		const TAG_REWARD_CLAIMED_30 = 'oct_plev_reward_claimed_30'
		const TAG_REWARD_CLAIMED_40 = 'oct_plev_reward_claimed_40'
		const TAG_REWARD_CLAIMED_50 = 'oct_plev_reward_claimed_50'
		const TAG_REWARD_CLAIMED_70 = 'oct_plev_reward_claimed_70'
		const TAG_REWARD_CLAIMED_100 = 'oct_plev_reward_claimed_100'

    // Giving rewards for level
    function main() {
        for (let player of world.getAllPlayers()) {
            if (player.hasTag(TAG_CLAIMING_REWARDS))  {
                if (player.level >= 1 && !player.hasTag(TAG_REWARD_CLAIMED_1)) { player.runCommand('/tellraw @s {"rawtext":[{"translate":"oct_plev.reward_claimed.1"}]}'); player.runCommand('/function oct/plev/experience/reward_threshold_1'); player.runCommand('/playsound random.toast @s ~ ~ ~ 1 1.5'); player.addTag(TAG_REWARD_CLAIMED_1); }
			if (player.level >= 5 && !player.hasTag(TAG_REWARD_CLAIMED_5)) { player.runCommand('/tellraw @s {"rawtext":[{"translate":"oct_plev.reward_claimed.5"}]}'); player.runCommand('/function oct/plev/experience/reward_threshold_5'); player.runCommand('/playsound random.toast @s ~ ~ ~ 1 1.5'); player.addTag(TAG_REWARD_CLAIMED_5); }
			if (player.level >= 10 && !player.hasTag(TAG_REWARD_CLAIMED_10)) { player.runCommand('/tellraw @s {"rawtext":[{"translate":"oct_plev.reward_claimed.10"}]}'); player.runCommand('/function oct/plev/experience/reward_threshold_10'); player.runCommand('/playsound random.toast @s ~ ~ ~ 1 1.5'); player.addTag(TAG_REWARD_CLAIMED_10); }
			if (player.level >= 15 && !player.hasTag(TAG_REWARD_CLAIMED_15)) { player.runCommand('/tellraw @s {"rawtext":[{"translate":"oct_plev.reward_claimed.15"}]}'); player.runCommand('/function oct/plev/experience/reward_threshold_15'); player.runCommand('/playsound random.toast @s ~ ~ ~ 1 1.5'); player.addTag(TAG_REWARD_CLAIMED_15); }
			if (player.level >= 20 && !player.hasTag(TAG_REWARD_CLAIMED_20)) { player.runCommand('/tellraw @s {"rawtext":[{"translate":"oct_plev.reward_claimed.20"}]}'); player.runCommand('/function oct/plev/experience/reward_threshold_20'); player.runCommand('/playsound random.toast @s ~ ~ ~ 1 1.5'); player.addTag(TAG_REWARD_CLAIMED_20); }
			if (player.level >= 25 && !player.hasTag(TAG_REWARD_CLAIMED_25)) { player.runCommand('/tellraw @s {"rawtext":[{"translate":"oct_plev.reward_claimed.25"}]}'); player.runCommand('/function oct/plev/experience/reward_threshold_25'); player.runCommand('/playsound random.toast @s ~ ~ ~ 1 1.5'); player.addTag(TAG_REWARD_CLAIMED_25); }
			if (player.level >= 30 && !player.hasTag(TAG_REWARD_CLAIMED_30)) { player.runCommand('/tellraw @s {"rawtext":[{"translate":"oct_plev.reward_claimed.30"}]}'); player.runCommand('/function oct/plev/experience/reward_threshold_30'); player.runCommand('/playsound random.toast @s ~ ~ ~ 1 1.5'); player.addTag(TAG_REWARD_CLAIMED_30); }
			if (player.level >= 40 && !player.hasTag(TAG_REWARD_CLAIMED_40)) { player.runCommand('/tellraw @s {"rawtext":[{"translate":"oct_plev.reward_claimed.40"}]}'); player.runCommand('/function oct/plev/experience/reward_threshold_40'); player.runCommand('/playsound random.toast @s ~ ~ ~ 1 1.5'); player.addTag(TAG_REWARD_CLAIMED_40); }
			if (player.level >= 50 && !player.hasTag(TAG_REWARD_CLAIMED_50)) { player.runCommand('/tellraw @s {"rawtext":[{"translate":"oct_plev.reward_claimed.50"}]}'); player.runCommand('/function oct/plev/experience/reward_threshold_50'); player.runCommand('/playsound random.toast @s ~ ~ ~ 1 1.5'); player.addTag(TAG_REWARD_CLAIMED_50); }
			if (player.level >= 70 && !player.hasTag(TAG_REWARD_CLAIMED_70)) { player.runCommand('/tellraw @s {"rawtext":[{"translate":"oct_plev.reward_claimed.70"}]}'); player.runCommand('/function oct/plev/experience/reward_threshold_70'); player.runCommand('/playsound random.toast @s ~ ~ ~ 1 1.5'); player.addTag(TAG_REWARD_CLAIMED_70); }
			if (player.level >= 100 && !player.hasTag(TAG_REWARD_CLAIMED_100)) { player.runCommand('/tellraw @s {"rawtext":[{"translate":"oct_plev.reward_claimed.100"}]}'); player.runCommand('/function oct/plev/experience/reward_threshold_100'); player.runCommand('/playsound random.toast @s ~ ~ ~ 1 1.5'); player.addTag(TAG_REWARD_CLAIMED_100); }
                player.removeTag(TAG_CLAIMING_REWARDS);
            }
        }
    }

system.runInterval(main, 5);
    