private void removeForeigners(int managerId, L2Party party) {
   if ((party != null)
       && ZONES.containsKey(managerId)
       && (ZoneManager.getInstance().getZoneById(ZONES.get(managerId)) != null)) {
     L2ZoneType zone = ZoneManager.getInstance().getZoneById(ZONES.get(managerId));
     for (L2PcInstance player : zone.getPlayersInside()) {
       if (player != null) {
         L2Party charParty = player.getParty();
         if ((charParty == null) || (charParty.getLeaderObjectId() != party.getLeaderObjectId())) {
           player.teleToLocation(16110, 243841, 11616);
         }
       }
     }
   }
 }
  @Override
  public final String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    String htmltext = event;

    // Timer. Spawns Naia Lock
    if (event.equalsIgnoreCase("spawn_lock")) {
      htmltext = null;
      _lock = (L2MonsterInstance) addSpawn(LOCK, 16409, 244438, 11620, -1048, false, 0, false);
      _counter = 90;
    }

    // Timer. Depending of _challengeState despans all spawned spores, or spores, reached assembly
    // point
    else if (event.equalsIgnoreCase("despawn_total")) {
      // Spores is not attacked too long - despawn them all, reinit values
      if (_challengeState == STATE_SPORE_IDLE_TOO_LONG) {
        for (L2Npc spore : _sporeSpawn) {
          if ((spore != null) && !spore.isDead()) {
            spore.deleteMe();
          }
        }
        _sporeSpawn.clear();
        initSporeChallenge();
      }
      // Spores are moving to assembly point. Despawn all reached, check for reached spores count.
      else if ((_challengeState == STATE_SPORE_CHALLENGE_SUCCESSFULL) && (_winIndex >= 0)) {
        // Requirements are met, despawn all spores, spawn Epidos
        if ((_despawnedSporesCount >= 10) || _sporeSpawn.isEmpty()) {
          if (!_sporeSpawn.isEmpty()) {
            for (L2Npc spore : _sporeSpawn) {
              if ((spore != null) && !spore.isDead()) {
                spore.deleteMe();
              }
            }
          }
          _sporeSpawn.clear();
          _despawnedSporesCount = 0;
          int[] coords = SPORES_MERGE_POSITION[_winIndex];
          addSpawn(EPIDOSES[_winIndex], coords[0], coords[1], coords[2], 0, false, 0, false);
          initSporeChallenge();
        }
        // Requirements aren't met, despawn reached spores
        else {
          Iterator<L2Npc> it = _sporeSpawn.iterator();
          while (it.hasNext()) {
            L2Npc spore = it.next();
            if ((spore != null)
                && !spore.isDead()
                && (spore.getX() == spore.getSpawn().getX())
                && (spore.getY() == spore.getSpawn().getY())) {
              spore.deleteMe();
              it.remove();
              _despawnedSporesCount++;
            }
          }

          startQuestTimer("despawn_total", 3000, null, null);
        }
      }
    }

    if (npc == null) {
      return null;
    }

    final int npcId = npc.getId();

    if (event.equalsIgnoreCase("despawn_spore")
        && !npc.isDead()
        && (_challengeState == STATE_SPORE_CHALLENGE_IN_PROGRESS)) {
      htmltext = null;

      _sporeSpawn.remove(npc);
      npc.deleteMe();

      if (npcId == SPORE_BASIC) {
        spawnRandomSpore();
        spawnRandomSpore();
      } else if ((npcId >= SPORE_FIRE) && (npcId <= SPORE_EARTH)) {
        _despawnedSporesCount++;

        if (_despawnedSporesCount < SELF_DESPAWN_LIMIT) {
          spawnOppositeSpore(npcId);
        } else {
          _challengeState = STATE_SPORE_IDLE_TOO_LONG;
          startQuestTimer("despawn_total", 60000, null, null);
        }
      }
    } else if (event.equalsIgnoreCase("18492-05.htm")) {
      if ((_lock == null) || (_lock.getCurrentHp() > (_lock.getMaxHp() / 10))) {
        htmltext = null;
        if (_lock != null) {
          _lock.deleteMe();
          _lock = null;
        }
        cancelQuestTimers("spawn_lock");
        startQuestTimer("spawn_lock", 300000, null, null);
        npc.setTarget(player);
        npc.doCast(SkillData.getInstance().getSkill(5527, 1));
      }
    } else if (event.equalsIgnoreCase("teleport") && (_lock != null)) {
      htmltext = null;
      L2Party party = player.getParty();
      if (party != null) {
        if (Util.checkIfInRange(3000, party.getLeader(), npc, true)) {
          for (L2PcInstance partyMember : party.getMembers()) {
            if (Util.checkIfInRange(2000, partyMember, npc, true)) {
              partyMember.teleToLocation(-47271, 246098, -9120, true);
            }
          }
          _lock.deleteMe();
          _lock = null;
          cancelQuestTimers("spawn_lock");
          startQuestTimer("spawn_lock", 1200000, null, null);
        } else {
          npc.setTarget(player);
          npc.doCast(SkillData.getInstance().getSkill(5527, 1));
        }
      } else {
        player.teleToLocation(-47271, 246098, -9120);
        _lock.deleteMe();
        _lock = null;
        cancelQuestTimers("spawn_lock");
        startQuestTimer("spawn_lock", 1200000, null, null);
      }
    } else if (event.equalsIgnoreCase("go")
        && _activeRooms.containsKey(npcId)
        && !_activeRooms.get(npcId)) {
      htmltext = null;
      L2Party party = player.getParty();

      if (party != null) {
        removeForeigners(npcId, party);
        startRoom(npcId);
        ThreadPoolManager.getInstance().scheduleGeneral(new StopRoomTask(npcId), 300000);
      } else {
        player.sendPacket(SystemMessageId.CAN_OPERATE_MACHINE_WHEN_IN_PARTY);
      }
    }
    return htmltext;
  }