Package lineage2.gameserver.model

Examples of lineage2.gameserver.model.Request


    Player parthner1 = getClient().getActiveChar();
    if (parthner1 == null)
    {
      return;
    }
    Request request = parthner1.getRequest();
    if ((request == null) || !request.isTypeOf(L2RequestType.TRADE))
    {
      parthner1.sendActionFailed();
      return;
    }
    if (!request.isInProgress())
    {
      request.cancel();
      parthner1.sendPacket(SendTradeDone.FAIL);
      parthner1.sendActionFailed();
      return;
    }
    if (parthner1.isOutOfControl())
    {
      request.cancel();
      parthner1.sendPacket(SendTradeDone.FAIL);
      parthner1.sendActionFailed();
      return;
    }
    Player parthner2 = request.getOtherPlayer(parthner1);
    if (parthner2 == null)
    {
      request.cancel();
      parthner1.sendPacket(SendTradeDone.FAIL);
      parthner1.sendPacket(Msg.THAT_PLAYER_IS_NOT_ONLINE);
      parthner1.sendActionFailed();
      return;
    }
    if (parthner2.getRequest() != request)
    {
      request.cancel();
      parthner1.sendPacket(SendTradeDone.FAIL);
      parthner1.sendActionFailed();
      return;
    }
    if (_response == 0)
    {
      request.cancel();
      parthner1.sendPacket(SendTradeDone.FAIL);
      parthner2.sendPacket(SendTradeDone.FAIL, new SystemMessage(SystemMessage.C1_HAS_CANCELLED_THE_TRADE).addString(parthner1.getName()));
      return;
    }
    if (!parthner1.isInRangeZ(parthner2, Creature.INTERACTION_DISTANCE))
    {
      parthner1.sendPacket(Msg.YOUR_TARGET_IS_OUT_OF_RANGE);
      return;
    }
    request.confirm(parthner1);
    parthner2.sendPacket(new SystemMessage(SystemMessage.C1_HAS_CONFIRMED_THE_TRADE).addString(parthner1.getName()), TradePressOtherOk.STATIC);
    if (!request.isConfirmed(parthner2))
    {
      parthner1.sendActionFailed();
      return;
    }
    List<TradeItem> tradeList1 = parthner1.getTradeList();
    List<TradeItem> tradeList2 = parthner2.getTradeList();
    int slots = 0;
    long weight = 0;
    boolean success = false;
    parthner1.getInventory().writeLock();
    parthner2.getInventory().writeLock();
    try
    {
      slots = 0;
      weight = 0;
      for (TradeItem ti : tradeList1)
      {
        ItemInstance item = parthner1.getInventory().getItemByObjectId(ti.getObjectId());
        if ((item == null) || (item.getCount() < ti.getCount()) || !item.canBeTraded(parthner1))
        {
          return;
        }
        weight = SafeMath.addAndCheck(weight, SafeMath.mulAndCheck(ti.getCount(), ti.getItem().getWeight()));
        if (!ti.getItem().isStackable() || (parthner2.getInventory().getItemByItemId(ti.getItemId()) == null))
        {
          slots++;
        }
      }
      if (!parthner2.getInventory().validateWeight(weight))
      {
        parthner2.sendPacket(Msg.YOU_HAVE_EXCEEDED_THE_WEIGHT_LIMIT);
        return;
      }
      if (!parthner2.getInventory().validateCapacity(slots))
      {
        parthner2.sendPacket(Msg.YOUR_INVENTORY_IS_FULL);
        return;
      }
      slots = 0;
      weight = 0;
      for (TradeItem ti : tradeList2)
      {
        ItemInstance item = parthner2.getInventory().getItemByObjectId(ti.getObjectId());
        if ((item == null) || (item.getCount() < ti.getCount()) || !item.canBeTraded(parthner2))
        {
          return;
        }
        weight = SafeMath.addAndCheck(weight, SafeMath.mulAndCheck(ti.getCount(), ti.getItem().getWeight()));
        if (!ti.getItem().isStackable() || (parthner1.getInventory().getItemByItemId(ti.getItemId()) == null))
        {
          slots++;
        }
      }
      if (!parthner1.getInventory().validateWeight(weight))
      {
        parthner1.sendPacket(Msg.YOU_HAVE_EXCEEDED_THE_WEIGHT_LIMIT);
        return;
      }
      if (!parthner1.getInventory().validateCapacity(slots))
      {
        parthner1.sendPacket(Msg.YOUR_INVENTORY_IS_FULL);
        return;
      }
      for (TradeItem ti : tradeList1)
      {
        ItemInstance item = parthner1.getInventory().removeItemByObjectId(ti.getObjectId(), ti.getCount());
        Log.LogItem(parthner1, Log.TradeSell, item);
        Log.LogItem(parthner2, Log.TradeBuy, item);
        parthner2.getInventory().addItem(item);
      }
      for (TradeItem ti : tradeList2)
      {
        ItemInstance item = parthner2.getInventory().removeItemByObjectId(ti.getObjectId(), ti.getCount());
        Log.LogItem(parthner2, Log.TradeSell, item);
        Log.LogItem(parthner1, Log.TradeBuy, item);
        parthner1.getInventory().addItem(item);
      }
      parthner1.sendPacket(Msg.YOUR_TRADE_IS_SUCCESSFUL);
      parthner2.sendPacket(Msg.YOUR_TRADE_IS_SUCCESSFUL);
      success = true;
    }
    finally
    {
      parthner2.getInventory().writeUnlock();
      parthner1.getInventory().writeUnlock();
      request.done();
      parthner1.sendPacket(success ? SendTradeDone.SUCCESS : SendTradeDone.FAIL);
      parthner2.sendPacket(success ? SendTradeDone.SUCCESS : SendTradeDone.FAIL);
    }
  }
View Full Code Here


    Player activeChar = getClient().getActiveChar();
    if (activeChar == null)
    {
      return;
    }
    Request request = activeChar.getRequest();
    if ((request == null) || !request.isTypeOf(L2RequestType.DUEL))
    {
      return;
    }
    if (!request.isInProgress())
    {
      request.cancel();
      activeChar.sendActionFailed();
      return;
    }
    if (activeChar.isActionsDisabled())
    {
      request.cancel();
      activeChar.sendActionFailed();
      return;
    }
    Player requestor = request.getRequestor();
    if (requestor == null)
    {
      request.cancel();
      activeChar.sendPacket(SystemMsg.THAT_PLAYER_IS_NOT_ONLINE);
      activeChar.sendActionFailed();
      return;
    }
    if (requestor.getRequest() != request)
    {
      request.cancel();
      activeChar.sendActionFailed();
      return;
    }
    if (_duelType != request.getInteger("duelType"))
    {
      request.cancel();
      activeChar.sendActionFailed();
      return;
    }
    DuelEvent duelEvent = EventHolder.getInstance().getEvent(EventType.PVP_EVENT, _duelType);
    switch (_response)
    {
      case 0:
        request.cancel();
        if (_duelType == 1)
        {
          requestor.sendPacket(SystemMsg.THE_OPPOSING_PARTY_HAS_DECLINED_YOUR_CHALLENGE_TO_A_DUEL);
        }
        else
        {
          requestor.sendPacket(new SystemMessage2(SystemMsg.C1_HAS_DECLINED_YOUR_CHALLENGE_TO_A_PARTY_DUEL).addName(activeChar));
        }
        break;
      case -1:
        request.cancel();
        requestor.sendPacket(new SystemMessage2(SystemMsg.C1_IS_SET_TO_REFUSE_DUEL_REQUESTS_AND_CANNOT_RECEIVE_A_DUEL_REQUEST).addName(activeChar));
        break;
      case 1:
        if (!duelEvent.canDuel(requestor, activeChar, false))
        {
          request.cancel();
          return;
        }
        SystemMessage2 msg1,
        msg2;
        if (_duelType == 1)
        {
          msg1 = new SystemMessage2(SystemMsg.YOU_HAVE_ACCEPTED_C1S_CHALLENGE_TO_A_PARTY_DUEL);
          msg2 = new SystemMessage2(SystemMsg.S1_HAS_ACCEPTED_YOUR_CHALLENGE_TO_DUEL_AGAINST_THEIR_PARTY);
        }
        else
        {
          msg1 = new SystemMessage2(SystemMsg.YOU_HAVE_ACCEPTED_C1S_CHALLENGE_A_DUEL);
          msg2 = new SystemMessage2(SystemMsg.C1_HAS_ACCEPTED_YOUR_CHALLENGE_TO_A_DUEL);
        }
        activeChar.sendPacket(msg1.addName(requestor));
        requestor.sendPacket(msg2.addName(activeChar));
        try
        {
          duelEvent.createDuel(requestor, activeChar);
        }
        finally
        {
          request.done();
        }
        break;
    }
  }
View Full Code Here

    Player activeChar = getClient().getActiveChar();
    if (activeChar == null)
    {
      return;
    }
    Request request = activeChar.getRequest();
    if ((request == null) || !request.isTypeOf(L2RequestType.PARTY))
    {
      return;
    }
    if (!request.isInProgress())
    {
      request.cancel();
      activeChar.sendActionFailed();
      return;
    }
    if (activeChar.isOutOfControl())
    {
      request.cancel();
      activeChar.sendActionFailed();
      return;
    }
    Player requestor = request.getRequestor();
    if (requestor == null)
    {
      request.cancel();
      activeChar.sendPacket(SystemMsg.THAT_PLAYER_IS_NOT_ONLINE);
      activeChar.sendActionFailed();
      return;
    }
    if (requestor.getRequest() != request)
    {
      request.cancel();
      activeChar.sendActionFailed();
      return;
    }
    if (_response <= 0)
    {
      request.cancel();
      requestor.sendPacket(JoinParty.FAIL);
      return;
    }
    if (activeChar.isInOlympiadMode())
    {
      request.cancel();
      activeChar.sendPacket(SystemMsg.A_PARTY_CANNOT_BE_FORMED_IN_THIS_AREA);
      requestor.sendPacket(JoinParty.FAIL);
      return;
    }
    if (requestor.isInOlympiadMode())
    {
      request.cancel();
      requestor.sendPacket(JoinParty.FAIL);
      return;
    }
    Party party = requestor.getParty();
    if ((party != null) && (party.getMemberCount() >= Party.MAX_SIZE))
    {
      request.cancel();
      activeChar.sendPacket(SystemMsg.THE_PARTY_IS_FULL);
      requestor.sendPacket(SystemMsg.THE_PARTY_IS_FULL);
      requestor.sendPacket(JoinParty.FAIL);
      return;
    }
    IStaticPacket problem = activeChar.canJoinParty(requestor);
    if (problem != null)
    {
      request.cancel();
      activeChar.sendPacket(problem, ActionFail.STATIC);
      requestor.sendPacket(JoinParty.FAIL);
      return;
    }
    if (party == null)
    {
      int itemDistribution = request.getInteger("itemDistribution");
      requestor.setParty(party = new Party(requestor, itemDistribution));
    }
    try
    {
      activeChar.joinParty(party);
      requestor.sendPacket(JoinParty.SUCCESS);
    }
    finally
    {
      request.done();
    }
  }
View Full Code Here

      int numHours = (int) Math.floor(countDown % 24);
      int numDays = (int) Math.floor((countDown - numHours) / 24);
      activeChar.sendPacket(new SystemMessage2(SystemMsg.YOU_CAN_BOND_WITH_A_NEW_MENTEE_IN_S1_DAYS_S2_HOUR_S3_MINUTE).addInteger(numDays).addInteger(numHours).addInteger(numMins));
      return;
    }
    new Request(L2RequestType.MENTEE, activeChar, newMentee).setTimeout(10000L);
    activeChar.sendPacket(new SystemMessage2(SystemMsg.YOU_HAVE_OFFERED_TO_BECOME_S1_MENTOR).addName(newMentee));
    newMentee.sendPacket(new ExMentorAdd(activeChar));
  }
View Full Code Here

    if (reciever.getTradeRefusal() || reciever.isBusy())
    {
      activeChar.sendPacket(new SystemMessage(SystemMessage.S1_IS_BUSY_PLEASE_TRY_AGAIN_LATER).addString(reciever.getName()));
      return;
    }
    new Request(L2RequestType.TRADE_REQUEST, activeChar, reciever).setTimeout(10000L);
    reciever.sendPacket(new SendTradeRequest(activeChar.getObjectId()));
    activeChar.sendPacket(new SystemMessage(SystemMessage.YOU_HAVE_REQUESTED_A_TRADE_WITH_C1).addString(reciever.getName()));
  }
View Full Code Here

    Player player = getClient().getActiveChar();
    if (player == null)
    {
      return;
    }
    Request request = player.getRequest();
    if ((request == null) || !request.isTypeOf(L2RequestType.CLAN))
    {
      return;
    }
    if (!request.isInProgress())
    {
      request.cancel();
      player.sendActionFailed();
      return;
    }
    if (player.isOutOfControl())
    {
      request.cancel();
      player.sendActionFailed();
      return;
    }
    Player requestor = request.getRequestor();
    if (requestor == null)
    {
      request.cancel();
      player.sendPacket(SystemMsg.THAT_PLAYER_IS_NOT_ONLINE);
      player.sendActionFailed();
      return;
    }
    if (requestor.getRequest() != request)
    {
      request.cancel();
      player.sendActionFailed();
      return;
    }
    Clan clan = requestor.getClan();
    if (clan == null)
    {
      request.cancel();
      player.sendActionFailed();
      return;
    }
    if (_response == 0)
    {
      request.cancel();
      requestor.sendPacket(new SystemMessage2(SystemMsg.S1_DECLINED_YOUR_CLAN_INVITATION).addName(player));
      return;
    }
    if (!player.canJoinClan())
    {
      request.cancel();
      player.sendPacket(SystemMsg.AFTER_LEAVING_OR_HAVING_BEEN_DISMISSED_FROM_A_CLAN_YOU_MUST_WAIT_AT_LEAST_A_DAY_BEFORE_JOINING_ANOTHER_CLAN);
      return;
    }
    try
    {
      player.sendPacket(new JoinPledge(requestor.getClanId()));
      int pledgeType = request.getInteger("pledgeType");
      SubUnit subUnit = clan.getSubUnit(pledgeType);
      if (subUnit == null)
      {
        return;
      }
      UnitMember member = new UnitMember(clan, player.getName(), player.getTitle(), player.getLevel(), player.getClassId().getId(), player.getObjectId(), pledgeType, player.getPowerGrade(), player.getApprentice(), player.getSex(), Clan.SUBUNIT_NONE);
      subUnit.addUnitMember(member);
      player.setPledgeType(pledgeType);
      player.setClan(clan);
      member.setPlayerInstance(player, false);
      if (pledgeType == Clan.SUBUNIT_ACADEMY)
      {
        player.setLvlJoinedAcademy(player.getLevel());
      }
      member.setPowerGrade(clan.getAffiliationRank(player.getPledgeType()));
      clan.broadcastToOtherOnlineMembers(new PledgeShowMemberListAdd(member), player);
      clan.broadcastToOnlineMembers(new SystemMessage2(SystemMsg.S1_HAS_JOINED_THE_CLAN).addString(player.getName()), new PledgeShowInfoUpdate(clan));
      player.sendPacket(SystemMsg.ENTERED_THE_CLAN);
      player.sendPacket(player.getClan().listAll());
      player.setLeaveClanTime(0);
      player.updatePledgeClass();
      clan.addSkillsQuietly(player);
      player.sendPacket(new PledgeSkillList(clan));
      player.sendSkillList();
      EventHolder.getInstance().findEvent(player);
      player.broadcastCharInfo();
      player.store(false);
    }
    finally
    {
      request.done();
    }
  }
View Full Code Here

      {
        activeChar.sendPacket(Msg.THE_ACADEMY_ROYAL_GUARD_ORDER_OF_KNIGHTS_IS_FULL_AND_CANNOT_ACCEPT_NEW_MEMBERS_AT_THIS_TIME);
      }
      return;
    }
    Request request = new Request(L2RequestType.CLAN, activeChar, member).setTimeout(10000L);
    request.set("pledgeType", _pledgeType);
    member.sendPacket(new AskJoinPledge(activeChar.getObjectId(), activeChar.getClan().getName()));
  }
View Full Code Here

    Player activeChar = getClient().getActiveChar();
    if (activeChar == null)
    {
      return;
    }
    Request request = activeChar.getRequest();
    if ((request == null) || !request.isTypeOf(Request.L2RequestType.MENTEE))
    {
      activeChar.sendActionFailed();
      return;
    }
    if (!request.isInProgress())
    {
      request.cancel();
      activeChar.sendActionFailed();
      return;
    }
    if (activeChar.isOutOfControl())
    {
      request.cancel();
      activeChar.sendActionFailed();
      return;
    }
    Player requestor = request.getRequestor();
    if (requestor == null)
    {
      request.cancel();
      activeChar.sendPacket(SystemMsg.THAT_PLAYER_IS_NOT_ONLINE);
      activeChar.sendActionFailed();
      return;
    }
    if (requestor.getRequest() != request)
    {
      request.cancel();
      activeChar.sendActionFailed();
      return;
    }
    if (_answer == 0)
    {
      request.cancel();
      requestor.sendPacket(new SystemMessage2(SystemMsg.S1_HAS_DECLINED_BECOMING_YOUR_MENTEE).addString(activeChar.getName()));
      return;
    }
    if (requestor.isActionsDisabled())
    {
      request.cancel();
      activeChar.sendPacket(new SystemMessage2(SystemMsg.C1_IS_ON_ANOTHER_TASK).addString(requestor.getName()));
      activeChar.sendActionFailed();
      return;
    }
    try
    {
      requestor.getMenteeMentorList().addMentee(activeChar);
      activeChar.getMenteeMentorList().addMentor(requestor);
      activeChar.sendPacket(new SystemMessage2(SystemMsg.FROM_NOW_ON_S1_WILL_BE_YOUR_MENTOR).addName(requestor), new ExMentorList(activeChar));
      requestor.sendPacket(new SystemMessage2(SystemMsg.FROM_NOW_ON_S1_WILL_BE_YOUR_MENTEE).addName(activeChar), new ExMentorList(requestor));
      Mentoring.applyMenteeBuffs(activeChar);
      Mentoring.applyMentorBuffs(requestor);
    }
    finally
    {
      request.done();
    }
  }
View Full Code Here

    Player activeChar = getClient().getActiveChar();
    if (activeChar == null)
    {
      return;
    }
    Request request = activeChar.getRequest();
    if ((request == null) || !request.isTypeOf(L2RequestType.PARTY_ROOM))
    {
      return;
    }
    if (!request.isInProgress())
    {
      request.cancel();
      activeChar.sendActionFailed();
      return;
    }
    if (activeChar.isOutOfControl())
    {
      request.cancel();
      activeChar.sendActionFailed();
      return;
    }
    Player requestor = request.getRequestor();
    if (requestor == null)
    {
      request.cancel();
      activeChar.sendPacket(SystemMsg.THAT_PLAYER_IS_NOT_ONLINE);
      activeChar.sendActionFailed();
      return;
    }
    if (requestor.getRequest() != request)
    {
      request.cancel();
      activeChar.sendActionFailed();
      return;
    }
    if (_response == 0)
    {
      request.cancel();
      requestor.sendPacket(SystemMsg.THE_PLAYER_DECLINED_TO_JOIN_YOUR_PARTY);
      return;
    }
    if (activeChar.getMatchingRoom() != null)
    {
      request.cancel();
      activeChar.sendActionFailed();
      return;
    }
    try
    {
      MatchingRoom room = requestor.getMatchingRoom();
      if ((room == null) || (room.getType() != MatchingRoom.PARTY_MATCHING))
      {
        return;
      }
      room.addMember(activeChar);
    }
    finally
    {
      request.done();
    }
  }
View Full Code Here

        if (!activeChar.checkCoupleAction(pcTarget))
        {
          activeChar.sendActionFailed();
          return;
        }
        new Request(L2RequestType.COUPLE_ACTION, activeChar, pcTarget).setTimeout(10000L);
        activeChar.sendPacket(new SystemMessage2(SystemMsg.YOU_HAVE_REQUESTED_A_COUPLE_ACTION_WITH_C1).addName(pcTarget));
        pcTarget.sendPacket(new ExAskCoupleAction(activeChar.getObjectId(), action.value));
        if (Config.ALT_SOCIAL_ACTION_REUSE)
        {
          ThreadPoolManager.getInstance().schedule(new SocialTask(activeChar), 2600);
View Full Code Here

TOP

Related Classes of lineage2.gameserver.model.Request

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.