@Override
  protected void runImpl() {
    final L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) {
      return;
    }

    activeChar.sendPacket(new UserInfo(activeChar));
    activeChar.sendPacket(new ExBrExtraUserInfo(activeChar));

    Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
    for (L2Object object : objs) {
      if (object.getPoly().isMorphed() && object.getPoly().getPolyType().equals("item")) {
        activeChar.sendPacket(new SpawnItem(object));
      } else {
        if (!object.isVisibleFor(activeChar)) {
          object.sendInfo(activeChar);

          if (object instanceof L2Character) {
            // Update the state of the L2Character object client
            // side by sending Server->Client packet
            // MoveToPawn/CharMoveToLocation and AutoAttackStart to
            // the L2PcInstance
            final L2Character obj = (L2Character) object;
            if (obj.getAI() != null) {
              obj.getAI().describeStateToPlayer(activeChar);
            }
          }
        }
      }
    }
  }
Пример #2
0
  /** Handle chat type 'all' */
  @Override
  public void handleChat(int type, L2PcInstance activeChar, String params, String text) {
    boolean vcd_used = false;
    if (text.startsWith(".")) {
      StringTokenizer st = new StringTokenizer(text);
      IVoicedCommandHandler vch;
      String command = "";

      if (st.countTokens() > 1) {
        command = st.nextToken().substring(1);
        params = text.substring(command.length() + 2);
        vch = VoicedCommandHandler.getInstance().getHandler(command);
      } else {
        command = text.substring(1);
        if (Config.DEBUG) {
          _log.info("Command: " + command);
        }
        vch = VoicedCommandHandler.getInstance().getHandler(command);
      }
      if (vch != null) {
        vch.useVoicedCommand(command, activeChar, params);
        vcd_used = true;
      } else {
        if (Config.DEBUG) {
          _log.warning("No handler registered for bypass '" + command + "'");
        }
        vcd_used = false;
      }
    }
    if (!vcd_used) {
      if (activeChar.isChatBanned() && Util.contains(Config.BAN_CHAT_CHANNELS, type)) {
        activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED);
        return;
      }

      /**
       * Match the character "." literally (Exactly 1 time) Match any character that is NOT a .
       * character. Between one and unlimited times as possible, giving back as needed (greedy)
       */
      if (text.matches("\\.{1}[^\\.]+")) {
        activeChar.sendPacket(SystemMessageId.INCORRECT_SYNTAX);
      } else {
        CreatureSay cs =
            new CreatureSay(
                activeChar.getObjectId(), type, activeChar.getAppearance().getVisibleName(), text);
        Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
        for (L2PcInstance player : plrs) {
          if ((player != null)
              && activeChar.isInsideRadius(player, 1250, false, true)
              && !BlockList.isBlocked(player, activeChar)) {
            player.sendPacket(cs);
          }
        }

        activeChar.sendPacket(cs);
      }
    }
  }
Пример #3
0
  @Override
  public void onStart(BuffInfo info) {
    if (info.getEffected().isPlayer()) {
      L2PcInstance activeChar = info.getEffected().getActingPlayer();
      activeChar.setInvisible(true);

      if ((activeChar.getAI().getNextIntention() != null)
          && (activeChar.getAI().getNextIntention().getCtrlIntention()
              == CtrlIntention.AI_INTENTION_ATTACK)) {
        activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
      }

      for (L2Character target : activeChar.getKnownList().getKnownCharacters()) {
        if ((target != null) && (target.getTarget() == activeChar)) {
          target.setTarget(null);
          target.abortAttack();
          target.abortCast();
          target.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
        }
      }
    }
  }
  @Override
  protected void runImpl() {
    L2PcInstance player = getActiveChar();
    if (player == null) {
      return;
    }

    if (!player.getAccessLevel().allowTransaction()) {
      player.sendMessage("Transactions are disabled for your current Access Level.");
      sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    BuffInfo info = player.getEffectList().getBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
    if (info != null) {
      for (AbstractEffect effect : info.getEffects()) {
        if (!effect.checkCondition(BotReportTable.TRADE_ACTION_BLOCK_ID)) {
          player.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REPORTED_SO_ACTIONS_NOT_ALLOWED);
          player.sendPacket(ActionFailed.STATIC_PACKET);
          return;
        }
      }
    }

    final L2Object target = L2World.getInstance().findObject(_objectId);
    // If there is no target, target is far away or
    // they are in different instances (except multiverse)
    // trade request is ignored and there is no system message.
    if ((target == null)
        || !player.getKnownList().knowsObject(target)
        || ((target.getInstanceId() != player.getInstanceId()) && (player.getInstanceId() != -1))) {
      return;
    }

    // If target and acting player are the same, trade request is ignored
    // and the following system message is sent to acting player.
    if (target.getObjectId() == player.getObjectId()) {
      player.sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
      return;
    }

    if (!target.isPlayer()) {
      player.sendPacket(SystemMessageId.INCORRECT_TARGET);
      return;
    }

    final L2PcInstance partner = target.getActingPlayer();
    if (partner.isInOlympiadMode() || player.isInOlympiadMode()) {
      player.sendMessage(
          "A user currently participating in the Olympiad cannot accept or request a trade.");
      return;
    }

    info = partner.getEffectList().getBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
    if (info != null) {
      for (AbstractEffect effect : info.getEffects()) {
        if (!effect.checkCondition(BotReportTable.TRADE_ACTION_BLOCK_ID)) {
          final SystemMessage sm =
              SystemMessage.getSystemMessage(SystemMessageId.C1_REPORTED_AND_IS_BEING_INVESTIGATED);
          sm.addCharName(partner);
          player.sendPacket(sm);
          player.sendPacket(ActionFailed.STATIC_PACKET);
          return;
        }
      }
    }

    // L2J Customs: Karma punishment
    if (!Config.ALT_GAME_KARMA_PLAYER_CAN_TRADE && (player.getKarma() > 0)) {
      player.sendMessage("You cannot trade while you are in a chaotic state.");
      return;
    }

    if (!Config.ALT_GAME_KARMA_PLAYER_CAN_TRADE && (partner.getKarma() > 0)) {
      player.sendMessage("You cannot request a trade while your target is in a chaotic state.");
      return;
    }

    if (Config.JAIL_DISABLE_TRANSACTION && (player.isJailed() || partner.isJailed())) {
      player.sendMessage("You cannot trade while you are in in Jail.");
      return;
    }

    if ((player.getPrivateStoreType() != PrivateStoreType.NONE)
        || (partner.getPrivateStoreType() != PrivateStoreType.NONE)) {
      player.sendPacket(SystemMessageId.CANNOT_TRADE_DISCARD_DROP_ITEM_WHILE_IN_SHOPMODE);
      return;
    }

    if (player.isProcessingTransaction()) {
      if (Config.DEBUG) {
        _log.fine("Already trading with someone else.");
      }
      player.sendPacket(SystemMessageId.ALREADY_TRADING);
      return;
    }

    SystemMessage sm;
    if (partner.isProcessingRequest() || partner.isProcessingTransaction()) {
      if (Config.DEBUG) {
        _log.info("Transaction already in progress.");
      }
      sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_BUSY_TRY_LATER);
      sm.addString(partner.getName());
      player.sendPacket(sm);
      return;
    }

    if (partner.getTradeRefusal()) {
      player.sendMessage("That person is in trade refusal mode.");
      return;
    }

    if (BlockList.isBlocked(partner, player)) {
      sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_ADDED_YOU_TO_IGNORE_LIST);
      sm.addCharName(partner);
      player.sendPacket(sm);
      return;
    }

    if (player.calculateDistance(partner, true, false) > 150) {
      player.sendPacket(SystemMessageId.TARGET_TOO_FAR);
      return;
    }

    player.onTransactionRequest(partner);
    partner.sendPacket(new SendTradeRequest(player.getObjectId()));
    sm = SystemMessage.getSystemMessage(SystemMessageId.REQUEST_C1_FOR_TRADE);
    sm.addString(partner.getName());
    player.sendPacket(sm);
  }