@Override
  public String onEvent(String event, QuestState qs, NpcInstance npc) {
    final Player player = qs.getPlayer();

    switch (event) {
      case "33155-9.htm":
        SupportMagic.getSupportMagic(npc, player);
        break;

      case "33155-10.htm":
        SupportMagic.getSupportServitorMagic(npc, player);
        break;

      case "advanceCond3":
        if (qs.getCond() != 3) {
          qs.setCond(3);
        }
        return null;

      case "teleportCruma":
        qs.setCond(1);
        qs.setState(STARTED);
        qs.playSound(SOUND_ACCEPT);
        player.teleToLocation(17192, 114173, -3439);
        return null;

      case "33163-8.htm":
        if (qs.getQuestItemsCount(TRESURE_TOOL) == 0) {
          qs.giveItems(TRESURE_TOOL, 30);
          qs.setCond(2);
        } else {
          return "33163-12.htm";
        }
        break;

      case "EnterInstance":
        if (player.getParty() == null) {
          player.sendMessage("You cannot enter without party!"); // pts message?
          return null;
        }
        for (Player member : player.getParty().getPartyMembers()) {
          final QuestState state = member.getQuestState(Q00480_AnotherLegacyOfCrumaTower.class);

          if ((state == null) || (state.getCond() != 3)) {
            // nothing as I've seen everybody can enter this instance
          } else if (state.getCond() == 3) {
            state.setCond(4);
          }
        }
        ReflectionUtils.enterReflection(player, 198);
        return null;

      case "LeaveInstance":
        player.teleToLocation(17192, 114173, -3439, ReflectionManager.DEFAULT);
        return null;
    }

    return event;
  }
 /** Method runImpl. */
 @Override
 public void runImpl() {
   Functions.npcShout(
       CastleMassTeleporterInstance.this,
       NpcString.THE_DEFENDERS_OF_S1_CASTLE_WILL_BE_TELEPORTED_TO_THE_INNER_CASTLE,
       "#" + getCastle().getNpcStringName().getId());
   for (Player p : World.getAroundPlayers(CastleMassTeleporterInstance.this, 200, 50)) {
     p.teleToLocation(Location.findPointToStay(_teleportLoc, 10, 100, p.getGeoIndex()));
   }
   _teleportTask = null;
 }
  @Override
  public void onBypassFeedback(Player player, String command) {
    if (!canBypassCheck(player, this)) {
      return;
    }

    if (command.startsWith("start1")) {
      Reflection r = player.getActiveReflection();
      if (r != null) {
        if (player.canReenterInstance(instanceId)) {
          player.teleToLocation(r.getTeleportLoc(), r);
        }
      } else if (player.canEnterInstance(193)) {
        ReflectionUtils.enterReflection(player, new AltarShilen(), instanceId);
      }
    } else if (command.startsWith("start2")) {

      for (Player party : GameObjectsStorage.getAllPlayersForIterate()) {
        party.unsetVar("Altar1");
        party.setVar("Altar2", "true", -1);
        party.teleToLocation(FLOOR2, player.getReflection());
      }
    } else if (command.startsWith("start3")) {
      for (Player party : GameObjectsStorage.getAllPlayersForIterate()) {
        party.unsetVar("Altar2");
        party.setVar("Altar3", "true", -1);
        party.teleToLocation(FLOOR3, player.getReflection());
      }

    } else if (command.startsWith("exit")) {
      for (Player party : GameObjectsStorage.getAllPlayersForIterate()) {
        party.unsetVar("Altar3");
        party.teleToLocation(OFF, 0);
      }
    } else {
      super.onBypassFeedback(player, command);
    }
  }
 /** Method setUpPlayers. */
 private void setUpPlayers() {
   HandysBlockCheckerManager.getInstance().setArenaBeingUsed(_arena);
   _redPoints = _spawns.size() / 2;
   _bluePoints = _spawns.size() / 2;
   final ExCubeGameChangePoints initialPoints =
       new ExCubeGameChangePoints(300, _bluePoints, _redPoints);
   ExCubeGameExtendedChangePoints clientSetUp;
   for (Player player : _holder.getAllPlayers()) {
     if (player == null) {
       continue;
     }
     player.addListener(_listener);
     boolean isRed = _holder.getRedPlayers().contains(player);
     clientSetUp =
         new ExCubeGameExtendedChangePoints(300, _bluePoints, _redPoints, isRed, player, 0);
     player.sendPacket(clientSetUp);
     player.sendActionFailed();
     int tc = _holder.getPlayerTeam(player) * 2;
     int x = _arenaCoordinates[_arena][tc];
     int y = _arenaCoordinates[_arena][tc + 1];
     player.teleToLocation(x, y, _zCoord);
     if (isRed) {
       _redTeamPoints.put(player, 0);
       player.setTeam(TeamType.RED);
     } else {
       _blueTeamPoints.put(player, 0);
       player.setTeam(TeamType.BLUE);
     }
     player.getEffectList().stopAllEffects();
     for (Summon summon : player.getSummonList()) {
       summon.unSummon();
     }
     _freeze.getEffects(player, player, false, false);
     if (_holder.getPlayerTeam(player) == 0) {
       _transformationRed.getEffects(player, player, false, false);
     } else {
       _transformationBlue.getEffects(player, player, false, false);
     }
     player.setBlockCheckerArena((byte) _arena);
     player.sendPacket(initialPoints);
     player.sendPacket(_closeUserInterface);
     player.sendPacket(new ExBasicActionList(player));
     broadcastRelationChanged(player);
     player.broadcastCharInfo();
   }
 }
 /**
  * Method onPlayerExit.
  *
  * @param player Player
  * @see lineage2.gameserver.listener.actor.player.OnPlayerExitListener#onPlayerExit(Player)
  */
 @Override
 public void onPlayerExit(final Player player) {
   if (player.getBlockCheckerArena() < 0) {
     return;
   }
   _isExit = true;
   player.teleToLocation(-57478, -60367, -2370);
   player.setTransformation(0);
   player.getEffectList().stopAllEffects();
   int arena = player.getBlockCheckerArena();
   int team = HandysBlockCheckerManager.getInstance().getHolder(arena).getPlayerTeam(player);
   HandysBlockCheckerManager.getInstance().removePlayer(player, arena, team);
   player.setTeam(TeamType.NONE);
   player.broadcastCharInfo();
   PcInventory inv = player.getInventory();
   inv.destroyItemByItemId(13787, inv.getCountOf(13787));
   inv.destroyItemByItemId(13788, inv.getCountOf(13788));
 }
 /** Method setPlayersBack. */
 private void setPlayersBack() {
   final ExCubeGameEnd end = new ExCubeGameEnd(_isRedWinner);
   for (Player player : _holder.getAllPlayers()) {
     if (player == null) {
       continue;
     }
     player.getEffectList().stopAllEffects();
     player.setTeam(TeamType.NONE);
     player.setBlockCheckerArena(DEFAULT_ARENA);
     PcInventory inv = player.getInventory();
     inv.destroyItemByItemId(13787, inv.getCountOf(13787));
     inv.destroyItemByItemId(13788, inv.getCountOf(13788));
     broadcastRelationChanged(player);
     player.teleToLocation(-57478, -60367, -2370);
     player.sendPacket(end);
     player.broadcastCharInfo();
   }
 }
  /**
   * Method onBypassFeedback.
   *
   * @param npc NpcInstance
   * @param player Player
   * @param command String
   * @see lineage2.gameserver.handlers.IBypassHandler#onBypassFeedback(NpcInstance, Player, String)
   */
  @Override
  public void onBypassFeedback(NpcInstance npc, Player player, String command) {
    Reflection r = player.getReflection();
    r.startCollapseTimer(60000);
    player.teleToLocation(r.getReturnLoc(), 0);

    if (command.length() > 22) {
      try {
        int val = Integer.parseInt(command.substring(22));
        npc.showChatWindow(player, val);
      } catch (NumberFormatException nfe) {
        String filename = command.substring(22).trim();

        if (filename.length() > 0) {
          npc.showChatWindow(player, filename);
        }
      }
    }
  }
 @Override
 public String onTalk(NpcInstance npc, QuestState st) {
   int npcId = npc.getNpcId();
   Player player = st.getPlayer();
   String back = player.getVar("FestivalBackCoords");
   if (back == null) {
     back = "1";
   }
   String htmltext = "Started.htm";
   if (npcId == GLUDIN_DAWN) {
     player.teleToLocation(-80157, 111344, -4901);
     player.setVar("id", "1", -1);
     return htmltext;
   }
   if (npcId == GLUDIO_DAWN) {
     player.teleToLocation(-80157, 111344, -4901);
     player.setVar("id", "2", -1);
     return htmltext;
   }
   if (npcId == DION_DAWN) {
     player.teleToLocation(-80157, 111344, -4901);
     player.setVar("id", "3", -1);
     return htmltext;
   }
   if (npcId == GIRAN_DAWN) {
     player.teleToLocation(-80157, 111344, -4901);
     player.setVar("id", "4", -1);
     return htmltext;
   }
   if (npcId == OREN_DAWN) {
     player.teleToLocation(-80157, 111344, -4901);
     player.setVar("id", "5", -1);
     return htmltext;
   }
   if (npcId == ADEN_DAWN) {
     player.teleToLocation(-80157, 111344, -4901);
     player.setVar("id", "6", -1);
     return htmltext;
   }
   if (npcId == HEINE_DAWN) {
     player.teleToLocation(-80157, 111344, -4901);
     player.setVar("id", "7", -1);
     return htmltext;
   }
   if (npcId == GODDARD_DAWN) {
     player.teleToLocation(-80157, 111344, -4901);
     player.setVar("id", "8", -1);
     return htmltext;
   }
   if (npcId == RUNE_DAWN) {
     player.teleToLocation(-80157, 111344, -4901);
     player.setVar("id", "9", -1);
     return htmltext;
   }
   if (npcId == SCHUTTGART_DAWN) {
     player.teleToLocation(-80157, 111344, -4901);
     player.setVar("id", "10", -1);
     return htmltext;
   }
   if (npcId == HV_DAWN) {
     player.teleToLocation(-80157, 111344, -4901);
     player.setVar("id", "11", -1);
     return htmltext;
   }
   if (npcId == GLUDIN_DUSK) {
     player.teleToLocation(-81261, 86531, -5157);
     player.setVar("id", "1", -1);
     return htmltext;
   }
   if (npcId == GLUDIO_DUSK) {
     player.teleToLocation(-81261, 86531, -5157);
     player.setVar("id", "2", -1);
     return htmltext;
   }
   if (npcId == DION_DUSK) {
     player.teleToLocation(-81261, 86531, -5157);
     player.setVar("id", "3", -1);
     return htmltext;
   }
   if (npcId == GIRAN_DUSK) {
     player.teleToLocation(-81261, 86531, -5157);
     player.setVar("id", "4", -1);
     return htmltext;
   }
   if (npcId == OREN_DUSK) {
     player.teleToLocation(-81261, 86531, -5157);
     player.setVar("id", "5", -1);
     return htmltext;
   }
   if (npcId == ADEN_DUSK) {
     player.teleToLocation(-81261, 86531, -5157);
     player.setVar("id", "6", -1);
     return htmltext;
   }
   if (npcId == HEINE_DUSK) {
     player.teleToLocation(-81261, 86531, -5157);
     player.setVar("id", "7", -1);
     return htmltext;
   }
   if (npcId == GODDARD_DUSK) {
     player.teleToLocation(-81261, 86531, -5157);
     player.setVar("id", "8", -1);
     return htmltext;
   }
   if (npcId == RUNE_DUSK) {
     player.teleToLocation(-81261, 86531, -5157);
     player.setVar("id", "9", -1);
     return htmltext;
   }
   if (npcId == SCHUTTGART_DUSK) {
     player.teleToLocation(-81261, 86531, -5157);
     player.setVar("id", "10", -1);
     return htmltext;
   }
   if (npcId == HV_DUSK) {
     player.teleToLocation(-81261, 86531, -5157);
     player.setVar("id", "11", -1);
     return htmltext;
   }
   htmltext = "Completed.htm";
   if (back.equals("1")) {
     player.teleToLocation(-80826, 149775, -3043);
     return htmltext;
   }
   if (back.equals("2")) {
     player.teleToLocation(-12672, 122776, -3116);
     return htmltext;
   }
   if (back.equals("3")) {
     player.teleToLocation(15670, 142983, -2705);
     return htmltext;
   }
   if (back.equals("4")) {
     player.teleToLocation(83400, 147943, -3404);
     return htmltext;
   }
   if (back.equals("5")) {
     player.teleToLocation(82956, 53162, -1495);
     return htmltext;
   }
   if (back.equals("6")) {
     player.teleToLocation(146331, 25762, -2018);
     return htmltext;
   }
   if (back.equals("7")) {
     player.teleToLocation(111409, 219364, -3545);
     return htmltext;
   }
   if (back.equals("8")) {
     player.teleToLocation(147928, -55273, -2734);
     return htmltext;
   }
   if (back.equals("9")) {
     player.teleToLocation(43799, -47727, -798);
     return htmltext;
   }
   if (back.equals("10")) {
     player.teleToLocation(87386, -143246, -1293);
     return htmltext;
   }
   if (back.equals("11")) {
     player.teleToLocation(116819, 76994, -2714);
     return htmltext;
   }
   return htmltext;
 }
  @Override
  public void onBypassFeedback(Player player, String command) {
    if (!canBypassCheck(player, this)) {
      return;
    }

    if (command.startsWith("teleport_harnak")) {
      if ((player.getLevel() >= 85) && player.isAwaking()) {
        player.teleToLocation(-114712, 147848, -7740);
      } else {
        showChatWindow(player, "default/33344-noreq.htm");
      }
    }

    if (command.startsWith("teleport_first_floor")) {
      player.teleToLocation(-114712, 147848, -7740);
    }

    if (command.startsWith("teleport_second_floor")) {
      player.teleToLocation(-114712, 149160, -10800);
    }

    if (command.startsWith("teleport_third_floor")) {
      player.teleToLocation(-114728, 183288, -13860);
    }

    if (command.startsWith("teleport_outside")) {
      player.teleToLocation(-116160, 236370, -3088);
    }

    if (command.startsWith("teleport_next")) {
      List<int[]> lst = Arrays.asList(cycleEndTeleports);

      if (lst.contains(getId())) {
        player.teleToLocation(teleCoords.get(Integer.valueOf(getId() - 7)));
      } else {
        player.teleToLocation(teleCoords.get(Integer.valueOf(getId() + 1)));
      }
    }

    if (command.startsWith("teleport_prev")) {
      List<int[]> lst = Arrays.asList(cycleStartTeleports);

      if (lst.contains(getId())) {
        player.teleToLocation(teleCoords.get(Integer.valueOf(getId() + 7)));
      } else {
        player.teleToLocation(teleCoords.get(Integer.valueOf(getId() - 1)));
      }
    }

    if (command.startsWith("key_altar")) {
      if (player.getInventory().getItemByItemId(SEALED_HARNAK_KEY) != null) {
        if (HarnakUndegroundManager.getInstance().addSecondStagePoint(getId(), player)) {
          showChatWindow(player, "default/altar-ok.htm");
          player.getInventory().removeItemByItemId(30429, 1);
          sayScreenMessage(player);

          if (getNpcState() == 0) {
            ThreadPoolManager.getInstance().schedule(new runNpcStateChangeSecond(), 1000L);
          }

          NpcInstance Noktum =
              NpcUtils.spawnSingle(
                  NOKTUM,
                  player.getLoc().getX() + 15,
                  player.getLoc().getY(),
                  player.getLoc().getZ(),
                  1800000L);
          Noktum.addListener(_deathListener);
        } else if (player.isInParty() && player.getParty().isLeader(player)) {
          sayScreenMessage(player);
          NpcInstance Noktum =
              NpcUtils.spawnSingle(
                  NOKTUM,
                  player.getLoc().getX() + 15,
                  player.getLoc().getY(),
                  player.getLoc().getZ(),
                  1800000L);
          Noktum.addListener(_deathListener);
        } else {
          showChatWindow(player, "default/altar-no.htm");
        }
      } else {
        showChatWindow(player, "default/" + getId() + "-1.htm");
      }
    }

    if (command.startsWith("key_prison")) {
      if (player.getInventory().getItemByItemId(HARNAK_KEY) != null) {
        if (HarnakUndegroundManager.getInstance().addThirdStagePoint(getId(), player)) {
          showChatWindow(player, "default/prison-ok.htm");
          player.getInventory().removeItemByItemId(30430, 1);
          sayScreenMessage(player);

          if (getNpcState() == 0) {
            ThreadPoolManager.getInstance().schedule(new runNpcStateChangeThird(), 1000L);
          }

          NpcInstance demonikNoktum =
              NpcUtils.spawnSingle(
                  DEMONIC_NOKTUM,
                  player.getLoc().getX() + 15,
                  player.getLoc().getY(),
                  player.getLoc().getZ(),
                  1800000L);
          demonikNoktum.addListener(_deathListener);
        } else if (player.isInParty() && player.getParty().isLeader(player)) {
          sayScreenMessage(player);
          NpcInstance demonikNoktum =
              NpcUtils.spawnSingle(
                  DEMONIC_NOKTUM,
                  player.getLoc().getX() + 15,
                  player.getLoc().getY(),
                  player.getLoc().getZ(),
                  1800000L);
          demonikNoktum.addListener(_deathListener);
        } else {
          showChatWindow(player, "default/prison-no.htm");
        }
      } else {
        showChatWindow(player, "default/" + getId() + "-1.htm");
      }
    } else {
      super.onBypassFeedback(player, command);
    }
  }