@Override
 public void QuestUseNpcInsideFunction(QuestCookie env) {
   Player player = env.getPlayer();
   if (env.getTargetId() == 700368)
     TeleportService.teleportTo(player, 320090000, 1, 276, 293, 163, (byte) 90, 500);
   else if (env.getTargetId() == 700369)
     TeleportService.teleportTo(player, 120010000, 1, 982, 1556, 210, (byte) 90, 500);
 }
 private void transfer(Player player, WorldMapInstance worldmapinstance) {
   TeleportService.teleportTo(
       player,
       WorldMapType.IDDRAMATA_01.getId(),
       worldmapinstance.getInstanceId(),
       369.41263F,
       528.68994F,
       67.28671F,
       0);
 }
  @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 == 798927) {
        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.COMPLETE) {
      if (targetId == 799022) {
        if (env.getDialogId() == -1) return sendQuestDialog(env, 2376);
        else if (env.getDialogId() == 10004) {
          if (player.getPlayerGroup() == null) {
            WorldMapTemplate world = DataManager.WORLD_MAPS_DATA.getTemplate(300190000);
            int mapname = DataManager.WORLD_MAPS_DATA.getTemplate(300190000).getMapNameId();
            if (!InstanceService.canEnterInstance(player, world.getInstanceMapId(), 0)) {
              int timeinMinutes =
                  InstanceService.getTimeInfo(player).get(world.getInstanceMapId()) / 60;
              if (timeinMinutes >= 60)
                PacketSendUtility.sendPacket(
                    player,
                    SM_SYSTEM_MESSAGE.STR_MSG_CANNOT_ENTER_INSTANCE_COOL_TIME_HOUR(
                        mapname, timeinMinutes / 60));
              else
                PacketSendUtility.sendPacket(
                    player,
                    SM_SYSTEM_MESSAGE.STR_MSG_CANNOT_ENTER_INSTANCE_COOL_TIME_MIN(
                        mapname, timeinMinutes));

              return false;
            }
            if (!hasItem(player, 182206627)) {
              if (!ItemService.addItems(
                  player, Collections.singletonList(new QuestItems(182206627, 1)))) return true;
            }
            if (!hasItem(player, 182206628)) {
              if (!ItemService.addItems(
                  player, Collections.singletonList(new QuestItems(182206628, 1)))) return true;
            }
            WorldMapInstance newInstance = InstanceService.getNextAvailableInstance(300190000);
            InstanceService.registerPlayerWithInstance(newInstance, player);
            TeleportService.teleportTo(
                player,
                300190000,
                newInstance.getInstanceId(),
                198.82353f,
                221.40387f,
                1098.4879f,
                (byte) 41);
            PortalController.setInstanceCooldown(player, 300190000, newInstance.getInstanceId());
            return true;
          } else return sendQuestDialog(env, 2546);
        } else return defaultQuestStartDialog(env);
      } else if (targetId == 799503) {
        switch (env.getDialogId()) {
          case 26:
            if (var == 1) return sendQuestDialog(env, 4080);
          case 1013:
          case 10000:
            if (var == 1) {
              PacketSendUtility.sendPacket(
                  player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 0));
              TeleportService.teleportTo(
                  player, 210050000, 2888.9226f, 359.70108f, 298.73184f, (byte) 56);
              return true;
            }
        }
      }
    } else if (qs.getStatus() != QuestStatus.START) {
      return false;
    }
    if (targetId == 798927) // Versetti
    {
      switch (env.getDialogId()) {
        case 26:
          if (var == 0) return sendQuestDialog(env, 1011);
        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;
          }
      }
    } else if (targetId == 798954) // Tialla
    {
      switch (env.getDialogId()) {
        case 26:
          if (var == 1) return sendQuestDialog(env, 1352);
          else if (var == 8) return sendQuestDialog(env, 3057);
        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 10255:
          if (var == 8) {
            qs.setQuestVarById(0, 11);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
      }
    } else if (targetId == 799022) // Lothas
    {
      switch (env.getDialogId()) {
        case -1:
          if (var == 2) return sendQuestDialog(env, 1779);
          else if (var > 2 && var < 3) return sendQuestDialog(env, 2461);
          break;
        case 26:
          if (var == 3) {
            if (qs.getQuestVarById(1) == 0) return sendQuestDialog(env, 1693);
            else return sendQuestDialog(env, 2375);
          } else if (var == 7) {
            if (player.getInventory().getItemCountByItemId(182206602) == 0)
              return sendQuestDialog(env, 2461);
            else return sendQuestDialog(env, 2716);
          } else if (var == 14) return sendQuestDialog(env, 4336);
        case 10002:
          if (var == 14) {
            qs.setStatus(QuestStatus.REWARD);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
        case 10003:
          if (var == 2) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(env);
          }
          PacketSendUtility.sendPacket(
              player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
          return true;
        case 10004:
          if (var == 3 || var < 7) {
            if (player.getPlayerGroup() == null) {
              if (!hasItem(player, 182206627)) {
                if (!ItemService.addItems(
                    player, Collections.singletonList(new QuestItems(182206627, 1)))) return true;
              }
              if (!hasItem(player, 182206628)) {
                if (!ItemService.addItems(
                    player, Collections.singletonList(new QuestItems(182206628, 1)))) return true;
              }
              if (var < 7) {
                qs.setQuestVarById(1, 0); // clear killed Brohums
                qs.setQuestVarById(2, 0); // clear used Tears
                qs.setQuestVarById(0, 5);
                updateQuestStatus(env);
              }
              WorldMapInstance newInstance = InstanceService.getNextAvailableInstance(300190000);
              InstanceService.registerPlayerWithInstance(newInstance, player);
              TeleportService.teleportTo(
                  player,
                  300190000,
                  newInstance.getInstanceId(),
                  198.82353f,
                  221.40387f,
                  1098.4879f,
                  (byte) 41);
              return true;
            } else return sendQuestDialog(env, 2546);
          }
        case 34:
          if (var == 7) {
            if (QuestService.collectItemCheck(env, true)) {
              long itemCount = player.getInventory().getItemCountByItemId(164000099);
              player.getInventory().removeFromBagByItemId(164000099, itemCount);
              qs.setQuestVarById(0, var + 1);
              updateQuestStatus(env);
              PacketSendUtility.sendPacket(
                  player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
              return sendQuestDialog(env, 10000);
            } else return sendQuestDialog(env, 10001);
          }
      }
    } else if (targetId == 730008 && var == 11) // Daminu
    {
      switch (env.getDialogId()) {
        case 26:
          return sendQuestDialog(env, 3398);
        case 10007:
          qs.setQuestVarById(0, var + 1);
          updateQuestStatus(env);
          PacketSendUtility.sendPacket(
              player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
          return true;
      }
    } else if (targetId == 730019 && var == 12) // Lodas
    {
      switch (env.getDialogId()) {
        case 26:
          return sendQuestDialog(env, 3739);
        case 10008:
          qs.setQuestVarById(0, var + 1);
          updateQuestStatus(env);
          PacketSendUtility.sendPacket(
              player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
          return true;
      }
    } else if (targetId == 730024 && var == 13) // Trajanus
    {
      switch (env.getDialogId()) {
        case 26:
          return sendQuestDialog(env, 4080);
        case 10009:
          qs.setQuestVarById(0, var + 1);
          updateQuestStatus(env);
          PacketSendUtility.sendPacket(
              player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
          return true;
      }
    }

    return false;
  }
  @Override
  public boolean onDialogEvent(QuestCookie env) {
    if (!super.defaultQuestOnDialogInitStart(env)) return false;

    Player player = env.getPlayer();
    QuestState qs = player.getQuestStateList().getQuestState(questId);
    int var = qs.getQuestVarById(0);

    if (qs.getStatus() == QuestStatus.START) {
      switch (env.getTargetId()) {
        case 204053:
          {
            switch (env.getDialogId()) {
              case 26:
                if (var == 0) return sendQuestDialog(env, 1011);
              case 10010:
                return defaultCloseDialog(env, 0, 1);
              case 10011:
                return defaultCloseDialog(env, 0, 4);
              case 10012:
                return defaultCloseDialog(env, 0, 9);
              case 34:
                if (var == 1 || var == 4 || var == 9) {
                  qs.setQuestVarById(0, 0);
                  updateQuestStatus(env);
                  return sendQuestDialog(env, 2375);
                }
            }
          }
          break;
        case 204301:
          {
            switch (env.getDialogId()) {
              case 26:
                if (var == 1) return sendQuestDialog(env, 1352);
                else if (var == 2) return sendQuestDialog(env, 3398);
                else if (var == 7) return sendQuestDialog(env, 3739);
                else return defaultQuestItemCheck(env, 9, 0, true, 7, 4080);
              case 10001:
                return defaultCloseDialog(env, 1, 2);
              case 1009:
                if (var == 2) {
                  qs.setStatus(QuestStatus.REWARD);
                  updateQuestStatus(env);
                  return sendQuestDialog(env, 5);
                }
                if (var == 7) {
                  qs.setStatus(QuestStatus.REWARD);
                  updateQuestStatus(env);
                  return sendQuestDialog(env, 6);
                }
            }
          }
          break;
        case 204089:
          {
            switch (env.getDialogId()) {
              case 26:
                if (var == 4) return sendQuestDialog(env, 1693);
                else if (var == 5) return sendQuestDialog(env, 2034);
              case 10002:
                if (defaultCloseDialog(env, 4, 5)) {
                  TeleportService.teleportTo(player, 320090000, 1, 276, 293, 163, (byte) 90, 500);
                  return true;
                } else return false;
              case 10003:
                if (var == 5) {
                  qs.setQuestVarById(0, 7);
                  updateQuestStatus(env);
                  PacketSendUtility.sendPacket(
                      player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 0));
                  return true;
                } else return false;
            }
          }
          break;
        case 700368:
        case 700369:
          if (env.getDialogId() == -1)
            return (defaultQuestUseNpc(
                env, 5, 6, EmotionType.NEUTRALMODE2, EmotionType.START_LOOT, false));
          break;
        case 700268:
          if (env.getDialogId() == -1)
            return (defaultQuestUseNpc(
                env, 9, 10, EmotionType.NEUTRALMODE2, EmotionType.START_LOOT, true));
          break;
      }
    } else if (qs.getStatus() == QuestStatus.REWARD) {
      if (var == 2) return defaultQuestRewardDialog(env, 204301, 3739);
      else if (var == 7) return defaultQuestRewardDialog(env, 204301, 3739, 1);
      else if (var == 9) return defaultQuestRewardDialog(env, 204301, 3739, 2);
    }
    return false;
  }
  /** Handle dialog */
  @Override
  public void onDialogSelect(int dialogId, final Player player, int questId) {

    Npc npc = getOwner();
    int targetObjectId = npc.getObjectId();

    if (QuestEngine.getInstance().onDialog(new QuestCookie(npc, player, questId, dialogId))) return;

    switch (dialogId) {
      case 2:
        PacketSendUtility.sendPacket(
            player,
            new SM_TRADELIST(
                npc,
                TradeService.getTradeListData().getTradeListTemplate(npc.getNpcId()),
                player.getPrices().getVendorBuyModifier(),
                player));
        break;
      case 3:
        PacketSendUtility.sendPacket(
            player,
            new SM_SELL_ITEM(
                targetObjectId,
                player.getPrices().getVendorSellModifier(player.getCommonData().getRace())));
        break;
      case 4:
        // stigma
        PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(targetObjectId, 1));
        break;
      case 5:
        // create legion
        if (MathUtil.isInRange(
            npc, player, 10)) // avoiding exploit with sending fake dialog_select packet
        {
          PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(targetObjectId, 2));
        } else {
          PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.LEGION_CREATE_TOO_FAR_FROM_NPC());
        }
        break;
      case 6:
        // disband legion
        if (MathUtil.isInRange(
            npc, player, 10)) // avoiding exploit with sending fake dialog_select packet
        {
          LegionService.getInstance().requestDisbandLegion(npc, player);
        } else {
          PacketSendUtility.sendPacket(
              player, SM_SYSTEM_MESSAGE.LEGION_DISPERSE_TOO_FAR_FROM_NPC());
        }
        break;
      case 7:
        // recreate legion
        if (MathUtil.isInRange(
            npc, player, 10)) // voiding exploit with sending fake client dialog_select
        // packet
        {
          LegionService.getInstance().recreateLegion(npc, player);
        } else {
          PacketSendUtility.sendPacket(
              player, SM_SYSTEM_MESSAGE.LEGION_DISPERSE_TOO_FAR_FROM_NPC());
        }
        break;
      case 20:
        // warehouse
        if (MathUtil.isInRange(
            npc, player, 10)) // voiding exploit with sending fake client dialog_select
        // packet
        {
          if (!RestrictionsManager.canUseWarehouse(player)) return;

          PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(targetObjectId, 26));
          WarehouseService.sendWarehouseInfo(player, true);
        }
        break;
      case 25:
        // TODO hotfix to prevent opening the legion wh when a quest returns false.
        break;
      case 27:
        // Consign trade?? npc karinerk, koorunerk
        PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(targetObjectId, 13));
        break;
      case 29:
        // soul healing
        final long expLost = player.getCommonData().getExpRecoverable();
        if (expLost == 0) player.getEffectController().removeEffect(8291);
        final double factor = (expLost < 1000000 ? 0.25 - (0.00000015 * expLost) : 0.1);
        final int price = (int) (expLost * factor * CustomConfig.SOULHEALING_PRICE_MULTIPLIER);

        RequestResponseHandler responseHandler =
            new RequestResponseHandler(npc) {
              @Override
              public void acceptRequest(Creature requester, Player responder) {
                if (player.getInventory().getKinahItem().getItemCount() >= price) {
                  PacketSendUtility.sendPacket(
                      player, SM_SYSTEM_MESSAGE.EXP(String.valueOf(expLost)));
                  PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.SOUL_HEALED());
                  player.getCommonData().resetRecoverableExp();
                  player.getInventory().decreaseKinah(price);
                  player.getEffectController().removeEffect(8291);
                } else {
                  PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.NOT_ENOUGH_KINAH(price));
                }
              }

              @Override
              public void denyRequest(Creature requester, Player responder) {
                // no message
              }
            };
        if (player.getCommonData().getExpRecoverable() > 0) {
          boolean result =
              player
                  .getResponseRequester()
                  .putRequest(SM_QUESTION_WINDOW.STR_SOUL_HEALING, responseHandler);
          if (result) {
            PacketSendUtility.sendPacket(
                player,
                new SM_QUESTION_WINDOW(
                    SM_QUESTION_WINDOW.STR_SOUL_HEALING, 0, String.valueOf(price)));
          }
        } else {
          PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.DONT_HAVE_RECOVERED_EXP());
        }
        break;
      case 30:
        switch (npc.getNpcId()) {
            // Triniel Arena (Enter)
          case 204089:
            TeleportService.teleportTo(player, 120010000, 1, 984f, 1543f, 222.1f, 0);
            ArenaService.getInstance().registerPlayerForTriniel(player);
            break;
            // Coliseum (Enter)
          case 203764:
            TeleportService.teleportTo(player, 110010000, 1, 1462.5f, 1326.1f, 564.1f, 0);
            ArenaService.getInstance().registerPlayerForColiseum(player);
            break;
            // Eracus Temple (Enter)
          case 203981:
            TeleportService.teleportTo(player, 210020000, 1, 439.3f, 422.2f, 274.3f, 0);
            break;
        }
        break;
      case 31:
        switch (npc.getNpcId()) {
            // Triniel Arena (Leave)
          case 204087:
            TeleportService.teleportTo(player, 120010000, 1, 1005.1f, 1528.9f, 222.1f, 0);
            ArenaService.getInstance().unregister(player);
            break;
            // Coliseum (Leave)
          case 203875:
            TeleportService.teleportTo(player, 110010000, 1, 1470.3f, 1343.5f, 563.7f, 21);
            ArenaService.getInstance().unregister(player);
            break;
            // Eracus Temple (Leave)
          case 203982:
            TeleportService.teleportTo(player, 210020000, 1, 446.2f, 431.1f, 274.5f, 0);
            break;
        }
        break;
      case 35:
        // Godstone socketing
        PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(targetObjectId, 21));
        break;
      case 36:
        // remove mana stone
        PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(targetObjectId, 20));
        break;
      case 37:
        // modify appearance
        PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(targetObjectId, 19));
        break;
      case 38:
        // flight and teleport
        TeleportService.showMap(player, targetObjectId, npc.getNpcId());
        break;
      case 39:
        // improve extraction
      case 40:
        // learn tailoring armor smithing etc...
        CraftSkillUpdateService.getInstance().learnSkill(player, npc);
        break;
      case 41:
        // expand cube
        CubeExpandService.expandCube(player, npc);
        break;
      case 42:
        WarehouseService.expandWarehouse(player, npc);
        break;
      case 47:
        // legion warehouse
        if (LegionConfig.LEGION_WAREHOUSE)
          if (MathUtil.isInRange(npc, player, 10))
            LegionService.getInstance().openLegionWarehouse(player);
        break;
      case 50:
        // WTF??? Quest dialog packet
        break;
      case 52:
        if (MathUtil.isInRange(
            npc, player, 10)) // avoiding exploit with sending fake dialog_select packet
        {
          PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(targetObjectId, 28));
        }
        break;
      case 53:
        // coin reward
        PacketSendUtility.sendPacket(
            player,
            new SM_MESSAGE(0, null, "This feature is not available yet", ChatType.ANNOUNCEMENTS));
        break;
      case 55:
      case 56:
        byte changesex = 0; // 0 plastic surgery, 1 gender switch
        byte check_ticket = 2; // 2 no ticket, 1 have ticket
        if (dialogId == 56) {
          // Gender Switch
          changesex = 1;
          if (player.getInventory().getItemCountByItemId(169660000) > 0
              || player.getInventory().getItemCountByItemId(169660001) > 0) check_ticket = 1;
        } else {
          // Plastic Surgery
          if (player.getInventory().getItemCountByItemId(169650000) > 0
              || player.getInventory().getItemCountByItemId(169650001) > 0) check_ticket = 1;
        }
        PacketSendUtility.sendPacket(
            player, new SM_PLASTIC_SURGERY(player, check_ticket, changesex));
        player.setEditMode(true);
        break;
      case 60:
        // armsfusion
        PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(targetObjectId, 29));
        break;
      case 61:
        // armsbreaking
        PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(targetObjectId, 30));
        break;
      case 64:
        // repurchase
        PacketSendUtility.sendPacket(player, new SM_REPURCHASE(npc, player));
        break;
      case 65:
        // adopt pet
        PacketSendUtility.sendPacket(player, new SM_PET(6));
        break;
      case 66:
        // surrender pet
        PacketSendUtility.sendPacket(player, new SM_PET(7));
        break;
      case 10000:
        // generic npc reply (most are teleporters)
        TeleporterTemplate template =
            DataManager.TELEPORTER_DATA.getTeleporterTemplate(npc.getNpcId());
        if (template != null) {
          TeleportLocation loc = template.getTeleLocIdData().getTelelocations().get(0);
          if (loc != null) {
            player.getInventory().decreaseKinah(loc.getPrice());
            TelelocationTemplate tlt =
                DataManager.TELELOCATION_DATA.getTelelocationTemplate(loc.getLocId());
            TeleportService.teleportTo(
                player, tlt.getMapId(), tlt.getX(), tlt.getY(), tlt.getZ(), 1000);
          }
        }
        break;
      default:
        if (questId > 0)
          PacketSendUtility.sendPacket(
              player, new SM_DIALOG_WINDOW(targetObjectId, dialogId, questId));
        else PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(targetObjectId, dialogId));
        break;
    }
  }
  @Override
  public void executeCommand(Player admin, String[] params) {
    String usage = "syntax; //ring <add (c|p1|p2)>|<save>|<next>";

    if (admin.getAccessLevel() < AdminConfig.COMMAND_RING) {
      PacketSendUtility.sendMessage(admin, "<You don't have the right to execute this command>");
    }

    if (params.length == 0) {
      PacketSendUtility.sendMessage(admin, usage);
      return;
    }

    if (params[0].equalsIgnoreCase("add")) {
      if (params.length < 2) {
        PacketSendUtility.sendMessage(admin, usage);
        return;
      }

      if (params[1].equalsIgnoreCase("c")) {
        if (params.length == 3 && params[2].equalsIgnoreCase("new")) {
          String newZoneName = admin.getZoneInstance().getTemplate().getName().name();
          if (zoneName != null && !zoneName.equalsIgnoreCase(newZoneName)) {
            zoneName = newZoneName;
          }
        }

        if (zoneName == null) {
          zoneName = admin.getZoneInstance().getTemplate().getName().name();
        }

        center = new Point3D(admin.getX(), admin.getY(), admin.getZ());
        ringId = nextIdForRegion(zoneName);
        ringName = zoneName + "_" + ringId;
        PacketSendUtility.sendMessage(admin, "Center for " + ringName + " added");
      }

      if (params[1].equalsIgnoreCase("p1")) {
        p1 = new Point3D(admin.getX(), admin.getY(), admin.getZ());
        PacketSendUtility.sendMessage(admin, "Point p1 for " + ringName + " added");
      }

      if (params[1].equalsIgnoreCase("p2")) {
        p2 = new Point3D(admin.getX(), admin.getY(), admin.getZ());
        PacketSendUtility.sendMessage(admin, "Point p2 for " + ringName + " added");
      }

      if (center != null && p1 != null && p2 != null) {
        rings
            .get(zoneName)
            .put(ringId, new FlyRingTemplate(ringName, admin.getWorldId(), center, p1, p2));
        center = null;
        p1 = null;
        p2 = null;
        PacketSendUtility.sendMessage(admin, "Added fly ring " + ringName + " !");
      }
      return;
    }

    if (params[0].equalsIgnoreCase("save")) {
      Schema schema = null;
      SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
      Logger log = Logger.getLogger(Ring.class);

      try {
        schema = sf.newSchema(new File("./data/static_data/fly_rings/fly_rings.xsd"));
      } catch (SAXException e1) {
        log.error("Error while saving data: " + e1.getMessage(), e1.getCause());
        PacketSendUtility.sendMessage(admin, "Unexpected error occured during saving");
        return;
      }

      File xml = new File("./data/static_data/fly_rings/generated_fly_rings.xml");
      JAXBContext jc;
      Marshaller marshaller;
      FlyRingData data = new FlyRingData();
      for (Map<Integer, FlyRingTemplate> e : rings.values()) {
        data.addAll(e.values());
      }
      try {
        jc = JAXBContext.newInstance(FlyRingData.class);
        marshaller = jc.createMarshaller();
        marshaller.setSchema(schema);
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        marshaller.marshal(data, xml);
      } catch (JAXBException e) {
        log.error("Error while saving data: " + e.getMessage(), e.getCause());
        PacketSendUtility.sendMessage(admin, "Unexpected error occured during saving");
        return;
      }

      PacketSendUtility.sendMessage(admin, "Saved successfully new fly_rings !");
    }

    if (params[0].equalsIgnoreCase("next")) {
      float x = (float) ringPositions[i].x;
      float y = (float) ringPositions[i].y;
      float z = (float) ringPositions[i].z;

      TeleportService.teleportTo(admin, admin.getWorldId(), x, y, z, 0);
      PacketSendUtility.sendMessage(
          admin, "Teleported to ring " + (i + 1) + "/" + ringPositions.length);

      i = (i + 1) % ringPositions.length;
    }
  }