import { world } from "@minecraft/server";
import { ActionFormData } from "@minecraft/server-ui";
import { ModalFormData } from "@minecraft/server-ui";
import { showBestiary as showBestiaryMenu } from "./bestiary/ui.js";

function showBestiary(player) {
    return showBestiaryMenu(player, showGuide);
}

// Utilidad para mostrar formularios
function showForm(player, form, callback) {
    form.show(player).then(result => {
        if (result.canceled) return;
        callback(result.selection);
    });
}

// Función principal
world.afterEvents.itemUse.subscribe((eventData) => {
    const player = eventData.source;
    const itemUse = eventData.itemStack.typeId;
    if (itemUse === "dungeon:guide_book") {
        showGuide(player);
    }
});

function showGuide(player) {
    const form = new ActionFormData()
        .title("Guide")
        .body({ translate: "dungeon.langcode.guide.body" })
        //   .button({ translate: "dungeon.langcode.guide.button.bestiary" }, "textures/ui/bestiary/icon") // NUEVO
        .button({ translate: "dungeon.langcode.guide.button.items" }, "textures/items/bone_bag")
        .button({ translate: "dungeon.langcode.guide.button.ores" }, "textures/items/glimmerite_ingot")
        .button({ translate: "dungeon.langcode.guide.button.difficulty" }, "textures/items/ancient_skull")
        .button({ translate: "dungeon.langcode.guide.button.config" }, "textures/items/paper");

    showForm(player, form, (selection) => {
        [
            // showBestiary, // NUEVO
            showItems,
            showOresAndMore,
            showDifficulty,
            showConfig,
        ][selection]?.(player);
    });
}

function showItems(player) {
    const form = new ActionFormData()
        .title({ translate: "dungeon.langcode.guide.body_items" })
        .button({ translate: "dungeon.langcode.guide.button.accessories" }, "textures/items/accessories/vampiric_amulet")
        .button({ translate: "dungeon.langcode.guide.button.artifacts" }, "textures/items/petrifyn")
        .button({ translate: "dungeon.langcode.guide.button.consumables" }, "textures/items/melon_redpie")
        .button({ translate: "dungeon.langcode.guide.button.material" }, "textures/items/material/silk")
        .button({ translate: "dungeon.langcode.guide.button.potions" }, "textures/items/potions/return_potion")
        .button({ translate: "dungeon.langcode.guide.button.weapons_and_tools" }, "textures/items/sword/lunar_sword")
        .button({ translate: "dungeon.langcode.guide.button.armors" }, "textures/items/titanium_chestplate")
        .button({ translate: "dungeon.langcode.guide.button.back" });

    showForm(player, form, (selection) => {
        const actions = [
            showAccessories, showArtifacts, showFood, showMaterial,
            showPotions, showWeaponsTools, showArmors, showGuide
        ];
        actions[selection]?.(player);
    });
}

function showCategory(player, titleKey, buttons, backCallback) {
    const form = new ActionFormData().title({ translate: titleKey });
    buttons.forEach(([key, texture]) => form.button({ translate: key }, texture));
    form.button({ translate: "dungeon.langcode.guide.button.back" });

    showForm(player, form, (selection) => {
        if (selection === buttons.length) return backCallback(player);
        buttons[selection][2](player);
    });
}

function showItemDetails(player, titleKey, descriptionKey, backCallback) {
    const form = new ActionFormData()
        .title({ translate: titleKey })
        .body({ translate: descriptionKey })
        .button({ translate: "dungeon.langcode.guide.button.back" });
    showForm(player, form, () => backCallback(player));
}

// Accessories
function showAccessories(player) {
    const buttons = [
        ["dungeon.langcode.guide.button.vampiric_amulet", "textures/items/accessories/vampiric_amulet", showVampiricAmulet],
        ["dungeon.langcode.guide.crystal_arrow", "textures/items/accessories/crystal_arrow", showCrystalArrow],
        ["dungeon.langcode.guide.button.feather_hat", "textures/items/accessories/feather_hat", showFeatherHat],
        ["dungeon.langcode.guide.button.heart", "textures/items/heart", showHeart],
        ["dungeon.langcode.guide.button.heavy_rock", "textures/items/accessories/heavy_rock", showHeavyRock],
        ["dungeon.langcode.guide.button.lightboots", "textures/items/accessories/lightboots", showLightboots],
        ["dungeon.langcode.guide.button.miner_glove", "textures/items/accessories/miner_glove", showMinerGlove],
        ["dungeon.langcode.guide.button.moonstone", "textures/items/accessories/moonstone", showMoonstone],
        ["dungeon.langcode.guide.button.silk_mask", "textures/items/accessories/silk_mask", showSilkMask],
        ["item.dungeon.silver_ring.name", "textures/items/accessories/silver_ring", showSilverRing],
        ["dungeon.langcode.guide.button.super_heart", "textures/items/super_heart", showSuperHeart],
        ["dungeon.langcode.guide.button.totemofrecovery", "textures/items/accessories/totemofrecovery", showTotemRecovery],
        ["dungeon.langcode.guide.button.ultimate_heart", "textures/items/ultimate_heart", showUltimateHeart],
    ];
    showCategory(player, "dungeon.langcode.guide.button.accessories", buttons, showItems);
}

// Una función por ítem detallado (puedes duplicar y adaptar para cada uno)
function showVampiricAmulet(player) {
    showItemDetails(player, "dungeon.langcode.guide.button.vampiric_amulet", "dungeon.langcode.guide.button.vampiric_amulet.description", showAccessories);
}
function showCrystalArrow(player) {
    showItemDetails(player, "dungeon.langcode.guide.crystal_arrow", "dungeon.langcode.guide.button.crystal_arrow.description", showAccessories);
}
function showFeatherHat(player) {
    showItemDetails(player, "dungeon.langcode.guide.button.feather_hat", "dungeon.langcode.guide.button.feather_hat.description", showAccessories);
}
function showHeart(player) {
    showItemDetails(player, "dungeon.langcode.guide.button.heart", "dungeon.langcode.guide.button.heart.description", showAccessories);
}
function showHeavyRock(player) {
    showItemDetails(player, "dungeon.langcode.guide.button.heavy_rock", "dungeon.langcode.guide.button.heavy_rock.description", showAccessories);
}
function showLightboots(player) {
    showItemDetails(player, "dungeon.langcode.guide.button.lightboots", "dungeon.langcode.guide.button.lightboots.description", showAccessories);
}
function showMinerGlove(player) {
    showItemDetails(player, "dungeon.langcode.guide.button.miner_glove", "dungeon.langcode.guide.button.miner_glove.description", showAccessories);
}
function showMoonstone(player) {
    showItemDetails(player, "dungeon.langcode.guide.button.moonstone", "dungeon.langcode.guide.button.moonstone.description", showAccessories);
}
function showSilkMask(player) {
    showItemDetails(player, "dungeon.langcode.guide.button.silk_mask", "dungeon.langcode.guide.button.silk_mask.description", showAccessories);
}
function showSilverRing(player) {
    showItemDetails(player, "item.dungeon.silk_ring.name", "dungeon.langcode.guide.button.silk_ring.description", showAccessories);
}
function showSuperHeart(player) {
    showItemDetails(player, "dungeon.langcode.guide.button.super_heart", "dungeon.langcode.guide.button.super_heart.description", showAccessories);
}
function showTotemRecovery(player) {
    showItemDetails(player, "dungeon.langcode.guide.button.totemofrecovery", "dungeon.langcode.guide.button.totemofrecovery.description", showAccessories);
}
function showUltimateHeart(player) {
    showItemDetails(player, "dungeon.langcode.guide.button.ultimate_heart", "dungeon.langcode.guide.button.ultimate_heart.description", showAccessories);
}

// Funciones vacías para evitar errores
function showOresAndMore(player) {
    const form = new ActionFormData()
        .title({ translate: "dungeon.langcode.guide.button.ores" })
        .body({ translate: "dungeon.langcode.guide.ores.guide" })
        .button({ translate: "dungeon.langcode.guide.button.back" });

    showForm(player, form, (selection) => {
        const actions = [
            showGuide
        ];
        actions[selection]?.(player);
    });

}
function showDifficulty(player) {
    const form = new ActionFormData()
        .title({ translate: "dungeon.langcode.guide.button.difficulty" })
        .body({ translate: "dungeon.langcode.guide.difficulty_system.description" })
        .button({ translate: "dungeon.langcode.guide.button.back" });

    showForm(player, form, (selection) => {
        const actions = [
            showGuide
        ];
        actions[selection]?.(player);
    });

}
export function fearMessagesToggle(player) {
    const hasFearTag = player.hasTag("fear_info");

    const form = new ModalFormData()
        .title({ translate: "dungeon.langcode.guide.button.fear_config" })
        .toggle(
            { translate: "dungeon.langcode.guide.button.fear_messages" },
            { defaultValue: hasFearTag }
        );

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

        const [enabled] = res.formValues;

        if (enabled) {
            player.addTag("fear_info");
        } else {
            player.removeTag("fear_info");
        }

        player.sendMessage([
            { text: "§8[§6OtherWorldly§8] §7" },
            { translate: enabled ? "dungeon.langcode.message.fear_disabled" : "dungeon.langcode.message.fear_enabled" }
        ]);

        showConfig(player);
    });
}

export function expertmodeToggle(player) {
    const isHardcore = world.isHardcore;
    const hasExpertTag = player.hasTag("player_expert");

    if (isHardcore && !hasExpertTag) {
        player.addTag("player_expert");
    }

    if (isHardcore) {
        player.sendMessage([
            { text: "§8[§6OtherWorldly§8] §7" },
            { translate: "dungeon.langcode.message.hardcore_expert" }
        ]);
        return;
    }

    const form = new ModalFormData()
        .title({ translate: "dungeon.langcode.guide.button.expert_mode_config" })
        .toggle(
            { translate: "dungeon.langcode.guide.button.expert_mode" },
            { defaultValue: hasExpertTag }
        );

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

        const [enabled] = res.formValues;

        if (enabled) {
            player.runCommand("difficulty hard");
            player.addTag("player_expert");
        } else {
            player.removeTag("player_expert");
        }

        player.sendMessage([
            { text: "§8[§6OtherWorldly§8] §7" },
            { translate: enabled ? "dungeon.langcode.message.expert_enabled" : "dungeon.langcode.message.expert_disabled" }
        ]);

        showConfig(player);
    });
}

export function teleportationToggle(player) {
    const hasTeleportTag = player.hasTag("allow_teleportation");
    const form = new ModalFormData()
        .title({ translate: "dungeon.langcode.guide.button.allow_teleportation" })
        .toggle(
            { translate: "dungeon.langcode.guide.button.teleportation_toggle" },
            { defaultValue: hasTeleportTag }
        );

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

        const [enabled] = res.formValues;

        if (enabled) {
            player.addTag("allow_teleportation");
        } else {
            player.removeTag("allow_teleportation");
        }

        player.sendMessage([
            { text: "§8[§6OtherWorldly§8] §7" },
            { translate: enabled ? "dungeon.langcode.message.teleport_enabled" : "dungeon.langcode.message.teleport_disabled" }
        ]);

        showConfig(player);
    });
}



/**
 * @param {import("@minecraft/server").Player} player
 */
export function showConfig(player) {
    const form = new ActionFormData()
        .title({ translate: "dungeon.langcode.guide.button.config" })
        .button({ translate: "dungeon.langcode.guide.button.expert_mode_config" }) // Modo experto
        .button({ translate: "dungeon.langcode.guide.button.fear_config" }) // Configurar miedo
        .button({ translate: "dungeon.langcode.guide.button.allow_teleportation" }) // Teletransportación

        .button({ translate: "dungeon.langcode.guide.button.back" });    // Regresar

    showForm(player, form, (selection) => {
        const actions = [
            expertmodeToggle, // Índice 1: selector de idioma
            fearMessagesToggle, // Índice 1: selector de idioma
            teleportationToggle, // Índice 1: selector de idioma
            showGuide             // Índice 2: regresar
        ];
        actions[selection]?.(player);
    });
}
function showEntities(player) { }
function showBoss(player) { }
function showArtifacts(player) {
    const buttons = [
        ["item.dungeon.bone_relic.name", "textures/items/bone_relic", showBoneRelic],
        ["item.dungeon.gauntlet.name", "textures/items/gauntlet", showgauntlet],
        ["item.dungeon.petrifyn.name", "textures/items/petrifyn", showpetrifyn],
        ["item.dungeon.punisher.name", "textures/items/punisher", showpunisher],
    ];
    showCategory(player, "dungeon.langcode.guide.button.artifacts", buttons, showItems);
}

function showBoneRelic(player) {
    showItemDetails(player, "item.dungeon.bone_relic.name", "dungeon.langcode.guide.button.bone_relic.description", showArtifacts);
}
function showgauntlet(player) {
    showItemDetails(player, "item.dungeon.gauntlet.name", "dungeon.langcode.guide.button.gauntlet.description", showArtifacts);
}
function showpetrifyn(player) {
    showItemDetails(player, "item.dungeon.petrifyn.name", "dungeon.langcode.guide.button.petrifyn.description", showArtifacts);
}
function showpunisher(player) {
    showItemDetails(player, "item.dungeon.punisher.name", "dungeon.langcode.guide.button.punisher.description", showArtifacts);
}

function showFood(player) {
    const buttons = [
        ["item.dungeon.bandage.name", "textures/items/consumables/bandage", showBandage],
        ["item.dungeon.ancient_apple.name", "textures/items/ancient/dancient_apple", showAncientApple],
        ["item.dungeon:glowing_mushroom.name", "textures/items/glowing_mushroom", showGlowingMushroom],
        ["item.dungeon.green_apple.name", "textures/items/dgreen_apple", showGreenApple],
        ["item.dungeon.magic_seeds.name", "textures/items/magic_seeds", showMagicSeeds],
        ["item.dungeon.melon_redpie.name", "textures/items/melon_redpie", showMelonRedPie],
    ];
    showCategory(player, "dungeon.langcode.guide.button.consumables", buttons, showItems);
}
function showAncientApple(player) {
    showItemDetails(player, "item.dungeon.ancient_apple.name", "dungeon.langcode.guide.button.ancient_sword.description", showFood);
}
function showBandage(player) {
    showItemDetails(player, "item.dungeon.bandage.name", "dungeon.langcode.guide.button.bandage.description", showFood);
}
function showGlowingMushroom(player) {
    showItemDetails(player, "item.dungeon.glowing_mushroom.name", "dungeon.langcode.guide.button.glowing_mushroom.description", showFood);
}
function showGreenApple(player) {
    showItemDetails(player, "item.dungeon.green_apple.name", "dungeon.langcode.guide.button.green_apple.description", showFood);
}
function showMagicSeeds(player) {
    showItemDetails(player, "item.dungeon.magic_seeds.name", "dungeon.langcode.guide.button.magic_seeds.description", showFood);
}
function showMelonRedPie(player) {
    showItemDetails(player, "item.dungeon.melon_redpie.name", "dungeon.langcode.guide.button.melon_redpie.description", showFood);
}
function showMaterial(player) {
    const buttons = [
        ["item.dungeon.bat_fang.name", "textures/items/material/bat_fang", showBatFang],
        ["item.dungeon.bone.name", "textures/items/bone1", showBone],
        ["item.dungeon.carnivorous_plant_leaf.name", "textures/items/material/carnivorous_plant_leaf", showCarnivorousPlantLeaf],
        ["item.dungeon.celestial_cloud.name", "textures/items/material/celestial_cloud", showCelestialCloud],
        ["item.dungeon.celestial_storm_cloud.name", "textures/items/material/celestial_storm_cloud", showCelestialStormCloud],
        ["item.dungeon.cursed_purple.name", "textures/items/cursed_purple", showCursedPurple],
        ["item.dungeon.chitin.name", "textures/items/chitin", showChitin],
        ["item.dungeon.crimson_sap.name", "textures/items/material/crimson_sap", showCrimsonSap],
        ["item.dungeon.dark_material.name", "textures/items/dark_material", showDarkMaterial],
        ["item.dungeon.green_chitin.name", "textures/items/material/green_chitin", showGreenChitin],
        ["item.dungeon.moth_powder.name", "textures/items/material/moth_powder", showMothPowder],
        ["item.dungeon.moth_silk.name", "textures/items/material/moth_silk", showMothSilk],
        ["item.dungeon.silk.name", "textures/items/material/silk", showSilk],
        ["item.dungeon.half_heart.name", "textures/items/half_heart", showHalfHeart],
        ["item.dungeon.lunar_essence.name", "textures/items/material/lunar_essence", showLunarEssence],
        ["item.dungeon.nature_essence.name", "textures/items/material/nature_essence", showNatureEssence],
        ["item.dungeon.poison.name", "textures/items/poison", showPoison],
        ["item.dungeon.poison_mushroom.name", "textures/items/poison_mushroom", showPoisonMushroom],
        ["item.dungeon.purple_material.name", "textures/items/purple_material", showPurpleMaterial],
        ["item.dungeon.purpur_slimeball.name", "textures/items/purpur_slime", showPurpurSlimeball],
        ["item.dungeon.red_slimeball.name", "textures/items/red_slime", showRedSlimeball],
        ["item.dungeon.rock.name", "textures/items/material/drock", showRock],
        ["item.dungeon.rock_fragment.name", "textures/items/material/rock_fragment", showRockFragment],
        ["item.dungeon.sky_essence.name", "textures/items/material/sky_essence", showSkyEssence],
        ["item.dungeon.solid_slimeball.name", "textures/items/solid_slime", showSolidSlimeball],
        ["item.dungeon.super_h_heart.name", "textures/items/super_h_heart", showSuperHalfHeart],
        ["item.dungeon.super_stick.name", "textures/items/super_stick", showSuperStick],
        ["item.dungeon.wither_bone.name", "textures/items/wither_bone1", showWitherBone],
        ["item.dungeon.wither_bone_normal.name", "textures/items/material/wither_bone", showWitherBoneNormal],
        ["item.dungeon.wither_bone_meal.name", "textures/items/material/wither_bone_meal", showWitherBoneMeal],
        ["item.dungeon.yellow_slimeball.name", "textures/items/yellow_slime", showYellowSlimeBall],
    ];
    showCategory(player, "dungeon.langcode.guide.button.material", buttons, showItems);
}

// Funciones individuales
function showBatFang(player) {
    showItemDetails(player, "item.dungeon.bat_fang.name", "dungeon.langcode.guide.button.crimson_sap.description", showMaterial);
}
function showBone(player) {
    showItemDetails(player, "item.dungeon.bone.name", "dungeon.langcode.guide.button.bone.description", showMaterial);
}
function showCarnivorousPlantLeaf(player) {
    showItemDetails(player, "item.dungeon.carnivorous_plant_leaf.name", "dungeon.langcode.guide.button.carnivorous_plant_leaf.description", showMaterial);
}
function showCelestialCloud(player) {
    showItemDetails(player, "item.dungeon.celestial_cloud.name", "dungeon.langcode.guide.button.celestial_cloud.description", showMaterial);
}
function showCelestialStormCloud(player) {
    showItemDetails(player, "item.dungeon.celestial_storm_cloud.name", "dungeon.langcode.guide.button.celestial_storm_cloud.description", showMaterial);
}
function showCursedPurple(player) {
    showItemDetails(player, "item.dungeon.cursed_purple.name", "dungeon.langcode.guide.button.cursed_purple.description", showMaterial);
}
function showChitin(player) {
    showItemDetails(player, "item.dungeon.chitin.name", "dungeon.langcode.guide.button.chitinitem.description", showMaterial);
}
function showCrimsonSap(player) {
    showItemDetails(player, "item.dungeon.crimson_sap.name", "dungeon.langcode.guide.button.crimson_sap.description", showMaterial);
}
function showDarkMaterial(player) {
    showItemDetails(player, "item.dungeon.dark_material.name", "dungeon.langcode.guide.button.dark_material.description", showMaterial);
}
function showGreenChitin(player) {
    showItemDetails(player, "item.dungeon.green_chitin.name", "dungeon.langcode.guide.button.green_chitin.description", showMaterial);
}
function showMothPowder(player) {
    showItemDetails(player, "item.dungeon.moth_powder.name", "dungeon.langcode.guide.button.moth_powder.description", showMaterial);
}
function showMothSilk(player) {
    showItemDetails(player, "item.dungeon.moth_silk.name", "dungeon.langcode.guide.button.moth_silk.description", showMaterial);
}
function showSilk(player) {
    showItemDetails(player, "item.dungeon.silk.name", "dungeon.langcode.guide.button.silk.description", showMaterial);
}
function showHalfHeart(player) {
    showItemDetails(player, "item.dungeon.half_heart.name", "dungeon.langcode.guide.button.half_heart.description", showMaterial);
}
function showLunarEssence(player) {
    showItemDetails(player, "item.dungeon.lunar_essence.name", "dungeon.langcode.guide.button.lunar_essence.description", showMaterial);
}
function showNatureEssence(player) {
    showItemDetails(player, "item.dungeon.nature_essence.name", "dungeon.langcode.guide.button.nature_essence.description", showMaterial);
}
function showPoison(player) {
    showItemDetails(player, "item.dungeon.poison.name", "dungeon.langcode.guide.button.poison.description", showMaterial);
}
function showPoisonMushroom(player) {
    showItemDetails(player, "item.dungeon.poison_mushroom.name", "dungeon.langcode.guide.button.poison_mushroom.description", showMaterial);
}
function showPurpleMaterial(player) {
    showItemDetails(player, "item.dungeon.purple_material.name", "dungeon.langcode.guide.button.purple_material.description", showMaterial);
}
function showPurpurSlimeball(player) {
    showItemDetails(player, "item.dungeon.purpur_slimeball.name", "dungeon.langcode.guide.button.purpur_slimeball.description", showMaterial);
}
function showRedSlimeball(player) {
    showItemDetails(player, "item.dungeon.red_slimeball.name", "dungeon.langcode.guide.button.red_slimeball.description", showMaterial);
}
function showRock(player) {
    showItemDetails(player, "item.dungeon.rock.name", "dungeon.langcode.guide.button.rock.description", showMaterial);
}
function showRockFragment(player) {
    showItemDetails(player, "item.dungeon.rock_fragment.name", "dungeon.langcode.guide.button.rock_fragment.description", showMaterial);
}
function showSkyEssence(player) {
    showItemDetails(player, "item.dungeon.sky_essence.name", "dungeon.langcode.guide.button.sky_essence.description", showMaterial);
}
function showSolidSlimeball(player) {
    showItemDetails(player, "item.dungeon.solid_slimeball.name", "dungeon.langcode.guide.button.solid_slimeball.description", showMaterial);
}
function showSuperHalfHeart(player) {
    showItemDetails(player, "item.dungeon.super_h_heart.name", "dungeon.langcode.guide.button.super_h_heart.description", showMaterial);
}
function showSuperStick(player) {
    showItemDetails(player, "item.dungeon.super_stick.name", "dungeon.langcode.guide.button.super_stick.description", showMaterial);
}
function showWitherBone(player) {
    showItemDetails(player, "item.dungeon.wither_bone.name", "dungeon.langcode.guide.button.wither_bone.description", showMaterial);
}
function showWitherBoneNormal(player) {
    showItemDetails(player, "item.dungeon.wither_bone_normal.name", "dungeon.langcode.guide.button.wither_bone_normal.description", showMaterial);
}
function showWitherBoneMeal(player) {
    showItemDetails(player, "item.dungeon.wither_bone_meal.name", "dungeon.langcode.guide.button.wither_bone_meal.description", showMaterial);
}
function showYellowSlimeBall(player) {
    showItemDetails(player, "item.dungeon.yellow_slimeball.name", "dungeon.langcode.guide.button.yellow_slimeball.description", showMaterial);
}

function showPotions(player) {
    const buttons = [
        ["item.dungeon.crimson_edge_potion.name", "textures/items/potions/crimson_edge_potion", showCrimsonEdgePotion],
        ["item.dungeon.haste_potion.name", "textures/items/haste_potion", showHastePotion],
        ["item.dungeon.haste_potion2.name", "textures/items/haste_potion2", showHastePotion2],
        ["item.dungeon.hunter_potion.name", "textures/items/potions/dhunter_potion", showHunterPotion],
        ["item.dungeon.dlevitation_potion.name", "textures/items/potions/dlevitation_potion", showLevitationPotion],
        ["item.dungeon.mining_fatigue_inmunity.name", "textures/items/mining_fatigue_inmunity", showFatigueInmunity],
        ["item.dungeon.poison_inmunity.name", "textures/items/poison_inmunity", showPoisonInmunity],
        ["item.dungeon.return_potion.name", "textures/items/potions/return_potion", showReturnPotion],
        ["item.dungeon.slowness_inmunity.name", "textures/items/slowness_inmunity", showSlownessInmunity],
        ["item.dungeon.teleport_potion.name", "textures/items/potions/teleport_potion", showTeleportPotion],
        ["item.dungeon.teleport_player_potion.name", "textures/items/teleport_player_potion", showTeleportPlayerPotion],
        ["item.dungeon.weakness_inmunity.name", "textures/items/weakness_inmunity", showWeaknessInmunity],
        ["item.dungeon.wither_inmunity.name", "textures/items/wither_inmunity", showWitherInmunity],
    ];
    showCategory(player, "dungeon.langcode.guide.button.potions", buttons, showItems);
}
function showCrimsonEdgePotion(player) {
    showItemDetails(player, "item.dungeon.crimson_edge_potion.name", "dungeon.langcode.guide.button.crimson_edge_potion.description", showPotions);
}
function showHastePotion(player) {
    showItemDetails(player, "item.dungeon.haste_potion.name", "dungeon.langcode.guide.button.haste_potion.description", showPotions);
}
function showHastePotion2(player) {
    showItemDetails(player, "item.dungeon.haste_potion2.name", "dungeon.langcode.guide.button.haste_potion2.description", showPotions);
}
function showHunterPotion(player) {
    showItemDetails(player, "item.dungeon.hunter_potion.name", "dungeon.langcode.guide.button.hunter_potion.description", showPotions);
}
function showLevitationPotion(player) {
    showItemDetails(player, "item.dungeon.dlevitation_potion.name", "dungeon.langcode.guide.button.levitation_potion.description", showPotions);
}
function showFatigueInmunity(player) {
    showItemDetails(player, "item.dungeon.mining_fatigue_inmunity.name", "dungeon.langcode.guide.button.inmunity_potion.description", showPotions);
}
function showPoisonInmunity(player) {
    showItemDetails(player, "item.dungeon.poison_inmunity.name", "dungeon.langcode.guide.button.inmunity_potion.description", showPotions);
}
function showReturnPotion(player) {
    showItemDetails(player, "item.dungeon.return_potion.name", "dungeon.langcode.guide.button.return_potion.description", showPotions);
}
function showSlownessInmunity(player) {
    showItemDetails(player, "item.dungeon.slowness_inmunity.name", "dungeon.langcode.guide.button.inmunity_potion.description", showPotions);
}
function showTeleportPotion(player) {
    showItemDetails(player, "item.dungeon.teleport_potion.name", "dungeon.langcode.guide.button.teleport_potion.description", showPotions);
}
function showTeleportPlayerPotion(player) {
    showItemDetails(player, "item.dungeon.teleport_player_potion.name", "dungeon.langcode.guide.button.teleport_player_potion.description", showPotions);
}
function showWeaknessInmunity(player) {
    showItemDetails(player, "item.dungeon.weakness_inmunity.name", "dungeon.langcode.guide.button.inmunity_potion.description", showPotions);
}
function showWitherInmunity(player) {
    showItemDetails(player, "item.dungeon.wither_inmunity.name", "dungeon.langcode.guide.button.inmunity_potion.description", showPotions);
}
function showWeaponsTools(player) {
    const buttons = [
        ["item.dungeon.ancient_copper_sword.name", "textures/items/sword/ancient_copper_sword", showCopperSword],
        ["item.dungeon.ancient_sword.name", "textures/items/ancient/dancient_sword", showAncientSword],
        ["item.dungeon.ancient_spider_staff.name", "textures/items/ancient/ancient_spider_staff", showAncientSpiderStaff],
        ["item.dungeon.bone_pickaxe.name", "textures/items/tools/bone_pickaxe", showBonePickaxe],
        ["item.dungeon.bone_dagger.name", "textures/items/dagger/bone_dagger", showBoneDagger],
        ["item.dungeon.tungsten_dagger.name", "textures/items/dagger/tungsten_dagger", showTungstenDagger],
        ["item.dungeon.staff_cloud.name", "textures/items/staff/cloud_staff", showCloudStaff],
        ["item.dungeon.cursed_sickle.name", "textures/items/weapons/cursed_sickle", showCursedSickle],
        ["item.dungeon.cobalt_hammer.name", "textures/items/hammers/cobalt_hammer", showCobaltHammer],
        ["item.dungeon.glimmerite_hammer.name", "textures/items/hammers/glimmerite_hammer", showGlimmeriteHammer],
        ["item.dungeon.glimmerite_pickaxe.name", "textures/items/cursed_pickaxe", showGlimmeritePickaxe],
        ["item.dungeon.hornet_staff.name", "textures/items/staff/hornet_staff", showHornetStaff],
        ["item.dungeon.jade_sword.name", "textures/items/jade_sword", showjadeSword],
        ["item.dungeon.luminarite_dagger.name", "textures/items/dagger/dvampiric_dagger", showLuminariteDagger],
        ["item.dungeon.lunar_sword.name", "textures/items/sword/lunar_sword", showMoonSword],
        ["item.dungeon.obsidian_sword.name", "textures/items/sword/dobsidian_sword", showObsiadianSword],
        ["item.dungeon.silver_sword.name", "textures/items/silver_sword", showSilverSword],
        ["item.dungeon.spider_fang.name", "textures/items/spider_fang", showSpiderFang],
        ["item.dungeon.spectrum_spike.name", "textures/items/weapons/spectrum_spike", showSpectrumSpike],
        ["item.dungeon.storm_sword.name", "textures/items/sword/dstorm_sword", showSpectrumSpike],
        ["item.dungeon.super_bone_sword.name", "textures/items/sword/super_bone_sword", showSuperBoneSword],
        ["item.dungeon.silvirum_pickaxe.name", "textures/items/silvirum_pickaxe", showSilvirumPickaxe],
        ["item.dungeon.titanium_sword.name", "textures/items/titanium_sword", showTitanitumSword],
        ["item.dungeon.tungsten_sword.name", "textures/items/tungsten_sword", showTungstenSword],
        ["item.dungeon.viritum_sword.name", "textures/items/viritum_sword", showViritumSword],
        ["item.dungeon.viritum_pickaxe.name", "textures/items/viritum_pickaxe", showViritumPickaxe],
        ["item.dungeon.wither_spike.name", "textures/items/weapons/wither_spike", showWitherSpike],
    ];
    showCategory(player, "dungeon.langcode.guide.button.weapons_and_tools", buttons, showItems);
}
function showCopperSword(player) {
    showItemDetails(player, "item.dungeon.ancient_copper_sword.name", "dungeon.langcode.guide.button.ancient_copper_sword.description", showWeaponsTools);
}
function showAncientSword(player) {
    showItemDetails(player, "item.dungeon.ancient_sword.name", "dungeon.langcode.guide.button.ancient_sword.description", showWeaponsTools);
}
function showAncientSpiderStaff(player) {
    showItemDetails(player, "item.dungeon.ancient_spider_staff.name", "dungeon.langcode.guide.button.ancient_sword.description", showWeaponsTools);
}
function showBonePickaxe(player) {
    showItemDetails(player, "item.dungeon.bone_pickaxe.name", "dungeon.langcode.guide.button.bone_pickaxe.description", showWeaponsTools);
}

function showBoneDagger(player) {
    showItemDetails(player, "item.dungeon.bone_dagger.name", "dungeon.langcode.guide.button.bone_dagger.description", showWeaponsTools);
}

function showTungstenDagger(player) {
    showItemDetails(player, "item.dungeon.tungsten_dagger.name", "dungeon.langcode.guide.button.tungsten_dagger.description", showWeaponsTools);
}

function showCloudStaff(player) {
    showItemDetails(player, "item.dungeon.staff_cloud.name", "dungeon.langcode.guide.button.cloud_staff.description", showWeaponsTools);
}

function showCursedSickle(player) {
    showItemDetails(player, "item.dungeon.cursed_sickle.name", "dungeon.langcode.guide.button.cursed_sickle.description", showWeaponsTools);
}
function showCobaltHammer(player) {
    showItemDetails(player, "item.dungeon.cobalt_hammer.name", "dungeon.langcode.guide.button.cobalt_hammer.description", showWeaponsTools);
}
function showGlimmeriteHammer(player) {
    showItemDetails(player, "item.dungeon.glimmerite_hammer.name", "dungeon.langcode.guide.button.glimmerite_hammer.description", showWeaponsTools);
}

function showGlimmeritePickaxe(player) {
    showItemDetails(player, "item.dungeon.glimmerite_pickaxe.name", "dungeon.langcode.guide.button.glimmerite_hammer.description", showWeaponsTools);
}

function showHornetStaff(player) {
    showItemDetails(player, "item.dungeon.hornet_staff.name", "dungeon.langcode.guide.button.hornet_staff.description", showWeaponsTools);
}

function showjadeSword(player) {
    showItemDetails(player, "item.dungeon.jade_sword.name", "dungeon.langcode.guide.button.jade_sword.description", showWeaponsTools);
}
function showLuminariteDagger(player) {
    showItemDetails(player, "item.dungeon.luminarite_dagger.name", "dungeon.langcode.guide.button.luminarite_dagger.description", showWeaponsTools);
}
function showMoonSword(player) {
    showItemDetails(player, "item.dungeon.moon_sword.name", "dungeon.langcode.guide.button.moon_sword.description", showWeaponsTools);
}

function showObsiadianSword(player) {
    showItemDetails(player, "item.dungeon.obsidian_sword.name", "dungeon.langcode.guide.button.obsidian_sword.description", showWeaponsTools);
}

function showSilverSword(player) {
    showItemDetails(player, "item.dungeon.silver_sword.name", "dungeon.langcode.guide.button.silver_sword.description", showWeaponsTools);
}

function showSpiderFang(player) {
    showItemDetails(player, "item.dungeon.spider_fang.name", "dungeon.langcode.guide.button.spider_fang.description", showWeaponsTools);
}

function showSpectrumSpike(player) {
    showItemDetails(player, "item.dungeon.spectrum_spike.name", "dungeon.langcode.guide.button.spectrum_spike.description", showWeaponsTools);
}

function showStormSword(player) {
    showItemDetails(player, "item.dungeon.storm_sword.name", "dungeon.langcode.guide.button.storm_sword.description", showWeaponsTools);
}

function showSuperBoneSword(player) {
    showItemDetails(player, "item.dungeon.super_bone_sword.name", "dungeon.langcode.guide.button.super_bone_sword.description", showWeaponsTools);
}

function showSilvirumPickaxe(player) {
    showItemDetails(player, "item.dungeon.silvirum_pickaxe.name", "dungeon.langcode.guide.button.silvirum_pickaxe.description", showWeaponsTools);
}

function showTitanitumSword(player) {
    showItemDetails(player, "item.dungeon.titanium_sword.name", "dungeon.langcode.guide.button.titanium_sword.description", showWeaponsTools);
}

function showTungstenSword(player) {
    showItemDetails(player, "item.dungeon.tungsten_sword.name", "dungeon.langcode.guide.button.tungsten_sword.description", showWeaponsTools);
}

function showViritumSword(player) {
    showItemDetails(player, "item.dungeon.viritum_sword.name", "dungeon.langcode.guide.button.viritum_sword.description", showWeaponsTools);
}

function showViritumPickaxe(player) {
    showItemDetails(player, "item.dungeon.viritum_pickaxe.name", "dungeon.langcode.guide.button.viritum_pickaxe.description", showWeaponsTools);
}

function showWitherSpike(player) {
    showItemDetails(player, "item.dungeon.wither_spike.name", "dungeon.langcode.guide.button.wither_spike.description", showWeaponsTools);
}

function showArmors(player) {
    const buttons = [
        ["dungeon.langcode.guide.button.wood", "textures/items/oak_chestplate", showWoodArmor],
        ["dungeon.langcode.guide.button.silver", "textures/items/silver_chestplate", showSilverArmor],
        ["dungeon.langcode.guide.button.cobalt", "textures/items/cobalt_chestplate", showCobaltArmor],
        ["dungeon.langcode.guide.button.chitin", "textures/items/chitin_chestplate", showChitinArmor],
        ["dungeon.langcode.guide.button.tungsten", "textures/items/tungsten_chestplate", showTungstenArmor],
        ["dungeon.langcode.guide.button.jade", "textures/items/jade_chestplate", showJadeArmor],
        ["dungeon.langcode.guide.button.glimmerita", "textures/items/glimmerite_chestplate", showGlimmeriteArmor],
        ["dungeon.langcode.guide.button.viritum", "textures/items/viritum_chestplate", showViritumArmor],
        ["dungeon.langcode.guide.button.titanium", "textures/items/titanium_chestplate", showTitaniumArmor],
        ["dungeon.langcode.guide.button.ancient", "textures/items/ancient/ancient_chestplate", showAncientarmor],
    ];
    showCategory(player, "dungeon.langcode.guide.button.weapons_and_tools", buttons, showItems);
}
function showWoodArmor(player) {
    showItemDetails(player, "dungeon.langcode.guide.button.wood", "dungeon.langcode.guide.button.wood.description", showArmors);
}

function showSilverArmor(player) {
    showItemDetails(player, "dungeon.langcode.guide.button.silver", "dungeon.langcode.guide.button.silver.description", showArmors);
}

function showCobaltArmor(player) {
    showItemDetails(player, "dungeon.langcode.guide.button.cobalt", "dungeon.langcode.guide.button.cobalt.description", showArmors);
}

function showChitinArmor(player) {
    showItemDetails(player, "dungeon.langcode.guide.button.chitin", "dungeon.langcode.guide.button.chitin.description", showArmors);
}

function showTungstenArmor(player) {
    showItemDetails(player, "dungeon.langcode.guide.button.tungsten", "dungeon.langcode.guide.button.tungsten.description", showArmors);
}

function showJadeArmor(player) {
    showItemDetails(player, "dungeon.langcode.guide.button.jade", "dungeon.langcode.guide.button.jade.description", showArmors);
}

function showGlimmeriteArmor(player) {
    showItemDetails(player, "dungeon.langcode.guide.button.glimmerita", "dungeon.langcode.guide.button.glimmerite.description", showArmors);
}

function showViritumArmor(player) {
    showItemDetails(player, "dungeon.langcode.guide.button.viritum", "dungeon.langcode.guide.button.viritum.description", showArmors);
}

function showTitaniumArmor(player) {
    showItemDetails(player, "dungeon.langcode.guide.button.tianium", "dungeon.langcode.guide.button.tianium.description", showArmors);
}
function showAncientarmor(player) {
    showItemDetails(player, "dungeon.langcode.guide.button.ancient", "dungeon.langcode.guide.button.ancient_sword.description", showArmors);
}
