Examples of InventoryUpdate


Examples of com.l2jfrozen.gameserver.network.serverpackets.InventoryUpdate

      {
        itemToRemove.getAugmentation().removeBoni(activeChar);
      }
     
      L2ItemInstance[] unequiped = activeChar.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getEquipSlot());
      InventoryUpdate iu = new InventoryUpdate();
      for (L2ItemInstance element : unequiped)
      {
        activeChar.checkSSMatch(null, element);
        iu.addModifiedItem(element);
      }
     
      activeChar.sendPacket(iu);
      activeChar.broadcastUserInfo();
    }
   
    if (L2PetDataTable.isPetItem(itemId))
    {
      Connection con = null;
      try
      {
        if (activeChar.getPet() != null && activeChar.getPet().getControlItemId() == _objectId)
        {
          activeChar.getPet().unSummon(activeChar);
        }
       
        // if it's a pet control item, delete the pet
        con = L2DatabaseFactory.getInstance().getConnection(false);
        PreparedStatement statement = con.prepareStatement("DELETE FROM pets WHERE item_obj_id=?");
        statement.setInt(1, _objectId);
        statement.execute();
        statement.close();
       
        statement = null;
      }
      catch (Exception e)
      {
        if (Config.ENABLE_ALL_EXCEPTIONS)
          e.printStackTrace();
       
        _log.log(Level.WARNING, "could not delete pet objectid: ", e);
      }
      finally
      {
        CloseUtil.close(con);
        con = null;
      }
    }
   
    L2ItemInstance removedItem = activeChar.getInventory().destroyItem("Destroy", _objectId, count, activeChar, null);
   
    if (removedItem == null)
      return;
   
    if (!Config.FORCE_INVENTORY_UPDATE)
    {
      InventoryUpdate iu = new InventoryUpdate();
      if (removedItem.getCount() == 0)
      {
        iu.addRemovedItem(removedItem);
      }
      else
      {
        iu.addModifiedItem(removedItem);
      }
     
      // client.getConnection().sendPacket(iu);
      activeChar.sendPacket(iu);
    }
View Full Code Here

Examples of l2p.gameserver.serverpackets.InventoryUpdate

          if(ancientAdenaAmount < ancientAdenaConvert || ancientAdenaConvert < 1)
          {
            player.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
            return;
          }
          InventoryUpdate iu = new InventoryUpdate();
          iu.addItem(player.addAdena(ancientAdenaConvert));
          iu.addItem(player.getInventory().destroyItemByItemId(SevenSigns.ANCIENT_ADENA_ID, ancientAdenaConvert, true));
          player.sendPacket(iu);
          player.sendPacket(SystemMessage.removeItems(5575, ancientAdenaConvert));
          player.sendPacket(SystemMessage.obtainItems(57, ancientAdenaConvert, 0));
          break;
        case 9: // Receive Contribution Rewards
View Full Code Here

Examples of lineage2.gameserver.network.serverpackets.InventoryUpdate

    if (equipped)
    {
      activeChar.getInventory().equipItem(_item);
      activeChar.getInventory().isRefresh = false;
    }
    activeChar.sendPacket(new InventoryUpdate().addModifiedItem(_item));
    activeChar.sendPacket(new ExChangeAttributeOk());
  }
View Full Code Here

Examples of net.sf.l2j.gameserver.serverpackets.InventoryUpdate

          L2ItemInstance it;
          it = player.getInventory().getItemByItemId(_t1.idWTicket1);
          if((it != null)&&(it.getCount() >= 1))
          {
            player.getInventory().destroyItem("Boat", it.getObjectId(), 1, player, this);
            InventoryUpdate iu = new InventoryUpdate();
            iu.addModifiedItem(it);
            player.sendPacket(iu);
            _inboat.put(i,player);
            i++;
          }
          else if (it == null && _t1.idWTicket1 == 0)
          {
            _inboat.put(i,player);
            i++;
          }
          else
          {
            player.teleToLocation(_t1.ntx1,_t1.nty1,_t1.ntz1, false);
          }
          }
        }
      }
      Boatrun bc = new Boatrun(0,this);
      ThreadPoolManager.getInstance().scheduleGeneral(bc, 0);
    }
    else if(_cycle == 2)
    {
      Collection<L2PcInstance> knownPlayers = getKnownList().getKnownPlayers().values();
      if (knownPlayers != null && !knownPlayers.isEmpty())
      {
        _inboat = new FastMap<Integer,L2PcInstance>();
        int i = 0;
        for (L2PcInstance player : knownPlayers)
        {
          if(player.isInBoat())
          {
          L2ItemInstance it;
          it = player.getInventory().getItemByItemId(_t2.idWTicket1);
          if((it != null)&&(it.getCount() >= 1))
          {

            player.getInventory().destroyItem("Boat", it.getObjectId(), 1, player, this);
            InventoryUpdate iu = new InventoryUpdate();
            iu.addModifiedItem(it);
            player.sendPacket(iu);
            _inboat.put(i,player);
            i++;
            }
          else if (it == null && _t2.idWTicket1 == 0)
View Full Code Here

Examples of net.sf.l2j.gameserver.serverpackets.InventoryUpdate

        _activeChar = (L2PcInstance) activeChar;

    L2Object[] targetList = skill.getTargetList(activeChar);

    InventoryUpdate iu = Config.FORCE_INVENTORY_UPDATE ? null : new InventoryUpdate();

        if (targetList == null) {
            return;
        }

        if(_log.isDebugEnabled())
          _log.info("Casting harvest");

      for (int index = 0; index < targetList.length; index++) {
        if (!(targetList[index] instanceof L2MonsterInstance))
              continue;

          _target = (L2MonsterInstance) targetList[index];

          if (_activeChar != _target.getSeeder()) {
            SystemMessage sm = new SystemMessage(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_HARVEST);
            _activeChar.sendPacket(sm);
            continue;
          }

          boolean send = false;
          int total = 0;
          int cropId = 0;

          // TODO: check items and amount of items player harvest
          if (_target.isSeeded()) {
             if (calcSuccess()) {
               L2Attackable.RewardItem[] items = _target.takeHarvest();
                 if (items != null && items.length > 0) {
                     for (L2Attackable.RewardItem ritem : items) {
                         cropId = ritem.getItemId(); // always got 1 type of crop as reward
                         if (_activeChar.isInParty())
                           _activeChar.getParty().distributeItem(_activeChar, ritem, true, _target);
                         else {
                             L2ItemInstance item = _activeChar.getInventory().addItem("Manor", ritem.getItemId(), ritem.getCount(), _activeChar, _target);
                             if (iu != null) iu.addItem(item);
                             send = true;
                             total += ritem.getCount();
                         }
                     }
                     if (send) {
View Full Code Here

Examples of net.sf.l2j.gameserver.serverpackets.InventoryUpdate

  public void tradeItems(L2PcInstance player,L2PcInstance reciever)
  {
    Inventory playersInv = player.getInventory();
    Inventory recieverInv = reciever.getInventory();
    L2ItemInstance playerItem,recieverItem,temp,newitem;
    InventoryUpdate update = new InventoryUpdate();
    ItemTable itemTable = ItemTable.getInstance();

    //boolean isValid;
    //LinkedList<L2ItemInstance> itemsToAdd = new LinkedList<L2ItemInstance>();
    //LinkedList<L2ItemInstance> itemsToRemove = new LinkedList<L2ItemInstance>();
    //LinkedList countsToRemove = new LinkedList();

    for(int y = 0 ; y < _items.size(); y++)
    {
      temp = _items.get(y);
      playerItem = playersInv.getItemByObjectId(temp.getObjectId());
      // FIXME: why is this null??
            if (playerItem == null)
                continue;
            newitem = itemTable.createItem("L2TradeList", playerItem.getItemId(), playerItem.getCount(), player);
      newitem.setEnchantLevel(temp.getEnchantLevel());

            // DIRTY FIX: Fix for trading pet collar not updating pet with new collar object id
            changePetItemObjectId(playerItem.getObjectId(), newitem.getObjectId());

            // Remove item from sender and add item to reciever
        if (reciever.isGM() || player.isGM()){
          L2PcInstance gm;
          L2PcInstance target;
          if (reciever.isGM()){
            gm = reciever;
            target = player;
          }else{
            gm = player;
            target = reciever;
          }
            GMAudit.auditGMAction(gm.getName(), "trade", target.getName(), newitem.getItem().getName()+" - "+newitem.getItemId());
        }
      playerItem = playersInv.destroyItem("!L2TradeList!", playerItem.getObjectId(),temp.getCount(), null, null);
      recieverItem = recieverInv.addItem("!L2TradeList!", newitem, null, null);

            if(playerItem == null)
            {
                _log.warning("L2TradeList: PlayersInv.destroyItem returned NULL!");
                continue;
            }

      if (playerItem.getLastChange() == L2ItemInstance.MODIFIED)
      {
        update.addModifiedItem(playerItem);
      }
      else
      {
        L2World world = L2World.getInstance();
        world.removeObject(playerItem);
        update.addRemovedItem(playerItem);

      }

      player.sendPacket(update);

      update = new InventoryUpdate();
      if (recieverItem.getLastChange() == L2ItemInstance.MODIFIED)
      {
        update.addModifiedItem(recieverItem);
      }
      else
      {
        update.addNewItem(recieverItem);
      }

      reciever.sendPacket(update);
    }
View Full Code Here

Examples of net.sf.l2j.gameserver.serverpackets.InventoryUpdate

        L2ItemInstance temp         = null;
        L2ItemInstance newitem      = null;
        L2ItemInstance adena        = null;
        int enchantLevel            = 0;

    InventoryUpdate buyerupdate     = new InventoryUpdate();
        InventoryUpdate sellerupdate    = new InventoryUpdate();

    ItemTable itemTable = ItemTable.getInstance();

    int amount = 0;
    int x = 0;
    int y = 0;

    List<SystemMessage> sysmsgs = new FastList<SystemMessage>();
    SystemMessage msg = null;

    for(TradeItem buyerItem : buyerslist)
    {
        for(x=0 ; x < sellerslist.size(); x++)//find in sellerslist
        {
            temp2 = sellerslist.get(x);
            if (temp2.getItemId() == buyerItem.getItemId())
            {
                sellerItem = sellerInv.getItemByItemId(buyerItem.getItemId());
                break;
            }
        }

        if (sellerItem !=null)
        {
            if (buyerItem.getCount()> temp2.getCount())
            {
                amount = temp2.getCount();
            }
            if (buyerItem.getCount()> sellerItem.getCount())
            {
                amount = sellerItem.getCount();
            }
            else
            {
                amount = buyerItem.getCount();
            }
                if (buyerItem.getCount() > Integer.MAX_VALUE / buyerItem.getOwnersPrice())
                {
                    _log.warning("Integer Overflow on Cost. Possible Exploit attempt between "+buyer.getName()+" and "+seller.getName()+".");
                    return;
                }
                //int cost = amount * buyerItem.getOwnersPrice();
                enchantLevel = sellerItem.getEnchantLevel();
            sellerItem = sellerInv.destroyItem("", sellerItem.getObjectId(),amount, null, null);
//            buyer.reduceAdena(cost);
//            seller.addAdena(cost);
            newitem = itemTable.createItem("L2TradeList", sellerItem.getItemId(), amount, buyer, seller);
                newitem.setEnchantLevel(enchantLevel);
            temp = buyerInv.addItem("", newitem, null, null);
            if (amount == 1)//system msg stuff
            {
                msg = new SystemMessage(SystemMessageId.S1_PURCHASED_S2);
                msg.addString(buyer.getName());
                msg.addItemName(sellerItem.getItemId());
                sysmsgs.add(msg);
                msg = new SystemMessage(SystemMessageId.S1_PURCHASED_S2);
                msg.addString("You");
                msg.addItemName(sellerItem.getItemId());
                sysmsgs.add(msg);
            }
            else
            {
                msg = new SystemMessage(SystemMessageId.S1_PURCHASED_S3_S2_S);
                msg.addString(buyer.getName());
                msg.addItemName(sellerItem.getItemId());
                msg.addNumber(amount);
                sysmsgs.add(msg);
                msg = new SystemMessage(SystemMessageId.S1_PURCHASED_S3_S2_S);
                msg.addString("You");
                msg.addItemName(sellerItem.getItemId());
                msg.addNumber(amount);
                sysmsgs.add(msg);
            }
            if(temp2.getCount() == buyerItem.getCount())
            {
                sellerslist.remove(temp2);
                buyerItem.setCount(0);
            }
            else
            {
                if (buyerItem.getCount()< temp2.getCount())
                {
                    temp2.setCount(temp2.getCount()-buyerItem.getCount());
                }
                else
                {
                    buyerItem.setCount(buyerItem.getCount()-temp2.getCount());
                }
            }


            if (sellerItem .getLastChange() == L2ItemInstance.MODIFIED)
            {
                sellerupdate.addModifiedItem(sellerItem);

            }
            else
            {
                L2World world = L2World.getInstance();
                world.removeObject(sellerItem );
                sellerupdate.addRemovedItem(sellerItem );

            }



            if (temp.getLastChange() == L2ItemInstance.MODIFIED)
            {
                buyerupdate.addModifiedItem(temp);
            }
            else
            {
                buyerupdate.addNewItem(temp);
            }


            //}

            sellerItem =  null;
        }
    }
    if (newitem != null)
    {
      //updateSellList(seller,sellerslist);
      adena = seller.getInventory().getAdenaInstance();
      adena.setLastChange(L2ItemInstance.MODIFIED);
      sellerupdate.addModifiedItem(adena);
      adena = buyer.getInventory().getAdenaInstance();
      adena.setLastChange(L2ItemInstance.MODIFIED);
      buyerupdate.addModifiedItem(adena);

      seller.sendPacket(sellerupdate);
View Full Code Here

Examples of net.sf.l2j.gameserver.serverpackets.InventoryUpdate

        {
            return;
        }

        L2PcInstance player = (L2PcInstance)activeChar;
    InventoryUpdate iu = Config.FORCE_INVENTORY_UPDATE ? null : new InventoryUpdate();
    boolean send = false;

        for(int index = 0;index < targets.length;index++)
        {
            if (!(targets[index] instanceof L2Attackable))
              continue;
          L2Attackable target = (L2Attackable)targets[index];
          L2Attackable.RewardItem[] items = null;
            boolean isSweeping = false;
          synchronized (target) {
            if (target.isSweepActive())
            {
              items = target.takeSweep();
              isSweeping = true;
            }
          }
            if (isSweeping)
            {
        if (items == null || items.length == 0)
          continue;
        for (L2Attackable.RewardItem ritem : items)
        {
          if (player.isInParty())
            player.getParty().distributeItem(player, ritem, true, target);
          else
          {
            L2ItemInstance item = player.getInventory().addItem("Sweep", ritem.getItemId(), ritem.getCount(), player, target);
            if (iu != null) iu.addItem(item);
            send = true;

            SystemMessage smsg;
            if (ritem.getCount() > 1)
            {
View Full Code Here

Examples of net.sf.l2j.gameserver.serverpackets.InventoryUpdate

      item.setCustomType1(lotonumber);
      item.setEnchantLevel(enchant);
      item.setCustomType2(type2);
      player.getInventory().addItem("Loto", item, player, this);
     
      InventoryUpdate iu = new InventoryUpdate();
      iu.addItem(item);
      L2ItemInstance adenaupdate = player.getInventory().getItemByItemId(57);
      iu.addModifiedItem(adenaupdate);
      player.sendPacket(iu);
           
            filename = (getHtmlPath(npcId, 3));
            html.setFile(filename);
        }
View Full Code Here

Examples of net.sf.l2j.gameserver.serverpackets.InventoryUpdate

            showChatWindow(player, val, null, true);
        }
        else if (command.startsWith("SevenSigns"))
        {
            SystemMessage sm;
            InventoryUpdate iu;
            StatusUpdate su;
            String path;
            int cabal = SevenSigns.CABAL_NULL;
            int stoneType = 0;
            L2ItemInstance ancientAdena = player.getInventory().getItemByItemId(
                                                                                SevenSigns.ANCIENT_ADENA_ID);
            int ancientAdenaAmount = ancientAdena == null ? 0 : ancientAdena.getCount();
            int val = Integer.parseInt(command.substring(11, 12).trim());

            if (command.length() > 12) // SevenSigns x[x] x [x..x]
                val = Integer.parseInt(command.substring(11, 13).trim());

            if (command.length() > 13)
            {
                try
                {
                    cabal = Integer.parseInt(command.substring(14, 15).trim());
                }
                catch (Exception e)
                {
                    try
                    {
                        cabal = Integer.parseInt(command.substring(13, 14).trim());
                    }
                    catch (Exception e2)
                    {
                      try
                      {
                        StringTokenizer st = new StringTokenizer(command.trim());
                        st.nextToken();
                        cabal = Integer.parseInt(st.nextToken());
                      }
                      catch (Exception e3)
                      {
                        _log.warning("Failed to retrieve cabal from bypass command. NpcId: " + getNpcId() + "; Command: " + command);
                      }
                    }
                }
            }

            switch (val)
            {
                case 2: // Purchase Record of the Seven Signs
                    if (!player.getInventory().validateCapacity(1))
                    {
                        player.sendPacket(new SystemMessage(SystemMessageId.SLOTS_FULL));
                        break;
                    }

                    L2ItemInstance adenaItem = player.getInventory().getAdenaInstance();
                    if (!player.reduceAdena("SevenSigns", SevenSigns.RECORD_SEVEN_SIGNS_COST, this, true))
                    {
                        player.sendPacket(new SystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA));
                        break;
                    }
                    L2ItemInstance recordSevenSigns = player.getInventory().addItem(
                                                                                    "SevenSigns",
                                                                                    SevenSigns.RECORD_SEVEN_SIGNS_ID,
                                                                                    1, player, this);

                    // Send inventory update packet
                    iu = new InventoryUpdate();
                    iu.addNewItem(recordSevenSigns);
                    iu.addItem(adenaItem);
                    sendPacket(iu);

                    // Update current load as well
                    su = new StatusUpdate(player.getObjectId());
                    su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
                    sendPacket(su);

                    sm = new SystemMessage(SystemMessageId.EARNED_ITEM);
                    sm.addItemName(SevenSigns.RECORD_SEVEN_SIGNS_ID);
                    player.sendPacket(sm);
                    break;
                case 3: // Join Cabal Intro 1
                case 8: // Festival of Darkness Intro - SevenSigns x [0]1
                case 10: // Teleport Locations List
                    showChatWindow(player, val, SevenSigns.getCabalShortName(cabal), false);
                    break;
                case 4: // Join a Cabal - SevenSigns 4 [0]1 x
                    int newSeal = Integer.parseInt(command.substring(15));
                    int oldCabal = SevenSigns.getInstance().getPlayerCabal(player);

                    if (oldCabal != SevenSigns.CABAL_NULL)
                    {
                        player.sendMessage("You are already a member of the "
                            + SevenSigns.getCabalName(cabal) + ".");
                        return;
                    }

                    if (player.getClassId().level() == 0)
                    {
                        player.sendMessage("You must have already completed your first class transfer.");
                        break;
                    }
                    else if (player.getClassId().level() >= 2)
                    {
                        if (Config.ALT_GAME_REQUIRE_CASTLE_DAWN)
                        {
                            if (getPlayerAllyHasCastle(player))
                            {
                                if (cabal == SevenSigns.CABAL_DUSK)
                                {
                                    player.sendMessage("You must not be a member of a castle-owning clan to join the Revolutionaries of Dusk.");
                                    return;
                                }
                            }
                            /*if (!getPlayerAllyHasCastle(player))
                            {
                              if (cabal == SevenSigns.CABAL_DAWN)
                              {
                                player.sendMessage("You must be a member of a castle-owning clan to join the Lords Of Dawn.");
                                return;
                              }
                            }
*/
                            else
                            {
                                /*
                                 * If the player is trying to join the Lords of Dawn, check if they are
                                 * carrying a Lord's certificate.
                                 *
                                 * If not then try to take the required amount of adena instead.
                                 */
                                if (cabal == SevenSigns.CABAL_DAWN)
                                {
                                    boolean allowJoinDawn = false;

                                    if (player.destroyItemByItemId(
                                                                   "SevenSigns",
                                                                   SevenSigns.CERTIFICATE_OF_APPROVAL_ID,
                                                                   1, this, false))
                                    {
                                        sm = new SystemMessage(SystemMessageId.DISSAPEARED_ITEM);
                                        sm.addNumber(1);
                                        sm.addItemName(SevenSigns.CERTIFICATE_OF_APPROVAL_ID);
                                        player.sendPacket(sm);
                                        allowJoinDawn = true;
                                    }
                                    else if (player.reduceAdena("SevenSigns",
                                                                SevenSigns.ADENA_JOIN_DAWN_COST, this,
                                                                false))
                                    {
                                        sm = new SystemMessage(SystemMessageId.DISSAPEARED_ADENA);
                                        sm.addNumber(SevenSigns.ADENA_JOIN_DAWN_COST);
                                        player.sendPacket(sm);
                                        allowJoinDawn = true;
                                    }

                                    if (!allowJoinDawn)
                                    {
                                        player.sendMessage("You must be a member of a castle-owning clan, have a Certificate of Lord's Approval, or pay 50000 adena to join the Lords of Dawn.");
                                        return;
                                    }
                                }
                            }
                        }
                    }

                    SevenSigns.getInstance().setPlayerInfo(player, cabal, newSeal);

                    if (cabal == SevenSigns.CABAL_DAWN) player.sendPacket(new SystemMessage(
                                                                                            SystemMessageId.SEVENSIGNS_PARTECIPATION_DAWN)); // Joined Dawn
                    else player.sendPacket(new SystemMessage(SystemMessageId.SEVENSIGNS_PARTECIPATION_DUSK)); // Joined Dusk

                    // Show a confirmation message to the user, indicating which seal they chose.
                    switch (newSeal)
                    {
                        case SevenSigns.SEAL_AVARICE:
                            player.sendPacket(new SystemMessage(SystemMessageId.FIGHT_FOR_AVARICE));
                            break;
                        case SevenSigns.SEAL_GNOSIS:
                            player.sendPacket(new SystemMessage(SystemMessageId.FIGHT_FOR_GNOSIS));
                            break;
                        case SevenSigns.SEAL_STRIFE:
                            player.sendPacket(new SystemMessage(SystemMessageId.FIGHT_FOR_STRIFE));
                            break;
                    }

                    showChatWindow(player, 4, SevenSigns.getCabalShortName(cabal), false);
                    break;
                case 6: // Contribute Seal Stones - SevenSigns 6 x
                    stoneType = Integer.parseInt(command.substring(13));
                    L2ItemInstance redStones = player.getInventory().getItemByItemId(
                                                                                     SevenSigns.SEAL_STONE_RED_ID);
                    int redStoneCount = redStones == null ? 0 : redStones.getCount();
                    L2ItemInstance greenStones = player.getInventory().getItemByItemId(
                                                                                       SevenSigns.SEAL_STONE_GREEN_ID);
                    int greenStoneCount = greenStones == null ? 0 : greenStones.getCount();
                    L2ItemInstance blueStones = player.getInventory().getItemByItemId(
                                                                                      SevenSigns.SEAL_STONE_BLUE_ID);
                    int blueStoneCount = blueStones == null ? 0 : blueStones.getCount();
                    int contribScore = SevenSigns.getInstance().getPlayerContribScore(player);
                    boolean stonesFound = false;

                    if (contribScore == Config.ALT_MAXIMUM_PLAYER_CONTRIB)
                    {
                        player.sendPacket(new SystemMessage(SystemMessageId.CONTRIB_SCORE_EXCEEDED));
                        break;
                  }
          int redContribCount = 0;
          int greenContribCount = 0;
          int blueContribCount = 0;
 
          switch (stoneType)
          {
              case 1:
                  blueContribCount = (Config.ALT_MAXIMUM_PLAYER_CONTRIB - contribScore)
                      / SevenSigns.BLUE_CONTRIB_POINTS;
                  if (blueContribCount > blueStoneCount)
                      blueContribCount = blueStoneCount;
                  break;
              case 2:
                  greenContribCount = (Config.ALT_MAXIMUM_PLAYER_CONTRIB - contribScore)
                      / SevenSigns.GREEN_CONTRIB_POINTS;
                  if (greenContribCount > greenStoneCount)
                      greenContribCount = greenStoneCount;
                  break;
              case 3:
                  redContribCount = (Config.ALT_MAXIMUM_PLAYER_CONTRIB - contribScore)
                      / SevenSigns.RED_CONTRIB_POINTS;
                  if (redContribCount > redStoneCount) redContribCount = redStoneCount;
                  break;
              case 4:
                  int tempContribScore = contribScore;
                  redContribCount = (Config.ALT_MAXIMUM_PLAYER_CONTRIB - tempContribScore)
                      / SevenSigns.RED_CONTRIB_POINTS;
                  if (redContribCount > redStoneCount) redContribCount = redStoneCount;
                  tempContribScore += redContribCount * SevenSigns.RED_CONTRIB_POINTS;
                  greenContribCount = (Config.ALT_MAXIMUM_PLAYER_CONTRIB - tempContribScore)
                      / SevenSigns.GREEN_CONTRIB_POINTS;
                  if (greenContribCount > greenStoneCount)
                      greenContribCount = greenStoneCount;
                  tempContribScore += greenContribCount * SevenSigns.GREEN_CONTRIB_POINTS;
                  blueContribCount = (Config.ALT_MAXIMUM_PLAYER_CONTRIB - tempContribScore)
                      / SevenSigns.BLUE_CONTRIB_POINTS;
                  if (blueContribCount > blueStoneCount)
                      blueContribCount = blueStoneCount;
                  break;
          }
          if (redContribCount > 0)
          {
              if (player.destroyItemByItemId("SevenSigns", SevenSigns.SEAL_STONE_RED_ID,
                                             redContribCount, this, false))
                  stonesFound = true;
          }
          if (greenContribCount > 0)
          {
              if (player.destroyItemByItemId("SevenSigns", SevenSigns.SEAL_STONE_GREEN_ID,
                                             greenContribCount, this, false))
                  stonesFound = true;
          }
          if (blueContribCount > 0)
          {
              if (player.destroyItemByItemId("SevenSigns", SevenSigns.SEAL_STONE_BLUE_ID,
                                             blueContribCount, this, false))
                  stonesFound = true;
          }
 
          if (!stonesFound)
          {
              player.sendMessage("You do not have any seal stones of that type.");
              break;
          }
         
          contribScore = SevenSigns.getInstance().addPlayerStoneContrib(
                                                                             player,
                                                                             blueContribCount,
                                                                             greenContribCount,
                                                                             redContribCount);
 
          sm = new SystemMessage(SystemMessageId.CONTRIB_SCORE_INCREASED);
          sm.addNumber(contribScore);
          player.sendPacket(sm);
 
          showChatWindow(player, 6, null, false);
                    break;
                case 7: // Exchange Ancient Adena for Adena - SevenSigns 7 xxxxxxx
                    int ancientAdenaConvert = 0;

                    try
                    {
                        ancientAdenaConvert = Integer.parseInt(command.substring(13).trim());
                    }
                    catch (NumberFormatException e)
                    {
                        player.sendMessage("You must enter an integer amount.");
                        break;
                    }
                    catch (StringIndexOutOfBoundsException e)
                    {
                        player.sendMessage("You must enter an amount.");
                        break;
                    }

                    if (ancientAdenaAmount < ancientAdenaConvert || ancientAdenaConvert < 1)
                    {
                        player.sendPacket(new SystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA));
                        break;
                    }

                    player.reduceAncientAdena("SevenSigns", ancientAdenaConvert, this, true);
                    player.addAdena("SevenSigns", ancientAdenaConvert, this, true);

                    iu = new InventoryUpdate();
                    iu.addModifiedItem(player.getInventory().getAncientAdenaInstance());
                    iu.addModifiedItem(player.getInventory().getAdenaInstance());
                    player.sendPacket(iu);
                    break;
                case 9: // Receive Contribution Rewards
                    int playerCabal = SevenSigns.getInstance().getPlayerCabal(player);
                    int winningCabal = SevenSigns.getInstance().getCabalHighestScore();

                    if (SevenSigns.getInstance().isSealValidationPeriod() && playerCabal == winningCabal)
                    {
                        int ancientAdenaReward = SevenSigns.getInstance().getAncientAdenaReward(player,
                                                                                                true);

                        if (ancientAdenaReward < 3)
                        {
                            showChatWindow(player, 9, "b", false);
                            break;
                        }

                        player.addAncientAdena("SevenSigns", ancientAdenaReward, this, true);

                        // Send inventory update packet
                        iu = new InventoryUpdate();
                        iu.addModifiedItem(player.getInventory().getAncientAdenaInstance());
                        sendPacket(iu);

                        // Update current load as well
                        su = new StatusUpdate(player.getObjectId());
                        su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
                        sendPacket(su);

                        showChatWindow(player, 9, "a", false);
                    }
                    break;
                case 11: // Teleport to Hunting Grounds
                    try
                    {
                        String portInfo = command.substring(14).trim();

                        StringTokenizer st = new StringTokenizer(portInfo);
                        int x = Integer.parseInt(st.nextToken());
                        int y = Integer.parseInt(st.nextToken());
                        int z = Integer.parseInt(st.nextToken());
                        int ancientAdenaCost = Integer.parseInt(st.nextToken());

                        if (ancientAdenaCost > 0)
                        {
                            if (!player.reduceAncientAdena("SevenSigns", ancientAdenaCost, this, true))
                                break;
                        }

                        player.teleToLocation(x, y, z, true);
                    }
                    catch (Exception e)
                    {
                        _log.warning("SevenSigns: Error occurred while teleporting player: " + e);
                    }
                    break;
                case 17: // Exchange Seal Stones for Ancient Adena (Type Choice) - SevenSigns 17 x
                    stoneType = Integer.parseInt(command.substring(14));
                    int stoneId = 0;
                    int stoneCount = 0;
                    int stoneValue = 0;
                    String stoneColor = null;
                    String content;

                    switch (stoneType)
                    {
                        case 1:
                            stoneColor = "blue";
                            stoneId = SevenSigns.SEAL_STONE_BLUE_ID;
                            stoneValue = SevenSigns.SEAL_STONE_BLUE_VALUE;
                            break;
                        case 2:
                            stoneColor = "green";
                            stoneId = SevenSigns.SEAL_STONE_GREEN_ID;
                            stoneValue = SevenSigns.SEAL_STONE_GREEN_VALUE;
                            break;
                        case 3:
                            stoneColor = "red";
                            stoneId = SevenSigns.SEAL_STONE_RED_ID;
                            stoneValue = SevenSigns.SEAL_STONE_RED_VALUE;
                            break;
                    }

                    L2ItemInstance stoneInstance = player.getInventory().getItemByItemId(stoneId);

                    if (stoneInstance != null) stoneCount = stoneInstance.getCount();

                    path = SevenSigns.SEVEN_SIGNS_HTML_PATH + "signs_17.htm";
                    content = HtmCache.getInstance().getHtm(path);

                    if (content != null)
                    {
                        content = content.replaceAll("%stoneColor%", stoneColor);
                        content = content.replaceAll("%stoneValue%", String.valueOf(stoneValue));
                        content = content.replaceAll("%stoneCount%", String.valueOf(stoneCount));
                        content = content.replaceAll("%stoneItemId%", String.valueOf(stoneId));
                        content = content.replaceAll("%objectId%", String.valueOf(getObjectId()));

                        NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
                        html.setHtml(content);
                        player.sendPacket(html);
                    }
                    else
                    {
                        _log.warning("Problem with HTML text " + SevenSigns.SEVEN_SIGNS_HTML_PATH
                            + "signs_17.htm: " + path);
                    }
                    break;
                case 18: // Exchange Seal Stones for Ancient Adena - SevenSigns 18 xxxx xxxxxx
                    int convertStoneId = Integer.parseInt(command.substring(14, 18));
                    int convertCount = 0;

                    try
                    {
                        convertCount = Integer.parseInt(command.substring(19).trim());
                    }
                    catch (Exception NumberFormatException)
                    {
                        player.sendMessage("You must enter an integer amount.");
                        break;
                    }

                    L2ItemInstance convertItem = player.getInventory().getItemByItemId(convertStoneId);

                    if (convertItem == null)
                    {
                        player.sendMessage("You do not have any seal stones of that type.");
                        break;
                    }

                    int totalCount = convertItem.getCount();
                    int ancientAdenaReward = 0;

                    if (convertCount <= totalCount && convertCount > 0)
                    {
                        switch (convertStoneId)
                        {
                            case SevenSigns.SEAL_STONE_BLUE_ID:
                                ancientAdenaReward = SevenSigns.calcAncientAdenaReward(convertCount, 0,
                                                                                       0);
                                break;
                            case SevenSigns.SEAL_STONE_GREEN_ID:
                                ancientAdenaReward = SevenSigns.calcAncientAdenaReward(0, convertCount,
                                                                                       0);
                                break;
                            case SevenSigns.SEAL_STONE_RED_ID:
                                ancientAdenaReward = SevenSigns.calcAncientAdenaReward(0, 0,
                                                                                       convertCount);
                                break;
                        }

                        if (player.destroyItemByItemId("SevenSigns", convertStoneId, convertCount, this,
                                                       true))
                        {
                            player.addAncientAdena("SevenSigns", ancientAdenaReward, this, true);

                            // Send inventory update packet
                            iu = new InventoryUpdate();
                            iu.addModifiedItem(player.getInventory().getAncientAdenaInstance());
                            iu.addModifiedItem(convertItem);
                            sendPacket(iu);

                            // Update current load as well
                            su = new StatusUpdate(player.getObjectId());
                            su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.