@Override
  public void onPlayerEnter(Player player) {
    if (player.getVarBoolean("@received_navari_letter_6th")) return;

    // System.out.println("Player enter");
    if (checkStartCondition(player)) {
      // System.out.println("Player enter and fit quest condition");
      Quest q = QuestManager.getQuest(10779);
      player.processQuestEvent(q.getName(), "start_quest_delay", null);
    }
  }
  @Override
  public void onLevelChange(Player player, int oldLvl, int newLvl) {
    // System.out.println("level change oldLvl " + oldLvl + " newLvl " + newLvl +
    // "checkStartCondition " + checkStartCondition(player));
    if (oldLvl < minLevel && newLvl >= minLevel && checkStartCondition(player)) {
      // System.out.println("received_navari_letter_6th " +
      // player.getVarBoolean("@received_navari_letter_6th"));
      if (player.getVarBoolean("@received_navari_letter_6th")) return;

      Quest q = QuestManager.getQuest(10779);
      player.processQuestEvent(q.getName(), "start_quest", null);
    }
  }
  @Override
  public String onEvent(String event, QuestState st, NpcInstance npc) {
    Player player = st.getPlayer();
    if (player == null) return null;

    String htmltext = event;

    System.out.println("quest event " + event.toString());

    int classId = player.getClassId().getId();
    if (event.startsWith("UC")) {
      if (checkStartCondition(player)) {
        Quest q = QuestManager.getQuest(10779);
        player.processQuestEvent(q.getName(), "start_quest", null);
      }

      htmltext = "";
    }

    if (event.equalsIgnoreCase("start_quest") || event.equalsIgnoreCase("start_quest_7s")) {
      st.setCond(1);
      st.setState(STARTED);
      alertLetterReceived(st);
      st.showQuestHTML(st.getQuest(), "queen_letter.htm");

      htmltext = "";
    }

    if (event.equalsIgnoreCase("start_quest_delay")) {
      st.startQuestTimer("start_quest_7s", 7000);
      // only start quest after 7s to avoid crash on enterworld
      htmltext = "";
    }

    if (event.equalsIgnoreCase("Quest _10779_LetterFromTheQueen_SeaOfSpores to_oren")) {
      // System.out.println("in Quest _10779_LetterFromTheQueen_SeaOfSpores to_dion");
      if (st.getCond() == 1) {
        if (getItemCountById(player, SOE_OREN) > 0) {
          st.takeItems(SOE_OREN, 1);
          player.teleToLocation(83633, 53064, -1456);
          player.sendPacket(TutorialCloseHtmlPacket.STATIC);
        } else {
          player.sendMessage("Không tìm thấy Scroll of Escape: Town of Oren");
        }
      }
      htmltext = "";
    }
    // System.out.println("out " + event);
    if (event.equalsIgnoreCase("Quest _10779_LetterFromTheQueen_SeaOfSpores close_window")) {
      // System.out.println("in Quest _10779_LetterFromTheQueen_SeaOfSpores close_window");
      player.sendPacket(TutorialCloseHtmlPacket.STATIC);
      htmltext = "";
    }

    // Question mark clicked
    if (event.startsWith("QM")) {
      int MarkId = Integer.valueOf(event.substring(2));
      // System.out.println("Mark id " + MarkId);
      if (MarkId == 10779) {
        if (player.getRace() == Race.ERTHEIA) st.showQuestHTML(st.getQuest(), "queen_letter.htm");
        htmltext = "";
      }
    }

    if (event.equalsIgnoreCase("30191-3.htm")) {
      st.giveItems(SOE_SEA_OF_SPORES, 1);
      st.setCond(2);

      htmltext = "30191-3.htm";
    }

    if (event.equalsIgnoreCase("33845-2.htm")) {
      st.giveItems(STEEL_DOOR_COIN, 37, true);
      st.giveItems(SCROLL_EWB, 3, true);
      st.addExpAndSp(635250, 152);
      st.setState(COMPLETED);
      st.exitCurrentQuest(false);
      st.playSound(SOUND_FINISH);
      st.getPlayer()
          .sendPacket(
              new ExShowScreenMessage(
                  NEXT_LETTER_STRING,
                  7000,
                  ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER,
                  true));

      htmltext = "33845-2.htm";
    }

    if (htmltext.isEmpty()) return null;
    else return htmltext;
  }