import { world, EquipmentSlot } from "@minecraft/server";
import * as utils from "../utils";

export async function onTick()
{
    try {
        for (const player of world.getPlayers()) {
            const equippable = player.getComponent('equippable');
            if(equippable){
                const head = equippable.getEquipment(EquipmentSlot.Head);
                if(head && head.typeId == "pu_sg:crown"){
                    utils.runPlayerCommand(player, "effect @s village_hero 11 255 true");
                }
            }
        }
    } catch (e) {
    }
};