@Override
  public boolean onDialogEvent(QuestCookie env) {
    final Player player = env.getPlayer();
    int targetId = 0;

    if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
    final QuestState qs = player.getQuestStateList().getQuestState(questId);
    if (targetId == 799523) {
      if (qs == null || qs.getStatus() == QuestStatus.NONE) {
        if (env.getDialogId() == 26) return sendQuestDialog(env, 1011);
        else return defaultQuestStartDialog(env);
      }
    } else if (targetId == 798029) {
      if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 0) {
        if (env.getDialogId() == 26) return sendQuestDialog(env, 2375);
        else if (env.getDialogId() == 34) {
          if (QuestService.collectItemCheck(env, true)) {
            qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
            qs.setStatus(QuestStatus.REWARD);
            updateQuestStatus(env);
            return sendQuestDialog(env, 5);
          } else return sendQuestDialog(env, 2716);
        } else return defaultQuestStartDialog(env);
      } else if (qs != null && qs.getStatus() == QuestStatus.REWARD)
        return defaultQuestEndDialog(env);
    } else if (targetId == 700853) {
      if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 0) {
        if (env.getDialogId() == -1
            && (player.getInventory().getItemCountByItemId(185000103) > 0
                && player.getInventory().getItemCountByItemId(185000107) >= 3)) {
          if (!ItemService.addItems(
              player, Collections.singletonList(new QuestItems(182212020, 1)))) return true;
          final int targetObjectId = env.getVisibleObject().getObjectId();
          PacketSendUtility.sendPacket(
              player, new SM_USE_OBJECT(player.getObjectId(), targetObjectId, 3000, 0));
          PacketSendUtility.broadcastPacket(
              player, new SM_EMOTION(player, EmotionType.START_LOOT, 0, targetObjectId), true);
          player.getInventory().removeFromBagByItemId(185000103, 1);
          player.getInventory().removeFromBagByItemId(185000107, 3);
        }
      }
    }

    return false;
  }
  @Override
  public boolean onDialogEvent(QuestCookie env) {
    final Player player = env.getPlayer();
    final QuestState qs = player.getQuestStateList().getQuestState(questId);
    if (qs == null) return false;

    int var = qs.getQuestVarById(0);
    int targetId = 0;
    if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();

    if (qs.getStatus() == QuestStatus.REWARD) {
      if (targetId == 799226) {
        if (env.getDialogId() == -1) return sendQuestDialog(env, 10002);
        else if (env.getDialogId() == 1009) return sendQuestDialog(env, 5);
        else return defaultQuestEndDialog(env);
      }
      return false;
    } else if (qs.getStatus() != QuestStatus.START) {
      return false;
    }
    if (targetId == 799226) {
      switch (env.getDialogId()) {
        case 26:
          if (var == 0) return sendQuestDialog(env, 1011);
          else if (var == 3) return sendQuestDialog(env, 2034);
        case 10000:
          if (var == 0) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
        case 10003:
          if (var == 3) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
      }
    } else if (targetId == 799292) {
      switch (env.getDialogId()) {
        case 26:
          if (var == 1) return sendQuestDialog(env, 1352);
          else if (var == 2) return sendQuestDialog(env, 1693);
          else if (var == 5) return sendQuestDialog(env, 2716);
          else if (var == 11) return sendQuestDialog(env, 1608);
          break;
        case 34:
          if (QuestService.collectItemCheck(env, true)) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          } else return sendQuestDialog(env, 10001);
        case 10001:
          if (var == 1) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
        case 10005:
          if (var == 5) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
        case 10255:
          if (var == 11) {
            qs.setStatus(QuestStatus.REWARD);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
      }
    } else if (targetId == 700810) {
      if (var == 2) return true;
    } else if (targetId == 204057) {
      switch (env.getDialogId()) {
        case 26:
          if (var == 4) return sendQuestDialog(env, 2375);
        case 10004:
          if (var == 4) {
            if (!ItemService.addItems(
                player, Collections.singletonList(new QuestItems(182207611, 1)))) return true;
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
      }
    } else if (targetId == 799341) {
      switch (env.getDialogId()) {
        case 26:
          if (var == 9) return sendQuestDialog(env, 4080);
        case 10009:
          if (var == 9) {
            if (!ItemService.addItems(
                player, Collections.singletonList(new QuestItems(182207613, 1)))) return true;
            player.getInventory().removeFromBagByItemId(182207611, 1);
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
      }
    } else if (targetId == 799513
        || targetId == 799514
        || targetId == 799515
        || targetId == 799516) // FIXME: Var !
    {
      switch (env.getDialogId()) {
        case 26:
          if (var == 7) return sendQuestDialog(env, 4080);
        case 10009:
          if (var == 7) {
            PacketSendUtility.sendPacket(player, new SM_PLAY_MOVIE(0, 442));
            qs.setQuestVar(8);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
      }
    } else if (targetId == 730243) {
      switch (env.getDialogId()) {
        case -1:
          if (var >= 6) return sendQuestDialog(env, 3057);
          break;
        case 26:
          if (var == 6) return sendQuestDialog(env, 3057);
          break;
        case 10006:
          if (var == 6) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(env);
            WorldMapInstance newInstance = InstanceService.getNextAvailableInstance(300150000);
            InstanceService.registerPlayerWithInstance(newInstance, player);
            TeleportService.teleportTo(
                player,
                300150000,
                newInstance.getInstanceId(),
                561.8651f,
                221.91483f,
                134.53333f,
                (byte) 90);
            return true;
          } else if (var > 6) {
            WorldMapInstance newInstance = InstanceService.getNextAvailableInstance(300150000);
            InstanceService.registerPlayerWithInstance(newInstance, player);
            TeleportService.teleportTo(
                player,
                300150000,
                newInstance.getInstanceId(),
                561.8651f,
                221.91483f,
                134.53333f,
                (byte) 90);
            return true;
          }
      }
    } else if (targetId == 700706) {
      switch (env.getDialogId()) {
        case -1:
          if (var == 10) {
            final int targetObjectId = env.getVisibleObject().getObjectId();
            PacketSendUtility.sendPacket(
                player, new SM_USE_OBJECT(player.getObjectId(), targetObjectId, 3000, 0));
            PacketSendUtility.broadcastPacket(
                player, new SM_EMOTION(player, EmotionType.START_LOOT, 0, targetObjectId), true);
            qs.setQuestVar(11);
            updateQuestStatus(env);
            TeleportService.teleportTo(
                player, 300150000, 561.8651f, 221.91483f, 134.53333f, (byte) 90);
          }
      }
    }

    return false;
  }
 @Override
 public boolean onDialogEvent(QuestCookie env) {
   final Player player = env.getPlayer();
   int targetId = 0;
   if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
   QuestState qs = player.getQuestStateList().getQuestState(questId);
   if (qs == null || qs.getStatus() == QuestStatus.NONE) {
     if (targetId == 799340) // Athana
     {
       switch (env.getDialogId()) {
         case 26:
           return sendQuestDialog(env, 4762);
         case 1007:
           return sendQuestDialog(env, 4);
         case 1002:
           if (!ItemService.addItems(
               player, Collections.singletonList(new QuestItems(182207932, 1))))
             ; // Piece Of Zikel
           if (QuestService.startQuest(env, QuestStatus.START)) return sendQuestDialog(env, 1003);
           else return false;
         case 1003:
           return sendQuestDialog(env, 1004);
       }
     }
   }
   if (qs == null || qs.getStatus() == QuestStatus.COMPLETE) {
     if (targetId == 798317) // Usener
     {
       if (env.getDialogId() == 26) {
         return sendQuestDialog(env, 1352);
       } else return defaultQuestStartDialog(env);
     }
   }
   if (qs.getStatus() == QuestStatus.START) {
     switch (targetId) {
         // Usener
       case 798317:
         switch (env.getDialogId()) {
             // Get HACTION_QUEST_SELECT in the eddit-HyperLinks.xml
           case 26:
             // Send select1 to eddit-HtmlPages.xml
             return sendQuestDialog(env, 2375);
           case 2034:
             // Send select2 to eddit-HtmlPages.xml
             return sendQuestDialog(env, 2034);
             // Get HACTION_CHECK_USER_HAS_QUEST_ITEM in the eddit-HyperLinks.xml
           case 34:
             // Piece Of Zikel (1)
             // Athana's Dagger (1)
             // Kinah (8000000)
             if (QuestService.collectItemCheck(env, true)) {
               player.getInventory().removeFromBagByItemId(182207932, 1); // Piece Of Zikel
               player.getInventory().removeFromBagByItemId(100200845, 1); // Athana's Dagger
               player.getInventory().removeFromBagByItemId(182400001, 8000000); // Kinah
               qs.setStatus(QuestStatus.REWARD);
               updateQuestStatus(env);
               return sendQuestDialog(env, 5);
             } else {
               //
               return sendQuestDialog(env, 2716);
             }
         }
         break;
         // No match
       default:
         return defaultQuestStartDialog(env);
     }
   } else if (qs.getStatus() == QuestStatus.REWARD) {
     if (targetId == 798317) // Usener
     return defaultQuestEndDialog(env);
   }
   return false;
 }