import * as ui from "@minecraft/server-ui";
import { ActionFormData,  MessageFormData,  ModalFormData} from "@minecraft/server-ui";
import { world, Scoreboard, system, ItemStack, Player, MolangVariableMap, Entity, BlockPermutation, CommandPermissionLevel, CustomCommandParamType, CustomCommandStatus} from "@minecraft/server";
import { setPlayerLore, updatePlayerNameTag, openLoreCommand, initLoreOnJoin } from "./chatbubbles/playerLore";


import { initCajadoMago } from "./Item_Events/mudar_skin";
initCajadoMago();

import { Missoes_NPC } from "./quests_well.js";
Missoes_NPC();

import { dialogue_npc } from "./dialogue_npc.js";
dialogue_npc();

import "./knockback/potencia";
import "./ruby_ferramentas/machado";
import "./ruby_ferramentas/picareta";
import './Mission/Mission.js';
import './Light.js';
import './Ticks/Ticks.js';
import "./Block_Events/interact_block";
import './durability.js';
import "./Item_Events/item_Use";
import "./Item_Events/projecteis";
import { FishingEvent, FishingResult } from "./fishingSystem.js";
import "./arena_pvp.js";
import "./ferramentas_armaduras.js";
import "./leveis_hp.js";
import "./gastar_durabilidade.js";
import "./pets.js";
import "./teleport_base.js";
import "./comandos_well.js";
import "./debug.js";
import { isInProtectedArena } from "./areas_protegidas.js"; 

import { enableEspadaCombos } from "./combos/combos.js";
import { enableFoiceCombos } from "./combos/combos_foice.js";
import { enableNinjaCombos } from "./combos/combos_ninja.js";
import { enableVentoCombos } from "./combos/combos_ventos.js";
import { enableMartelaoCombos } from "./combos/combo_marreta.js";

//import "./ui/custom_uis"; // ← BACKUP UIS 09.01.26
//import { getMoonPhase, getDayTime } from "./sensores";
//import "./protecao_area.js";
//import "./clas.js";
//import 'onInteract'
//import 'onPlayerDestroy'


const TAGS_BLOQUEADORAS = [
    "tutorial_completo",
    "staff",
    "admin",
    // Adicione aqui outras tags que nunca devem iniciar tutorial
];

const TAGS_DE_PROGRESSAO = [
    "novice1",
    "novice2",
    "novice3",
    "boss1",
    "adventure",
    "adventure1",
    "adventure2",
    "adventure3",
    "adventure4",
    "boss2",
    "master",
    "master1",
    "master2",
    "boss3",
    "hero",
    "hero1",
    "hero2",
    "hero3",
    "hero4",
    "boss4",
    "legendary",
    // "novice" NÃO entra aqui, porque novice é o estado inicial
];

world.afterEvents.playerSpawn.subscribe((event) => {
    const player = event.player;

    // Só na primeira entrada no mundo
    if (!event.initialSpawn) return;

    // Tags que bloqueiam completamente (staff, admin, tutorial_completo)
    for (const tag of TAGS_BLOQUEADORAS) {
        if (player.hasTag(tag)) return;
    }

    // Verifica se o jogador já tem alguma tag de progressão
    const jaTemProgressao = TAGS_DE_PROGRESSAO.some(tag => player.hasTag(tag));

    // Se já tem alguma tag avançada → pula o tutorial
    if (jaTemProgressao) {
        console.warn(`[Spawn] ${player.name} tem progressão avançada → pulando tutorial`);
        return;
    }

    // Se chegou aqui → é jogador novo ou resetado
    // (pode ter "novice" ou nenhuma tag)
    system.runTimeout(() => iniciarTutorial(player), 60);
});
function iniciarTutorial(player) {
    try {
        // ===== ENTREGA ITENS INICIAIS =====
        player.runCommand('replaceitem entity @s slot.hotbar 7 well:bussola_alma 1 0 {"item_lock":{"mode":"lock_in_inventory"},"keep_on_death":{}}');
        player.runCommand('replaceitem entity @s slot.hotbar 8 well:teleporterapido 1 0 {"item_lock":{"mode":"lock_in_slot"},"keep_on_death":{}}');
        player.runCommand('function Kit_Inicio');
        
        // ===== CONFIGURAÇÕES INICIAIS =====
        player.runCommand("time add 24000");
        player.runCommand("scoreboard players set @s esquiva 1");
        player.runCommand("scoreboard players set @s animacao_esquiva 1");
        player.runCommand("scoreboard players set @s missaowell1 1");
        
        // ===== PREPARA CINEMÁTICA =====
        player.runCommand("tag @s add cinematica");
        player.runCommand("camera @s fade time 0.1 10 1 color 0 0 0");
        player.runCommand("inputpermission set @s movement disabled");
        player.runCommand("inputpermission set @s camera disabled");
        
        // ===== EFEITOS DO TUTORIAL =====
        player.runCommand("effect @s blindness infinite 1 true");
        player.runCommand("effect @s invisibility infinite 1 true");
        player.runCommand("effect @s levitation infinite 1 true");
        player.runCommand("effect @s weakness infinite 60 true");
        player.runCommand("effect @s water_breathing infinite 1 true");
        
        // Marca que já iniciou o processo (opcional, mas pode ajudar em debug)
        player.addTag("tutorial_intro");
        
        // Chama a cinemática automaticamente
        system.runTimeout(() => {
            try {
                IniciarCinematica(player);
                console.warn(`[Cinemática] Iniciada automaticamente para ${player.name}`);
            } catch (err) {
                console.warn(`[Cinemática] Erro ao iniciar: ${err}`);
            }
        }, 40);
        
        console.warn(`[Tutorial] Iniciado para ${player.name}`);
    } catch (e) {
        console.warn(`[Tutorial] Erro ao iniciar:`, e);
    }
}

world.beforeEvents.itemUse.subscribe((eventData) => {
    if (eventData.itemStack?.typeId !== "well:teleporterapido") return;
    
    const player = eventData.source;
    console.warn(`[Pergaminho] ${player.name} usou teleporterapido`);
    
    // Comandos base sempre executam
    system.run(() => {
        try {
            player.runCommand("scoreboard players add @s cinematica 1");
            player.runCommand("event entity @s remove_animacao_combo");
            player.runCommand("event entity @s remove_charged");
            player.runCommand("scoreboard players set @s combos_animacoes 1");
            player.runCommand("scoreboard players set @s cinematica 12");
        } catch (e) {
            console.warn(`[Pergaminho] Erro nos comandos base: ${e}`);
        }
    });
    
    // PRIORIDADE 1: Arena
    if (player.hasTag("arena")) {
        console.warn(`[Pergaminho] ${player.name} está na arena → desistencia`);
        system.run(() => {
            try { arena_desistencia(player); } catch (e) {}
        });
        return;
    }
    
    // NOVA ORDEM DE PRIORIDADE:
    
    // 1. Cinemática tem prioridade máxima
    if (player.hasTag("cinematica")) {
        console.warn(`[Pergaminho] ${player.name} tem tag cinematica → chamando IniciarCinematica`);
        system.run(() => {
            try {
                IniciarCinematica(player);
            } catch (e) {
                console.warn(`[Pergaminho] Erro ao chamar IniciarCinematica: ${e}`);
            }
        });
        return;
    }
    
    // 2. Tag "genero" agora também tem prioridade (antes do tutorial_intro)
    if (player.hasTag("genero")) {
        console.warn(`[Pergaminho] ${player.name} tem tag genero → chamando genero(player)`);
        system.run(() => {
            try {
                genero(player);
            } catch (e) {
                console.warn(`[Pergaminho] Erro ao chamar genero: ${e}`);
            }
        });
        return;
    }
    
    // 3. Se já terminou o tutorial (e não tem mais cinematica nem genero) → menu normal
    if (player.hasTag("tutorial_intro")) {
        console.warn(`[Pergaminho] ${player.name} tem tutorial_intro → abrindo menulistwell`);
        system.run(() => {
            try {
                menulistwell(player);
            } catch (e) {
                console.warn(`[Pergaminho] Erro ao abrir menulistwell: ${e}`);
            }
        });
        return;
    }
    
    // Remove efeitos residuais (caso esteja em transição)
    system.run(() => {
        try {
            player.runCommand("effect @s invisibility 0 1 true");
            player.runCommand("effect @s water_breathing 0 1 true");
            player.runCommand("inputpermission set @s movement enabled");
            player.runCommand("inputpermission set @s camera enabled");
        } catch (e) {
            console.warn(`[Pergaminho] Erro ao remover efeitos: ${e}`);
        }
    });
    
    // Sistema de tags (outras tags normais)
    const tagActions = {
        "novice": () => menulistwell(player),
        "novice1": () => menulistwell(player),
        "novice2": () => menulistwell(player),
        "novice3": () => menulistwell(player),
        "boss1": () => menulistwell(player),
        "adventure": () => menulistwell1(player),
        "adventure1": () => menulistwell1(player),
        "adventure2": () => menulistwell1(player),
        "adventure3": () => menulistwell1(player),
        "adventure4": () => menulistwell1(player),
        "boss2": () => menulistwell1(player),
        "master": () => menulistwell2(player),
        "master1": () => menulistwell2(player),
        "master2": () => menulistwell2(player),
        "boss3": () => menulistwell2(player),
        "hero": () => menulistwell3(player),
        "hero1": () => menulistwell3(player),
        "hero2": () => menulistwell3(player),
        "hero3": () => menulistwell3(player),
        "hero4": () => menulistwell3(player),
        "boss4": () => menulistwell4(player),
        "legendary": () => menulistwell4(player),
        // "cinematica" e "genero" foram movidas para prioridades acima
    };
    
    let encontrouTag = false;
    for (const tag in tagActions) {
        if (player.hasTag(tag)) {
            console.warn(`[Pergaminho] Tag "${tag}" encontrada → executando`);
            system.run(() => {
                try {
                    tagActions[tag]();
                } catch (e) {
                    console.warn(`[Pergaminho] Erro na tag ${tag}: ${e}`);
                }
            });
            encontrouTag = true;
            return;
        }
    }
    
    // Fallback final
    if (!encontrouTag) {
        console.warn(`[Pergaminho] Sem tags especiais → fallback menulistwell`);
        system.run(() => {
            try {
                menulistwell(player);
            } catch (e) {
                console.warn(`[Pergaminho] Erro no fallback: ${e}`);
            }
        });
    }
});

export function IniciarCinematica(player) {
    let form = new MessageFormData();
    form.title({ rawtext: [{ translate: "cinematica.title" }]});
    form.body({ rawtext: [{ translate: "cinematica.body" }]});
    form.button1({ rawtext: [{ translate: "iniciar.cinematica.sim" }]});
    form.button2({ rawtext: [{ translate: "iniciar.cinematica.nao" }]});

    form.show(player).then(res => {
        if (res.canceled) return;
        if (res.selection === 0) {
			player.runCommand("tag @s add genero");
			player.runCommand("tag @s remove cinematica");
			player.runCommand("hud @s hide all");
			
			playCinematic(player);
        }
		if (res.selection === 1) {
			player.runCommand("tag @s add genero");
			player.runCommand("tag @s remove cinematica");
			genero(player);
        }
    }).catch(error => {
        console.error(error, error.stack);
    });
}

function playCinematic(player) {

    // Configuração inicial
    system.run(() => {
        player.runCommand("title @s times 20 140 40");
		player.runCommand("gamemode spectator @s");
		player.runCommand("tp @s ~ ~200 ~");
		player.runCommand("gamerule showcoordinates false");
		
    });

    // Cada passo da cinemática
    const steps = [
        {
            title: "§´",
            duration: 3,
            commands: [
			    "camera @s fade time 1 1 1 color 0 0 0"
            ]
        },
		{
            title: "cinematica1",
            duration: 9,
            commands: [
			    "inputpermission set @s camera disabled",
                "inputpermission set @s movement disabled",
				//"gamemode spectator @s",
			    //"tp @s ~ ~200 ~",
				"effect @s darkness",
				"effect @s invisibility 300 1 true",
				
			    "stopsound @s",
				"playsound orgao.monster @s ~ ~ ~ 0.3",
                "playsound voice1 @s"
            ]
        },
        {
            title: "cinematica2",
            duration: 9,
            commands: [
			   "playsound voice2 @s",
			   "effect @s darkness"
			]
        },
        {
            title: "cinematica3",
            duration: 12,
            commands: [
                "playsound voice3 @s",
			   "effect @s darkness"
            ]
        },
        {
            title: "cinematica4",
            duration: 11,
            commands: [
                "playsound voice4 @s",
			   "effect @s darkness"
            ]
        },
        {
            title: "cinematica5",
            duration: 10,
            commands: [
			    "playsound voice5 @s",
			   "effect @s darkness"
			]
        },
        {
            title: "cinematica6",
            duration: 7,
            commands: [
                "playsound voice6 @s",
			   "effect @s darkness"
            ]
        },
        {
            title: "cinematica7",
            duration: 9,
            commands: [
			    "playsound voice7 @s",
			   "effect @s darkness"
			]
        },
        {
            title: "cinematica8",
            duration: 18,
            commands: [
                "playsound voice8 @s",
			   "effect @s darkness"
            ]
        },
        {
            title: "cinematica9",
            duration: 24,
            commands: [
			    "playsound voice9 @s",
			   "effect @s darkness"
			]
        },
        {
            title: "cinematica10",
            duration: 23,
            commands: [
			    "playsound voice10 @s",
			   "effect @s darkness"
			]
        },
        {
            title: "cinematica11",
            duration: 21,
            commands: [
			    "playsound voice11 @s",
                "camera @s fade time 20 20 20",
			    "effect @s darkness"
            ]
        }
    ];

    let delayTicks = 0;

    steps.forEach(step => {
        const thisDelay = Math.round(delayTicks * 20);

        system.runTimeout(() => {
            system.run(() => {
                const stayTicks = step.duration * 20;

                // Ajusta tempo do title
                player.runCommand(`title @s times 30 ${stayTicks - 60} 40`);

                // Mostra o title
                player.runCommand(`title @s title ${step.title}`);

                // Executa comandos extras
                step.commands.forEach(cmd => {
                    player.runCommand(cmd);
                });
            });
        }, thisDelay);

        delayTicks += step.duration;
    });

    // Limpa no final da cinemática
        // Limpa no final da cinemática
    system.runTimeout(() => {
        system.run(() => {
            player.runCommand("title @s clear");
            player.runCommand("inputpermission set @s camera enabled");
            player.runCommand("inputpermission set @s movement enabled");
            player.runCommand("effect @s slow_falling 100 1 true");
            
            player.runCommand("gamemode survival @s");
            player.runCommand("hud @s reset all");
            player.runCommand("gamerule showcoordinates true");
            
            // Limpa efeitos e tags temporárias
            player.runCommand("effect @s clear");
            player.removeTag("cinematica");
            player.removeTag("tutorial_intro");     // opcional, se não quiser mais
            
            // TP final
            player.runCommand("tp @s 35 72 6");
            
            // <<<< ESSA LINHA É A MAIS IMPORTANTE >>>>
            player.addTag("tutorial_completo");     // marca que terminou TUDO
            
            console.warn(`[Tutorial] Completo! Tag "tutorial_completo" adicionada para ${player.name}`);
        });
    }, Math.round(delayTicks * 20) + 40);

}

function playCinematicOpcoes(player) {

    // Configuração inicial
    system.run(() => {
        player.runCommand("title @s times 20 140 40");
		player.runCommand("gamemode spectator @s");
		player.runCommand("hud @s hide all");
		player.runCommand("gamerule showcoordinates false");
		
    });

    // Cada passo da cinemática
    const steps = [
        {
            title: "cinematica1",
            duration: 9,
            commands: [
			    "inputpermission set @s camera disabled",
                "inputpermission set @s movement disabled",
				//"gamemode spectator @s",
			    //"tp @s ~ ~200 ~",
				"effect @s darkness",
				"effect @s invisibility 300 1 true",
				
			    "stopsound @s",
				//"playsound orgao.monster @s",
                "playsound voice1 @s"
            ]
        },
        {
            title: "cinematica2",
            duration: 9,
            commands: [
			   "playsound voice2 @s",
			   "effect @s darkness"
			]
        },
        {
            title: "cinematica3",
            duration: 12,
            commands: [
                "playsound voice3 @s",
			   "effect @s darkness"
            ]
        },
        {
            title: "cinematica4",
            duration: 11,
            commands: [
                "playsound voice4 @s",
			   "effect @s darkness"
            ]
        },
        {
            title: "cinematica5",
            duration: 10,
            commands: [
			    "playsound voice5 @s",
			   "effect @s darkness"
			]
        },
        {
            title: "cinematica6",
            duration: 7,
            commands: [
                "playsound voice6 @s",
			   "effect @s darkness"
            ]
        },
        {
            title: "cinematica7",
            duration: 9,
            commands: [
			    "playsound voice7 @s",
			   "effect @s darkness"
			]
        },
        {
            title: "cinematica8",
            duration: 18,
            commands: [
                "playsound voice8 @s",
			   "effect @s darkness"
            ]
        },
        {
            title: "cinematica9",
            duration: 24,
            commands: [
			    "playsound voice9 @s",
			   "effect @s darkness"
			]
        },
        {
            title: "cinematica10",
            duration: 23,
            commands: [
			    "playsound voice10 @s",
			   "effect @s darkness"
			]
        },
        {
            title: "cinematica11",
            duration: 21,
            commands: [
			    "playsound voice11 @s",
                "camera @s fade time 20 20 20",
			    "effect @s darkness"
            ]
        }
    ];

    let delayTicks = 0;

    steps.forEach(step => {
        const thisDelay = Math.round(delayTicks * 20);

        system.runTimeout(() => {
            system.run(() => {
                const stayTicks = step.duration * 20;

                // Ajusta tempo do title
                player.runCommand(`title @s times 30 ${stayTicks - 60} 40`);
				player.runCommand("hud @s reset all");

                // Mostra o title
                player.runCommand(`title @s title ${step.title}`);

                // Executa comandos extras
                step.commands.forEach(cmd => {
                    player.runCommand(cmd);
                });
            });
        }, thisDelay);

        delayTicks += step.duration;
    });

    // Limpa no final
    system.runTimeout(() => {
        system.run(() => {
			player.runCommand("title @s clear");
            player.runCommand("inputpermission set @s camera enabled");
			player.runCommand("inputpermission set @s movement enabled");
			player.runCommand("effect @s invisibility 0 1 true");
			
			player.runCommand("gamemode survival @s");
			player.runCommand("hud @s reset all");
			
			player.runCommand("gamerule showcoordinates true");
        });
    }, Math.round(delayTicks * 20) + 40);
}

export function genero(player) {
    let form = new ui.ActionFormData();
    form.title("wellforced:genero");
    form.body("");
    form.button({ rawtext: [{ translate: "opcoes.masculino" }]}, "textures/ui/icon_steve.png");
    form.button({ rawtext: [{ translate: "opcoes.feminino" }]}, "textures/ui/icon_alex.png");
    
    form.show(player).then((result) => {
        if (result === null) {
            // Se result for null, significa que o jogador fechou o formulário sem seleção
			player.runCommand("/tag @s add genero");
            genero(player); // Reabre o formulário
        } else {
            // Verifica a seleção feita pelo jogador
            if (result.selection == 0) {
                player.runCommand("/scoreboard players set @s genero 1");
                raca_mago(player); // Chama a próxima função após definir o gênero
            } else if (result.selection == 1) {
                player.runCommand("/scoreboard players set @s genero 2");
                raca_mago(player); // Chama a próxima função após definir o gênero
            }
        }
    });
}

function garantirNovice(player) {
    const tagsBloqueadas = [
        "novice","novice1","novice2","novice3",
        "adventure","adventure1","adventure2","adventure3","adventure4",
        "master","master1","master2",
        "hero","hero1","hero2","hero3","hero4",
        "legendary",
        "boss1","boss2","boss3","boss4"
    ];

    for (const tag of tagsBloqueadas) {
        if (player.hasTag(tag)) return;
    }

    player.addTag("novice");
}

export function raca_humana(player) {
    let form = new ui.ActionFormData();
    form.title("wellforced:raca_humana");
    form.body("");
    form.button({ rawtext: [{ translate: "<<" }] });
    form.button({ rawtext: [{ translate: "select_class.ok" }] });
    form.button({ rawtext: [{ translate: ">>" }] });

    form.show(player).then((result) => {

        if (result.selection == 0) {
            raca_mago(player);
        }

        if (result.selection == 1) {
            garantirNovice(player);
			player.removeTag("tutorial_intro");
            player.runCommand("effect @s clear");
            player.runCommand("/function classe/humano");
        }

        if (result.selection == 2) {
            raca_elfo(player);
        }
    });
}

export function raca_elfo(player) {
    let form = new ui.ActionFormData();
    form.title("wellforced:raca_elfo");
    form.body("");
    form.button({ rawtext: [{ translate: "<<" }] });
    form.button({ rawtext: [{ translate: "select_class.ok" }] });
    form.button({ rawtext: [{ translate: ">>" }] });

    form.show(player).then((result) => {

        if (result.selection == 0) {
            raca_humana(player);
        }

        if (result.selection == 1) {
            garantirNovice(player);
			player.removeTag("tutorial_intro");
            player.runCommand("effect @s clear");
            player.runCommand("/function classe/elfo");
        }

        if (result.selection == 2) {
            raca_mago(player);
        }
    });
}

export function raca_mago(player) {
    let form = new ui.ActionFormData();
    form.title("wellforced:raca_mago");
    form.body("");
    form.button({ rawtext: [{ translate: "<<" }] });
    form.button({ rawtext: [{ translate: "select_class.ok" }] });
    form.button({ rawtext: [{ translate: ">>" }] });

    form.show(player).then((result) => {

        if (result.selection == 0) {
            raca_elfo(player);
        }

        if (result.selection == 1) {
            garantirNovice(player);
			player.removeTag("tutorial_intro");
            player.runCommand("effect @s clear");
            player.runCommand("/function classe/mago");
        }

        if (result.selection == 2) {
            raca_humana(player);
        }
    });
}

function Zeramento(player) {

    // Configuração inicial
    system.run(() => {
		
		player.runCommand("stopsound @s");
        player.runCommand("title @s times 20 140 40");
		player.runCommand("effect @s blindness infinite 10 true");
		player.runCommand("gamemode spectator @s");
		player.runCommand("tp @s ~ ~200 ~");
		player.runCommand("hud @s hide all");
		
		player.runCommand("gamerule showcoordinates false");
		
    });

    // Cada passo da cinemática
    const steps = [
        {
            title: "§´",
            duration: 2,
            commands: [
			    "camera @s fade time 1 1 1 color 0 2 2",
		        "playsound mob.boss4.morte @s ~ ~ ~ 0.8 1.0",
                "playsound invocacao @s ~ ~ ~ 0.8 1.0",        // Verifique se "invocacao" existe no seu resource pack
                "playsound firework.blast @s ~ ~ ~ 0.6 1.0",
                "playsound firework.twinkle @s ~ ~ ~ 0.6 1.0",
                "playsound random.explode @s ~ ~ ~ 0.7 1.0"
            ]
        },
		{
            title: "§´",
            duration: 1,
            commands: [
                "playsound invocacao @s ~ ~ ~ 0.8 1.0",        // Verifique se "invocacao" existe no seu resource pack
                "playsound firework.blast @s ~ ~ ~ 0.6 1.0",
                "playsound firework.twinkle @s ~ ~ ~ 0.6 1.0",
                "playsound random.explode @s ~ ~ ~ 0.7 1.0"
            ]
        },
		{
            title: "§´",
            duration: 1,
            commands: [

                "playsound invocacao @s ~ ~ ~ 0.8 1.0",        // Verifique se "invocacao" existe no seu resource pack
                "playsound firework.blast @s ~ ~ ~ 0.6 1.0",
                "playsound firework.twinkle @s ~ ~ ~ 0.6 1.0",
                "playsound random.explode @s ~ ~ ~ 0.7 1.0"
            ]
        },
		{
            title: "§´",
            duration: 1,
            commands: [

                "playsound invocacao @s ~ ~ ~ 0.8 1.0",        // Verifique se "invocacao" existe no seu resource pack
                "playsound firework.blast @s ~ ~ ~ 0.6 1.0",
                "playsound firework.twinkle @s ~ ~ ~ 0.6 1.0",
                "playsound random.explode @s ~ ~ ~ 0.7 1.0"
            ]
        },
		{
            title: "§´",
            duration: 8,
            commands: [

                "playsound invocacao @s ~ ~ ~ 0.8 1.0",        // Verifique se "invocacao" existe no seu resource pack
                "playsound firework.blast @s ~ ~ ~ 0.6 1.0",
                "playsound firework.twinkle @s ~ ~ ~ 0.6 1.0",
                "playsound random.explode @s ~ ~ ~ 0.7 1.0"
            ]
        },
		{
            title: "zeramento1",
            duration: 20,
            commands: [
			    "inputpermission set @s camera disabled",
                "inputpermission set @s movement disabled",
				"music play zeramento 0.5 1 loop",
			    //"tp @s ~ ~200 ~",
				"effect @s darkness",
				"effect @s invisibility 300 1 true"
				
            ]
        },
        {
            title: "zeramento2",
            duration: 20,
            commands: [
			   "hud @s hide all",
			   "effect @s darkness"
			]
        },
        {
            title: "zeramento3",
            duration: 20,
            commands: [
                
			   "effect @s darkness"
            ]
        },
        {
            title: "zeramento4",
            duration: 20,
            commands: [
               
			   "effect @s darkness"
            ]
        },
        {
            title: "zeramento5",
            duration: 20,
            commands: [
			   "effect @s darkness"
			]
        },
        {
            title: "zeramento6",
            duration: 20,
            commands: [
               
			   "effect @s darkness"
            ]
        },
        {
            title: "zeramento7",
            duration: 20,
            commands: [
			   
			   "effect @s darkness"
			]
        },
        {
            title: "zeramento8",
            duration: 20,
            commands: [
               "effect @s invisibility 0 1 true",
			   "gamemode creative @s",
			   "effect @s darkness"
            ]
        },
        {
            title: "zeramento9",
            duration: 30,
            commands: [
                "camera @s fade time 20 20 20",
			    "effect @s darkness"
            ]
        }
    ];

    let delayTicks = 0;

    steps.forEach(step => {
        const thisDelay = Math.round(delayTicks * 20);

        system.runTimeout(() => {
            system.run(() => {
                const stayTicks = step.duration * 20;

                // Ajusta tempo do title
                player.runCommand(`title @s times 30 ${stayTicks - 60} 40`);

                // Mostra o title
                player.runCommand(`title @s title ${step.title}`);

                // Executa comandos extras
                step.commands.forEach(cmd => {
                    player.runCommand(cmd);
                });
            });
        }, thisDelay);

        delayTicks += step.duration;
    });

    // Limpa no final da cinemática
        // Limpa no final da cinemática
    system.runTimeout(() => {
        system.run(() => {
            player.runCommand("title @s clear");
            player.runCommand("inputpermission set @s camera enabled");
            player.runCommand("inputpermission set @s movement enabled");
            player.runCommand("effect @s slow_falling 100 1 true");
            
            player.runCommand("gamemode survival @s");
            player.runCommand("hud @s reset all");
            player.runCommand("gamerule showcoordinates true");
            
            // Limpa efeitos e tags temporárias
            player.runCommand("effect @s clear");
            // TP final
            player.runCommand("tp @s 35 72 6");
			player.runCommand("music stop 5");
			
			player.runCommand("tellraw @a {\"rawtext\":[{\"selector\": \"@a[r=80, tag=boss4, c=1]\"}, { \"translate\":\"missao.concluida.boss4.morto\" }]}");
			player.runCommand("tag @a [tag=boss4, r=80] add legendary");
			player.runCommand("tag @a [tag=boss4, r=80] remove boss4");
			player.runCommand("titleraw @a [tag=legendary, r=80] title {\"rawtext\":[{ \"translate\":\"missao.atualizacao.titulo\" }]}");
			player.runCommand("titleraw @a [tag=legendary, r=80] subtitle {\"rawtext\":[{ \"translate\":\"missao.atualizacao.subtitulo.final\" }]}");
			player.runCommand("playsound missioncomplete @a [tag=legendary, r=80] ~ ~ ~");
			
            
            // <<<< ESSA LINHA É A MAIS IMPORTANTE >>>>
            player.addTag("legendary");     // marca que terminou TUDO
        });
    }, Math.round(delayTicks * 20) + 40);

}

world.afterEvents.entityDie.subscribe(event => {
    const entity = event.deadEntity;
    const killer = event.damageSource?.damagingEntity;
    
    if (
        killer?.typeId === "minecraft:player" &&
        entity.typeId === "well:boss4_morte" // <-- Removido o "&&" extra que tava quebrando!
    ) {
        try {
            Zeramento(killer);
        } catch (e) {
            console.warn("Erro no Zeramento: " + e.message);
        }
    }
});

system.run(() => {
    enableEspadaCombos();
    enableFoiceCombos();
    enableNinjaCombos();
    enableVentoCombos();
    enableMartelaoCombos();
    // chama todos os outros aqui

    console.warn("§a[Todos os combos ativados com sucesso! Addon carregado.]");
});

world.beforeEvents.playerBreakBlock.subscribe(ev => {
    const block = ev.block;
    const dimension = ev.dimension;
    const player = ev.player;

    if (!block || !player) return;
    if (block.typeId !== "well:estatua_de_teleporte") return;

    // ❌ cancela a quebra normal
    ev.cancel = true;

    const loc = block.location;

    system.run(() => {
        try {
            // =====================
            // CAMERA SHAKE (EXPLOSÃO)
            // =====================
            player.runCommand(
                `camerashake add @s 0.3 1.2 positional`
            );
			player.runCommand(
                `effect @a [r=10] blindness 3 10 true`
            );

            // =====================
            // SOM DE EXPLOSÃO
            // =====================
            player.playSound("random.explode", {
                location: loc,
                volume: 1,
                pitch: 0.8
            });

            player.playSound("portal.travel", {
                location: loc,
                volume: 0.8,
                pitch: 0.9
            });

            // =====================
            // PARTÍCULAS DE EXPLOSÃO
            // =====================
            for (let i = 0; i < 6; i++) {
                dimension.spawnParticle(
                    "minecraft:large_explosion",
                    {
                        x: loc.x + 0.5,
                        y: loc.y + 0.7,
                        z: loc.z + 0.5
                    }
                );
            }

            // =====================
            // FUMAÇA + FAÍSCAS (LOOP)
            // =====================
            let ticks = 0;

            const loop = system.runInterval(() => {
                ticks++;

                // fumaça
                dimension.spawnParticle(
                    "minecraft:smoke",
                    {
                        x: loc.x + Math.random(),
                        y: loc.y + 0.5 + Math.random(),
                        z: loc.z + Math.random()
                    }
                );

                // faíscas mágicas
                dimension.spawnParticle(
                    "minecraft:enchanting_table_particle",
                    {
                        x: loc.x + Math.random(),
                        y: loc.y + Math.random(),
                        z: loc.z + Math.random()
                    }
                );

                if (ticks >= 12) {
                    system.clearRun(loop);
                }
            }, 1);

            // =====================
            // TROCA DO BLOCO
            // =====================
            const direction = block.permutation.getState(
                "minecraft:cardinal_direction"
            );

            const newPerm = BlockPermutation
                .resolve("well:pedra_teleporte_animada")
                .withState("minecraft:cardinal_direction", direction);

            dimension.getBlock(loc)?.setPermutation(newPerm);

        } catch (e) {
            console.warn("Erro ao aplicar explosão:", e);
        }
    });
});


// ================= CONFIG =================
const RANGE = 30;
const SCORE_REGISTER = "register_mob_level";
const SCORE_MOB = "mob_level";

// PLAYER TAGS → MOB LEVEL
const TAG_LEVEL_MAP = [
    { tags: ["adventure", "adventure1", "adventure2", "adventure3", "adventure4"], min: 2, max: 3 },
    { tags: ["master", "master1", "master1", "master2"], min: 4, max: 6 },
    { tags: ["hero", "hero1", "hero2", "hero3"], min: 7, max: 10 }
];
// =========================================

// distância
function dist(a, b) {
    const dx = a.x - b.x;
    const dy = a.y - b.y;
    const dz = a.z - b.z;
    return Math.sqrt(dx*dx + dy*dy + dz*dz);
}

function playerHasAnyTag(player, tags) {
    return tags.some(t => player.hasTag(t));
}

// score
function getScore(entity, objective) {
    try {
        const obj = world.scoreboard.getObjective(objective);
        if (!obj) return null;

        const id = entity.scoreboardIdentity;
        if (!id) return null;

        return obj.getScore(id);
    } catch {
        return null;
    }
}

function setScore(entity, objective, value) {
    try {
        world.scoreboard.getObjective(objective)?.setScore(entity, value);
    } catch {}
}

function hasScore(entity, objective) {
    try {
        const obj = world.scoreboard.getObjective(objective);
        if (!obj) return false;

        const id = entity.scoreboardIdentity;
        if (!id) return false;

        return obj.getScore(id) !== undefined;
    } catch {
        return false;
    }
}

// LOOP
system.runInterval(() => {

    const players = world.getAllPlayers();
    const obj = world.scoreboard.getObjective(SCORE_MOB);
    if (!obj) return;

    for (const dim of ["overworld", "nether", "the_end"]) {
        const dimension = world.getDimension(dim);
        if (!dimension) continue;

        const entities = dimension.getEntities();

        for (const mob of entities) {

            // 🔥 FILTRO PRINCIPAL
            if (!hasScore(mob, SCORE_REGISTER)) continue;

            let targetLevel = null;

            for (const player of players) {
                if (dist(mob.location, player.location) > RANGE) continue;

                for (const map of TAG_LEVEL_MAP) {
                    if (playerHasAnyTag(player, map.tags)) {
                        targetLevel = map.max;
                    }
                }
            }

            if (targetLevel === null) continue;

            const currentLevel = getScore(mob, SCORE_MOB);
            if (currentLevel === targetLevel) continue;

            setScore(mob, SCORE_MOB, targetLevel);

            if (targetLevel <= 3) mob.triggerEvent("transformation_2_3");
            else if (targetLevel <= 6) mob.triggerEvent("transformation_4_6");
            else mob.triggerEvent("transformation_7_10");
        }
    }
}, 20);


world.afterEvents.projectileHitEntity.subscribe(event => {
    const projectile = event.projectile;
    const target = event.getEntityHit().entity;

    // Verifica se o projétil é a nossa shuriken envenenada
    if (projectile.typeId === "well:shuriken_envenenada") {
        
        // Aplica veneno forte por 10 segundos (nível 2)
        target.addEffect("poison", 200, { // 200 ticks = 10 segundos
            amplifier: 2,        // Nível 2 (amplifier 1)
            showParticles: true
        });

        // Opcional: som de veneno
        target.playSound("mob.witch.drink", { pitch: 1.3 });

        // Opcional: faz a shuriken sumir com estilo
        system.run(() => {
            projectile.triggerEvent("despawn");
        });
    }
});


// Configurações
const BIOME_ID = "well:floresta_mistica";
const MUSIC_SOUND = "floresta_mistica";
const MUSIC_VOLUME = 0.27;
const INTERVALO_MINUTOS = 2;
const INTERVALO_TICKS = INTERVALO_MINUTOS * 60 * 20; // 2400 ticks = 2 min

const playerInBiome = new WeakMap();
const musicTimeout = new WeakMap(); // Armazena o ID do timeout

// Função para tocar e agendar próxima
function tocarEAguardar(player) {
  player.playSound(MUSIC_SOUND, {
    volume: MUSIC_VOLUME,
    pitch: 1.0
  });
  //player.sendMessage("§a♫ Floresta Mística - Música tocando...");

  // Cancela qualquer agendamento antigo
  const oldTimeout = musicTimeout.get(player);
  if (oldTimeout) system.clearRun(oldTimeout);

  // Agenda a próxima em 2 minutos
  const timeoutId = system.runTimeout(() => {
    const location = player.location;
    let biome;
    try {
      biome = player.dimension.getBiome(location);
    } catch {
      return;
    }
    if (biome?.id === BIOME_ID) {
      tocarEAguardar(player); // Loop!
    }
  }, INTERVALO_TICKS);

  musicTimeout.set(player, timeoutId);
}

// Verifica entrada/saída
system.runInterval(() => {
  for (const player of world.getPlayers()) {
    const location = player.location;
    let biome;
    try {
      biome = player.dimension.getBiome(location);
    } catch {
      continue;
    }

    const inBiome = biome?.id === BIOME_ID;
    const wasInBiome = playerInBiome.get(player) ?? false;

    // === ENTROU NO BIOMA ===
    if (inBiome && !wasInBiome) {
      //player.sendMessage("§a♫ Entrou na Floresta Mística!");
      player.stopSound(MUSIC_SOUND); // Limpa som antigo
	  
	  
	  //player.runCommand(`title @s times 10 70 20`); // fadeIn 0.5s, stay 3.5s, fadeOut 1s
      //player.runCommand(`title @s subtitle §´Uma aura mágica te envolve`);
	  
	  player.runCommand(`titleraw @s actionbar {\"rawtext\":[{\"text\":\"§´§l§6Floresta Mística\\n\"},{\"text\":\"§r§´§oUma aura mágica te envolve\"}]}`);
	  
      //player.runCommand(`title @s actionbar §6✨Floresta Mística ✨`);
	  
	  
	  

      // Toca AGORA + agenda loop
      tocarEAguardar(player);
    }

    // === SAIU DO BIOMA ===
    if (!inBiome && wasInBiome) {
      player.stopSound(MUSIC_SOUND);
      //player.sendMessage("§7Música parou (saiu do bioma).");

      // Cancela próximo play
      const timeoutId = musicTimeout.get(player);
      if (timeoutId) {
        system.clearRun(timeoutId);
        musicTimeout.delete(player);
      }
    }

    playerInBiome.set(player, inBiome);
  }
}, 10); // Verifica a cada 0.5s (mais responsivo)


// =====================================================
// PERSISTÊNCIA DE CLÃS (clãs ficam salvos mesmo offline)
// =====================================================
const CLAN_PROPERTY_KEY = "clans_persistentes";

function getPersistentClans() {
    try {
        const data = world.getDynamicProperty(CLAN_PROPERTY_KEY);
        return data ? JSON.parse(data) : [];
    } catch {
        return [];
    }
}

function savePersistentClans(clans) {
    try {
        world.setDynamicProperty(CLAN_PROPERTY_KEY, JSON.stringify(clans));
    } catch {}
}

function addPersistentClan(name, noPvp = false) {
    const clans = getPersistentClans();
    if (!clans.some(c => c.name === name)) {
        clans.push({ name, noPvp });
        savePersistentClans(clans);
    }
}

function removePersistentClan(name) {
    let clans = getPersistentClans();
    clans = clans.filter(c => c.name !== name);
    savePersistentClans(clans);
}

function clanExists(name) {
    return getPersistentClans().some(c => c.name === name);
}

// Limpa tags de clã deletado ao entrar
world.afterEvents.playerSpawn.subscribe(({ player }) => {
    const clanName = getClan(player);
    if (clanName && !clanExists(clanName)) {
        removeClanTags(player);
        clearClanInvite(player);
        player.sendMessage({ rawtext: [{ translate: "clan.deletado" }] });
    }
});

// =====================================================
// FUNÇÕES BÁSICAS DE CLÃ
// =====================================================
function getClan(player) {
    const tag = player.getTags().find(t => t.startsWith("clan:"));
    if (!tag) return null;
    return tag.replace("clan:", "");
}

function isClanLeader(player) {
    return player.hasTag("clan_leader");
}

function getClanInvite(player) {
    const tag = player.getTags().find(t => t.startsWith("clan_invite:"));
    if (!tag) return null;
    return tag.replace("clan_invite:", "");
}

function clearClanInvite(player) {
    for (const tag of player.getTags()) {
        if (tag.startsWith("clan_invite:")) {
            player.removeTag(tag);
        }
    }
}

function removeClanTags(player) {
    for (const tag of player.getTags()) {
        if (tag.startsWith("clan:") || tag.startsWith("clan_")) {
            player.removeTag(tag);
        }
    }
}

// =====================================================
// CRIAR CLÃ (AGORA COM LIMITAÇÃO: APENAS 1 CLÃ POR JOGADOR)
// =====================================================
export function modalCriarClan(player) {
    // Verifica se o jogador já está em um clã
    if (getClan(player)) {
        player.sendMessage({ rawtext: [{ translate: "clan.ja_esta_em_clan" }] });
        return;
    }

    const form = new ModalFormData()
        .title({ rawtext: [{ translate: "clan.criar_titulo" }] })
        .textField(
            { rawtext: [{ translate: "clan.nome_label" }] },
            { rawtext: [{ translate: "clan.nome_placeholder" }] }
        )
        .toggle({ "rawtext": [{ "translate": "clan.toggle_pvp" }]}, { defaultValue: true });

    form.show(player).then(res => {
        if (res.canceled) return;

        let nomeClan = res.formValues[0]?.trim();
        const noPvp = res.formValues[1] === true;

        if (!nomeClan || nomeClan.length > 20) {
            player.sendMessage({ rawtext: [{ translate: "clan.nome_invalido" }] });
            return;
        }

        nomeClan = nomeClan.replace(/§./g, "");

        removeClanTags(player);
        player.addTag(`clan:${nomeClan}`);
        player.addTag("clan_leader");
        if (noPvp) player.addTag("clan_no_pvp");

        player.sendMessage({ rawtext: [{ translate: "clan.criado_sucesso" }] });

        addPersistentClan(nomeClan, noPvp);
    });
}

// =====================================================
// DELETAR CLÃ
// =====================================================
export function deletarClan(player) {
    if (!isClanLeader(player)) {
        player.sendMessage({ rawtext: [{ translate: "clan.apenas_lider" }] });
        return;
    }

    const clanName = getClan(player);
    if (!clanName) {
        player.sendMessage({ rawtext: [{ translate: "clan.sem_clan" }] });
        return;
    }

    const form = new ActionFormData()
        .title({ rawtext: [{ translate: "clan.deletar_titulo" }] })
        .body({
            rawtext: [
                { translate: "clan.deletar_confirmar" },
                { text: `§c ${clanName}\n\n` },
                { translate: "clan.deletar_aviso" }
            ]
        })
        .button({ rawtext: [{ translate: "clan.deletar_sim" }] })
        .button({ rawtext: [{ translate: "clan.voltar" }] });

    form.show(player).then(res => {
        if (res.canceled || res.selection !== 0) return;

        for (const p of world.getAllPlayers()) {
            if (getClan(p) === clanName) {
                removeClanTags(p);
                clearClanInvite(p);
                p.sendMessage({ rawtext: [{ translate: "clan.deletado" }] });
            }
        }

        removePersistentClan(clanName);
        player.sendMessage({ rawtext: [{ translate: "clan.deletado_sucesso" }] });
    });
}

// =====================================================
// MENU PRINCIPAL
// =====================================================
export function abrirMenuClas(player) {
    const form = new ActionFormData()
        .title({ rawtext: [{ translate: "clan.menu_titulo" }] })
        .body({ rawtext: [{ translate: "clan.menu_desc" }] })
        .button({ rawtext: [{ translate: "clan.btn_criar" }] })
        .button({ rawtext: [{ translate: "clan.btn_convidar" }] })
        .button({ rawtext: [{ translate: "clan.btn_convites" }] })
        .button({ rawtext: [{ translate: "clan.btn_lista" }] })
        .button({ rawtext: [{ translate: "clan.btn_deletar" }] });

    form.show(player).then(res => {
        if (res.canceled) return;
        if (res.selection === 0) modalCriarClan(player);
        if (res.selection === 1) abrirListaJogadores(player);
        if (res.selection === 2) abrirConvitesClan(player);
        if (res.selection === 3) abrirListaClas(player);
        if (res.selection === 4) deletarClan(player);
    });
}

// =====================================================
// LISTA DE CLÃS (persistente)
// =====================================================
export function abrirListaClas(player) {
    const form = new ActionFormData();
    const persistentClans = getPersistentClans();

    const clansWithMembers = persistentClans.map(clan => {
        const members = world.getAllPlayers().filter(p => getClan(p) === clan.name);
        return {
            name: clan.name,
            members,
            noPvp: clan.noPvp
        };
    }).sort((a, b) => a.name.localeCompare(b.name));

    form.title({ rawtext: [{ translate: "clan.lista_titulo" }] });
    form.body({
        rawtext: [
            { translate: "clan.lista_qtd_clans" },
            { text: `§a ${clansWithMembers.length}\n` },
            { translate: "clan.lista_qtd_players" },
            { text: `§a ${clansWithMembers.reduce((a, c) => a + c.members.length, 0)}\n\n` },
            { translate: "clan.lista_clique" }
        ]
    });

    clansWithMembers.forEach(clan => {
        const pvpStatus = clan.noPvp ? " [PvP Off]" : "";
        form.button({
            rawtext: [{ text: `§b ${clan.name} §7 (${clan.members.length})${pvpStatus}` }]
        });
    });

    form.button({ rawtext: [{ translate: "clan.voltar" }] });

    form.show(player).then(res => {
        if (res.canceled) return;
        if (res.selection === clansWithMembers.length) {
            abrirMenuClas(player);
            return;
        }
        mostrarMembrosClan(player, clansWithMembers[res.selection]);
    });
}

// =====================================================
// MOSTRAR MEMBROS DO CLÃ
// =====================================================
function mostrarMembrosClan(viewer, clanData) {
    const form = new ActionFormData();
    form.title({
        rawtext: [
            { translate: "clan.membros_titulo" },
            { text: ` §b ${clanData.name}` }
        ]
    });
    form.body({
        rawtext: [
            { translate: "clan.membros_online" },
            { text: `§a ${clanData.members.length}\n\n` },
            { translate: "clan.clique_status" }
        ]
    });

    clanData.members
        .sort((a, b) => a.name.localeCompare(b.name))
        .forEach(member => {
            const voce = member.name === viewer.name ? " §c(Você)" : "";
            const lider = isClanLeader(member) ? " §6★" : "";
            form.button({
                rawtext: [{ text: `§a ${member.name}${lider}${voce}` }]
            });
        });

    form.button({ rawtext: [{ translate: "clan.voltar" }] });

    form.show(viewer).then(res => {
        if (res.canceled) return;

        if (res.selection === clanData.members.length) {
            abrirListaClas(viewer);
            return;
        }

        const target = clanData.members[res.selection];
        if (!target) {
            viewer.sendMessage({ rawtext: [{ translate: "clan.erro_jogador" }] });
            return;
        }

        status_interacao(viewer, target);
    });
}

// =====================================================
// CONVITES
// =====================================================
export function abrirConvitesClan(player) {
    const inviteClan = getClanInvite(player);
    const form = new ActionFormData();
    form.title({ rawtext: [{ translate: "clan.convites_titulo" }] });

    if (!inviteClan) {
        form.body({ rawtext: [{ translate: "clan.sem_convites" }] });
        form.button({ rawtext: [{ translate: "clan.voltar" }] });
        form.show(player).then(() => abrirMenuClas(player));
        return;
    }

    form.body({
        rawtext: [
            { translate: "clan.convite_de" },
            { text: `§a ${inviteClan}\n\n` }
        ]
    });

    form.button({ rawtext: [{ translate: "clan.aceitar" }] });
    form.button({ rawtext: [{ translate: "clan.recusar" }] });

    form.show(player).then(res => {
        if (res.canceled) return;
        if (res.selection === 0) {
            removeClanTags(player);
            player.addTag(`clan: ${inviteClan}`);
            clearClanInvite(player);
            player.sendMessage({ rawtext: [{ translate: "clan.entrou" }] });
        }
        if (res.selection === 1) {
            clearClanInvite(player);
            player.sendMessage({ rawtext: [{ translate: "clan.recusado" }] });
        }
    });
}

// =====================================================
// CONVIDAR JOGADORES
// =====================================================
export function abrirListaJogadores(player) {
    if (!isClanLeader(player)) {
        player.sendMessage({ rawtext: [{ translate: "clan.apenas_lider" }] });
        return;
    }

    const myClan = getClan(player);
    if (!myClan) return;

    const players = world.getAllPlayers()
        .filter(p => p.name !== player.name)
        .sort((a, b) => a.name.localeCompare(b.name));

    const form = new ActionFormData();
    form.title({ rawtext: [{ translate: "clan.convidar_titulo" }] });
    form.body({ rawtext: [{ translate: "clan.convidar_desc" }] });

    players.forEach(p => {
        form.button({ rawtext: [{ text: `§a ${p.name}` }] });
    });

    form.button({ rawtext: [{ translate: "clan.voltar" }] });

    form.show(player).then(res => {
        if (res.canceled) return;
        if (res.selection === players.length) {
            abrirMenuClas(player);
            return;
        }

        const alvo = players[res.selection];
        if (getClan(alvo)) {
            player.sendMessage({ rawtext: [{ translate: "clan.ja_tem_clan" }] });
            return;
        }

        clearClanInvite(alvo);
        alvo.addTag(`clan_invite: ${myClan}`);

        player.sendMessage({ rawtext: [{ translate: "clan.convite_enviado" }] });
        alvo.sendMessage({ rawtext: [{ translate: "clan.convite_recebido" }] });
    });
}

console.warn("§a[Sistema de Clãs] Carregado - Apenas 1 clã por jogador!");
// STATUS INTERAÇÃO (simplificado)
// =====================================================
export function status_interacao(viewer, target) {
    let form = new ui.ActionFormData();

    // Proteção contra undefined
    const ranksTexto = getTagsPorCategoria(target, TAGS_RANK) ?? "§7Nenhum";
    const racaTexto = getTagsPorCategoria(target, TAGS_RACA) ?? "§7Nenhuma";
    const dungeonTexto = getTagsPorCategoria(target, TAGS_DUNGEON) ?? "§70";
    const claTexto = getClan(target) ?? "§7Sem clã";

    // Progresso do bestiário com fallback (se a função não existir, mostra 0/0)
    let progressoBestiario = { descobertos: 0, total: 0 };
    try {
        progressoBestiario = getProgressoBestiario(target) ?? { descobertos: 0, total: 0 };
    } catch (e) {
        // Se a função não existir, ignora silenciosamente
    }

    // Função segura para pegar score (substitua por getScoreSafe se tiver)
    const safeScore = (objective) => {
        try {
            return getScorePlayer(target, objective) ?? 0;
        } catch {
            return 0;
        }
    };

    form.title("wellforced:status_interacao_outros_players");

    form.body({
        rawtext: [
            { text: `§eStatus de §a${target.name ?? "Jogador"} || ` },
            { text: `§bGemas: §f${dungeonTexto}\n\n` },

            { text: `§6Rank: §f${ranksTexto} || ` },
            { text: `§6Raça: §f${racaTexto} || ` },
            { text: `§bClã: §f${claTexto}\n` },

            { text: `§dBestiário: §a${progressoBestiario.descobertos ?? 0}§7/§f${progressoBestiario.total ?? 0} mobs\n\n` },

            { translate: "coleta_madeira.status" },
            { text: `§f${safeScore("coleta_madeira")}\n` },

            { translate: "mineiracao.status" },
            { text: `§f${safeScore("mineiracao")}\n` },

            { translate: "pescaria.status" },
            { text: `§f${safeScore("pescaria")}\n` },

            { translate: "agricultura.status" },
            { text: `§f${safeScore("agricultura")}\n\n` },

            { translate: "mortes_player.status" },
            { text: `§c${safeScore("mortes")}\n` },

            { translate: "mortes_monstros.status" },
            { text: `§c${safeScore("mortes_monstros")}` }
        ]
    });

    form.button({ rawtext: [{ text: "exit.button.form" }] }, "textures/ui/undoArrow.png");
    //form.button({ rawtext: [{ text: "§cSair" }] });

    form.show(viewer).then((result) => {
        if (result.canceled) return;

        if (result.selection === 0) {
            sair(viewer);
        }
    });
}

world.afterEvents.entityDie.subscribe(event => {
  const dead = event.deadEntity;
  const killer = event.damageSource?.damagingEntity;

  // 1. Se quem morreu foi um jogador, aumentamos o contador de mortes
  if (dead.typeId === "minecraft:player") {
    const deathsObj = world.scoreboard.getObjective("mortes");
    if (deathsObj) {
      const current = deathsObj.getScore(dead) ?? 0;
      deathsObj.setScore(dead, current + 1);
    }
  }
});

world.afterEvents.entityDie.subscribe(event => {
  const dead = event.deadEntity;
  const killer = event.damageSource?.damagingEntity;

  if (killer?.typeId === "minecraft:player") {
    // Lista completa (ou parcial) de famílias para teste
    const allKnownFamilies = [
      'monster', 'undead', 'illager', 'arthropod', 'boss',
      'player', 'dragon'
    ];

    // Famílias que interessam para pontuar
    const includedFamilies = [
      'monster', 'undead', 'illager', 'arthropod', 'boss'
    ];

    // Detecta todas as famílias que o mob possui
    const detectedFamilies = allKnownFamilies.filter(fam => dead.matches({ families: [fam] }));

    // Verifica se detectou pelo menos uma da lista que interessa
    const matchedIncluded = detectedFamilies.some(fam => includedFamilies.includes(fam));

    // Debug: mostra todas as famílias detectadas
    //killer.runCommand(`tellraw @s {"rawtext":[{"text":"§e[Debug] Famílias detectadas: §f${detectedFamilies.join(", ") || "Nenhuma"}"}]}`);

    if (matchedIncluded) {
      killer.runCommand(`scoreboard players add @s mortes_monstros 1`);
      //killer.runCommand(`tellraw @s {"rawtext":[{"text":"§a[Debug] Pontuado por família incluída."}]}`);
    } else {
      //killer.runCommand(`tellraw @s {"rawtext":[{"text":"§c[Debug] Nenhuma família relevante encontrada para §f${dead.typeId}"}]}`);
    }
  }
});

FishingEvent.playerStartFishing.subscribe(({ player }) => {
    //player.sendMessage("§bVocê lançou a linha!");
});

FishingEvent.playerReleaseFishing.subscribe(async ({ player, fishingInfo }) => {
    const result = fishingInfo.result;

    if (result === FishingResult.Success) {
        const items = fishingInfo.fishedItems.map(item => item?.typeId ?? "desconhecido").join(", ");
        //player.sendMessage(`§aVocê pescou: §f${items}`);

        // ✅ Comando após pesca com sucesso
        try {
            //await player.runCommand(`say ${player.name} pescou ${items}`);
            // ou qualquer outro comando como:
             await player.runCommand("function pontos_status/pescaria");
        } catch (e) {
            //player.sendMessage("§cErro ao executar comando.");
        }

    } else if (result === FishingResult.Missed) {
        //player.sendMessage("§eVocê não pescou nada.");
    } else if (result === FishingResult.AttachedToEntity) {
        //player.sendMessage("§cVocê fisgou uma entidade!");
    } else {
        //player.sendMessage("§7Você errou a pescaria.");
    }
});

// Objeto para armazenar o tempo de cada jogador com o componente
const stunnedTimers = new Map();

system.runInterval(() => {
  const players = world.getAllPlayers();

  for (const player of players) {
    const id = player.id;
    const hasStunned = player.getComponent("minecraft:is_stunned");

    if (hasStunned) {
      if (!stunnedTimers.has(id)) {
        stunnedTimers.set(id, 0);
        //player.runCommand(`say §eStunned detectado! Iniciando contagem...`);
      } else {
        const current = stunnedTimers.get(id);
        const updated = current + 1;
        stunnedTimers.set(id, updated);

       //player.runCommand(`say §aTempo com stunned: ${(updated * 0.05).toFixed(2)}s`);

        // Verifica se chegou a 600 ticks (30 segundos)
        if (updated === 600) {
          player.runCommand(`event entity @s remove_animacao_combo`);
          //player.runCommand(`say §bComponente remove_animacao_combo executado após 30s!`);
        }
      }
    } else {
      if (stunnedTimers.has(id)) {
        const total = stunnedTimers.get(id);
        //player.runCommand(`say §cStunned removido! Tempo total: ${(total * 0.05).toFixed(2)}s`);
        stunnedTimers.delete(id);
      } else {
        //player.runCommand(`say §4NÃO tem o componente is_stunned`);
      }
    }
  }
}, 1); // executa a cada tick (20 vezes por segundo)

const COOLDOWN_SECONDS_BOSS_MORTE = 3; // Tempo mínimo entre mensagens (ajuste aqui)

world.afterEvents.entityHitEntity.subscribe(ev => {
    const { damagingEntity, hitEntity } = ev;

    if (damagingEntity.typeId !== "minecraft:player") return;
    if (hitEntity.typeId !== "well:boss4_morte") return;

    const player = damagingEntity;

    // Se o jogador já tem a tag de cooldown → ignora
    if (player.hasTag("mensagem_cooldown")) return;

    // Chance de aparecer
    const chanceDeAparecer = 0.25;
    if (Math.random() > chanceDeAparecer) return;

    // Mostra a mensagem
    const totalMensagens = 6;
    const indice = Math.floor(Math.random() * totalMensagens) + 1;
    const chave = `hit.weak.${indice}`;

    player.runCommand(
        `tellraw @s {"rawtext":[{"translate":"${chave}"}]}`
    );

    // Ou no actionbar (menos intrusivo):
    // player.runCommand(`title @s actionbar {"rawtext":[{"translate":"${chave}"}]}`);

    // Ativa o cooldown
    player.addTag("mensagem_cooldown");

    // Remove a tag depois do tempo
    system.runTimeout(() => {
        player.removeTag("mensagem_cooldown");
    }, COOLDOWN_SECONDS_BOSS_MORTE * 20); // 20 ticks = 1 segundo
});


world.afterEvents.entityHitEntity.subscribe(ev => {
  const { damagingEntity, hitEntity } = ev;

  // Verifica se a entidade atingida é um jogador
  if (hitEntity.typeId !== "minecraft:player") return;

  // Verifica se o jogador tem score "classe_humana" igual a 1
  const scoreboard = world.scoreboard.getObjective("classe_humana");
  if (!scoreboard || scoreboard.getScore(hitEntity) !== 1) return;

  // Gera uma chance aleatória
  const chance = Math.random();

  // Atribui pontuação com base na chance
  if (chance < 0.1) {
    hitEntity.runCommand('scoreboard players add @s furia 10');
	hitEntity.runCommand('function msg_furia');
    hitEntity.runCommand('particle well:furia ~ ~1.5 ~');
  } 
  else if (chance < 0.2) {
    hitEntity.runCommand('scoreboard players add @s furia 5');
	hitEntity.runCommand('function msg_furia');
    hitEntity.runCommand('particle well:furia ~ ~1.5 ~');
  } 
  else if (chance < 0.4) {
    hitEntity.runCommand('scoreboard players add @s furia 2');
	hitEntity.runCommand('function msg_furia');
    hitEntity.runCommand('particle well:furia ~ ~1.5 ~');
  } 
  else {
    hitEntity.runCommand('scoreboard players add @s furia 0');
	hitEntity.runCommand('function msg_furia');
    //hitEntity.runCommand('say furia 0');
  }
});

world.afterEvents.entityDie.subscribe(({ deadEntity, damageSource: { damagingEntity } }) => {
  if (damagingEntity?.typeId !== 'minecraft:player') return;

  const family = deadEntity.getComponent('type_family');
  if (!family) return;

  // Mapeamento: família => lista de comandos
  const commandsByFamily = {
    boss1: [
        'scoreboard players set @s [tag=boss1, r=50] Selva 1',
        'tp @s ~~1~',
        'execute as @s [tag=boss1, r=50] run tellraw @a {\"rawtext\":[{\"selector\": \"@s[r=15, tag=boss1, c=1]\"}, { \"translate\":\"missao.concluida.boss1.morto\" }]}',
        'tag @s [tag=boss1, r=50] add adventure',
        'tag @s [tag=boss1, r=50] remove boss1',
        'titleraw @s [tag=adventure, r=20] title {\"rawtext\":[{ \"translate\":\"missao.atualizacao.titulo\" }]}',
        'titleraw @s [tag=adventure, r=20] subtitle {\"rawtext\":[{ \"translate\":\"missao.atualizacao.subtitulo\" }]}',
        'playsound missioncomplete @s [tag=adventure, r=20] ~ ~ ~',
        'stopsound @s dungeon_music',
        'stopsound @s Boss1',
        'music stop 1',
		'scoreboard players set @s [tag=adventure, r=50] missaowell5 1',
		'scoreboard players add @s horda 0'
	],
	boss2: [
        'tp @s ~~1~',
		'tag @s [tag=boss2, r=50] add master',
		'tag @s [tag=boss2, r=50] remove boss2',
		'execute as @s [tag=master, r=50] run tellraw @a {\"rawtext\":[{\"selector\": \"@s[r=15, tag=master, c=1]\"}, { \"translate\":\"missao.concluida.boss2.morto\" }]}',
		'stopsound @s dungeon_music',
		'stopsound @s Boss2',
		'music stop 1',
		'titleraw @s [tag=master, r=20] title {\"rawtext\":[{ \"translate\":\"missao.atualizacao.titulo\" }]}',
		'titleraw @s [tag=master, r=20] subtitle {\"rawtext\":[{ \"translate\":\"missao.atualizacao.subtitulo\" }]}',
		'playsound missioncomplete @s [tag=master, r=20] ~ ~ ~',
		'scoreboard players set @s [tag=master, r=50] missaowell10 1'
	],
	
	boss3: [
        'tp @s ~~1~',
		'execute as @s [tag=boss3, r=50] run tellraw @a {\"rawtext\":[{\"selector\": \"@a[r=15, tag=boss3, c=1]\"}, { \"translate\":\"missao.concluida.boss3.morto\" }]}',
		'tag @s [tag=boss3, r=50] add hero',
		'tag @s [tag=boss3, r=50] remove boss3',
		'titleraw @s [tag=hero, r=20] title {\"rawtext\":[{ \"translate\":\"missao.atualizacao.titulo\" }]}',
		'titleraw @s [tag=hero, r=20] subtitle {\"rawtext\":[{ \"translate\":\"missao.atualizacao.subtitulo\" }]}',
		'playsound missioncomplete @s [tag=hero, r=20] ~ ~ ~',
		'stopsound @s dungeon_music',
		'stopsound @s Boss1',
		'scoreboard players set @s [tag=hero, r=50] missaowell13 1',
		'music stop 1'
	],
	
	
	
	zombie: [
        'scoreboard players add @s zumbi 1',
		'titleraw @s [scores={zumbi=..20}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.zumbi\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.zumbi.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"zumbi\"}}, {\"translate\": \"barra.vinte\"}]}',
		'titleraw @s [scores={zumbi=..20}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.zumbi\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.zumbi.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"zumbi\"}}, {\"translate\": \"barra.vinte\"}]}',
		'titleraw @s [scores={zumbi=..20}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.zumbi\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.zumbi.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"zumbi\"}}, {\"translate\": \"barra.vinte\"}]}',
		'titleraw @s [scores={zumbi=..20}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.zumbi\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.zumbi.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"zumbi\"}}, {\"translate\": \"barra.vinte\"}]}',
		'titleraw @s [scores={zumbi=..20}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.zumbi\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.zumbi.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"zumbi\"}}, {\"translate\": \"barra.vinte\"}]}',
		'titleraw @s [scores={zumbi=..20}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.zumbi\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.zumbi.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"zumbi\"}}, {\"translate\": \"barra.vinte\"}]}',
		'titleraw @s [scores={zumbi=..20}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.zumbi\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.zumbi.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"zumbi\"}}, {\"translate\": \"barra.vinte\"}]}',
		'titleraw @s [scores={zumbi=..20}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.zumbi\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.zumbi.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"zumbi\"}}, {\"translate\": \"barra.vinte\"}]}',
		'titleraw @s [scores={zumbi=..20}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.zumbi\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.zumbi.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"zumbi\"}}, {\"translate\": \"barra.vinte\"}]}',
		'titleraw @s [scores={zumbi=..20}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.zumbi\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.zumbi.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"zumbi\"}}, {\"translate\": \"barra.vinte\"}]}'
    ],
    skeleton: [
        'scoreboard players add @s esqueleto 1',
		'scoreboard players add @s [r=10, tag=adventure, scores={horda=0..}] horda 1',
		'scoreboard players add @s [r=10, tag=adventure, scores={horda=0..}] horda_iniciada 1',
		'titleraw @s [scores={esqueleto=..30}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.esqueleto\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.skeleton.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\", \"objective\": \"esqueleto\"}}, {\"translate\": \"barra.trinta\"}]}',
		'titleraw @s [scores={esqueleto=..30}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.esqueleto\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.skeleton.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\", \"objective\": \"esqueleto\"}}, {\"translate\": \"barra.trinta\"}]}',
		'titleraw @s [scores={esqueleto=..30}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.esqueleto\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.skeleton.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\", \"objective\": \"esqueleto\"}}, {\"translate\": \"barra.trinta\"}]}',
		'titleraw @s [scores={esqueleto=..30}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.esqueleto\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.skeleton.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\", \"objective\": \"esqueleto\"}}, {\"translate\": \"barra.trinta\"}]}',
		'titleraw @s [scores={esqueleto=..30}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.esqueleto\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.skeleton.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\", \"objective\": \"esqueleto\"}}, {\"translate\": \"barra.trinta\"}]}',
		'titleraw @s [scores={esqueleto=..30}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.esqueleto\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.skeleton.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\", \"objective\": \"esqueleto\"}}, {\"translate\": \"barra.trinta\"}]}',
		'titleraw @s [scores={esqueleto=..30}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.esqueleto\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.skeleton.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\", \"objective\": \"esqueleto\"}}, {\"translate\": \"barra.trinta\"}]}',
		'titleraw @s [scores={esqueleto=..30}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.esqueleto\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.skeleton.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\", \"objective\": \"esqueleto\"}}, {\"translate\": \"barra.trinta\"}]}',
		'titleraw @s [scores={esqueleto=..30}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.esqueleto\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.skeleton.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\", \"objective\": \"esqueleto\"}}, {\"translate\": \"barra.trinta\"}]}',
		'titleraw @s [scores={esqueleto=..30}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.esqueleto\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.skeleton.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\", \"objective\": \"esqueleto\"}}, {\"translate\": \"barra.trinta\"}]}',
		'titleraw @s [scores={esqueleto=31..50}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.esqueleto.divino\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.skeleton.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\", \"objective\": \"esqueleto\"}}, {\"translate\": \"barra.cinquenta\"}]}',
		'titleraw @s [scores={esqueleto=31..50}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.esqueleto.divino\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.skeleton.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\", \"objective\": \"esqueleto\"}}, {\"translate\": \"barra.cinquenta\"}]}',
		'titleraw @s [scores={esqueleto=31..50}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.esqueleto.divino\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.skeleton.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\", \"objective\": \"esqueleto\"}}, {\"translate\": \"barra.cinquenta\"}]}',
		'titleraw @s [scores={esqueleto=31..50}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.esqueleto.divino\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.skeleton.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\", \"objective\": \"esqueleto\"}}, {\"translate\": \"barra.cinquenta\"}]}',
		'titleraw @s [scores={esqueleto=31..50}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.esqueleto.divino\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.skeleton.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\", \"objective\": \"esqueleto\"}}, {\"translate\": \"barra.cinquenta\"}]}',
		'titleraw @s [scores={esqueleto=31..50}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.esqueleto.divino\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.skeleton.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\", \"objective\": \"esqueleto\"}}, {\"translate\": \"barra.cinquenta\"}]}',
		'titleraw @s [scores={esqueleto=31..50}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.esqueleto.divino\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.skeleton.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\", \"objective\": \"esqueleto\"}}, {\"translate\": \"barra.cinquenta\"}]}',
		'titleraw @s [scores={esqueleto=31..50}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.esqueleto.divino\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.skeleton.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\", \"objective\": \"esqueleto\"}}, {\"translate\": \"barra.cinquenta\"}]}',
		'titleraw @s [scores={esqueleto=31..50}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.esqueleto.divino\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.skeleton.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\", \"objective\": \"esqueleto\"}}, {\"translate\": \"barra.cinquenta\"}]}',
		'titleraw @s [scores={esqueleto=31..50}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.esqueleto.divino\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.skeleton.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\", \"objective\": \"esqueleto\"}}, {\"translate\": \"barra.cinquenta\"}]}'
    ],
    arthropod: [
        'scoreboard players add @s aranha 1',
		'titleraw @s [scores={aranha=..10}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.aranha\" }, {\"text\": \" \n\"}, { \"translate\":\"entity.aranha.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"aranha\"}}, {\"translate\": \"barra.dez\"}]}',
		'titleraw @s [scores={aranha=..10}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.aranha\" }, {\"text\": \" \n\"}, { \"translate\":\"entity.aranha.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"aranha\"}}, {\"translate\": \"barra.dez\"}]}',
		'titleraw @s [scores={aranha=..10}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.aranha\" }, {\"text\": \" \n\"}, { \"translate\":\"entity.aranha.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"aranha\"}}, {\"translate\": \"barra.dez\"}]}',
		'titleraw @s [scores={aranha=..10}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.aranha\" }, {\"text\": \" \n\"}, { \"translate\":\"entity.aranha.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"aranha\"}}, {\"translate\": \"barra.dez\"}]}',
		'titleraw @s [scores={aranha=..10}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.aranha\" }, {\"text\": \" \n\"}, { \"translate\":\"entity.aranha.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"aranha\"}}, {\"translate\": \"barra.dez\"}]}',
		'titleraw @s [scores={aranha=..10}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.aranha\" }, {\"text\": \" \n\"}, { \"translate\":\"entity.aranha.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"aranha\"}}, {\"translate\": \"barra.dez\"}]}',
		'titleraw @s [scores={aranha=..10}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.aranha\" }, {\"text\": \" \n\"}, { \"translate\":\"entity.aranha.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"aranha\"}}, {\"translate\": \"barra.dez\"}]}',
		'titleraw @s [scores={aranha=..10}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.aranha\" }, {\"text\": \" \n\"}, { \"translate\":\"entity.aranha.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"aranha\"}}, {\"translate\": \"barra.dez\"}]}',
		'titleraw @s [scores={aranha=..10}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.aranha\" }, {\"text\": \" \n\"}, { \"translate\":\"entity.aranha.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"aranha\"}}, {\"translate\": \"barra.dez\"}]}',
		'titleraw @s [scores={aranha=..10}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.aranha\" }, {\"text\": \" \n\"}, { \"translate\":\"entity.aranha.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"aranha\"}}, {\"translate\": \"barra.dez\"}]}'
    ],
    witch: [
        'scoreboard players add @s bruxa 1',
		'titleraw @s [scores={bruxa=..10}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.bruxa\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.bruxa.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"bruxa\"}}, {\"translate\": \"barra.dez\"}]}',
		'titleraw @s [scores={bruxa=..10}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.bruxa\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.bruxa.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"bruxa\"}}, {\"translate\": \"barra.dez\"}]}',
		'titleraw @s [scores={bruxa=..10}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.bruxa\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.bruxa.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"bruxa\"}}, {\"translate\": \"barra.dez\"}]}',
		'titleraw @s [scores={bruxa=..10}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.bruxa\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.bruxa.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"bruxa\"}}, {\"translate\": \"barra.dez\"}]}',
		'titleraw @s [scores={bruxa=..10}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.bruxa\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.bruxa.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"bruxa\"}}, {\"translate\": \"barra.dez\"}]}',
		'titleraw @s [scores={bruxa=..10}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.bruxa\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.bruxa.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"bruxa\"}}, {\"translate\": \"barra.dez\"}]}',
		'titleraw @s [scores={bruxa=..10}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.bruxa\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.bruxa.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"bruxa\"}}, {\"translate\": \"barra.dez\"}]}',
		'titleraw @s [scores={bruxa=..10}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.bruxa\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.bruxa.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"bruxa\"}}, {\"translate\": \"barra.dez\"}]}',
		'titleraw @s [scores={bruxa=..10}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.bruxa\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.bruxa.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"bruxa\"}}, {\"translate\": \"barra.dez\"}]}',
		'titleraw @s [scores={bruxa=..10}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.bruxa\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.bruxa.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"bruxa\"}}, {\"translate\": \"barra.dez\"}]}'
    ],
    enderman: [
        'scoreboard players add @s enderman 1',
		'titleraw @s [scores={enderman=..30}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.enderman\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.enderman.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"enderman\"}}, {\"translate\": \"barra.trinta\"}]}',
		'titleraw @s [scores={enderman=..30}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.enderman\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.enderman.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"enderman\"}}, {\"translate\": \"barra.trinta\"}]}',
		'titleraw @s [scores={enderman=..30}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.enderman\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.enderman.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"enderman\"}}, {\"translate\": \"barra.trinta\"}]}',
		'titleraw @s [scores={enderman=..30}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.enderman\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.enderman.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"enderman\"}}, {\"translate\": \"barra.trinta\"}]}',
		'titleraw @s [scores={enderman=..30}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.enderman\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.enderman.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"enderman\"}}, {\"translate\": \"barra.trinta\"}]}',
		'titleraw @s [scores={enderman=..30}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.enderman\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.enderman.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"enderman\"}}, {\"translate\": \"barra.trinta\"}]}',
		'titleraw @s [scores={enderman=..30}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.enderman\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.enderman.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"enderman\"}}, {\"translate\": \"barra.trinta\"}]}',
		'titleraw @s [scores={enderman=..30}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.enderman\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.enderman.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"enderman\"}}, {\"translate\": \"barra.trinta\"}]}',
		'titleraw @s [scores={enderman=..30}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.enderman\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.enderman.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"enderman\"}}, {\"translate\": \"barra.trinta\"}]}',
		'titleraw @s [scores={enderman=..30}] actionbar { \"rawtext\": [ { \"translate\":\"up.armadura.level.enderman\" }, {\"text\": \"\n\"}, { \"translate\":\"entity.enderman.death\" }, {\"text\": \" \"}, {\"score\":{\"name\": \"@s\",\"objective\": \"enderman\"}}, {\"translate\": \"barra.trinta\"}]}'
    ],
	fantasma_labirinto: [
        'scoreboard players set @s [tag=boss3] fantasma_morto 1'
    ]
	//creeper: [
    //  'say BOOM! Você matou um creeper!',
    //  'effect @s minecraft:resistance 5 1 true'
    //],
    //warden: [
    //  'say VOCÊ MATOU O WARDEN! INSANO!',
    //  'title @s actionbar Você é corajoso!',
    //  'effect @s minecraft:strength 10 2 true'
    //],
    //illager: [
    //  'say Um illager a menos!',
    //  'give @s minecraft:emerald 1'
    //]
  };

  for (const [familyName, commands] of Object.entries(commandsByFamily)) {
    if (family.hasTypeFamily(familyName)) {
      // Executa todos os comandos associados àquela família
      for (const cmd of commands) {
        damagingEntity.runCommand(cmd);
      }
      break; // Para após encontrar a primeira família compatível
    }
  }
});

world.afterEvents.entityHitEntity.subscribe(ev => {
  const { damagingEntity, hitEntity } = ev;

  if (damagingEntity.typeId !== "minecraft:player") return;

  // Corrigido: array de famílias separadas
  if (hitEntity.matches({ families: ['monster'] })) {
    const chance = Math.random();

    // Corrigido: ordem correta dos ifs
    if (chance < 0.1) {
      damagingEntity.runCommand('scoreboard players add @s furia 5');
      //damagingEntity.runCommand('say furia 10');
    } 
    else if (chance < 0.2) {
      damagingEntity.runCommand('scoreboard players add @s furia 3');
      //damagingEntity.runCommand('say furia 5');
    } 
    else if (chance < 0.4) {
      damagingEntity.runCommand('scoreboard players add @s furia 2');
      //damagingEntity.runCommand('say furia 3');
    } 
    else {
      damagingEntity.runCommand('scoreboard players add @s furia 1');
      //damagingEntity.runCommand('say furia 1');
    }
  }
});


world.afterEvents.entityHitEntity.subscribe(ev => {
  const { damagingEntity, hitEntity } = ev;

  // Verifica se a entidade atingida é um jogador
  if (hitEntity.typeId !== "minecraft:player") return;

  // Lista de famílias hostis adicionais
  const hostileFamilies = ['monster', 'undead', 'illager', 'arthropod', 'player', 'mob', 'boss'];

  // Verifica se quem causou o dano pertence a uma das famílias hostis
  if (damagingEntity && hostileFamilies.some(fam => damagingEntity.matches({ families: [fam] }))) {
    const chance = Math.random();

    if (chance < 0.3) {
      hitEntity.runCommand('particle well:sangue_humano ^^-0.5^2');
    } 
    else if (chance < 0.7) {
      hitEntity.runCommand('execute as @s[scores={genero=1}, r=10] run playsound hurt.male @a [r=15]');
      hitEntity.runCommand('execute as @s[scores={genero=2}, r=10] run playsound hurt.female @a [r=15]');
      hitEntity.runCommand('particle well:sangue_humano ^^-0.5^2');
    }
  }
});

//Mostrar coordenadas de morte
world.afterEvents.entityDie.subscribe(data => {
  if (data.deadEntity.typeId == "minecraft:player") {
  const player = data.deadEntity
  const vida = Number(player.getComponent("minecraft:health").currentValue)
  let x = player.location["x"]
  let y = player.location["y"]
  let z = player.location["z"]
  let name = player.nameTag
  let xt  = Math.trunc(x)
  let yt = Math.trunc(y)
  let zt = Math.trunc(z)
  
player.runCommand(`tellraw @s {"rawtext":[{"translate":"morreu.em.coordenadas"}, {"text":" §4X = ${xt}, §aY = ${yt}, §3Z = ${zt}"}]}`)
 }
})

//Adicionar comandos Scores ao quebrar blocos específicos
world.afterEvents.playerBreakBlock.subscribe(function (event) {
    switch (event.brokenBlockPermutation.type.id) {
		
		//Pontos de Agricultura
		case "minecraft:wheat":
            switch (event.brokenBlockPermutation.getState("growth")) {
                case 7:
                    event.player.runCommand("function pontos_status/agricultura");
                    break;
            }
            break;
        case "minecraft:potatoes":
            switch (event.brokenBlockPermutation.getState("growth")) {
                case 7:
                    event.player.runCommand("function pontos_status/agricultura");
                    break;
            }
            break;
		case "minecraft:carrots":
            switch (event.brokenBlockPermutation.getState("growth")) {
                case 7:
                    event.player.runCommand("function pontos_status/agricultura");
                    break;
            }
            break;
        case "minecraft:cocoa":
            switch (event.brokenBlockPermutation.getState("growth")) {
                case 3:
                    event.player.runCommand("function pontos_status/agricultura");
                    break;
            }
            break;
		case "minecraft:nether_wart":
            switch (event.brokenBlockPermutation.getState("growth")) {
                case 3:
                    event.player.runCommand("function pontos_status/agricultura");
                    break;
            }
            break;	
        case "minecraft:beetroot":
            switch (event.brokenBlockPermutation.getState("growth")) {
                case 7:
                    event.player.runCommand("function pontos_status/agricultura");
                    break;
            }
            break;
        
		//Pontos de Lenhador
		case "minecraft:acacia_log":
            event.player.runCommand("function pontos_status/lenhador1");
            break;
		case "minecraft:jungle_log":
            event.player.runCommand("function pontos_status/lenhador2");
            break;	
        case "minecraft:birch_log":
            event.player.runCommand("function pontos_status/lenhador3");
            break;
        case "minecraft:cherry_log":
            event.player.runCommand("function pontos_status/lenhador4");
            break;
        case "minecraft:dark_oak_log":
            event.player.runCommand("function pontos_status/lenhador5");
            break;
        case "minecraft:mangrove_log":
            event.player.runCommand("function pontos_status/lenhador6");
            break;
        case "minecraft:oak_log":
            event.player.runCommand("function pontos_status/lenhador7");
            break;
        case "minecraft:spruce_log":
            event.player.runCommand("function pontos_status/lenhador8");
            break;
		case "minecraft:crimson_stem":
            event.player.runCommand("function pontos_status/lenhador9");
            break;	
		case "minecraft:warped_stem":
            event.player.runCommand("function pontos_status/lenhador10");
            break;	
		
		//Pontos de Arqueologia
        case "minecraft:suspicius_gravel":
            event.player.runCommand("function pontos_status/arqueologia");
            break;
        case "minecraft:suspicius_sand":
            event.player.runCommand("function pontos_status/arqueologia");
            break;
		
		//Pontos de Mineirador
        case "minecraft:copper_ore":
            event.player.runCommand("function pontos_status/mineirador");
            break;
        case "minecraft:coal_ore":
            event.player.runCommand("function pontos_status/mineirador");
            break;
		case "minecraft:diamond_ore":
            event.player.runCommand("function pontos_status/mineirador");
            break;
        case "minecraft:emerald_ore":
            event.player.runCommand("function pontos_status/mineirador");
            break;
        case "minecraft:gold_ore":
            event.player.runCommand("function pontos_status/mineirador");
            break;
        case "minecraft:iron_ore":
            event.player.runCommand("function pontos_status/mineirador");
            break;
		case "minecraft:lapis_ore":
            event.player.runCommand("function pontos_status/mineirador");
            break;
        case "minecraft:nether_gold_ore":
            event.player.runCommand("function pontos_status/mineirador");
            break;
        case "minecraft:quartz_ore":
            event.player.runCommand("function pontos_status/mineirador");
            break;
        case "minecraft:redstone_ore":
            event.player.runCommand("function pontos_status/mineirador");
            break;
		case "minecraft:deepslate_coal_ore":
            event.player.runCommand("function pontos_status/mineirador");
            break;
        case "minecraft:deepslate_copper_ore":
            event.player.runCommand("function pontos_status/mineirador");
            break;
        case "minecraft:deepslate_diamond_ore":
            event.player.runCommand("function pontos_status/mineirador");
            break;
        case "minecraft:deepslate_emerald_ore":
            event.player.runCommand("function pontos_status/mineirador");
            break;
		case "minecraft:deepslate_gold_ore":
            event.player.runCommand("function pontos_status/mineirador");
            break;
        case "minecraft:deepslate_iron_ore":
            event.player.runCommand("function pontos_status/mineirador");
            break;
        case "minecraft:deepslate_lapis_ore":
            event.player.runCommand("function pontos_status/mineirador");
            break;
        case "minecraft:deepslate_redstone_ore":
            event.player.runCommand("function pontos_status/mineirador");
            break;
			case "minecraft:ancient_debris":
            event.player.runCommand("function pontos_status/mineirador");
            break;
		case "well:ore_ruby":
            event.player.runCommand("function pontos_status/mineirador");
            break;
        case "minecraft:amethyst_cluster":
            event.player.runCommand("function pontos_status/mineirador");
            break;
    }
});
 
export function player_npc(player) {
    let form = new MessageFormData();
    form.title({ rawtext: [{ translate: "npc.title.render" }]});
    form.body({ rawtext: [{ translate: "npc.body.render" }]});
    form.button1({ rawtext: [{ translate: "render.npc.sim" }]});
    form.button2({ rawtext: [{ translate: "render.npc.nao" }]});

    form.show(player).then(res => {
        if (res.canceled) return;
        if (res.selection === 0) {
			player.runCommand("event entity @s aparecer_nickname");
			player.runCommand("effect @s blindness 2 10 true");
			player.runCommand("titleraw @s actionbar {\"rawtext\":[{ \"translate\":\"render.msg.npc.sim\" }]}");
        }
		if (res.selection === 1) {
			player.runCommand("event entity @s remover_nickname");
			player.runCommand("effect @s blindness 2 10 true");
			player.runCommand("titleraw @s actionbar {\"rawtext\":[{ \"translate\":\"render.msg.npc.nao\" }]}");
        }
    }).catch(error => {
        console.error(error, error.stack);
    });
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function getScorePlayer(player, objective) {
    try {
        const obj = world.scoreboard.getObjective(objective);
        if (!obj) return 0;

        const identity = player.scoreboardIdentity;
        if (!identity) return 0;

        return obj.getScore(identity) ?? 0;
    } catch {
        return 0;
    }
}

const TAGS_RANK = {
    novice: "§aNovato",
    novice1: "§aNovato I",
    novice2: "§aNovato II",
    novice3: "§aNovato III",

    adventure: "§eAventureiro",
    adventure1: "§eAventureiro I",
    adventure2: "§eAventureiro II",
    adventure3: "§eAventureiro III",
    adventure4: "§eAventureiro IV",

    master: "§bMestre",
    master1: "§bMestre I",
    master2: "§bMestre II",

    hero: "§dHerói",
    hero1: "§dHerói I",
    hero2: "§dHerói II",
    hero3: "§dHerói III",
    hero4: "§dHerói IV",

    legendary: "§6Lendário",

    boss1: "§aNovato III",
    boss2: "§eAventureiro IV",
    boss3: "§bMestre II",
    boss4: "§dHerói IV"
};

const TAGS_RACA = {
    mago: "§4Mago  §4",
    elfo: "§3Elfo  §3",
    humano: "§5Humano  §0"
};

const TAGS_DUNGEON = {
    novice: "   ",
    novice1: "   ",
    novice2: "   ",
    novice3: "   ",

    adventure: "   ",
    adventure1: "   ",
    adventure2: "   ",
    adventure3: "   ",
    adventure4: "   ",

    master: "   ",
    master1: "   ",
    master2: "   ",

    hero: "   ",
    hero1: "   ",
    hero2: "   ",
    hero3: "   ",
    hero4: "   ",

    legendary: "   ",

    boss1: "   ",
    boss2: "   ",
    boss3: "   ",
    boss4: "   "
};

function getTagsPorCategoria(player, categoria) {
    for (const tag in categoria) {
        if (player.hasTag(tag)) {
            return categoria[tag];
        }
    }
    return "§0Nenhum";
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
world.afterEvents.playerInteractWithEntity.subscribe(({player, target}) => {
    if (target.typeId === "well:bau_interface_lula") {
        {menu_lula_d2(player)}
    }
})
world.afterEvents.playerInteractWithEntity.subscribe(({player, target}) => {
    if (target.typeId === "well:bau_interface_allay") {
        {menu_allay_d2(player)}
    }
})

world.afterEvents.playerInteractWithEntity.subscribe(({player, target}) => {
    if (target.typeId === "well:bau_interface_zumbi") {
        {menu_zumbi_d2(player)}
    }
})
world.afterEvents.playerInteractWithEntity.subscribe(({player, target}) => {
    if (target.typeId === "well:bandeira_chunk") {
        {Chunk_menu_bandeira(player)}
    }
})
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
world.afterEvents.playerInteractWithEntity.subscribe(({player, target}) => {
    if (target.typeId === "well:mago_misterio") {
        {verificarSenha(player)}
    }
})
async function verificarSenha(player) {
    const senhaCorreta = "Abomination of the Swamp";

    const form = new ui.ModalFormData()
        .title({ "rawtext": [{ "translate": "missao.labirinto.npc" }] })
        //.body({ "rawtext": [{ "translate": "missao.labirinto.npc" }] })
        .textField({ "rawtext": [{ "translate": "senha.boss3.puzzle" }]}, { "rawtext": [{ "translate": "senha.boss3.text" }]});

    const result = await form.show(player);

    if (result.canceled) return;

    const senhaDigitada = result.formValues[0];

    if (senhaDigitada === senhaCorreta) {
        player.sendMessage({ "rawtext": [{ "translate": "senha.boss3.correta" }]});

        system.run(() => {
            // Executa a função desejada
            player.runCommand("function dungeon_combate_boss3");
        });
    } else {
        player.sendMessage({ "rawtext": [{ "translate": "senha.boss3.incorreta" }]});
    }
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
world.afterEvents.itemUse.subscribe((eventData) => {
    if (eventData.itemStack.typeId === "well:livro_do_mago") {
        let player = eventData.source;
        livro_do_mago(player);
    }
});

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
export function livro_do_mago(player) {
    let form = new ui.ActionFormData();
	form.title("wellforced:magaopagynaum");
    form.body("");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/undoArrow.png");
    
    form.show(player).then((result) => {
        
		if (result.selection == 0) {
			
			livro_do_mago1(player)
			
        }
    });
}
export function livro_do_mago1(player) {
    let form = new ui.ActionFormData();
	form.title("wellforced:magaopagynadois");
    form.body("");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/undoArrow.png");
    
    form.show(player).then((result) => {
        
		if (result.selection == 0) {
			
			livro_do_mago2(player)
        }
    });
}
export function livro_do_mago2(player) {
    let form = new ui.ActionFormData();
	form.title("wellforced:magaopagynatres");
    form.body("");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/undoArrow.png");
    
    form.show(player).then((result) => {
        
		if (result.selection == 0) {
			
			livro_do_mago(player)
        }
    });
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
export function menulistwell(player) {
    let form = new ui.ActionFormData();
    form.title("wellforced:menu_pergaminho_principal");
    form.body({ rawtext: [{ translate: "menu.acao.jogador" }]});

    form.button({ rawtext: [{ translate: "missoes.menu" }] }, "textures/items/teleporterapido.png");
    form.button({ rawtext: [{ translate: "bestiario.menu" }] }, "textures/items/bestiario.png");
    form.button({ rawtext: [{ translate: "status.menu" }] }, "textures/ui/FriendsDiversity.png");
    form.button({ rawtext: [{ translate: "teleporte.menu" }] }, "textures/items/ender_pearl.png");
    form.button({ rawtext: [{ translate: "opcoes.menu" }] }, "textures/ui/settings_glyph_color_2x.png");
    form.button({ rawtext: [{ translate: "criadores.text" }] }, "textures/ui/Espadas.png");
	
	form.button({ rawtext: [{ translate: "criadores.text" }] }, "textures/ui/menu_acao/menu_0");

    form.show(player).then((result) => {
        if (result.canceled) {
            player.runCommand("event entity @s remove_player_npc");
            return;
        }

        if (result.selection == 0) {
            player.runCommand("event entity @s remove_player_npc");
            menu_missao(player);
        }
        if (result.selection == 1) {
            abrirBestiario(player);
        }
        if (result.selection == 2) {
            player.runCommand("event entity @s remove_player_npc");
			if (player.hasTag("novice") || player.hasTag("novice1") || player.hasTag("novice2") || player.hasTag("novice3") || player.hasTag("boss1")) {
                statusplayer(player);
            }
        }
        if (result.selection == 3) {
			player.runCommand("event entity @s remove_player_npc");
            teleporte_principal(player);
        }
        if (result.selection == 4) {
            opcoes_menu(player);
        }
        if (result.selection == 5) {
			player.runCommand("event entity @s remove_player_npc");
            creditos(player);
        }
    });
}
export function menulistwell1(player) {
    let form = new ui.ActionFormData();
	form.title("wellforced:menu_pergaminho_principal");
    form.body({ rawtext: [{ translate: "menu.acao.jogador" }]});
	form.button({ rawtext: [ { translate: "missoes.menu" }]}, "textures/items/teleporterapido.png");
	form.button({ rawtext: [ { translate: "bestiario.menu" }]}, "textures/items/bestiario.png");
	form.button({ rawtext: [ { translate: "status.menu" }]}, "textures/ui/FriendsDiversity.png");
	form.button({ rawtext: [ { translate: "teleporte.menu" }]}, "textures/items/ender_pearl.png");
	form.button({ rawtext: [ { translate: "opcoes.menu" }]}, "textures/ui/settings_glyph_color_2x.png");
	form.button({ rawtext: [ { translate: "criadores.text" }]}, "textures/ui/Espadas.png");
	
	form.button({ rawtext: [{ translate: "criadores.text" }] }, "textures/ui/menu_acao/menu_1");
    
    form.show(player).then((result) => {
		if (result.canceled) {
            player.runCommand("event entity @s remove_player_npc");
            return;
        }
        if (result.selection == 0) {
            {menu_missao(player)}
        }
        if (result.selection == 1) {
            abrirBestiario(player);
        }
		if (result.selection == 2) {
            
			
			if (player.hasTag("adventure")) {
                statusplayer1(player);
            }
			if (player.hasTag("adventure1")) {
                statusplayer1(player);
            }
			if (player.hasTag("adventure2")) {
                statusplayer1(player);
            }
			if (player.hasTag("adventure3")) {
                statusplayer1(player);
            }
			if (player.hasTag("adventure4")) {
                statusplayer1(player);
            }
			if (player.hasTag("boss2")) {
                statusplayer1(player);
            }
			
			
        }
		if (result.selection == 3) {
            teleporte_principal(player);
        }
		if (result.selection == 4) {
            opcoes_menu(player);
        }
		if (result.selection == 5) {
            creditos(player);
        }
    });
}
export function menulistwell2(player) {
    let form = new ui.ActionFormData();
	form.title("wellforced:menu_pergaminho_principal");
    form.body({ rawtext: [{ translate: "menu.acao.jogador" }]});
	form.button({ rawtext: [ { translate: "missoes.menu" }]}, "textures/items/teleporterapido.png");
	form.button({ rawtext: [ { translate: "bestiario.menu" }]}, "textures/items/bestiario.png");
	form.button({ rawtext: [ { translate: "status.menu" }]}, "textures/ui/FriendsDiversity.png");
	form.button({ rawtext: [ { translate: "teleporte.menu" }]}, "textures/items/ender_pearl.png");
	form.button({ rawtext: [ { translate: "opcoes.menu" }]}, "textures/ui/settings_glyph_color_2x.png");
	form.button({ rawtext: [ { translate: "criadores.text" }]}, "textures/ui/Espadas.png");
	
	form.button({ rawtext: [{ translate: "criadores.text" }] }, "textures/ui/menu_acao/menu_2");
    
    form.show(player).then((result) => {
		if (result.canceled) {
            player.runCommand("event entity @s remove_player_npc");
            return;
        }
        if (result.selection == 0) {
            {menu_missao(player)}
        }
        if (result.selection == 1) {
            abrirBestiario(player);
        }
		if (result.selection == 2) {
            
			if (player.hasTag("master")) {
                statusplayer2(player);
            }
			if (player.hasTag("master1")) {
                statusplayer2(player);
            }
			if (player.hasTag("master2")) {
                statusplayer2(player);
            }
			if (player.hasTag("boss3")) {
                statusplayer2(player);
            }
			
			
        }
		if (result.selection == 3) {
            teleporte_principal(player);
        }
		if (result.selection == 4) {
            opcoes_menu(player);
        }
		if (result.selection == 5) {
            creditos(player);
        }
    });
}
export function menulistwell3(player) {
    let form = new ui.ActionFormData();
	form.title("wellforced:menu_pergaminho_principal");
    form.body({ rawtext: [{ translate: "menu.acao.jogador" }]});
	form.button({ rawtext: [ { translate: "missoes.menu" }]}, "textures/items/teleporterapido.png");
	form.button({ rawtext: [ { translate: "bestiario.menu" }]}, "textures/items/bestiario.png");
	form.button({ rawtext: [ { translate: "status.menu" }]}, "textures/ui/FriendsDiversity.png");
	form.button({ rawtext: [ { translate: "teleporte.menu" }]}, "textures/items/ender_pearl.png");
	form.button({ rawtext: [ { translate: "opcoes.menu" }]}, "textures/ui/settings_glyph_color_2x.png");
	form.button({ rawtext: [ { translate: "criadores.text" }]}, "textures/ui/Espadas.png");
	
	form.button({ rawtext: [{ translate: "criadores.text" }] }, "textures/ui/menu_acao/menu_3");
    
    form.show(player).then((result) => {
		if (result.canceled) {
            player.runCommand("event entity @s remove_player_npc");
            return;
        }
        if (result.selection == 0) {
            {menu_missao(player)}
        }
        if (result.selection == 1) {
            abrirBestiario(player);
        }
		if (result.selection == 2) {
            
			if (player.hasTag("hero")) {
                statusplayer3(player);
            }
			if (player.hasTag("hero1")) {
                statusplayer3(player);
            }
			if (player.hasTag("hero2")) {
                statusplayer3(player);
            }
			if (player.hasTag("hero3")) {
                statusplayer3(player);
            }
			
        }
		if (result.selection == 3) {
            teleporte_principal(player);
        }
		if (result.selection == 4) {
            opcoes_menu(player);
        }
		if (result.selection == 5) {
            creditos(player);
        }
    });
}
export function menulistwell4(player) {
    let form = new ui.ActionFormData();
	form.title("wellforced:menu_pergaminho_principal");
    form.body({ rawtext: [{ translate: "menu.acao.jogador" }]});
	form.button({ rawtext: [ { translate: "missoes.menu" }]}, "textures/items/teleporterapido.png");
	form.button({ rawtext: [ { translate: "bestiario.menu" }]}, "textures/items/bestiario.png");
	form.button({ rawtext: [ { translate: "status.menu" }]}, "textures/ui/FriendsDiversity.png");
	form.button({ rawtext: [ { translate: "teleporte.menu" }]}, "textures/items/ender_pearl.png");
	form.button({ rawtext: [ { translate: "opcoes.menu" }]}, "textures/ui/settings_glyph_color_2x.png");
	form.button({ rawtext: [ { translate: "criadores.text" }]}, "textures/ui/Espadas.png");
	
	form.button({ rawtext: [{ translate: "criadores.text" }] }, "textures/ui/menu_acao/menu_completo");
    
    form.show(player).then((result) => {
		if (result.canceled) {
            player.runCommand("event entity @s remove_player_npc");
            return;
        }
        if (result.selection == 0) {
            {menu_missao(player)}
        }
        if (result.selection == 1) {
            abrirBestiario(player);
        }
		if (result.selection == 2) {
            
			if (player.hasTag("boss4")) {
                statusplayer4(player);
            }
			if (player.hasTag("legendary")) {
                statusplayer4(player);
            }
			
        }
		if (result.selection == 3) {
            teleporte_principal(player);
        }
		if (result.selection == 4) {
            opcoes_menu(player);
        }
		if (result.selection == 5) {
            creditos(player);
        }
    });
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
export function statusplayer(player) {
    let form = new ui.ActionFormData();
    const ranksTexto = getTagsPorCategoria(player, TAGS_RANK);
    const racaTexto = getTagsPorCategoria(player, TAGS_RACA);
	const DungeonTexto = getTagsPorCategoria(player, TAGS_DUNGEON);
    const ClaTexto = getClan(player);
	
	form.title("wellforced:menu_status_player");
    form.body({
        rawtext: [
			{ text: "|| §1Rank: §3" + ranksTexto + "\n\n" }, { text: "|| §4Raça: §2" + racaTexto + "|| " }, { text: "§5Clã: §1" + ClaTexto + "\n\n" },
			{ translate: "coleta_madeira.status" }, { text: `${getScore(player, "coleta_madeira")}` }, { text: "\n" },
            { translate: "mineiracao.status" }, { text: `${getScore(player, "mineiracao")}` }, { text: "\n" },
            { translate: "pescaria.status" }, { text: `${getScore(player, "pescaria")}` }, { text: "\n" },
            { translate: "agricultura.status" }, { text: `${getScore(player, "agricultura")}` },
			
			{ text: "\n" },
			
			{ translate: "mortes_player.status" }, { text: `${getScore(player, "mortes")}` }, { text: "\n" },
			{ translate: "mortes_monstros.status" }, { text: `${getScore(player, "mortes_monstros")}` }
        ]
    });
    form.button({ rawtext: [{ translate: "menu.voltar" }] }, "textures/ui/undoArrow.png");
    form.button({ rawtext: [{ translate: "up.armaduras" }] }, "textures/items/well_armadura_divina.png");
    form.button({ rawtext: [{ translate: "up.ferramentas" }] }, "textures/items/pamobile/well_espada_ruby.png");
	form.button({ rawtext: [{ translate: "menu.invitar" }] }, "textures/ui/icon_best3.png");
	
	form.button({ rawtext: [{ translate: "criadores.text" }] }, "textures/ui/menu_acao/menu_0");

    form.show(player).then((result) => {
        if (result.selection == 0) {
            if (player.hasTag("novice")) {
                menulistwell(player);
            }
			if (player.hasTag("novice1")) {
                menulistwell(player);
            }
			if (player.hasTag("novice2")) {
                menulistwell(player);
            }
			if (player.hasTag("novice3")) {
                menulistwell(player);
            }
			if (player.hasTag("boss1")) {
                menulistwell(player);
            }
			
        }
        if (result.selection == 1) {
            status_armadura(player)
        }
        if (result.selection == 2) {
            status_ferramentas(player)
        }
		
		if (result.selection == 3) {
            abrirMenuClas(player)
			
        }
    });
}
export function statusplayer1(player) {
    let form = new ui.ActionFormData();
	const ranksTexto = getTagsPorCategoria(player, TAGS_RANK);
    const racaTexto = getTagsPorCategoria(player, TAGS_RACA);
	const DungeonTexto = getTagsPorCategoria(player, TAGS_DUNGEON);
    const ClaTexto = getClan(player);
    form.title("wellforced:menu_status_player");
    form.body({
        rawtext: [
            { text: "|| §1Rank: §3" + ranksTexto + "\n\n" }, { text: "|| §4Raça: §2" + racaTexto + "|| " }, { text: "§5Clã: §1" + ClaTexto + "\n\n" },
			{ translate: "coleta_madeira.status" }, { text: `${getScore(player, "coleta_madeira")}` }, { text: "\n" },
            { translate: "mineiracao.status" }, { text: `${getScore(player, "mineiracao")}` }, { text: "\n" },
            { translate: "pescaria.status" }, { text: `${getScore(player, "pescaria")}` }, { text: "\n" },
            { translate: "agricultura.status" }, { text: `${getScore(player, "agricultura")}` },
			
			{ text: "\n" },
			
			{ translate: "mortes_player.status" }, { text: `${getScore(player, "mortes")}` }, { text: "\n" },
			{ translate: "mortes_monstros.status" }, { text: `${getScore(player, "mortes_monstros")}` }
        ]
    });
    form.button({ rawtext: [{ translate: "menu.voltar" }] }, "textures/ui/undoArrow.png");
    form.button({ rawtext: [{ translate: "up.armaduras" }] }, "textures/items/well_armadura_divina.png");
    form.button({ rawtext: [{ translate: "up.ferramentas" }] }, "textures/items/pamobile/well_espada_ruby.png");
	form.button({ rawtext: [{ translate: "menu.invitar" }] }, "textures/ui/icon_best3.png");
	
	form.button({ rawtext: [{ translate: "criadores.text" }] }, "textures/ui/menu_acao/menu_1");

    form.show(player).then((result) => {
        if (result.selection == 0) {
            
			if (player.hasTag("adventure")) {
                menulistwell1(player);
            }
			if (player.hasTag("adventure1")) {
                menulistwell1(player);
            }
			if (player.hasTag("adventure2")) {
                menulistwell1(player);
            }
			if (player.hasTag("adventure3")) {
                menulistwell1(player);
            }
			if (player.hasTag("adventure4")) {
                menulistwell1(player);
            }
			if (player.hasTag("boss2")) {
                menulistwell1(player);
            }
			
        }
        if (result.selection == 1) {
            status_armadura(player)
        }
        if (result.selection == 2) {
            status_ferramentas(player)
        }
		if (result.selection == 3) {
            abrirMenuClas(player)
			
        }
    });
}
export function statusplayer2(player) {
    let form = new ui.ActionFormData();
	const ranksTexto = getTagsPorCategoria(player, TAGS_RANK);
    const racaTexto = getTagsPorCategoria(player, TAGS_RACA);
	const DungeonTexto = getTagsPorCategoria(player, TAGS_DUNGEON);
    const ClaTexto = getClan(player);
    form.title("wellforced:menu_status_player");
    form.body({
        rawtext: [
            { text: "|| §1Rank: §3" + ranksTexto + "\n\n" }, { text: "|| §4Raça: §2" + racaTexto + "|| " }, { text: "§5Clã: §1" + ClaTexto + "\n\n" },
			{ translate: "coleta_madeira.status" }, { text: `${getScore(player, "coleta_madeira")}` }, { text: "\n" },
            { translate: "mineiracao.status" }, { text: `${getScore(player, "mineiracao")}` }, { text: "\n" },
            { translate: "pescaria.status" }, { text: `${getScore(player, "pescaria")}` }, { text: "\n" },
            { translate: "agricultura.status" }, { text: `${getScore(player, "agricultura")}` },
			
			{ text: "\n" },
			
			{ translate: "mortes_player.status" }, { text: `${getScore(player, "mortes")}` }, { text: "\n" },
			{ translate: "mortes_monstros.status" }, { text: `${getScore(player, "mortes_monstros")}` }
        ]
    });
    form.button({ rawtext: [{ translate: "menu.voltar" }] }, "textures/ui/undoArrow.png");
    form.button({ rawtext: [{ translate: "up.armaduras" }] }, "textures/items/well_armadura_divina.png");
    form.button({ rawtext: [{ translate: "up.ferramentas" }] }, "textures/items/pamobile/well_espada_ruby.png");
	form.button({ rawtext: [{ translate: "menu.invitar" }] }, "textures/ui/icon_best3.png");
	
	form.button({ rawtext: [{ translate: "criadores.text" }] }, "textures/ui/menu_acao/menu_2");

    form.show(player).then((result) => {
        if (result.selection == 0) {
            
			if (player.hasTag("master")) {
                menulistwell2(player);
            }
			if (player.hasTag("master1")) {
                menulistwell2(player);
            }
			if (player.hasTag("master2")) {
                menulistwell2(player);
            }
			if (player.hasTag("boss3")) {
                menulistwell2(player);
            }
			
        }
        if (result.selection == 1) {
            status_armadura(player)
        }
        if (result.selection == 2) {
            status_ferramentas(player)
        }
		if (result.selection == 3) {
            abrirMenuClas(player)
			
        }
    });
}
export function statusplayer3(player) {
    let form = new ui.ActionFormData();
	const ranksTexto = getTagsPorCategoria(player, TAGS_RANK);
    const racaTexto = getTagsPorCategoria(player, TAGS_RACA);
	const DungeonTexto = getTagsPorCategoria(player, TAGS_DUNGEON);
    const ClaTexto = getClan(player);
    form.title("wellforced:menu_status_player");
    form.body({
        rawtext: [
            { text: "|| §1Rank: §3" + ranksTexto + "\n\n" }, { text: "|| §4Raça: §2" + racaTexto + "|| " }, { text: "§5Clã: §1" + ClaTexto + "\n\n" },
			{ translate: "coleta_madeira.status" }, { text: `${getScore(player, "coleta_madeira")}` }, { text: "\n" },
            { translate: "mineiracao.status" }, { text: `${getScore(player, "mineiracao")}` }, { text: "\n" },
            { translate: "pescaria.status" }, { text: `${getScore(player, "pescaria")}` }, { text: "\n" },
            { translate: "agricultura.status" }, { text: `${getScore(player, "agricultura")}` },
			
			{ text: "\n" },
			
			{ translate: "mortes_player.status" }, { text: `${getScore(player, "mortes")}` }, { text: "\n" },
			{ translate: "mortes_monstros.status" }, { text: `${getScore(player, "mortes_monstros")}` }
        ]
    });
    form.button({ rawtext: [{ translate: "menu.voltar" }] }, "textures/ui/undoArrow.png");
    form.button({ rawtext: [{ translate: "up.armaduras" }] }, "textures/items/well_armadura_divina.png");
    form.button({ rawtext: [{ translate: "up.ferramentas" }] }, "textures/items/pamobile/well_espada_ruby.png");
	form.button({ rawtext: [{ translate: "menu.invitar" }] }, "textures/ui/icon_best3.png");
	
	form.button({ rawtext: [{ translate: "criadores.text" }] }, "textures/ui/menu_acao/menu_3");

    form.show(player).then((result) => {
        if (result.selection == 0) {
            
			if (player.hasTag("hero")) {
                menulistwell3(player);
            }
			if (player.hasTag("hero1")) {
                menulistwell3(player);
            }
			if (player.hasTag("hero2")) {
                menulistwell3(player);
            }
			if (player.hasTag("hero3")) {
                menulistwell3(player);
            }
        }
        if (result.selection == 1) {
            status_armadura(player)
        }
        if (result.selection == 2) {
            status_ferramentas(player)
        }
		if (result.selection == 3) {
            abrirMenuClas(player)
			
        }
    });
}
export function statusplayer4(player) {
    let form = new ui.ActionFormData();
	const ranksTexto = getTagsPorCategoria(player, TAGS_RANK);
    const racaTexto = getTagsPorCategoria(player, TAGS_RACA);
	const DungeonTexto = getTagsPorCategoria(player, TAGS_DUNGEON);
    const ClaTexto = getClan(player);
    form.title("wellforced:menu_status_player");
    form.body({
        rawtext: [
            { text: "|| §1Rank: §3" + ranksTexto + "\n\n" }, { text: "|| §4Raça: §2" + racaTexto + "|| " }, { text: "§5Clã: §1" + ClaTexto + "\n\n" },
			{ translate: "coleta_madeira.status" }, { text: `${getScore(player, "coleta_madeira")}` }, { text: "\n" },
            { translate: "mineiracao.status" }, { text: `${getScore(player, "mineiracao")}` }, { text: "\n" },
            { translate: "pescaria.status" }, { text: `${getScore(player, "pescaria")}` }, { text: "\n" },
            { translate: "agricultura.status" }, { text: `${getScore(player, "agricultura")}` },
			
			{ text: "\n" },
			
			{ translate: "mortes_player.status" }, { text: `${getScore(player, "mortes")}` }, { text: "\n" },
			{ translate: "mortes_monstros.status" }, { text: `${getScore(player, "mortes_monstros")}` }
        ]
    });
    form.button({ rawtext: [{ translate: "menu.voltar" }] }, "textures/ui/undoArrow.png");
    form.button({ rawtext: [{ translate: "up.armaduras" }] }, "textures/items/well_armadura_divina.png");
    form.button({ rawtext: [{ translate: "up.ferramentas" }] }, "textures/items/pamobile/well_espada_ruby.png");
	form.button({ rawtext: [{ translate: "menu.invitar" }] }, "textures/ui/icon_best3.png");
	
	form.button({ rawtext: [{ translate: "criadores.text" }] }, "textures/ui/menu_acao/menu_completo");

    form.show(player).then((result) => {
        if (result.selection == 0) {
            
			if (player.hasTag("boss4")) {
                menulistwell4(player);
            }
			if (player.hasTag("legendary")) {
                menulistwell4(player);
            }
        }
        if (result.selection == 1) {
            status_armadura(player)
        }
        if (result.selection == 2) {
            status_ferramentas(player)
        }
		if (result.selection == 3) {
            abrirMenuClas(player)
			
        }
    });
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
export function menu_lula_d2(player) {
    let form = new ui.ActionFormData();
	form.title("wellforced:bau_interface_lula_d2");
    form.body("");
    form.button({ rawtext: [{ translate: "ok" }] });
    
    form.show(player).then((result) => {
        
		if (result.selection == 0) {
        }
    });
}
export function menu_zumbi_d2(player) {
    let form = new ui.ActionFormData();
	form.title("wellforced:bau_interface_zumbi_d2");
    form.body("");
    form.button({ rawtext: [{ translate: "ok" }] });
    
    form.show(player).then((result) => {
        
		if (result.selection == 0) {
        }
    });
}
export function menu_allay_d2(player) {
    let form = new ui.ActionFormData();
	form.title("wellforced:bau_interface_allay_d2");
    form.body("");
    form.button({ rawtext: [{ translate: "ok" }] });
    
    form.show(player).then((result) => {
        
		if (result.selection == 0) {
        }
    });
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// missao1
export function missao1(player) {
    let form = new ui.ActionFormData();
    form.title("wellforced:quests_principais");
    form.body({ rawtext: [{ translate: "descricao.titulo.menu.missao1" }]});
    form.button({ rawtext: [{ translate: "dicas.menu" }]});
    form.button({ rawtext: [{ translate: "reset.missao" }]});
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/tela_livro.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_missoes/silpho.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/icones_missoes/alex.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/recompensas/orbe.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_nomes/nome-silpho");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/estrelas/1");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/level/1");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/menu_acao/1");
   
    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) {
            player.runCommand("function scripts_forms/dicas_missoes");
        }
        if (result.selection === 1) {
            resetmissao(player, 1);
        }
    });
}

// missao2
export function missao2(player) {
    let form = new ui.ActionFormData();
    form.title("wellforced:quests_principais");
    form.body({ rawtext: [{ translate: "descricao.titulo.menu.missao2" }]});
    form.button({ rawtext: [{ translate: "dicas.menu" }]});
    form.button({ rawtext: [{ translate: "reset.missao" }]});
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/tela_livro.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_missoes/silpho.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/icones_missoes/alex.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/recompensas/orbe.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_nomes/nome-silpho");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/estrelas/1");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/level/2");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/menu_acao/2");
    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_missoes");
        if (result.selection === 1) resetmissao(player, 2);
    });
}

// missao3
export function missao3(player) {
    let form = new ui.ActionFormData();
    form.title("wellforced:quests_principais");
    form.body({ rawtext: [{ translate: "descricao.titulo.menu.missao3" }]});
    form.button({ rawtext: [{ translate: "dicas.menu" }]});
    form.button({ rawtext: [{ translate: "reset.missao" }]});
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/tela_livro.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_missoes/kile.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/icones_missoes/creeper.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/recompensas/Alma_da_Arvore.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_nomes/nome-kile");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/estrelas/2");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/level/3");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/menu_acao/3");
    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_missoes");
        if (result.selection === 1) resetmissao(player, 3);
    });
}

// missao4
export function missao4(player) {
    let form = new ui.ActionFormData();
    form.title("wellforced:quests_principais");
    form.body({ rawtext: [{ text: "\n" },{ text: "\n" },{ text: "\n" },{ text: "\n" }, { translate: "descricao.titulo.menu.missao4" }]});
    form.button({ rawtext: [{ translate: "dicas.menu" }]});
    form.button({ rawtext: [{ translate: "reset.missao" }]});
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/tela_livro.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_missoes/kile.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/icones_missoes/arvore_morta.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/recompensas/orbe.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_nomes/nome-kile");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/estrelas/3");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/level/4");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/menu_acao/4");
    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_missoes");
        if (result.selection === 1) resetmissao(player, 4);
    });
}

// missao5
export function missao5(player) {
    let form = new ui.ActionFormData();
    form.title("wellforced:quests_principais");
    form.body({ rawtext: [{ translate: "descricao.titulo.menu.missao5" }]});
    form.button({ rawtext: [{ translate: "dicas.menu" }]});
    form.button({ rawtext: [{ translate: "reset.missao" }]});
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/tela_livro.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_missoes/alana.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/icones_missoes/invasao.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/recompensas/Fertilizante_Mistico.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_nomes/nome-alana");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/estrelas/3");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/level/5");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/menu_acao/5");
    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_missoes");
        if (result.selection === 1) resetmissao(player, 5);
    });
}

// missao6
export function missao6(player) {
    let form = new ui.ActionFormData();
    form.title("wellforced:quests_principais");
    form.body({ rawtext: [{ translate: "descricao.titulo.menu.missao6" }]});
    form.button({ rawtext: [{ translate: "dicas.menu" }]});
    form.button({ rawtext: [{ translate: "reset.missao" }]});
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/tela_livro.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_missoes/karlos.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/icones_missoes/plantacoes.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/recompensas/Literatura_dos_Arqueologos.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_nomes/nome-karlos");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/estrelas/3");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/level/6");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/menu_acao/6");
    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_missoes");
        if (result.selection === 1) resetmissao(player, 6);
    });
}

// missao7
export function missao7(player) {
    let form = new ui.ActionFormData();
    form.title("wellforced:quests_principais");
    form.body({ rawtext: [{ text: "\n" },{ translate: "descricao.titulo.menu.missao7" }]});
    form.button({ rawtext: [{ translate: "dicas.menu" }]});
    form.button({ rawtext: [{ translate: "reset.missao" }]});
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/tela_livro.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_missoes/nord.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/icones_missoes/poco.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/recompensas/orbe.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_nomes/nome-nord");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/estrelas/2");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/level/7");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/menu_acao/7");
    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_missoes");
        if (result.selection === 1) resetmissao(player, 7);
    });
}

// missao8
export function missao8(player) {
    let form = new ui.ActionFormData();
    form.title("wellforced:quests_principais");
    form.body({ rawtext: [{ text: "\n" },{ text: "\n" },{ text: "\n" },{ translate: "descricao.titulo.menu.missao8" }]});
    form.button({ rawtext: [{ translate: "dicas.menu" }]});
    form.button({ rawtext: [{ translate: "reset.missao" }]});
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/tela_livro.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_missoes/ossos_secos.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/icones_missoes/cabecas_ossos.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/recompensas/gelo_arcaico.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_nomes/nome-ossos");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/estrelas/4");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/level/8");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/menu_acao/8");
    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_missoes");
        if (result.selection === 1) resetmissao(player, 8);
    });
}

// missao9
export function missao9(player) {
    let form = new ui.ActionFormData();
    form.title("wellforced:quests_principais");
    form.body({ rawtext: [{ text: "\n" },{ text: "\n" },{ text: "\n" },{ translate: "descricao.titulo.menu.missao9" }]});
    form.button({ rawtext: [{ translate: "dicas.menu" }]});
    form.button({ rawtext: [{ translate: "reset.missao" }]});
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/tela_livro.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_missoes/ossos_secos.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/icones_missoes/esqueleto.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/recompensas/orbe.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_nomes/nome-ossos");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/estrelas/3");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/level/9");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/menu_acao/9");
    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_missoes");
        if (result.selection === 1) resetmissao(player, 9);
    });
}

// missao10
export function missao10(player) {
    let form = new ui.ActionFormData();
    form.title("wellforced:quests_principais");
    form.body({ rawtext: [{ translate: "descricao.titulo.menu.missao10" }]});
    form.button({ rawtext: [{ translate: "dicas.menu" }]});
    form.button({ rawtext: [{ translate: "reset.missao" }]});
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/tela_livro.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_missoes/silpho.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/icones_missoes/guerreiros.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/recompensas/orbe.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_nomes/nome-silpho");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/estrelas/3");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/level/10");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/menu_acao/10");
    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_missoes");
        if (result.selection === 1) resetmissao(player, 10);
    });
}

// missao11
export function missao11(player) {
    let form = new ui.ActionFormData();
    form.title("wellforced:quests_principais");
    form.body({ rawtext: [{ translate: "descricao.titulo.menu.missao11" }]});
    form.button({ rawtext: [{ translate: "dicas.menu" }]});
    form.button({ rawtext: [{ translate: "reset.missao" }]});
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/tela_livro.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_missoes/silpho-mapa.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/icones_missoes/navio-mapa.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/recompensas/Essencia_da_Bruxa.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_nomes/nome-silpho");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/estrelas/4");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/level/11");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/menu_acao/11");
    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_missoes");
        if (result.selection === 1) resetmissao(player, 11);
    });
}

// missao12
export function missao12(player) {
    let form = new ui.ActionFormData();
    form.title("wellforced:quests_principais");
    form.body({ rawtext: [{ text: "\n" },{ text: "\n" },{ text: "\n" },{ text: "\n" },{ translate: "descricao.titulo.menu.missao12" }]});
    form.button({ rawtext: [{ translate: "dicas.menu" }]});
    form.button({ rawtext: [{ translate: "reset.missao" }]});
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/tela_livro.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_missoes/silpho.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/icones_missoes/caveira.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/recompensas/Gema_do_Caos.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_nomes/nome-silpho");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/estrelas/4");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/level/12");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/menu_acao/12");
    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_missoes");
        if (result.selection === 1) resetmissao(player, 12);
    });
}

// missao13
export function missao13(player) {
    let form = new ui.ActionFormData();
    form.title("wellforced:quests_principais");
    form.body({ rawtext: [{ translate: "descricao.titulo.menu.missao13" }]});
    form.button({ rawtext: [{ translate: "dicas.menu" }]});
    form.button({ rawtext: [{ translate: "reset.missao" }]});
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/tela_livro.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_missoes/mestre-bardo.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/icones_missoes/bardos-box.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/recompensas/flauta.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_nomes/nome-bardo");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/estrelas/5");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/level/13");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/menu_acao/13");
    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_missoes");
        if (result.selection === 1) resetmissao(player, 13);
    });
}

// missao14
export function missao14(player) {
    let form = new ui.ActionFormData();
    form.title("wellforced:quests_principais");
    form.body({ rawtext: [{ text: "\n" }, { translate: "descricao.titulo.menu.missao14" }]});
    form.button({ rawtext: [{ translate: "dicas.menu" }]});
    form.button({ rawtext: [{ translate: "reset.missao" }]});
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/tela_livro.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_missoes/hilda.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/icones_missoes/flauta.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/recompensas/Amuleto_de_Farao.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_nomes/nome-hilda");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/estrelas/4");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/level/14");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/menu_acao/14");
    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_missoes");
        if (result.selection === 1) resetmissao(player, 14);
    });
}

// missao15
export function missao15(player) {
    let form = new ui.ActionFormData();
    form.title("wellforced:quests_principais");
    form.body({ rawtext: [{ text: "\n" }, { translate: "descricao.titulo.menu.missao15" }]});
    form.button({ rawtext: [{ translate: "dicas.menu" }]});
    form.button({ rawtext: [{ translate: "reset.missao" }]});
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/tela_livro.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_missoes/lundon.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/icones_missoes/portal.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/recompensas/Chave_Hilda.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_nomes/nome-lundon");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/estrelas/5");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/level/15");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/menu_acao/15");
    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_missoes");
        if (result.selection === 1) resetmissao(player, 15);
    });
}

// missao16
export function missao16(player) {
    let form = new ui.ActionFormData();
    form.title("wellforced:quests_principais");
    form.body({ rawtext: [{ translate: "descricao.titulo.menu.missao16" }]});
    form.button({ rawtext: [{ translate: "dicas.menu" }]});
    form.button({ rawtext: [{ translate: "reset.missao" }]});
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/tela_livro.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_missoes/hilda.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/icones_missoes/flauta.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/recompensas/Amuleto_de_Farao.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_nomes/nome-hilda");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/estrelas/4");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/level/16");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/menu_acao/16");
    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_missoes");
        if (result.selection === 1) resetmissao(player, 16);
    });
}

// missao17
export function missao17(player) {
    let form = new ui.ActionFormData();
    form.title("wellforced:quests_principais");
    form.body({ rawtext: [{ translate: "descricao.titulo.menu.missao17" }]});
    form.button({ rawtext: [{ translate: "dicas.menu" }]});
    form.button({ rawtext: [{ translate: "reset.missao" }]});
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/tela_livro.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_missoes/silpho.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/icones_missoes/mago.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/recompensas/Cristal_da_Transmutacao.png");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/npcs_nomes/nome-silpho");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/estrelas/5");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/pergaminhos/level/17");
    form.button({ rawtext: [{ translate: ">>" }] }, "textures/ui/menu_acao/17");
    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_missoes");
        if (result.selection === 1) resetmissao(player, 17);
    });
}

export function resetmissao(player) {

    const confirmForm = new ui.MessageFormData()
        .title({ rawtext: [{ translate: "reset.total.titulo" }] })
        .body({ rawtext: [{ translate: "reset.total.corpo" }] })
        .button1({ rawtext: [{ translate: "botao.cancelar" }] })
        .button2({ rawtext: [{ translate: "botao.resetar_tudo" }] });


    confirmForm.show(player).then((response) => {
        if (response.selection !== 1) return;

        let comandos = [];

        // =====================================================
        // 💥 REMOVER TODAS AS TAGS DE PROGRESSÃO
        // =====================================================
        comandos.push(

            // NOVICE
            "tag @s remove novice",
            "tag @s remove novice1",
            "tag @s remove novice2",
            "tag @s remove novice3",
            "tag @s remove boss1",

            // ADVENTURE
            "tag @s remove adventure",
            "tag @s remove adventure1",
            "tag @s remove adventure2",
            "tag @s remove adventure3",
            "tag @s remove adventure4",
            "tag @s remove boss2",

            // MASTER
            "tag @s remove master",
            "tag @s remove master1",
            "tag @s remove master2",
            "tag @s remove boss3",

            // HERO
            "tag @s remove hero",
            "tag @s remove hero1",
            "tag @s remove hero2",
            "tag @s remove hero3",
            "tag @s remove hero4",

            // ENDGAME
            "tag @s remove boss4",
            "tag @s remove legendary"
        );

        // =====================================================
        // 🎯 ZERAR TODOS OS SCOREBOARDS DE MISSÃO
        // =====================================================
        comandos.push(

            "scoreboard players set @s missaowell1 0",
            "scoreboard players set @s missaowell2 0",
            "scoreboard players set @s missaowell3 0",
            "scoreboard players set @s missaowell4 0",
            "scoreboard players set @s missaowell5 0",
            "scoreboard players set @s missaowell6 0",
            "scoreboard players set @s missaowell7 0",
            "scoreboard players set @s missaowell8 0",
            "scoreboard players set @s missaowell9 0",
            "scoreboard players set @s missaowell10 0",
            "scoreboard players set @s missaowell11 0",
            "scoreboard players set @s missaowell12 0",
            "scoreboard players set @s missaowell13 0",
            "scoreboard players set @s missaowell14 0",
            "scoreboard players set @s missaowell15 0",
            "scoreboard players set @s missaowell16 0",
            "scoreboard players set @s missaowell17 0",
            "scoreboard players set @s missaowell18 0",

            // sistemas paralelos
            "scoreboard players set @s horda 0",
            "scoreboard players set @s horda_iniciada 0",
            "scoreboard players set @s fertilizante 0",
            "scoreboard players set @s discos1 0",
            "scoreboard players set @s discos2 0",
            "scoreboard players set @s discos3 0",
            "scoreboard players set @s discos4 0",
            "scoreboard players set @s discos5 0",
            "scoreboard players set @s discos_completo 0",
            "scoreboard players set @s chave 0"
        );

        // =====================================================
        // 🧹 LIMPAR TODOS OS ITENS DE QUEST
        // =====================================================
        comandos.push(
            "clear @s well:alma_da_arvore_item 0 -1",
            "clear @s well:fertilizante_mistico 0 -1",
            "clear @s well:literatura_dos_arqueologos 0 -1",
            "clear @s well:gelo_arcaico_item 0 -1",
            "clear @s well:flauta_do_deserto 0 -1",
            "clear @s well:chave_hilda 0 -1",
            "clear @s well:gema_cristalina 0 -1",
            "clear @s well:amuleto_de_farao_item 0 -1",
            "clear @s filled_map 7 -1"
        );

        // =====================================================
        // 🌱 VOLTAR PARA O INÍCIO DO JOGO
        // =====================================================
        comandos.push(
            "scoreboard players set @s missaowell1 1",
            "tag @s add novice"
        );

        comandos.forEach(cmd => {
            try { player.runCommand(cmd); } catch {}
        });

        player.runCommand("playsound random.totem @s ~ ~ ~ 1 1");
    });
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
export function missao_boss1(player) {
    let form = new ui.ActionFormData();
	form.title("wellforced:missao_boss1");
    form.body("");
    form.button({ rawtext: [{ translate: "dicas.menu" }]});
	form.button({ rawtext: [{ translate: "dungeon.reset" }]});
    
    form.show(player).then((result) => {
        
		if (result.selection == 0) {
        player.runCommand("function scripts_forms/dicas_missoes")}
		
		if (result.selection == 1) {
        resetmissao_missao_boss1(player) }
    });
}
export function missao_boss2(player) {
    let form = new ui.ActionFormData();
	form.title("wellforced:missao_boss2");
    form.body("");
    form.button({ rawtext: [{ translate: "dicas.menu" }]});
	form.button({ rawtext: [{ translate: "dungeon.reset" }]});
    
    form.show(player).then((result) => {
        
		if (result.selection == 0) {
        player.runCommand("function scripts_forms/dicas_missoes")}
		
		if (result.selection == 1) {
        resetmissao_missao_boss2(player) }
    });
}
export function missao_boss3(player) {
    let form = new ui.ActionFormData();
	form.title("wellforced:missao_boss3");
    form.body("");
    form.button({ rawtext: [{ translate: "dicas.menu" }]});
	form.button({ rawtext: [{ translate: "dungeon.reset" }]});
    
    form.show(player).then((result) => {
        
		if (result.selection == 0) {
        player.runCommand("function scripts_forms/dicas_missoes")}
		
		if (result.selection == 1) {
        resetmissao_missao_boss3(player) }
    });
}
export function missao_boss4(player) {
    let form = new ui.ActionFormData();
	form.title("wellforced:missao_boss4");
    form.body("");
    form.button({ rawtext: [{ translate: "dicas.menu" }]});
	form.button({ rawtext: [{ translate: "dungeon.reset" }]});
    
    form.show(player).then((result) => {
        
		if (result.selection == 0) {
        player.runCommand("function scripts_forms/dicas_missoes")}
		
		if (result.selection == 1) {
        resetmissao_missao_boss4(player) }
    });
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// submissao0 - Sem subquest ativa
export function submissao0(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body({ rawtext: [{ translate: "sem.missoes.ativas" }] })
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
		
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        //.button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_missoes/mago.png") // genérico
        //.button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/0") // sem estrelas
        //.button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        //.button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        //.button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao1
export function submissao1(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/items/beetroot_soup")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/2")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao2
export function submissao2(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/items/clock_item")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/1")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao3
export function submissao3(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body({ rawtext: [{ text: "§l§4" }, { translate: "subquest.2.menu" },{ text: "\n" }, { text: "§r§r" }, { translate: "dialogo.2.subquest" }] })
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/items/nautilus")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/2")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao4
export function submissao4(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/items/bucket_axolotl")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/3")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao5
export function submissao5(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/items/itens_misticos/erva_gato")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/1")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao6
export function submissao6(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/items/fungos_nether")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/2")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao7
export function submissao7(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/items/goat_horn")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/3")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao8
export function submissao8(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/items/slimeball")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/2")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao9
export function submissao9(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/cabeca_dragao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/4")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao10
export function submissao10(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/bestiario/Descoberto/ruminantes")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/5")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao11
export function submissao11(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/plantas_ancestrais")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/3")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao12
export function submissao12(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/blocks/coral_pink")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/3")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao13
export function submissao13(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/bestiario/Descoberto/papagaio")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/1")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao14
export function submissao14(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/bestiario/Descoberto/lavagante")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/4")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao15
export function submissao15(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/sapo")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/4")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao16
export function submissao16(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/bestiario/Descoberto/fantasma_fim")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/4")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao17
export function submissao17(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/bestiario/Descoberto/vagalume")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/1")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao18
export function submissao18(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/items/sniffer_egg")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/4")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao19
export function submissao19(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/spore_blossom")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/3")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao20
export function submissao20(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/para_raios")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/1")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao21
export function submissao21(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/items/cake")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/2")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao22
export function submissao22(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/items/heartofthesea_closed")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/5")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao23
export function submissao23(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/items/carrot")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/3")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao24
export function submissao24(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/blocks/pumpkin_face_off")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/2")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao25
export function submissao25(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/cajados")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/5")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao26
export function submissao26(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/blocks/mesa_transmutacao_cima")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/2")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao27
export function submissao27(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/velas")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/2")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao28
export function submissao28(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/porta")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/2")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao29
export function submissao29(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/burro_carga")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/4")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}

// submissao30
export function submissao30(player) {
    const form = new ActionFormData()
        .title("wellforced:subquest_menu")
        .body("")
        .button({ rawtext: [{ translate: "dicas.menu" }] })
        .button({ rawtext: [{ translate: "reset.missao" }] })
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/logo-espada")
        .button({ rawtext: [{ text: "" }] }, "textures/items/fish_pufferfish_raw")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/estrelas/2")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/recompensas/orbe")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/container_coracao")
        .button({ rawtext: [{ text: "" }] }, "textures/ui/pergaminhos/icones_submissoes/orbe_evolutiva");

    form.show(player).then((result) => {
        if (result.canceled) return;
        if (result.selection === 0) player.runCommand("function scripts_forms/dicas_submissoes");
        if (result.selection === 1) resetsubmissao(player);
    });
}//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
export function status_armadura(player) {
    let form = new ui.ActionFormData();
	form.title("wellforced:status_armaduras");
    form.body({
        rawtext: [
		    { text: "\n" }, { text: "\n" }, { text: "\n" },
            { text: "\n" }, { text: "\n" }, { text: "\n" }, { text: "\n" }, { text: "§l§5" },
			
            { text: `${getScore(player, "aranha")}` },{ translate: "status.do.jogador.chainmail" },
            { text: "\n" }, { text: "\n" }, { text: "§l§5" },
			
            { text: `${getScore(player, "bruxa")}` },{ translate: "status.do.jogador.gold" },
            { text: "\n" }, { text: "\n" }, { text: "§l§5" },
			
           { text: `${getScore(player, "zumbi")}` }, { translate: "status.do.jogador.iron" },
            { text: "\n" }, { text: "\n" }, { text: "§l§5" },
			
            { text: `${getScore(player, "esqueleto")}` },{ translate: "status.do.jogador.diamond" },
			{ text: "\n" }, { text: "\n" }, { text: "§l§5" },
			
           { text: `${getScore(player, "enderman")}` }, { translate: "status.do.jogador.netherite" },
			{ text: "\n" }, { text: "\n" }, { text: "§l§5" },
			
            { text: `${getScore(player, "esqueleto")}` }, { translate: "status.do.jogador.divino.armadura" }
			
        ]
    });
    form.button({ rawtext: [{ translate: "menu.voltar" }] }, "textures/ui/undoArrow.png");
    
    form.show(player).then((result) => {
        
		if (result.selection == 0) {
        player.runCommand("")}
		
    });
}
export function status_ferramentas(player) {
    let form = new ui.ActionFormData();
	form.title("wellforced:status_ferramentas");
    form.body({
        rawtext: [
            { text: "\n" }, { text: "\n" },
            { translate: "menu.acao.jogador.painel.itens" },
            { text: "\n" }, { text: "\n" },
			{ translate: " " },
            { translate: "status.do.jogador.2" },
            { text: "\n" }, { text: "\n" },
			{ translate: " " },
            { translate: "status.do.jogador.3" },
            { text: "\n" }, { text: "\n" },
			{ translate: " " },
            { translate: "status.do.jogador.4" },
            { text: "\n" }, { text: "\n" },
			{ translate: " " },
            { translate: "status.do.jogador.5" },
			{ text: "\n" }, { text: "\n" },
			{ translate: " " },
            { translate: "status.do.jogador.6" },
			{ text: "\n" }, { text: "\n" },
			{ translate: " " },
            { translate: "status.do.jogador.espada_divina" }
			
        ]
    });
    form.button({ rawtext: [{ translate: "menu.voltar" }] }, "textures/ui/undoArrow.png");
    
    form.show(player).then((result) => {
        
		if (result.selection == 0) {
        player.runCommand("")}
		
    });
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
export function Chunk_menu_bandeira(player) {
    let form = new ui.ActionFormData();
	form.title("§´Chunk Menu");
    form.body("");
    form.button({ rawtext: [{ translate: "ativar.marcacao"}] }, "textures/ui/toggle_on.png");
	form.button({ rawtext: [{ translate: "remover.marcacao"}] }, "textures/ui/toggle_off.png");
	form.button({ rawtext: [{ translate: "remover.bandeira"}] }, "textures/ui/realms_red_x.png"); 
    
    form.show(player).then((result) => {
        
		
		if (result.selection == 0) {
        player.runCommand("/scoreboard players set @e [type=well:bandeira_chunk, r=10] border 1");}
		
		if (result.selection == 1) {
        player.runCommand("/scoreboard players set @e [type=well:bandeira_chunk, r=10] border 0");}
		
		if (result.selection == 2) {
        player.runCommand("/event entity @e [type=well:bandeira_chunk, r=10] comando");}
		
    });
}
async function showTeleportForm(player) {
    const form = new ui.ModalFormData()
      .title({"rawtext": [{ "translate": "teleporte.pedra" }]})
      .textField( {"rawtext": [{ "translate": "coordenada.x" }]}, { "rawtext": [{ "translate": "admin.textField2" }]})
      .textField( {"rawtext": [{ "translate": "coordenada.y" }]}, { "rawtext": [{ "translate": "admin.textField2" }]})
      .textField( {"rawtext": [{ "translate": "coordenada.z" }]}, { "rawtext": [{ "translate": "admin.textField2" }]});
    const result = await form.show(player);
    if (result.canceled) return;
    if (result.formValues === undefined) return;
    player.teleport({
        x: parseInt(result.formValues[0]),
        y: parseInt(result.formValues[1]),
        z: parseInt(result.formValues[2])
    });
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
export function opcoes_menu(player) {
    let form = new ui.ActionFormData();
	form.title({ rawtext: [{ translate: "opcoes.menu"}]});
    form.body("");
	form.button("§´Camera", "textures/ui/dressing_room_capes.png");
	form.button({ rawtext: [{ translate: "menu.cinematica" }] }, "textures/ui/creative_icon.png");
	form.button({ rawtext: [{ translate: "menu.esquiva" }] }, "textures/ui/speed_effect.png");
	form.button({ rawtext: [{ translate: "menu.armadura.render" }] }, "textures/ui/armor_half.png");
	form.button({ rawtext: [{ translate: "menu.nickname.render" }] }, "textures/ui/nickname.png");

    form.show(player).then((result) => {
        
		
		if (result.selection == 0) {
            camera(player);
        }
		
		if (result.selection == 1) {
            playCinematicOpcoes(player);
        }
		
		if (result.selection == 2) {
            esquiva(player);
        }
		if (result.selection == 3) {
            render_armor(player);
        }
		if (result.selection == 4) {
            player_npc(player);
        }
		
    });
}
export function render_armor(player) {
    let form = new ui.ActionFormData();
	form.title({ rawtext: [{ translate: "menu.armadura.render"}]});
    form.body({ rawtext: [{ translate: "opcoes.render_armor.title"}]});
    form.button({ rawtext: [{ translate: "opcoes.render_armor.ativada"}]}, "textures/ui/armor_full.png");
	form.button({ rawtext: [{ translate: "opcoes.render_armor.desativada"}]}, "textures/ui/armor_empty.png");
    
    form.show(player).then((result) => {
        
		if (result.selection == 0) {
        player.runCommand("event entity @s remove_tamed_dummy_armor_invisible"); 
		player.runCommand("effect @s blindness 2 10 true");
		player.runCommand("titleraw @s actionbar {\"rawtext\":[{ \"translate\":\"actionbar.armor.visivel\" }]}"); }
		
		if (result.selection == 1) {
        player.runCommand("event entity @s add_tamed_dummy_armor_invisible");
		player.runCommand("effect @s blindness 2 10 true");
		player.runCommand("titleraw @s actionbar {\"rawtext\":[{ \"translate\":\"actionbar.armor.invisivel\" }]}"); }
		
    });
}
export function esquiva(player) {
    let form = new ui.ActionFormData();
	form.title({ rawtext: [{ translate: "menu.esquiva"}]});
    form.body({ rawtext: [{ translate: "opcoes.esquiva.title"}]});
    form.button({ rawtext: [{ translate: "opcoes.esquiva.ativada"}]}, "textures/ui/check.png");
	form.button({ rawtext: [{ translate: "opcoes.esquiva.desativada"}]}, "textures/ui/realms_red_x.png");
    
    form.show(player).then((result) => {
        
		if (result.selection == 0) {
        player.runCommand("/function scripts_forms/esquiva_ativada"); }
		
		if (result.selection == 1) {
        player.runCommand("/function scripts_forms/esquiva_desativada"); }
		
    });
}
export function teleporte_principal(player) {
    let form = new ui.ActionFormData();
	form.title({ rawtext: [{ translate: "menu.acao.teleporte"}]});
    form.body("");
    form.button({ rawtext: [{ translate: "title.tp.player" }]}, "textures/ui/dressing_room_skins.png");
	form.button({ rawtext: [{ translate: "title.tp.cidades" }]}, "textures/ui/icon_recipe_nature.png");
	form.button({ rawtext: [{ translate: "title.tp.arena" }]}, "textures/ui/icon_recipe_equipment.png");
    
    form.show(player).then((result) => {
        
		if (result.selection == 0) {
        tpa(player) }
		
		if (result.selection == 1) {
        teleporte(player) }
		
		if (result.selection == 2) {
        tp_arena(player) }
    });
}
export function camera(player) {
    let form = new ui.ActionFormData();
	form.title({ rawtext: [{ translate: "camera.menus"}]});
    form.body("");
	form.button({ rawtext: [{ translate: "camera.desativada" }] }, "textures/ui/realms_red_x.png");
    form.button({ rawtext: [{ translate: "camera.primeira" }] }, "textures/ui/sidebar_icons/dressing_room_animation.png");
	form.button({ rawtext: [{ translate: "camera.terceira" }] }, "textures/ui/sidebar_icons/dressing_room_capes.png");
	form.button({ rawtext: [{ translate: "camera.rpg" }] }, "textures/ui/icon_recipe_equipment.png");
	form.button({ rawtext: [{ translate: "camera.expansiva" }] }, "textures/ui/World.png");
    
    form.show(player).then((result) => {
        
		if (result.selection == 0) {
            player.runCommand("/camera @s clear");
			player.runCommand("/scoreboard players set @s camera_rpg 0")
			//player.runCommand("/scoreboard players set @s camera_dragao 0");
        }
        if (result.selection == 1) {
            
			player.runCommand("/camera @s set minecraft:first_person")
			player.runCommand("/scoreboard players set @s camera_rpg 0");
			//player.runCommand("/scoreboard players set @s camera_dragao 0");
        }
		if (result.selection == 2) {
            player.runCommand("/camera @s set minecraft:third_person")
			player.runCommand("/scoreboard players set @s camera_rpg 0");
			//player.runCommand("/scoreboard players set @s camera_dragao 0");
        }
		if (result.selection == 3) {
            player.runCommand("/scoreboard players set @s camera_rpg 1")
			player.runCommand("/scoreboard players set @s camera_dragao 0");
        }
		if (result.selection == 4) {
            player.runCommand("/scoreboard players set @s camera_rpg 2")
			//player.runCommand("/scoreboard players set @s camera_dragao 0");
        }
    });
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
export function menu_missao(player) {
    let form = new ui.ActionFormData();
    form.title({ rawtext: [{ translate: "menu.missao.submissao" }] });
    form.body("");
    form.button({ rawtext: [{ translate: "menu.ver.principaismissoes" }] }, "textures/items/book_enchanted.png");
    form.button({ rawtext: [{ translate: "menu.ver.submissoes" }] }, "textures/items/book_writable.png");

    form.show(player).then((result) => {
        if (result.canceled) return;

        if (result.selection === 0) { // Principais missões
            // Verifica da tag MAIS AVANÇADA para a mais inicial (prioridade correta)
            if (player.hasTag("boss4")) {
                missao_boss4(player);
            } else if (player.hasTag("hero4")) {
                missao17(player);
            } else if (player.hasTag("hero3")) {
                missao16(player);
            } else if (player.hasTag("hero2")) {
                missao15(player);
            } else if (player.hasTag("hero1")) {
                missao14(player);
            } else if (player.hasTag("hero")) {
                missao13(player);
            } else if (player.hasTag("boss3")) {
                missao_boss3(player);
            } else if (player.hasTag("master2")) {
                missao12(player);
            } else if (player.hasTag("master1")) {
                missao11(player);
            } else if (player.hasTag("master")) {
                missao10(player);
            } else if (player.hasTag("boss2")) {
                missao_boss2(player);
            } else if (player.hasTag("adventure4")) {
                missao9(player);
            } else if (player.hasTag("adventure3")) {
                missao8(player);
            } else if (player.hasTag("adventure2")) {
                missao7(player);
            } else if (player.hasTag("adventure1")) {
                missao6(player);
            } else if (player.hasTag("adventure")) {
                missao5(player);
            } else if (player.hasTag("boss1")) {
                missao_boss1(player);
            } else if (player.hasTag("novice3")) {
                missao4(player);
            } else if (player.hasTag("novice2")) {
                missao3(player);
            } else if (player.hasTag("novice1")) {
                missao2(player);
            } else if (player.hasTag("novice")) {
                missao1(player);
            } else {
                player.sendMessage("§cVocê não tem nenhuma missão principal ativa no momento.");
            }
        }

        if (result.selection === 1) { // Submissões
            // Submissões podem acumular, então continua com if separado
            if (player.hasTag("subquest0")) submissao0(player);
            if (player.hasTag("subquest1")) submissao1(player);
            if (player.hasTag("subquest2")) submissao2(player);
            if (player.hasTag("subquest3")) submissao3(player);
            if (player.hasTag("subquest4")) submissao4(player);
            if (player.hasTag("subquest5")) submissao5(player);
            if (player.hasTag("subquest6")) submissao6(player);
            if (player.hasTag("subquest7")) submissao7(player);
            if (player.hasTag("subquest8")) submissao8(player);
            if (player.hasTag("subquest9")) submissao9(player);
            if (player.hasTag("subquest10")) submissao10(player);
            if (player.hasTag("subquest11")) submissao11(player);
            if (player.hasTag("subquest12")) submissao12(player);
            if (player.hasTag("subquest13")) submissao13(player);
            if (player.hasTag("subquest14")) submissao14(player);
            if (player.hasTag("subquest15")) submissao15(player);
            if (player.hasTag("subquest16")) submissao16(player);
            if (player.hasTag("subquest17")) submissao17(player);
            if (player.hasTag("subquest18")) submissao18(player);
            if (player.hasTag("subquest19")) submissao19(player);
            if (player.hasTag("subquest20")) submissao20(player);
            if (player.hasTag("subquest21")) submissao21(player);
            if (player.hasTag("subquest22")) submissao22(player);
            if (player.hasTag("subquest23")) submissao23(player);
            if (player.hasTag("subquest24")) submissao24(player);
            if (player.hasTag("subquest25")) submissao25(player);
            if (player.hasTag("subquest26")) submissao26(player);
            if (player.hasTag("subquest27")) submissao27(player);
            if (player.hasTag("subquest28")) submissao28(player);
            if (player.hasTag("subquest29")) submissao29(player);
            if (player.hasTag("subquest30")) submissao30(player);

            // Se nenhuma submissão ativa
            if (!player.getTags().some(tag => tag.startsWith("subquest"))) {
                //player.sendMessage("§cVocê não tem submissões ativas no momento.");
            }
        }
    });
}
export function creditos(player) {
    let form = new ui.ActionFormData();
	form.title("wellforced:menu_creditos");
    form.body("");
    form.button({ rawtext: [{ translate: "menu.voltar" }] }, "textures/ui/undoArrow.png");
    
    form.show(player).then((result) => {
        
		if (result.selection == 0) {
        }
    });
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
export function tp_arena(player) {
    let form = new MessageFormData();
    form.title({ rawtext: [{ translate: "tp.arena.title" }]});
    form.body({ rawtext: [{ translate: "dialogo.msg.arena.tp" }]});
    form.button1({ rawtext: [{ translate: "dialogo.nao" }]});
    form.button2({ rawtext: [{ translate: "dialogo.sim" }]});

    form.show(player).then(result => {
        if (result.selection === 0) {
            
            return;
        } else if (result.selection === 1) {
            player.runCommand("teleport @s 7000 220 7033");
			player.runCommand("spawnpoint @s 7000 220 7033");
			player.runCommand("tag @s add arena");
        }
    }).catch(error => {
        console.error(error, error.stack);
    });
}
export function arena_desistencia(player) {
    let form = new MessageFormData();
    form.title({ rawtext: [{ translate: "desistencia.arena.title" }]});
    form.body({ rawtext: [{ translate: "desistencia.msg.arena" }]});
    form.button1({ rawtext: [{ translate: "dialogo.nao" }]});
    form.button2({ rawtext: [{ translate: "dialogo.sim" }]});

    form.show(player).then(result => {
        if (result.selection === 0) {
            
            return;
        } else if (result.selection === 1) {
            player.runCommand("teleport @s 41 70 36");
			player.runCommand("spawnpoint @s 41 70 36");
			player.runCommand("tag @s remove arena");
			player.runCommand("scoreboard players set @s kills_arena 0");
			
			player.runCommand("stopsound @s");
		    player.runCommand("playsound FarLand @s");
		    player.runCommand("titleraw @s title {\"rawtext\":[{ \"translate\":\"title.farlands.msg\" }]}");
		    player.runCommand("titleraw @s subtitle {\"rawtext\":[{ \"translate\":\"title.welcome.msg\" }]}")
			
			
        }
    }).catch(error => {
        console.error(error, error.stack);
    });
}
export function teleporte(player) {
    let form = new ui.ActionFormData();
	form.title({ rawtext: [{ translate: "menu.acao.teleporte"}]});
    form.body("");
    form.button({ rawtext: [{ translate: "title.farlands.msg" }]}, "textures/items/totem.png");
	form.button({ rawtext: [{ translate: "title.mosscity.msg" }]}, "textures/items/itens_misticos/erva_gato.png");
	form.button({ rawtext: [{ translate: "title.glowstonecity.msg" }]}, "textures/items/itens_misticos/frasco_mana.png");
    
    form.show(player).then((result) => {
        
		if (result.selection == 0) {
		player.runCommand("tickingarea add circle ~ ~ ~ 4 padrao")
		player.runCommand("tag @s add contagem_remove_npc")
		
		player.runCommand("stopsound @s")
		player.runCommand("playsound FarLand @s")
		player.runCommand("titleraw @s title {\"rawtext\":[{ \"translate\":\"title.farlands.msg\" }]}")
		player.runCommand("titleraw @s subtitle {\"rawtext\":[{ \"translate\":\"title.welcome.msg\" }]}")
		
		
		
		player.runCommand("tag @e [family=pet, r=10] add tp_pets_farlands")
		player.runCommand("execute in overworld run tp @s 41 70 36")
		player.runCommand("kill @e [type=item]")
		
		
		
		}
		
		if (result.selection == 1) {
		player.runCommand("function teleporte/tp_Moss")
		
		}
		
		if (result.selection == 2) {
		player.runCommand("function teleporte/tp_Glowstone")
		
		}
    });
}
function tpa(player) {
	const allPlayers = world.getAllPlayers().filter(p => p.name !== player.name);

	if (allPlayers.length === 0) {
		player.sendMessage({ "rawtext": [{ "translate": "menu.teleporte.sem.players" }]});
		player.playSound('random.hurt');
		return;
	}

	// Opção "vazia" no topo do dropdown
	const playerNames = [{ "rawtext": [{ "translate": "menu.teleporte.vazio" }] }].concat(
		allPlayers.map(p => ({ text: p.name }))
	);

	const form = new ModalFormData()
		.title({ "rawtext": [{ "translate": "menu.teleporte.players" }]})
		.dropdown({ "rawtext": [{ "translate": "menu.teleporte.escolher.players" }]}, playerNames)
		.toggle({ "rawtext": [{ "translate": "title.botao.toggle" }]}, { defaultValue: true });

	form.show(player).then(({ formValues, canceled, cancelationReason }) => {
		if (cancelationReason === 'UserBusy') return tpa(player);
		if (canceled || formValues === undefined) return;

		const dropdownIndex = formValues[0];
		const toggleValue = formValues[1];

		// ✅ Sempre executa o toggle, mesmo se o jogador não selecionar ninguém
		if (toggleValue) {
			player.runCommand(`scoreboard players set @s solicitacao_teleporte 1`);
			player.runCommand(`titleraw @s actionbar {\"rawtext\":[{ \"translate\":\"botao.solicitacao.desativada\"}]}`);
		} else {
			player.runCommand(`scoreboard players set @s solicitacao_teleporte 0`);
			player.runCommand(`titleraw @s actionbar {\"rawtext\":[{ \"translate\":\"botao.solicitacao.ativada\"}]}`);
		}

		// ❌ Jogador não selecionou ninguém
		if (dropdownIndex === 0) {
			player.sendMessage("§cVocê não selecionou nenhum jogador.");
			player.playSound('random.hurt');
			return;
		}

		const selectedPlayer = allPlayers[dropdownIndex - 1]; // Corrige índice

		if (!selectedPlayer) {
			player.sendMessage({ "rawtext": [{ "translate": "menu.teleporte.offline.players" }]});
			player.playSound('random.hurt');
			return;
		}

		// Verifica o scoreboard solicitacao_teleporte do jogador selecionado
		const scoreObj = world.scoreboard.getObjective("solicitacao_teleporte");
		if (!scoreObj) {
			player.sendMessage("§cScoreboard 'solicitacao_teleporte' não existe!");
			player.playSound('random.hurt');
			return;
		}

		const score = scoreObj.getScore(selectedPlayer) ?? 0;

		if (score !== 1) {
			player.sendMessage({
				rawtext: [
					{ text: `§c${selectedPlayer.name}` },
					{ translate: "score.solicitacao.negada" }
				]
			});
			player.playSound('random.hurt');
			return;
		}

		// Se passou na checagem, envia a solicitação
		requestTpa(player, selectedPlayer);
		selectedPlayer.playSound('random.toast');
		player.sendMessage({
			rawtext: [
				{ translate: "menu.teleporte.solicitacao.players" },
				{ text: ` ${selectedPlayer.name}` }
			]
		});
		player.playSound('random.pop', { volume: 5 });
	});
}
function requestTpa(sender, targetPlayer) {
	new MessageFormData()
		.title({ "rawtext": [{ "translate": "menu.teleporte.solicitacao.teleporte" }]})
		.body({ "rawtext": [{ text: ` ${sender.name}`}, { "translate": "menu.teleporte.solicitacao.mensagem" }]})
		.button1({ "rawtext": [{ "translate": "menu.teleporte.solicitacao.aceitar" }]})
		.button2({ "rawtext": [{ "translate": "menu.teleporte.solicitacao.recusar" }]})
		.show(targetPlayer).then((request) => {
			if (request.canceled && request.cancelationReason === 'UserBusy') requestTpa(sender, targetPlayer);
			if (request.canceled && request.cancelationReason === 'UserClosed') return;
			if (request.selection === 0) {
				sender.teleport(targetPlayer.location);
				sender.sendMessage({ "rawtext": [{ "translate": "menu.teleporte.aceitou.mensagem" }, { text: ` ${targetPlayer.name}` }]});
				system.runTimeout(() => {
					sender.playSound('mob.enderman.portal', {
						volume: 5
					})
				}, 10);
				targetPlayer.playSound('random.orb');
				targetPlayer.sendMessage({ "rawtext": [{ "translate": "menu.teleporte.aceitou.mensagem.console" }, { text: ` ${sender.name}` }]});
			} else if (request.selection === 1) {
				sender.sendMessage({"rawtext": [{ "translate": "menu.teleporte.msg.player" }, { text: ` ${targetPlayer.name} ` }, { translate: "menu.teleporte.aceitou.mensagem.console.negou" }]});
				sender.playSound('random.hurt');
				targetPlayer.sendMessage({ "rawtext": [{ "translate": "menu.teleporte.msg.player.negada" }, { text: ` ${sender.name}` }]});
				targetPlayer.playSound('note.hat');
			}
		});
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const bestiarioMobs = [
    // 1
    { emoji: "", nome: "wiki.nome.aldeao", vida: "wiki.vida.aldeao", alimentacao: "wiki.alimentacao.aldeao", habitat: "wiki.habitat.aldeao", ataque: "wiki.ataque.aldeao", descricao: "wiki.bestiario.aldeao", texturaPreview: "textures/ui/bestiario/Descoberto/aldeao.png" },
    // 2
    { emoji: "", nome: "wiki.nome.allay", vida: "wiki.vida.allay", alimentacao: "wiki.alimentacao.allay", habitat: "wiki.habitat.allay", ataque: "wiki.ataque.allay", descricao: "wiki.bestiario.allay", texturaPreview: "textures/ui/bestiario/Descoberto/allay.png" },
    // 3
    { emoji: "", nome: "wiki.nome.axolote", vida: "wiki.vida.axolote", alimentacao: "wiki.alimentacao.axolote", habitat: "wiki.habitat.axolote", ataque: "wiki.ataque.axolote", descricao: "wiki.bestiario.axolote", texturaPreview: "textures/ui/bestiario/Descoberto/axolote.png" },
    // 4
    { emoji: "", nome: "wiki.nome.peixes", vida: "wiki.vida.peixes", alimentacao: "wiki.alimentacao.peixes", habitat: "wiki.habitat.peixes", ataque: "wiki.ataque.peixes", descricao: "wiki.bestiario.peixes", texturaPreview: "textures/ui/bestiario/Descoberto/peixes.png" },
    // 5
    { emoji: "", nome: "wiki.nome.baiacu", vida: "wiki.vida.baiacu", alimentacao: "wiki.alimentacao.baiacu", habitat: "wiki.habitat.baiacu", ataque: "wiki.ataque.baiacu", descricao: "wiki.bestiario.baiacu", texturaPreview: "textures/ui/bestiario/Descoberto/baiacu.png" },
    // 6
    { emoji: "", nome: "wiki.nome.equinos", vida: "wiki.vida.equinos", alimentacao: "wiki.alimentacao.equinos", habitat: "wiki.habitat.equinos", ataque: "wiki.ataque.equinos", descricao: "wiki.bestiario.equinos", texturaPreview: "textures/ui/bestiario/Descoberto/equinos.png" },
    // 7
    { emoji: "", nome: "wiki.nome.coelho", vida: "wiki.vida.coelho", alimentacao: "wiki.alimentacao.coelho", habitat: "wiki.habitat.coelho", ataque: "wiki.ataque.coelho", descricao: "wiki.bestiario.coelho", texturaPreview: "textures/ui/bestiario/Descoberto/coelho.png" },
    // 8
    { emoji: "", nome: "wiki.nome.ruminantes", vida: "wiki.vida.ruminantes", alimentacao: "wiki.alimentacao.ruminantes", habitat: "wiki.habitat.ruminantes", ataque: "wiki.ataque.ruminantes", descricao: "wiki.bestiario.ruminantes", texturaPreview: "textures/ui/bestiario/Descoberto/ruminantes.png" },
    // 9
    { emoji: "", nome: "wiki.nome.galinha", vida: "wiki.vida.galinha", alimentacao: "wiki.alimentacao.galinha", habitat: "wiki.habitat.galinha", ataque: "wiki.ataque.galinha", descricao: "wiki.bestiario.galinha", texturaPreview: "textures/ui/bestiario/Descoberto/galinha.png" },
    // 10
    { emoji: "", nome: "wiki.nome.gato", vida: "wiki.vida.gato", alimentacao: "wiki.alimentacao.gato", habitat: "wiki.habitat.gato", ataque: "wiki.ataque.gato", descricao: "wiki.bestiario.gato", texturaPreview: "textures/ui/bestiario/Descoberto/gato.png" },
    // 11
    { emoji: "", nome: "wiki.nome.sapo", vida: "wiki.vida.sapo", alimentacao: "wiki.alimentacao.sapo", habitat: "wiki.habitat.sapo", ataque: "wiki.ataque.sapo", descricao: "wiki.bestiario.sapo", texturaPreview: "textures/ui/bestiario/Descoberto/sapo.png" },
    // 12
    { emoji: "", nome: "wiki.nome.golens", vida: "wiki.vida.golens", alimentacao: "wiki.alimentacao.golens", habitat: "wiki.habitat.golens", ataque: "wiki.ataque.golens", descricao: "wiki.bestiario.golens", texturaPreview: "textures/ui/bestiario/Descoberto/golens.png" },
    // 13
    { emoji: "", nome: "wiki.nome.ocelote", vida: "wiki.vida.ocelote", alimentacao: "wiki.alimentacao.ocelote", habitat: "wiki.habitat.ocelote", ataque: "wiki.ataque.ocelote", descricao: "wiki.bestiario.ocelote", texturaPreview: "textures/ui/bestiario/Descoberto/ocelote.png" },
    // 14
    { emoji: "", nome: "wiki.nome.lavagante", vida: "wiki.vida.lavagante", alimentacao: "wiki.alimentacao.lavagante", habitat: "wiki.habitat.lavagante", ataque: "wiki.ataque.lavagante", descricao: "wiki.bestiario.lavagante", texturaPreview: "textures/ui/bestiario/Descoberto/lavagante.png" },
    // 15
    { emoji: "", nome: "wiki.nome.lulas", vida: "wiki.vida.lulas", alimentacao: "wiki.alimentacao.lulas", habitat: "wiki.habitat.lulas", ataque: "wiki.ataque.lulas", descricao: "wiki.bestiario.lulas", texturaPreview: "textures/ui/bestiario/Descoberto/lulas.png" },
    // 16
    { emoji: "", nome: "wiki.nome.morcego", vida: "wiki.vida.morcego", alimentacao: "wiki.alimentacao.morcego", habitat: "wiki.habitat.morcego", ataque: "wiki.ataque.morcego", descricao: "wiki.bestiario.morcego", texturaPreview: "textures/ui/bestiario/Descoberto/morcego.png" },
    // 17
    { emoji: "", nome: "wiki.nome.ovelha", vida: "wiki.vida.ovelha", alimentacao: "wiki.alimentacao.ovelha", habitat: "wiki.habitat.ovelha", ataque: "wiki.ataque.ovelha", descricao: "wiki.bestiario.ovelha", texturaPreview: "textures/ui/bestiario/Descoberto/ovelha.png" },
    // 18
    { emoji: "", nome: "wiki.nome.papagaio", vida: "wiki.vida.papagaio", alimentacao: "wiki.alimentacao.papagaio", habitat: "wiki.habitat.papagaio", ataque: "wiki.ataque.papagaio", descricao: "wiki.bestiario.papagaio", texturaPreview: "textures/ui/bestiario/Descoberto/papagaio.png" },
    // 19
    { emoji: "", nome: "wiki.nome.piglin", vida: "wiki.vida.piglin", alimentacao: "wiki.alimentacao.piglin", habitat: "wiki.habitat.piglin", ataque: "wiki.ataque.piglin", descricao: "wiki.bestiario.piglin", texturaPreview: "textures/ui/bestiario/Descoberto/piglin.png" },
    // 20
    { emoji: "", nome: "wiki.nome.porco", vida: "wiki.vida.porco", alimentacao: "wiki.alimentacao.porco", habitat: "wiki.habitat.porco", ataque: "wiki.ataque.porco", descricao: "wiki.bestiario.porco", texturaPreview: "textures/ui/bestiario/Descoberto/porco.png" },
    // 21
    { emoji: "", nome: "wiki.nome.raposa", vida: "wiki.vida.raposa", alimentacao: "wiki.alimentacao.raposa", habitat: "wiki.habitat.raposa", ataque: "wiki.ataque.raposa", descricao: "wiki.bestiario.raposa", texturaPreview: "textures/ui/bestiario/Descoberto/raposa.png" },
    // 22
    { emoji: "", nome: "wiki.nome.tartaruga", vida: "wiki.vida.tartaruga", alimentacao: "wiki.alimentacao.tartaruga", habitat: "wiki.habitat.tartaruga", ataque: "wiki.ataque.tartaruga", descricao: "wiki.bestiario.tartaruga", texturaPreview: "textures/ui/bestiario/Descoberto/tartaruga.png" },
    // 23
    { emoji: "", nome: "wiki.nome.urso", vida: "wiki.vida.urso", alimentacao: "wiki.alimentacao.urso", habitat: "wiki.habitat.urso", ataque: "wiki.ataque.urso", descricao: "wiki.bestiario.urso", texturaPreview: "textures/ui/bestiario/Descoberto/urso.png" },
    // 24
    { emoji: "", nome: "wiki.nome.vendedor", vida: "wiki.vida.vendedor", alimentacao: "wiki.alimentacao.vendedor", habitat: "wiki.habitat.vendedor", ataque: "wiki.ataque.vendedor", descricao: "wiki.bestiario.vendedor", texturaPreview: "textures/ui/bestiario/Descoberto/vendedor.png" },
    // 25
    { emoji: "", nome: "wiki.nome.abelha", vida: "wiki.vida.abelha", alimentacao: "wiki.alimentacao.abelha", habitat: "wiki.habitat.abelha", ataque: "wiki.ataque.abelha", descricao: "wiki.bestiario.abelha", texturaPreview: "textures/ui/bestiario/Descoberto/abelha.png" },
    // 26
    { emoji: "", nome: "wiki.nome.aranhas", vida: "wiki.vida.aranhas", alimentacao: "wiki.alimentacao.aranhas", habitat: "wiki.habitat.aranhas", ataque: "wiki.ataque.aranhas", descricao: "wiki.bestiario.aranhas", texturaPreview: "textures/ui/bestiario/Descoberto/aranhas.png" },
    // 27
    { emoji: "", nome: "wiki.nome.cabras", vida: "wiki.vida.cabras", alimentacao: "wiki.alimentacao.cabras", habitat: "wiki.habitat.cabras", ataque: "wiki.ataque.cabras", descricao: "wiki.bestiario.cabras", texturaPreview: "textures/ui/bestiario/Descoberto/cabras.png" },
    // 28
    { emoji: "", nome: "wiki.nome.enderman", vida: "wiki.vida.enderman", alimentacao: "wiki.alimentacao.enderman", habitat: "wiki.habitat.enderman", ataque: "wiki.ataque.enderman", descricao: "wiki.bestiario.enderman", texturaPreview: "textures/ui/bestiario/Descoberto/enderman.png" },
    // 29
    { emoji: "", nome: "wiki.nome.golfinho", vida: "wiki.vida.golfinho", alimentacao: "wiki.alimentacao.golfinho", habitat: "wiki.habitat.golfinho", ataque: "wiki.ataque.golfinho", descricao: "wiki.bestiario.golfinho", texturaPreview: "textures/ui/bestiario/Descoberto/golfinho.png" },
    // 30
    { emoji: "", nome: "wiki.nome.lhamas", vida: "wiki.vida.lhamas", alimentacao: "wiki.alimentacao.lhamas", habitat: "wiki.habitat.lhamas", ataque: "wiki.ataque.lhamas", descricao: "wiki.bestiario.lhamas", texturaPreview: "textures/ui/bestiario/Descoberto/lhamas.png" },
    // 31
    { emoji: "", nome: "wiki.nome.lobo", vida: "wiki.vida.lobo", alimentacao: "wiki.alimentacao.lobo", habitat: "wiki.habitat.lobo", ataque: "wiki.ataque.lobo", descricao: "wiki.bestiario.lobo", texturaPreview: "textures/ui/bestiario/Descoberto/lobo.png" },
    // 32
    { emoji: "", nome: "wiki.nome.panda", vida: "wiki.vida.panda", alimentacao: "wiki.alimentacao.panda", habitat: "wiki.habitat.panda", ataque: "wiki.ataque.panda", descricao: "wiki.bestiario.panda", texturaPreview: "textures/ui/bestiario/Descoberto/panda.png" },
    // 33
    { emoji: "", nome: "wiki.nome.afogado", vida: "wiki.vida.afogado", alimentacao: "wiki.alimentacao.zumbis", habitat: "wiki.habitat.afogado", ataque: "wiki.ataque.afogado", descricao: "wiki.bestiario.afogado", texturaPreview: "textures/ui/bestiario/Descoberto/zumbis.png" },
    // 34
    { emoji: "", nome: "wiki.nome.zumbis", vida: "wiki.vida.zumbis", alimentacao: "wiki.alimentacao.zumbis", habitat: "wiki.habitat.zumbis", ataque: "wiki.ataque.zumbis", descricao: "wiki.bestiario.zumbis", texturaPreview: "textures/ui/bestiario/Descoberto/zumbis.png" },
    // 35
    { emoji: "", nome: "wiki.nome.blaze", vida: "wiki.vida.blaze", alimentacao: "wiki.alimentacao.blaze", habitat: "wiki.habitat.blaze", ataque: "wiki.ataque.blaze", descricao: "wiki.bestiario.blaze", texturaPreview: "textures/ui/bestiario/Descoberto/blaze.png" },
    // 36
    { emoji: "", nome: "wiki.nome.bruxa", vida: "wiki.vida.bruxa", alimentacao: "wiki.alimentacao.bruxa", habitat: "wiki.habitat.bruxa", ataque: "wiki.ataque.bruxa", descricao: "wiki.bestiario.bruxa", texturaPreview: "textures/ui/bestiario/Descoberto/bruxa.png" },
    // 37
    { emoji: "", nome: "wiki.nome.cavaleiro", vida: "wiki.vida.cavaleiro", alimentacao: "wiki.alimentacao.cavaleiro", habitat: "wiki.habitat.cavaleiro", ataque: "wiki.ataque.cavaleiro", descricao: "wiki.bestiario.cavaleiro", texturaPreview: "textures/ui/bestiario/Descoberto/cavaleiro.png" },
    // 38
    { emoji: "", nome: "wiki.nome.creeper", vida: "wiki.vida.creeper", alimentacao: "wiki.alimentacao.creeper", habitat: "wiki.habitat.creeper", ataque: "wiki.ataque.creeper", descricao: "wiki.bestiario.creeper", texturaPreview: "textures/ui/bestiario/Descoberto/creeper.png" },
    // 39
    { emoji: "", nome: "wiki.nome.magma_cube", vida: "wiki.vida.magma_cube", alimentacao: "wiki.alimentacao.magma_cube", habitat: "wiki.habitat.magma_cube", ataque: "wiki.ataque.magma_cube", descricao: "wiki.bestiario.magma_cube", texturaPreview: "textures/ui/bestiario/Descoberto/magma_cube.png" },
    // 40
    { emoji: "", nome: "wiki.nome.warden", vida: "wiki.vida.warden", alimentacao: "wiki.alimentacao.warden", habitat: "wiki.habitat.warden", ataque: "wiki.ataque.warden", descricao: "wiki.bestiario.warden", texturaPreview: "textures/ui/bestiario/Descoberto/warden.png" },
    // 41
    { emoji: "", nome: "wiki.nome.devastador", vida: "wiki.vida.devastador", alimentacao: "wiki.alimentacao.devastador", habitat: "wiki.habitat.devastador", ataque: "wiki.ataque.devastador", descricao: "wiki.bestiario.devastador", texturaPreview: "textures/ui/bestiario/Descoberto/devastador.png" },
    // 42
    { emoji: "", nome: "wiki.nome.endermite", vida: "wiki.vida.endermite", alimentacao: "wiki.alimentacao.endermite", habitat: "wiki.habitat.endermite", ataque: "wiki.ataque.endermite", descricao: "wiki.bestiario.endermite", texturaPreview: "textures/ui/bestiario/Descoberto/endermite.png" },
    // 43
    { emoji: "", nome: "wiki.nome.esqueletos", vida: "wiki.vida.esqueletos", alimentacao: "wiki.alimentacao.esqueletos", habitat: "wiki.habitat.esqueletos", ataque: "wiki.ataque.esqueletos", descricao: "wiki.bestiario.esqueletos", texturaPreview: "textures/ui/bestiario/Descoberto/esqueletos.png" },
    // 44
    { emoji: "", nome: "wiki.nome.ghast", vida: "wiki.vida.ghast", alimentacao: "wiki.alimentacao.ghast", habitat: "wiki.habitat.ghast", ataque: "wiki.ataque.ghast", descricao: "wiki.bestiario.ghast", texturaPreview: "textures/ui/bestiario/Descoberto/ghast.png" },
    // 45
    { emoji: "", nome: "wiki.nome.guardiao", vida: "wiki.vida.guardiao", alimentacao: "wiki.alimentacao.guardiao", habitat: "wiki.habitat.guardiao", ataque: "wiki.ataque.guardiao", descricao: "wiki.bestiario.guardiao", texturaPreview: "textures/ui/bestiario/Descoberto/guardiao.png" },
    // 46
    { emoji: "", nome: "wiki.nome.hoglin", vida: "wiki.vida.hoglin", alimentacao: "wiki.alimentacao.hoglin", habitat: "wiki.habitat.hoglin", ataque: "wiki.ataque.hoglin", descricao: "wiki.bestiario.hoglin", texturaPreview: "textures/ui/bestiario/Descoberto/hoglin.png" },
    // 47
    { emoji: "", nome: "wiki.nome.invocador", vida: "wiki.vida.invocador", alimentacao: "wiki.alimentacao.invocador", habitat: "wiki.habitat.invocador", ataque: "wiki.ataque.invocador", descricao: "wiki.bestiario.invocador", texturaPreview: "textures/ui/bestiario/Descoberto/invocador.png" },
    // 48
    { emoji: "", nome: "wiki.nome.phantom", vida: "wiki.vida.phantom", alimentacao: "wiki.alimentacao.phantom", habitat: "wiki.habitat.phantom", ataque: "wiki.ataque.phantom", descricao: "wiki.bestiario.phantom", texturaPreview: "textures/ui/bestiario/Descoberto/phantom.png" },
    // 49
    { emoji: "", nome: "wiki.nome.piglin_brute", vida: "wiki.vida.piglin_brute", alimentacao: "wiki.alimentacao.piglin_brute", habitat: "wiki.habitat.piglin_brute", ataque: "wiki.ataque.piglin_brute", descricao: "wiki.bestiario.piglin_brute", texturaPreview: "textures/ui/bestiario/Descoberto/piglin_brute.png" },
    // 50
    { emoji: "", nome: "wiki.nome.saqueadores", vida: "wiki.vida.saqueadores", alimentacao: "wiki.alimentacao.saqueadores", habitat: "wiki.habitat.saqueadores", ataque: "wiki.ataque.saqueadores", descricao: "wiki.bestiario.saqueadores", texturaPreview: "textures/ui/bestiario/Descoberto/saqueadores.png" },
    // 51
    { emoji: "", nome: "wiki.nome.shulker", vida: "wiki.vida.shulker", alimentacao: "wiki.alimentacao.shulker", habitat: "wiki.habitat.shulker", ataque: "wiki.ataque.shulker", descricao: "wiki.bestiario.shulker", texturaPreview: "textures/ui/bestiario/Descoberto/shulker.png" },
    // 52
    { emoji: "", nome: "wiki.nome.slime", vida: "wiki.vida.slime", alimentacao: "wiki.alimentacao.slime", habitat: "wiki.habitat.slime", ataque: "wiki.ataque.slime", descricao: "wiki.bestiario.slime", texturaPreview: "textures/ui/bestiario/Descoberto/slime.png" },
    // 53
    { emoji: "", nome: "wiki.nome.traca", vida: "wiki.vida.traca", alimentacao: "wiki.alimentacao.traca", habitat: "wiki.habitat.traca", ataque: "wiki.ataque.traca", descricao: "wiki.bestiario.traca", texturaPreview: "textures/ui/bestiario/Descoberto/traca.png" },
    // 54
    { emoji: "", nome: "wiki.nome.vex", vida: "wiki.vida.vex", alimentacao: "wiki.alimentacao.vex", habitat: "wiki.habitat.vex", ataque: "wiki.ataque.vex", descricao: "wiki.bestiario.vex", texturaPreview: "textures/ui/bestiario/Descoberto/vex.png" },
    // 55
    { emoji: "", nome: "wiki.nome.vingador", vida: "wiki.vida.vingador", alimentacao: "wiki.alimentacao.vingador", habitat: "wiki.habitat.vingador", ataque: "wiki.ataque.vingador", descricao: "wiki.bestiario.vingador", texturaPreview: "textures/ui/bestiario/Descoberto/vingador.png" },
    // 56
    { emoji: "", nome: "wiki.nome.zoglin", vida: "wiki.vida.zoglin", alimentacao: "wiki.alimentacao.zoglin", habitat: "wiki.habitat.zoglin", ataque: "wiki.ataque.zoglin", descricao: "wiki.bestiario.zoglin", texturaPreview: "textures/ui/bestiario/Descoberto/zoglin.png" },
    // 57
    { emoji: "", nome: "wiki.nome.dragao", vida: "wiki.vida.dragao", alimentacao: "wiki.alimentacao.dragao", habitat: "wiki.habitat.dragao", ataque: "wiki.ataque.dragao", descricao: "wiki.bestiario.dragao", texturaPreview: "textures/ui/bestiario/Descoberto/dragao.png" },
    // 58
    { emoji: "", nome: "wiki.nome.wither", vida: "wiki.vida.wither", alimentacao: "wiki.alimentacao.wither", habitat: "wiki.habitat.wither", ataque: "wiki.ataque.wither", descricao: "wiki.bestiario.wither", texturaPreview: "textures/ui/bestiario/Descoberto/wither.png" },
    // 59
    { emoji: "", nome: "wiki.nome.camelo", vida: "wiki.vida.camelo", alimentacao: "wiki.alimentacao.camelo", habitat: "wiki.habitat.camelo", ataque: "wiki.ataque.camelo", descricao: "wiki.bestiario.camelo", texturaPreview: "textures/ui/bestiario/Descoberto/camelo.png" },
    // 60
    { emoji: "", nome: "wiki.nome.farejador", vida: "wiki.vida.farejador", alimentacao: "wiki.alimentacao.farejador", habitat: "wiki.habitat.farejador", ataque: "wiki.ataque.farejador", descricao: "wiki.bestiario.farejador", texturaPreview: "textures/ui/bestiario/Descoberto/farejador.png" },
    // 61
    { emoji: "", nome: "wiki.nome.olhos", vida: "wiki.vida.olhos", alimentacao: "wiki.alimentacao.olhos", habitat: "wiki.habitat.olhos", ataque: "wiki.ataque.olhos", descricao: "wiki.bestiario.olhos", texturaPreview: "textures/ui/bestiario/Descoberto/olhos.png" },
    // 62
    { emoji: "", nome: "wiki.nome.fantasma", vida: "wiki.vida.fantasma", alimentacao: "wiki.alimentacao.fantasma", habitat: "wiki.habitat.fantasma", ataque: "wiki.ataque.fantasma", descricao: "wiki.bestiario.fantasma", texturaPreview: "textures/ui/bestiario/Descoberto/fantasma.png" },
    // 63
    { emoji: "", nome: "wiki.nome.navi", vida: "wiki.vida.navi", alimentacao: "wiki.alimentacao.navi", habitat: "wiki.habitat.navi", ataque: "wiki.ataque.navi", descricao: "wiki.bestiario.navi", texturaPreview: "textures/ui/bestiario/Descoberto/navi.png" },
    // 64
    { emoji: "", nome: "wiki.nome.bau.monstro", vida: "wiki.vida.bau.monstro", alimentacao: "wiki.alimentacao.bau.monstro", habitat: "wiki.habitat.bau.monstro", ataque: "wiki.ataque.bau.monstro", descricao: "wiki.bestiario.bau.monstro", texturaPreview: "textures/ui/bestiario/Descoberto/bau_monstro.png" },
    // 65
    { emoji: "", nome: "wiki.nome.briza", vida: "wiki.vida.briza", alimentacao: "mob.alimentacao.desconhecida", habitat: "wiki.habitat.briza", ataque: "wiki.ataque.briza", descricao: "wiki.bestiario.briza", texturaPreview: "textures/ui/bestiario/Descoberto/briza.png" },
    // 66
    { emoji: "", nome: "wiki.nome.tatu", vida: "wiki.vida.tatu", alimentacao: "wiki.alimentacao.tatu", habitat: "wiki.habitat.tatu", ataque: "wiki.ataque.tatu", descricao: "wiki.bestiario.tatu", texturaPreview: "textures/ui/bestiario/Descoberto/tatu.png" },
    // 67
    { emoji: "", nome: "wiki.nome.sereia", vida: "wiki.vida.sereia", alimentacao: "wiki.alimentacao.sereia", habitat: "wiki.habitat.sereia", ataque: "wiki.ataque.sereia", descricao: "wiki.bestiario.sereia", texturaPreview: "textures/ui/bestiario/Descoberto/sereia.png" },
    // 68
    { emoji: "", nome: "wiki.nome.goblins", vida: "wiki.vida.goblins", alimentacao: "mob.alimentacao.desconhecida", habitat: "wiki.habitat.goblins", ataque: "wiki.ataque.goblins", descricao: "wiki.bestiario.goblins", texturaPreview: "textures/ui/bestiario/Descoberto/goblins.png" },
    // 69
    { emoji: "", nome: "wiki.nome.dragao_almas", vida: "wiki.vida.dragao_almas", alimentacao: "wiki.alimentacao.dragoes.sombrios", habitat: "wiki.habitat.dragao_almas", ataque: "wiki.ataque.dragao_almas", descricao: "wiki.bestiario.dragao_almas", texturaPreview: "textures/ui/bestiario/Descoberto/dragao_almas.png" },
    // 70
    { emoji: "", nome: "wiki.nome.dragao_sangue", vida: "wiki.vida.dragao_sangue", alimentacao: "wiki.alimentacao.dragoes.gerais", habitat: "wiki.habitat.dragao_sangue", ataque: "wiki.ataque.dragao_sangue", descricao: "wiki.bestiario.dragao_sangue", texturaPreview: "textures/ui/bestiario/Descoberto/dragao_sangue.png" },
    // 71
    { emoji: "", nome: "wiki.nome.dragao_gelo", vida: "wiki.vida.dragao_gelo", alimentacao: "wiki.alimentacao.dragoes.gerais", habitat: "wiki.habitat.dragao_gelo", ataque: "wiki.ataque.dragao_gelo", descricao: "wiki.bestiario.dragao_gelo", texturaPreview: "textures/ui/bestiario/Descoberto/dragao_gelo.png" },
    // 72
    { emoji: "", nome: "wiki.nome.dragao_venenoso", vida: "wiki.vida.dragao_venenoso", alimentacao: "wiki.alimentacao.dragoes.gerais", habitat: "wiki.habitat.dragao_venenoso", ataque: "wiki.ataque.dragao_venenoso", descricao: "wiki.bestiario.dragao_venenoso", texturaPreview: "textures/ui/bestiario/Descoberto/dragao_venenoso.png" },
    // 73
    { emoji: "", nome: "wiki.nome.vagalume", vida: "wiki.vida.vagalume", alimentacao: "mob.alimentacao.desconhecida", habitat: "wiki.habitat.vagalume", ataque: "wiki.ataque.vagalume", descricao: "wiki.bestiario.vagalume", texturaPreview: "textures/ui/bestiario/Descoberto/vagalume.png" },
    // 74
    { emoji: "", nome: "wiki.nome.boss3", vida: "wiki.vida.boss3", alimentacao: "mob.alimentacao.desconhecida", habitat: "wiki.habitat.boss3", ataque: "wiki.ataque.boss3", descricao: "wiki.bestiario.boss3", texturaPreview: "textures/ui/bestiario/Descoberto/boss3.png" },
    // 75
    { emoji: "", nome: "wiki.nome.boss2", vida: "wiki.vida.boss2", alimentacao: "mob.alimentacao.desconhecida", habitat: "wiki.habitat.boss2", ataque: "wiki.ataque.boss2", descricao: "wiki.bestiario.boss2", texturaPreview: "textures/ui/bestiario/Descoberto/boss2.png" },
    // 76
    { emoji: "", nome: "wiki.nome.golem_mago", vida: "wiki.vida.golem_mago", alimentacao: "mob.alimentacao.desconhecida", habitat: "wiki.habitat.golem_mago", ataque: "wiki.ataque.golem_mago", descricao: "wiki.bestiario.golem_mago", texturaPreview: "textures/ui/bestiario/Descoberto/golem_mago.png" },
    // 77
    { emoji: "", nome: "wiki.nome.boss1", vida: "wiki.vida.boss1", alimentacao: "mob.alimentacao.desconhecida", habitat: "wiki.habitat.boss1", ataque: "wiki.ataque.boss1", descricao: "wiki.bestiario.boss1", texturaPreview: "textures/ui/bestiario/Descoberto/boss1.png" },
    // 78
    { emoji: "", nome: "wiki.nome.lingua_viva", vida: "wiki.vida.lingua_viva", alimentacao: "mob.alimentacao.desconhecida", habitat: "wiki.habitat.lingua_viva", ataque: "wiki.ataque.lingua_viva", descricao: "wiki.bestiario.lingua_viva", texturaPreview: "textures/ui/bestiario/Descoberto/lingua_viva.png" },
    // 79
    { emoji: "", nome: "wiki.nome.fantasma_fim", vida: "wiki.vida.fantasma_fim", alimentacao: "mob.alimentacao.desconhecida", habitat: "wiki.habitat.fantasma_fim", ataque: "wiki.ataque.fantasma_fim", descricao: "wiki.bestiario.fantasma_fim", texturaPreview: "textures/ui/bestiario/Descoberto/fantasma_fim.png" },
    // 80
    { emoji: "", nome: "wiki.nome.boss4", vida: "wiki.vida.boss4", alimentacao: "mob.alimentacao.desconhecida", habitat: "wiki.habitat.boss4", ataque: "wiki.ataque.boss4", descricao: "wiki.bestiario.boss4", texturaPreview: "textures/ui/bestiario/Descoberto/boss4.png" }
];
// Função única para abrir qualquer mob
const POKEDEX_PAGES = [
    {
        id: 1,
        pagina: "pagina1",
        nome: { translate: "wiki.nome.aldeao" },
        icon: "textures/ui/bestiario/Descoberto/aldeao",
        abrir: abrirMob_1
    },
    {
        id: 2,
        pagina: "pagina2",
        nome: { translate: "wiki.nome.allay" },
        icon: "textures/ui/bestiario/Descoberto/allay",
        abrir: abrirMob_2
    },
    {
        id: 3,
        pagina: "pagina3",
        nome: { translate: "wiki.nome.axolote" },
        icon: "textures/ui/bestiario/Descoberto/axolote",
        abrir: abrirMob_3
    },
    {
        id: 4,
        pagina: "pagina4",
        nome: { translate: "wiki.nome.peixes" },
        icon: "textures/ui/bestiario/Descoberto/peixes",
        abrir: abrirMob_4
    },
    {
        id: 5,
        pagina: "pagina5",
        nome: { translate: "wiki.nome.baiacu" },
        icon: "textures/ui/bestiario/Descoberto/baiacu",
        abrir: abrirMob_5
    },
    {
        id: 6,
        pagina: "pagina6",
        nome: { translate: "wiki.nome.equinos" },
        icon: "textures/ui/bestiario/Descoberto/equinos",
        abrir: abrirMob_6
    },
    {
        id: 7,
        pagina: "pagina7",
        nome: { translate: "wiki.nome.coelho" },
        icon: "textures/ui/bestiario/Descoberto/coelho",
        abrir: abrirMob_7
    },
    {
        id: 8,
        pagina: "pagina8",
        nome: { translate: "wiki.nome.ruminantes" },
        icon: "textures/ui/bestiario/Descoberto/ruminantes",
        abrir: abrirMob_8
    },
    {
        id: 9,
        pagina: "pagina9",
        nome: { translate: "wiki.nome.galinha" },
        icon: "textures/ui/bestiario/Descoberto/galinha",
        abrir: abrirMob_9
    },
    {
        id: 10,
        pagina: "pagina10",
        nome: { translate: "wiki.nome.gato" },
        icon: "textures/ui/bestiario/Descoberto/gato",
        abrir: abrirMob_10
    },
    {
        id: 11,
        pagina: "pagina11",
        nome: { translate: "wiki.nome.sapo" },
        icon: "textures/ui/bestiario/Descoberto/sapo",
        abrir: abrirMob_11
    },
    {
        id: 12,
        pagina: "pagina12",
        nome: { translate: "wiki.nome.golens" },
        icon: "textures/ui/bestiario/Descoberto/golens",
        abrir: abrirMob_12
    },
    {
        id: 13,
        pagina: "pagina13",
        nome: { translate: "wiki.nome.ocelote" },
        icon: "textures/ui/bestiario/Descoberto/ocelote",
        abrir: abrirMob_13
    },
    {
        id: 14,
        pagina: "pagina14",
        nome: { translate: "wiki.nome.lavagante" },
        icon: "textures/ui/bestiario/Descoberto/lavagante",
        abrir: abrirMob_14
    },
    {
        id: 15,
        pagina: "pagina15",
        nome: { translate: "wiki.nome.lulas" },
        icon: "textures/ui/bestiario/Descoberto/lulas",
        abrir: abrirMob_15
    },
    {
        id: 16,
        pagina: "pagina16",
        nome: { translate: "wiki.nome.morcego" },
        icon: "textures/ui/bestiario/Descoberto/morcego",
        abrir: abrirMob_16
    },
    {
        id: 17,
        pagina: "pagina17",
        nome: { translate: "wiki.nome.ovelha" },
        icon: "textures/ui/bestiario/Descoberto/ovelha",
        abrir: abrirMob_17
    },
    {
        id: 18,
        pagina: "pagina18",
        nome: { translate: "wiki.nome.papagaio" },
        icon: "textures/ui/bestiario/Descoberto/papagaio",
        abrir: abrirMob_18
    },
    {
        id: 19,
        pagina: "pagina19",
        nome: { translate: "wiki.nome.piglin" },
        icon: "textures/ui/bestiario/Descoberto/piglin",
        abrir: abrirMob_19
    },
    {
        id: 20,
        pagina: "pagina20",
        nome: { translate: "wiki.nome.porco" },
        icon: "textures/ui/bestiario/Descoberto/porco",
        abrir: abrirMob_20
    },
    {
        id: 21,
        pagina: "pagina21",
        nome: { translate: "wiki.nome.raposa" },
        icon: "textures/ui/bestiario/Descoberto/raposa",
        abrir: abrirMob_21
    },
    {
        id: 22,
        pagina: "pagina22",
        nome: { translate: "wiki.nome.tartaruga" },
        icon: "textures/ui/bestiario/Descoberto/tartaruga",
        abrir: abrirMob_22
    },
    {
        id: 23,
        pagina: "pagina23",
        nome: { translate: "wiki.nome.urso" },
        icon: "textures/ui/bestiario/Descoberto/urso",
        abrir: abrirMob_23
    },
    {
        id: 24,
        pagina: "pagina24",
        nome: { translate: "wiki.nome.vendedor" },
        icon: "textures/ui/bestiario/Descoberto/vendedor",
        abrir: abrirMob_24
    },
    {
        id: 25,
        pagina: "pagina25",
        nome: { translate: "wiki.nome.abelha" },
        icon: "textures/ui/bestiario/Descoberto/abelha",
        abrir: abrirMob_25
    },
    {
        id: 26,
        pagina: "pagina26",
        nome: { translate: "wiki.nome.aranhas" },
        icon: "textures/ui/bestiario/Descoberto/aranhas",
        abrir: abrirMob_26
    },
    {
        id: 27,
        pagina: "pagina27",
        nome: { translate: "wiki.nome.cabras" },
        icon: "textures/ui/bestiario/Descoberto/cabras",
        abrir: abrirMob_27
    },
    {
        id: 28,
        pagina: "pagina28",
        nome: { translate: "wiki.nome.enderman" },
        icon: "textures/ui/bestiario/Descoberto/enderman",
        abrir: abrirMob_28
    },
    {
        id: 29,
        pagina: "pagina29",
        nome: { translate: "wiki.nome.golfinho" },
        icon: "textures/ui/bestiario/Descoberto/golfinho",
        abrir: abrirMob_29
    },
    {
        id: 30,
        pagina: "pagina30",
        nome: { translate: "wiki.nome.lhamas" },
        icon: "textures/ui/bestiario/Descoberto/lhamas",
        abrir: abrirMob_30
    },
    {
        id: 31,
        pagina: "pagina31",
        nome: { translate: "wiki.nome.lobo" },
        icon: "textures/ui/bestiario/Descoberto/lobo",
        abrir: abrirMob_31
    },
    {
        id: 32,
        pagina: "pagina32",
        nome: { translate: "wiki.nome.panda" },
        icon: "textures/ui/bestiario/Descoberto/panda",
        abrir: abrirMob_32
    },
    {
        id: 33,
        pagina: "pagina33",
        nome: { translate: "wiki.nome.afogado" },
        icon: "textures/ui/bestiario/Descoberto/zumbis",
        abrir: abrirMob_33
    },
    {
        id: 34,
        pagina: "pagina34",
        nome: { translate: "wiki.nome.zumbis" },
        icon: "textures/ui/bestiario/Descoberto/zumbis",
        abrir: abrirMob_34
    },
    {
        id: 35,
        pagina: "pagina35",
        nome: { translate: "wiki.nome.blaze" },
        icon: "textures/ui/bestiario/Descoberto/blaze",
        abrir: abrirMob_35
    },
    {
        id: 36,
        pagina: "pagina36",
        nome: { translate: "wiki.nome.bruxa" },
        icon: "textures/ui/bestiario/Descoberto/bruxa",
        abrir: abrirMob_36
    },
    {
        id: 37,
        pagina: "pagina37",
        nome: { translate: "wiki.nome.cavaleiro" },
        icon: "textures/ui/bestiario/Descoberto/cavaleiro",
        abrir: abrirMob_37
    },
    {
        id: 38,
        pagina: "pagina38",
        nome: { translate: "wiki.nome.creeper" },
        icon: "textures/ui/bestiario/Descoberto/creeper",
        abrir: abrirMob_38
    },
    {
        id: 39,
        pagina: "pagina39",
        nome: { translate: "wiki.nome.magma_cube" },
        icon: "textures/ui/bestiario/Descoberto/magma_cube",
        abrir: abrirMob_39
    },
    {
        id: 40,
        pagina: "pagina40",
        nome: { translate: "wiki.nome.warden" },
        icon: "textures/ui/bestiario/Descoberto/warden",
        abrir: abrirMob_40
    },
    {
        id: 41,
        pagina: "pagina41",
        nome: { translate: "wiki.nome.devastador" },
        icon: "textures/ui/bestiario/Descoberto/devastador",
        abrir: abrirMob_41
    },
    {
        id: 42,
        pagina: "pagina42",
        nome: { translate: "wiki.nome.endermite" },
        icon: "textures/ui/bestiario/Descoberto/endermite",
        abrir: abrirMob_42
    },
    {
        id: 43,
        pagina: "pagina43",
        nome: { translate: "wiki.nome.esqueletos" },
        icon: "textures/ui/bestiario/Descoberto/esqueletos",
        abrir: abrirMob_43
    },
    {
        id: 44,
        pagina: "pagina44",
        nome: { translate: "wiki.nome.ghast" },
        icon: "textures/ui/bestiario/Descoberto/ghast",
        abrir: abrirMob_44
    },
    {
        id: 45,
        pagina: "pagina45",
        nome: { translate: "wiki.nome.guardiao" },
        icon: "textures/ui/bestiario/Descoberto/guardiao",
        abrir: abrirMob_45
    },
    {
        id: 46,
        pagina: "pagina46",
        nome: { translate: "wiki.nome.hoglin" },
        icon: "textures/ui/bestiario/Descoberto/hoglin",
        abrir: abrirMob_46
    },
    {
        id: 47,
        pagina: "pagina47",
        nome: { translate: "wiki.nome.invocador" },
        icon: "textures/ui/bestiario/Descoberto/invocador",
        abrir: abrirMob_47
    },
    {
        id: 48,
        pagina: "pagina48",
        nome: { translate: "wiki.nome.phantom" },
        icon: "textures/ui/bestiario/Descoberto/phantom",
        abrir: abrirMob_48
    },
    {
        id: 49,
        pagina: "pagina49",
        nome: { translate: "wiki.nome.piglin_brute" },
        icon: "textures/ui/bestiario/Descoberto/piglin_brute",
        abrir: abrirMob_49
    },
    {
        id: 50,
        pagina: "pagina50",
        nome: { translate: "wiki.nome.saqueadores" },
        icon: "textures/ui/bestiario/Descoberto/saqueadores",
        abrir: abrirMob_50
    },
    {
        id: 51,
        pagina: "pagina51",
        nome: { translate: "wiki.nome.shulker" },
        icon: "textures/ui/bestiario/Descoberto/shulker",
        abrir: abrirMob_51
    },
    {
        id: 52,
        pagina: "pagina52",
        nome: { translate: "wiki.nome.slime" },
        icon: "textures/ui/bestiario/Descoberto/slime",
        abrir: abrirMob_52
    },
    {
        id: 53,
        pagina: "pagina53",
        nome: { translate: "wiki.nome.traca" },
        icon: "textures/ui/bestiario/Descoberto/traca",
        abrir: abrirMob_53
    },
    {
        id: 54,
        pagina: "pagina54",
        nome: { translate: "wiki.nome.vex" },
        icon: "textures/ui/bestiario/Descoberto/vex",
        abrir: abrirMob_54
    },
    {
        id: 55,
        pagina: "pagina55",
        nome: { translate: "wiki.nome.vingador" },
        icon: "textures/ui/bestiario/Descoberto/vingador",
        abrir: abrirMob_55
    },
    {
        id: 56,
        pagina: "pagina56",
        nome: { translate: "wiki.nome.zoglin" },
        icon: "textures/ui/bestiario/Descoberto/zoglin",
        abrir: abrirMob_56
    },
    {
        id: 57,
        pagina: "pagina57",
        nome: { translate: "wiki.nome.dragao" },
        icon: "textures/ui/bestiario/Descoberto/dragao",
        abrir: abrirMob_57
    },
    {
        id: 58,
        pagina: "pagina58",
        nome: { translate: "wiki.nome.wither" },
        icon: "textures/ui/bestiario/Descoberto/wither",
        abrir: abrirMob_58
    },
    {
        id: 59,
        pagina: "pagina59",
        nome: { translate: "wiki.nome.camelo" },
        icon: "textures/ui/bestiario/Descoberto/camelo",
        abrir: abrirMob_59
    },
    {
        id: 60,
        pagina: "pagina60",
        nome: { translate: "wiki.nome.farejador" },
        icon: "textures/ui/bestiario/Descoberto/farejador",
        abrir: abrirMob_60
    },
    {
        id: 61,
        pagina: "pagina61",
        nome: { translate: "wiki.nome.olhos" },
        icon: "textures/ui/bestiario/Descoberto/olhos",
        abrir: abrirMob_61
    },
    {
        id: 62,
        pagina: "pagina62",
        nome: { translate: "wiki.nome.fantasma" },
        icon: "textures/ui/bestiario/Descoberto/fantasma",
        abrir: abrirMob_62
    },
    {
        id: 62,
        pagina: "pagina63",
        nome: { translate: "wiki.nome.navi" },
        icon: "textures/ui/bestiario/Descoberto/navi",
        abrir: abrirMob_63
    },
    {
        id: 64,
        pagina: "pagina64",
        nome: { translate: "wiki.nome.bau.monstro" },
        icon: "textures/ui/bestiario/Descoberto/bau_monstro",
        abrir: abrirMob_64
    },
    {
        id: 65,
        pagina: "pagina65",
        nome: { translate: "wiki.nome.briza" },
        icon: "textures/ui/bestiario/Descoberto/briza",
        abrir: abrirMob_65
    },
    {
        id: 66,
        pagina: "pagina66",
        nome: { translate: "wiki.nome.tatu" },
        icon: "textures/ui/bestiario/Descoberto/tatu",
        abrir: abrirMob_66
    },
    {
        id: 67,
        pagina: "pagina67",
        nome: { translate: "wiki.nome.sereia" },
        icon: "textures/ui/bestiario/Descoberto/sereia",
        abrir: abrirMob_67
    },
    {
        id: 68,
        pagina: "pagina68",
        nome: { translate: "wiki.nome.goblins" },
        icon: "textures/ui/bestiario/Descoberto/goblins",
        abrir: abrirMob_68
    },
    {
        id: 69,
        pagina: "pagina69",
        nome: { translate: "wiki.nome.dragao_almas" },
        icon: "textures/ui/bestiario/Descoberto/dragao_almas",
        abrir: abrirMob_69
    },
    {
        id: 70,
        pagina: "pagina70",
        nome: { translate: "wiki.nome.dragao_sangue" },
        icon: "textures/ui/bestiario/Descoberto/dragao_sangue",
        abrir: abrirMob_70
    },
    {
        id: 71,
        pagina: "pagina71",
        nome: { translate: "wiki.nome.dragao_gelo" },
        icon: "textures/ui/bestiario/Descoberto/dragao_gelo",
        abrir: abrirMob_71
    },
    {
        id: 72,
        pagina: "pagina72",
        nome: { translate: "wiki.nome.dragao_venenoso" },
        icon: "textures/ui/bestiario/Descoberto/dragao_venenoso",
        abrir: abrirMob_72
    },
    {
        id: 73,
        pagina: "pagina73",
        nome: { translate: "wiki.nome.vagalume" },
        icon: "textures/ui/bestiario/Descoberto/vagalume",
        abrir: abrirMob_73
    },
    {
        id: 74,
        pagina: "pagina74",
        nome: { translate: "wiki.nome.boss3" },
        icon: "textures/ui/bestiario/Descoberto/boss3",
        abrir: abrirMob_74
    },
    {
        id: 75,
        pagina: "pagina75",
        nome: { translate: "wiki.nome.boss2" },
        icon: "textures/ui/bestiario/Descoberto/boss2",
        abrir: abrirMob_75
    },
    {
        id: 76,
        pagina: "pagina76",
        nome: { translate: "wiki.nome.golem_mago" },
        icon: "textures/ui/bestiario/Descoberto/golem_mago",
        abrir: abrirMob_76
    },
    {
        id: 77,
        pagina: "pagina77",
        nome: { translate: "wiki.nome.boss1" },
        icon: "textures/ui/bestiario/Descoberto/boss1",
        abrir: abrirMob_77
    },
    {
        id: 78,
        pagina: "pagina78",
        nome: { translate: "wiki.nome.lingua_viva" },
        icon: "textures/ui/bestiario/Descoberto/lingua_viva",
        abrir: abrirMob_78
    },
    {
        id: 79,
        pagina: "pagina79",
        nome: { translate: "wiki.nome.fantasma_fim" },
        icon: "textures/ui/bestiario/Descoberto/fantasma_fim",
        abrir: abrirMob_79
    },
    {
        id: 80,
        pagina: "pagina80",
        nome: { translate: "wiki.nome.boss4" },
        icon: "textures/ui/bestiario/Descoberto/boss4",
        abrir: abrirMob_80
    }
];
function getPokedexProgress(player) {
    let descobertos = 0;

    for (const pet of POKEDEX_PAGES) {
        const score = getScorePlayer(player, pet.pagina);
        if (score > 0) descobertos++;
    }

    const total = POKEDEX_PAGES.length;
    const porcentagem = total === 0 ? 0 : Math.floor((descobertos / total) * 100);

    // atualiza scoreboards usados na UI
    ScoreUtils.set(player, "pokedex_descobertos", descobertos);
    ScoreUtils.set(player, "pokedex_total", total);

    return { descobertos, total, porcentagem };
}
export function abrirBestiario(player) {

    // Atualiza progresso e scoreboard antes de abrir UI
    getPokedexProgress(player);
	const progresso = getPokedexProgress(player);
    const form = new ui.ActionFormData();
    
    // Título traduzível
    form.title({ rawtext: [{ translate: "bestiario.titulo" }] });
    
    // Body usando SCOREBOARD (agora vai funcionar!)
    form.body({
        rawtext: [
            { translate: "bestiario.progresso" },
            { score: { name: "*", objective: "pokedex_descobertos" } },
            { text: "/" },
            { score: { name: "*", objective: "pokedex_total" } }, { text: " " }, { text: "§g§´(" }, { text: `${progresso.porcentagem}%` }, { text: "%" }, { text: ")§r" }, { text: " " }, { translate: "bestiario.progresso.descobertos" }, 
			
            { text: "\n\n" }
        ]
    });
    
    // Botões dos mobs
    for (const pet of POKEDEX_PAGES) {
        const score = getScorePlayer(player, pet.pagina);
        const descoberto = score > 0;
        
        if (descoberto) {
            form.button(pet.nome, pet.icon);
        } else {
            form.button(
                { rawtext: [{ translate: "bestiario.desconhecido" }] },
                "textures/ui/lock_color.png"
            );
        }
    }
    
    form.show(player).then((result) => {
        if (result.canceled) return;
        
        const pet = POKEDEX_PAGES[result.selection];
        const score = getScorePlayer(player, pet.pagina);
        
        if (score <= 0) {
            player.sendMessage({
                rawtext: [{ translate: "bestiario.mob_nao_descoberto" }]
            });
            return;
        }
        
        pet.abrir(player);
    });
}
export const ScoreUtils = {

    ensureObjective(objectiveId) {
        let obj = world.scoreboard.getObjective(objectiveId);
        if (!obj) {
            obj = world.scoreboard.addObjective(objectiveId, objectiveId);
        }
        return obj;
    },
    
    set(player, objectiveId, value) {
        const obj = this.ensureObjective(objectiveId);
        obj.setScore(player.scoreboardIdentity, value);
    }

};
function abrirMob(mobIndex, player) {
    const mob = bestiarioMobs[mobIndex];
    if (!mob) {
        player.sendMessage("§cMob não encontrado.");
        return;
    }

    const form = new ui.ActionFormData();
    form.title("wellforced:bestiario");

    // Body dinâmico com rawtext
    form.body({
        rawtext: [
            { text: "\n\n\n\n" },
            //{ text: mob.emoji },
            { text: "\n\n\n\n\n\n" },
            { text: "§6" }, { text: "§l" }, { translate: mob.nome }, { text: "\n" }, { text: "§r" },
            { text: "§a" }, { translate: mob.vida },
            { text: "\n" },
            { text: "§d" }, { translate: mob.alimentacao || "mob.alimentacao.desconhecida" },
            { text: "\n" },
            { text: "§c" }, { translate: mob.habitat },
            { text: "\n" },
            { text: "§b" }, { translate: mob.ataque },
            { text: "\n" },
            { text: "\n\n" },
            { text: "§e" }, { translate: mob.descricao }
        ]
    });

    // Botões
    form.button({ rawtext: [{ translate: "menu.voltar" }] }, "textures/ui/undoArrow.png");   // índice 0
    form.button("", mob.texturaPreview);                       // índice 2 → TEXTURA DINÂMICA PARA O PREVIEW

    form.show(player).then(res => {
        if (res.canceled) return;
        if (res.selection === 0) {
            player.runCommand("event entity @s remove_player_npc");
            abrirBestiario(player);
        }
    });
}
// Funções de chamada (mantenha para compatibilidade com o resto do seu código)
function abrirMob_1(player)  { abrirMob(0, player); }
function abrirMob_2(player)  { abrirMob(1, player); }
function abrirMob_3(player)  { abrirMob(2, player); }
function abrirMob_4(player)  { abrirMob(3, player); }
function abrirMob_5(player)  { abrirMob(4, player); }
function abrirMob_6(player)  { abrirMob(5, player); }
function abrirMob_7(player)  { abrirMob(6, player); }
function abrirMob_8(player)  { abrirMob(7, player); }
function abrirMob_9(player)  { abrirMob(8, player); }
function abrirMob_10(player) { abrirMob(9, player); }
function abrirMob_11(player) { abrirMob(10, player); }
function abrirMob_12(player) { abrirMob(11, player); }
function abrirMob_13(player) { abrirMob(12, player); }
function abrirMob_14(player) { abrirMob(13, player); }
function abrirMob_15(player) { abrirMob(14, player); }
function abrirMob_16(player) { abrirMob(15, player); }
function abrirMob_17(player) { abrirMob(16, player); }
function abrirMob_18(player) { abrirMob(17, player); }
function abrirMob_19(player) { abrirMob(18, player); }
function abrirMob_20(player) { abrirMob(19, player); }
function abrirMob_21(player) { abrirMob(20, player); }
function abrirMob_22(player) { abrirMob(21, player); }
function abrirMob_23(player) { abrirMob(22, player); }
function abrirMob_24(player) { abrirMob(23, player); }
function abrirMob_25(player) { abrirMob(24, player); }
function abrirMob_26(player) { abrirMob(25, player); }
function abrirMob_27(player) { abrirMob(26, player); }
function abrirMob_28(player) { abrirMob(27, player); }
function abrirMob_29(player) { abrirMob(28, player); }
function abrirMob_30(player) { abrirMob(29, player); }
function abrirMob_31(player) { abrirMob(30, player); }
function abrirMob_32(player) { abrirMob(31, player); }
function abrirMob_33(player) { abrirMob(32, player); }
function abrirMob_34(player) { abrirMob(33, player); }
function abrirMob_35(player) { abrirMob(34, player); }
function abrirMob_36(player) { abrirMob(35, player); }
function abrirMob_37(player) { abrirMob(36, player); }
function abrirMob_38(player) { abrirMob(37, player); }
function abrirMob_39(player) { abrirMob(38, player); }
function abrirMob_40(player) { abrirMob(39, player); }
function abrirMob_41(player) { abrirMob(40, player); }
function abrirMob_42(player) { abrirMob(41, player); }
function abrirMob_43(player) { abrirMob(42, player); }
function abrirMob_44(player) { abrirMob(43, player); }
function abrirMob_45(player) { abrirMob(44, player); }
function abrirMob_46(player) { abrirMob(45, player); }
function abrirMob_47(player) { abrirMob(46, player); }
function abrirMob_48(player) { abrirMob(47, player); }
function abrirMob_49(player) { abrirMob(48, player); }
function abrirMob_50(player) { abrirMob(49, player); }
function abrirMob_51(player) { abrirMob(50, player); }
function abrirMob_52(player) { abrirMob(51, player); }
function abrirMob_53(player) { abrirMob(52, player); }
function abrirMob_54(player) { abrirMob(53, player); }
function abrirMob_55(player) { abrirMob(54, player); }
function abrirMob_56(player) { abrirMob(55, player); }
function abrirMob_57(player) { abrirMob(56, player); }
function abrirMob_58(player) { abrirMob(57, player); }
function abrirMob_59(player) { abrirMob(58, player); }
function abrirMob_60(player) { abrirMob(59, player); }
function abrirMob_61(player) { abrirMob(60, player); }
function abrirMob_62(player) { abrirMob(61, player); }
function abrirMob_63(player) { abrirMob(62, player); }
function abrirMob_64(player) { abrirMob(63, player); }
function abrirMob_65(player) { abrirMob(64, player); }
function abrirMob_66(player) { abrirMob(65, player); }
function abrirMob_67(player) { abrirMob(66, player); }
function abrirMob_68(player) { abrirMob(67, player); }
function abrirMob_69(player) { abrirMob(68, player); }
function abrirMob_70(player) { abrirMob(69, player); }
function abrirMob_71(player) { abrirMob(70, player); }
function abrirMob_72(player) { abrirMob(71, player); }
function abrirMob_73(player) { abrirMob(72, player); }
function abrirMob_74(player) { abrirMob(73, player); }
function abrirMob_75(player) { abrirMob(74, player); }
function abrirMob_76(player) { abrirMob(75, player); }
function abrirMob_77(player) { abrirMob(76, player); }
function abrirMob_78(player) { abrirMob(77, player); }
function abrirMob_79(player) { abrirMob(78, player); }
function abrirMob_80(player) { abrirMob(79, player); }