@Override
  public final boolean useBypass(String command, L2PcInstance activeChar, L2Character target) {
    try {
      final L2Npc olymanager = activeChar.getLastFolkNPC();

      if (command.startsWith(COMMANDS[0])) // list
      {
        if (!Olympiad.getInstance().inCompPeriod()) {
          activeChar.sendPacket(SystemMessageId.THE_OLYMPIAD_GAME_IS_NOT_CURRENTLY_IN_PROGRESS);
          return false;
        }

        activeChar.sendPacket(new ExOlympiadMatchList());
      } else {
        if ((olymanager == null) || !(olymanager instanceof L2OlympiadManagerInstance)) {
          return false;
        }

        if (!activeChar.inObserverMode()
            && !activeChar.isInsideRadius(olymanager, 300, false, false)) {
          return false;
        }

        if (OlympiadManager.getInstance().isRegisteredInComp(activeChar)) {
          activeChar.sendPacket(
              SystemMessageId
                  .WHILE_YOU_ARE_ON_THE_WAITING_LIST_YOU_ARE_NOT_ALLOWED_TO_WATCH_THE_GAME);
          return false;
        }

        if (!Olympiad.getInstance().inCompPeriod()) {
          activeChar.sendPacket(SystemMessageId.THE_OLYMPIAD_GAME_IS_NOT_CURRENTLY_IN_PROGRESS);
          return false;
        }

        if (activeChar.isOnEvent()) {
          activeChar.sendMessage("You can not observe games while registered on an event");
          return false;
        }

        final int arenaId = Integer.parseInt(command.substring(12).trim());
        final OlympiadGameTask nextArena =
            OlympiadGameManager.getInstance().getOlympiadTask(arenaId);
        if (nextArena != null) {
          activeChar.enterOlympiadObserverMode(
              nextArena.getZone().getSpectatorSpawns().get(0), arenaId);
          activeChar.setInstanceId(
              OlympiadGameManager.getInstance().getOlympiadTask(arenaId).getZone().getInstanceId());
        }
      }
      return true;

    } catch (Exception e) {
      _log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
    }
    return false;
  }
Esempio n. 2
0
  @Override
  public boolean useUserCommand(int id, L2PcInstance activeChar) {
    if (id != COMMAND_IDS[0]) {
      return false;
    }

    int nobleObjId = activeChar.getObjectId();
    final L2Object target = activeChar.getTarget();
    if (target != null) {
      if (target.isPlayer() && target.getActingPlayer().isNoble()) {
        nobleObjId = target.getObjectId();
      } else {
        activeChar.sendPacket(SystemMessageId.NOBLESSE_ONLY);
        return false;
      }
    } else if (!activeChar.isNoble()) {
      activeChar.sendPacket(SystemMessageId.NOBLESSE_ONLY);
      return false;
    }

    final SystemMessage sm =
        SystemMessage.getSystemMessage(
            SystemMessageId
                .THE_CURRENT_RECORD_FOR_THIS_OLYMPIAD_SESSION_IS_S1_MATCHES_S2_WINS_S3_DEFEATS_YOU_HAVE_EARNED_S4_OLYMPIAD_POINTS);
    sm.addInt(Olympiad.getInstance().getCompetitionDone(nobleObjId));
    sm.addInt(Olympiad.getInstance().getCompetitionWon(nobleObjId));
    sm.addInt(Olympiad.getInstance().getCompetitionLost(nobleObjId));
    sm.addInt(Olympiad.getInstance().getNoblePoints(nobleObjId));
    activeChar.sendPacket(sm);

    final SystemMessage sm2 =
        SystemMessage.getSystemMessage(
            SystemMessageId
                .YOU_HAVE_S1_MATCHES_REMAINING_THAT_YOU_CAN_PARTECIPATE_IN_THIS_WEEK_S2_CLASSED_S3_NON_CLASSED_S4_TEAM);
    sm2.addInt(Olympiad.getInstance().getRemainingWeeklyMatches(nobleObjId));
    sm2.addInt(Olympiad.getInstance().getRemainingWeeklyMatchesClassed(nobleObjId));
    sm2.addInt(Olympiad.getInstance().getRemainingWeeklyMatchesNonClassed(nobleObjId));
    sm2.addInt(Olympiad.getInstance().getRemainingWeeklyMatchesTeam(nobleObjId));
    activeChar.sendPacket(sm2);
    return true;
  }