Example #1
0
  @Override
  public void handleChat(int type, L2PcInstance activeChar, String target, String text) {
    if (!FloodProtectors.performAction(activeChar.getClient(), Action.TRADE_CHAT)) return;

    final CreatureSay cs =
        new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
    final int region = MapRegionTable.getMapRegion(activeChar.getX(), activeChar.getY());

    for (L2PcInstance player : L2World.getInstance().getPlayers()) {
      if (!BlockList.isBlocked(player, activeChar)
          && region == MapRegionTable.getMapRegion(player.getX(), player.getY()))
        player.sendPacket(cs);
    }
  }
Example #2
0
  @Override
  protected void runImpl() {
    if (!FloodProtectors.performAction(getClient(), Action.SERVER_BYPASS)) return;

    final L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) return;

    if (_command.isEmpty()) {
      _log.info(activeChar.getName() + " sent an empty requestBypass packet.");
      activeChar.logout();
      return;
    }

    try {
      if (_command.startsWith("admin_")) {
        String command = _command.split(" ")[0];

        IAdminCommandHandler ach =
            AdminCommandHandler.getInstance().getAdminCommandHandler(command);
        if (ach == null) {
          if (activeChar.isGM())
            activeChar.sendMessage("The command " + command.substring(6) + " doesn't exist.");

          _log.warning("No handler registered for admin command '" + command + "'");
          return;
        }

        if (!AdminCommandAccessRights.getInstance()
            .hasAccess(command, activeChar.getAccessLevel())) {
          activeChar.sendMessage("You don't have the access rights to use this command.");
          _log.warning(
              activeChar.getName()
                  + " tried to use admin command "
                  + command
                  + " without proper Access Level.");
          return;
        }

        if (Config.GMAUDIT)
          GMAudit.auditGMAction(
              activeChar.getName() + " [" + activeChar.getObjectId() + "]",
              _command,
              (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target"));

        ach.useAdminCommand(_command, activeChar);
      } else if (_command.startsWith("player_help ")) {
        playerHelp(activeChar, _command.substring(12));
      } else if (_command.startsWith("npc_")) {
        if (!activeChar.validateBypass(_command)) return;

        int endOfId = _command.indexOf('_', 5);
        String id;
        if (endOfId > 0) id = _command.substring(4, endOfId);
        else id = _command.substring(4);

        try {
          final L2Object object = L2World.getInstance().getObject(Integer.parseInt(id));

          if (object != null
              && object instanceof L2Npc
              && endOfId > 0
              && ((L2Npc) object).canInteract(activeChar))
            ((L2Npc) object).onBypassFeedback(activeChar, _command.substring(endOfId + 1));

          activeChar.sendPacket(ActionFailed.STATIC_PACKET);
        } catch (NumberFormatException nfe) {
        }
      }
      // Navigate throught Manor windows
      else if (_command.startsWith("manor_menu_select?")) {
        L2Object object = activeChar.getTarget();
        if (object instanceof L2Npc) ((L2Npc) object).onBypassFeedback(activeChar, _command);
      } else if (_command.startsWith("bbs_")
          || _command.startsWith("_bbs")
          || _command.startsWith("_friend")
          || _command.startsWith("_mail")
          || _command.startsWith("_block")) {
        CommunityBoard.getInstance().handleCommands(getClient(), _command);
      } else if (_command.startsWith("Quest ")) {
        if (!activeChar.validateBypass(_command)) return;

        String[] str = _command.substring(6).trim().split(" ", 2);
        if (str.length == 1) activeChar.processQuestEvent(str[0], "");
        else activeChar.processQuestEvent(str[0], str[1]);
      } else if (_command.startsWith("_match")) {
        String params = _command.substring(_command.indexOf("?") + 1);
        StringTokenizer st = new StringTokenizer(params, "&");
        int heroclass = Integer.parseInt(st.nextToken().split("=")[1]);
        int heropage = Integer.parseInt(st.nextToken().split("=")[1]);
        int heroid = Hero.getInstance().getHeroByClass(heroclass);
        if (heroid > 0) Hero.getInstance().showHeroFights(activeChar, heroclass, heroid, heropage);
      } else if (_command.startsWith("_diary")) {
        String params = _command.substring(_command.indexOf("?") + 1);
        StringTokenizer st = new StringTokenizer(params, "&");
        int heroclass = Integer.parseInt(st.nextToken().split("=")[1]);
        int heropage = Integer.parseInt(st.nextToken().split("=")[1]);
        int heroid = Hero.getInstance().getHeroByClass(heroclass);
        if (heroid > 0) Hero.getInstance().showHeroDiary(activeChar, heroclass, heroid, heropage);
      } else if (_command.startsWith("arenachange")) // change
      {
        final boolean isManager =
            activeChar.getCurrentFolkNPC() instanceof L2OlympiadManagerInstance;
        if (!isManager) {
          // Without npc, command can be used only in observer mode on arena
          if (!activeChar.inObserverMode()
              || activeChar.isInOlympiadMode()
              || activeChar.getOlympiadGameId() < 0) return;
        }

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

        final int arenaId = Integer.parseInt(_command.substring(12).trim());
        activeChar.enterOlympiadObserverMode(arenaId);
      }
    } catch (Exception e) {
      _log.log(Level.WARNING, "Bad RequestBypassToServer: ", e);
    }
  }