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:hard_quest") {
    const player = event.source
    //form code
    let form = new ActionFormData();
    form.title("§c§6Hard Quest Scroll");
    form.body("§cHard Quests, §foften requiring you to kill minibosses or obtain extremely rare items, giving you end-game items.");
    form.button("§lJungle Quest I", "textures/items/vine_blade");

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

      let response = r.selection;
      switch (response) {
        case 0:
          obtainquest("§lRuby Collector", "Aquire 64 rubies! §lReward: Diamond x8", "")
          break;

        case 1:

          break;

        case 2:

          break;
        case 3:


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

