Package net.sf.l2j.gameserver.model

Examples of net.sf.l2j.gameserver.model.ItemContainer


        continue;
      L2Clan clan = ClanTable.getInstance().getClan(c.getOwnerId());
      if (clan == null)
        continue;

      ItemContainer cwh = clan.getWarehouse();
      if (!(cwh instanceof ClanWarehouse)) {
        _log.info("Can't get clan warehouse for clan " + ClanTable.getInstance().getClan(c.getOwnerId()));
        return;
      }

      for (CropProcure crop: c.getCropProcure(PERIOD_CURRENT)) {
        if (crop.getStartAmount() == 0)
          continue;
        // adding bought crops to clan warehouse
        if (crop.getStartAmount() - crop.getAmount() > 0) {
          int count = crop.getStartAmount() - crop.getAmount();
          count = count * 90 / 100;
          if (count < 1) {
            if (Rnd.nextInt(99) < 90)
              count = 1;
          }
          if (count > 0) {
            cwh.addItem("Manor", L2Manor.getInstance().getMatureCrop(crop.getId()), count, null, null);
          }
        }
        // reserved and not used money giving back to treasury
        if (crop.getAmount() > 0) {
          c.addToTreasuryNoTax(crop.getAmount() * crop.getPrice());
 
View Full Code Here


      } else if (c.getTreasury() < c.getManorCost(PERIOD_NEXT)) {
        notFunc = true;
        c.setSeedProduction(getNewSeedsList(c.getCastleId()), PERIOD_NEXT);
        c.setCropProcure(getNewCropsList(c.getCastleId()), PERIOD_NEXT);
      } else {
        ItemContainer cwh = ClanTable.getInstance().getClan(c.getOwnerId()).getWarehouse();
        if (!(cwh instanceof ClanWarehouse)) {
          _log.info("Can't get clan warehouse for clan " + ClanTable.getInstance().getClan(c.getOwnerId()));
          return;
        }
        int slots = 0;
        for (CropProcure crop : c.getCropProcure(PERIOD_NEXT)) {
          if (crop.getStartAmount() > 0) {
            slots++;
          }
        }
        if (!cwh.validateCapacity(slots)) {
          notFunc = true;
          c.setSeedProduction(getNewSeedsList(c.getCastleId()), PERIOD_NEXT);
          c.setCropProcure(getNewCropsList(c.getCastleId()), PERIOD_NEXT);
        }
      }
View Full Code Here

    public void run()
    {
      try
      {
        // Move current castle treasury to clan warehouse every 2 hour
        ItemContainer warehouse = _clan.getWarehouse();
        if ((warehouse != null) && (_clan.getHasCastle() > 0))
        {
          Castle castle = CastleManager.getInstance().getCastleById(_clan.getHasCastle());
          if (!Config.ALT_MANOR_SAVE_ALL_ACTIONS)
          {
View Full Code Here

  @Override
  protected void runImpl()
  {
    L2PcInstance player = getClient().getActiveChar();
        if (player == null) return;
        ItemContainer warehouse = player.getActiveWarehouse();
        if (warehouse == null) return;
    L2FolkInstance manager = player.getLastFolkNPC();
    if ((manager == null || !player.isInsideRadius(manager, L2NpcInstance.INTERACTION_DISTANCE, false, false)) && !player.isGM()) return;

        if (warehouse instanceof ClanWarehouse && Config.GM_DISABLE_TRANSACTION && player.getAccessLevel() >= Config.GM_TRANSACTION_MIN && player.getAccessLevel() <= Config.GM_TRANSACTION_MAX)
        {
            player.sendMessage("Transactions are disable for your Access Level");
            return;
        }

        // Alt game - Karma punishment
        if (!Config.ALT_GAME_KARMA_PLAYER_CAN_USE_WAREHOUSE && player.getKarma() > 0) return;

        if (Config.ALT_MEMBERS_CAN_WITHDRAW_FROM_CLANWH)
        {
          if (warehouse instanceof ClanWarehouse &&
              ((player.getClanPrivileges() & L2Clan.CP_CL_VIEW_WAREHOUSE)
              != L2Clan.CP_CL_VIEW_WAREHOUSE))
          {
            return;
          }
        }
        else
        {
          if (warehouse instanceof ClanWarehouse && !player.isClanLeader())
          {
            // this msg is for depositing but maybe good to send some msg?
            player.sendPacket(new SystemMessage(SystemMessageId.ONLY_CLAN_LEADER_CAN_RETRIEVE_ITEMS_FROM_CLAN_WAREHOUSE));
            return;
          }
        }

        int weight = 0;
        int slots = 0;

    for (int i = 0; i < _count; i++)
    {
      int objectId = _items[i * 2 + 0];
      int count = _items[i * 2 + 1];

            // Calculate needed slots
            L2ItemInstance item = warehouse.getItemByObjectId(objectId);
            if (item == null) continue;
            weight += weight * item.getItem().getWeight();
      if (!item.isStackable()) slots += count;
            else if (player.getInventory().getItemByItemId(item.getItemId()) == null) slots++;
    }

        // Item Max Limit Check
        if (!player.getInventory().validateCapacity(slots))
        {
            sendPacket(new SystemMessage(SystemMessageId.SLOTS_FULL));
            return;
        }

        // Weight limit Check
        if (!player.getInventory().validateWeight(weight))
        {
            sendPacket(new SystemMessage(SystemMessageId.WEIGHT_LIMIT_EXCEEDED));
            return;
        }

        // Proceed to the transfer
    InventoryUpdate playerIU = Config.FORCE_INVENTORY_UPDATE ? null : new InventoryUpdate();
    for (int i = 0; i < _count; i++)
    {
      int objectId = _items[i * 2 + 0];
      int count = _items[i * 2 + 1];

      L2ItemInstance oldItem = warehouse.getItemByObjectId(objectId);
      if (oldItem == null || oldItem.getCount() < count)
        player.sendMessage("Can't withdraw requested item"+(count>1?"s":""));
      L2ItemInstance newItem = warehouse.transferItem("Warehouse", objectId, count, player.getInventory(), player, player.getLastFolkNPC());
            if (newItem == null)
            {
              _log.warning("Error withdrawing a warehouse object for char " + player.getName());
              continue;
            }
View Full Code Here

        if (player == null) return;
    L2PcInstance target = L2PcInstance.load(_objectID);
    PcFreight freight = target.getFreight();
    getClient().getActiveChar().setActiveWarehouse(freight);
    target.deleteMe();
        ItemContainer warehouse = player.getActiveWarehouse();
        if (warehouse == null) return;
    L2FolkInstance manager = player.getLastFolkNPC();
        if ((manager == null || !player.isInsideRadius(manager, L2NpcInstance.INTERACTION_DISTANCE, false, false)) && !player.isGM()) return;

        if (warehouse instanceof PcFreight && Config.GM_DISABLE_TRANSACTION && player.getAccessLevel() >= Config.GM_TRANSACTION_MIN && player.getAccessLevel() <= Config.GM_TRANSACTION_MAX)
        {
            player.sendMessage("Transactions are disable for your Access Level");
            return;
        }

        // Alt game - Karma punishment
        if (!Config.ALT_GAME_KARMA_PLAYER_CAN_USE_WAREHOUSE && player.getKarma() > 0) return;

        // Freight price from config or normal price per item slot (30)
    int fee = _count * Config.ALT_GAME_FREIGHT_PRICE;
    int currentAdena = player.getAdena();
        int slots = 0;

    for (Item i : _items)
    {
      int objectId = i.id;
      int count = i.count;

      // Check validity of requested item
      L2ItemInstance item = player.checkItemManipulation(objectId, count, "deposit");
            if (item == null)
            {
              _log.warning("Error depositing a warehouse object for char "+player.getName()+" (validity check)");
              i.id = 0;
              i.count = 0;
              continue;
            }

            if (!item.isTradeable() || item.getItemType() == L2EtcItemType.QUEST) return;

      // Calculate needed adena and slots
      if (item.getItemId() == 57) currentAdena -= count;
            if (!item.isStackable()) slots += count;
            else if (warehouse.getItemByItemId(item.getItemId()) == null) slots++;
    }

        // Item Max Limit Check
        if (!warehouse.validateCapacity(slots))
        {
            sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_EXCEEDED_QUANTITY_THAT_CAN_BE_INPUTTED));
            return;
        }

View Full Code Here

  @Override
  protected void runImpl()
  {
    L2PcInstance player = getClient().getActiveChar();
        if (player == null) return;
        ItemContainer warehouse = player.getActiveWarehouse();
        if (warehouse == null) return;
    L2FolkInstance manager = player.getLastFolkNPC();
        if ((manager == null || !player.isInsideRadius(manager, L2NpcInstance.INTERACTION_DISTANCE, false, false)) && !player.isGM()) return;

        if ((warehouse instanceof ClanWarehouse) && Config.GM_DISABLE_TRANSACTION && player.getAccessLevel() >= Config.GM_TRANSACTION_MIN && player.getAccessLevel() <= Config.GM_TRANSACTION_MAX)
        {
            player.sendMessage("Transactions are disable for your Access Level");
            return;
        }

        // Alt game - Karma punishment
        if (!Config.ALT_GAME_KARMA_PLAYER_CAN_USE_WAREHOUSE && player.getKarma() > 0) return;

        // Freight price from config or normal price per item slot (30)
    int fee = _count * 30;
    int currentAdena = player.getAdena();
        int slots = 0;

    for (int i = 0; i < _count; i++)
    {
      int objectId = _items[i * 2 + 0];
      int count = _items[i * 2 + 1];

      // Check validity of requested item
      L2ItemInstance item = player.checkItemManipulation(objectId, count, "deposit");
            if (item == null)
            {
              _log.warning("Error depositing a warehouse object for char "+player.getName()+" (validity check)");
              _items[i * 2 + 0] = 0;
              _items[i * 2 + 1] = 0;
              continue;
            }

            if ((warehouse instanceof ClanWarehouse) && !item.isTradeable() || item.getItemType() == L2EtcItemType.QUEST) return;
            // Calculate needed adena and slots
            if (item.getItemId() == 57) currentAdena -= count;
            if (!item.isStackable()) slots += count;
            else if (warehouse.getItemByItemId(item.getItemId()) == null) slots++;
    }

        // Item Max Limit Check
        if (!warehouse.validateCapacity(slots))
        {
            sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_EXCEEDED_QUANTITY_THAT_CAN_BE_INPUTTED));
            return;
        }

View Full Code Here

TOP

Related Classes of net.sf.l2j.gameserver.model.ItemContainer

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.