import { ActionFormData, MessageFormData, ModalFormData } from "@minecraft/server-ui";
import { world, system } from "@minecraft/server"
import { obtainquest } from "./obtainquestfunction.js"

//initiate form
world.afterEvents.itemUse.subscribe(event => {
  if (event.itemStack.typeId === "redstone:legendary_quest") {
    const player = event.source
    //form code
    let form = new ActionFormData();
    form.title("§gLegendary Quest Scroll");
    form.body("§gLegendary Quests, §foften requiring you to find easter eggs or obtain exeedingly rare items, giving you god-like items.");
    form.button("§lI Would Never", "textures/items/legendary_quest")
    form.button("§l§cINSANE - §l§dMiner VII", "textures/items/netherite_pickaxe")

    //form button effects
    form.show(player).then(r => {
      if (r.canceled) return;

      let response = r.selection;
      switch (response) {
        case 0:
          obtainquest(1, 1, 1, 1, 1, 1, player, true, true)
          break;

        case 1:
          obtainquest("§l§cINSANE - §1§dMiner VII", "Gather 64 ancient debris, truly become rich", "minecraft:ancient_debris", 64, "redstone:bane_of_embers", 1, player, true, true)
          break;

        case 2:

          break;
        case 3:


        default:
      }
    }).catch(e => {
      console.error(e, e.stack);
    });
  };
});

