Package net.sf.l2j.gameserver.model

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


    {
      Inventory petInventory = getInventory();
      L2ItemInstance[] items = petInventory.getItems();
      for (int i = 0; (i < items.length); i++)
      {
        L2ItemInstance giveit = items[i];
        if (((giveit.getItem().getWeight() * giveit.getCount())
            + getOwner().getInventory().getTotalWeight())
            < getOwner().getMaxLoad())
        {
          // If the owner can carry it give it to them
          giveItemToOwner(giveit);
View Full Code Here


    L2World.getInstance().removePet(owner.getObjectId());

    // delete from inventory
    try
    {
      L2ItemInstance removedItem = owner.getInventory().destroyItem("PetDestroy", getControlItemId(), 1, getOwner(), this);

      InventoryUpdate iu = new InventoryUpdate();
      iu.addRemovedItem(removedItem);

      owner.sendPacket(iu);
View Full Code Here

      _logPet.warning("could not store pet data: "+e);
    } finally {
      try { con.close(); } catch (Exception e) {}
    }

    L2ItemInstance itemInst = getControlItem();
    if (itemInst != null && itemInst.getEnchantLevel() != getStat().getLevel())
    {
      itemInst.setEnchantLevel(getStat().getLevel());
      itemInst.updateDatabase();
    }
  }
View Full Code Here

    L2PetInstance pet = (L2PetInstance)activeChar.getPet();

    if (pet == null)
      return;

    L2ItemInstance item = pet.getInventory().getItemByObjectId(_objectId);

        if (item == null)
            return;

        if (item.isWear())
            return;

    int itemId = item.getItemId();

    if (activeChar.isAlikeDead() || pet.isDead())
        {
      SystemMessage sm = new SystemMessage(SystemMessageId.S1_CANNOT_BE_USED);
      sm.addItemName(item.getItemId());
      activeChar.sendPacket(sm);
      sm = null;
      return;
    }

    if (Config.DEBUG)
            _log.finest(activeChar.getObjectId()+": pet use item " + _objectId);

    //check if the item matches the pet
    if (item.isEquipable())
    {
      if (L2PetDataTable.isWolf(pet.getNpcId()) && // wolf
                    item.getItem().isForWolf())
      {
        useItem(pet, item, activeChar);
        return;
      }
      else if (L2PetDataTable.isHatchling(pet.getNpcId()) && // hatchlings
                        item.getItem().isForHatchling())
      {
        useItem(pet, item, activeChar);
        return;
      }
            else if (L2PetDataTable.isStrider(pet.getNpcId()) && // striders
                    item.getItem().isForStrider())
            {
                useItem(pet, item, activeChar);
                return;
            }
            else if (L2PetDataTable.isBaby(pet.getNpcId()) && // baby pets (buffalo, cougar, kookaboora)
                    item.getItem().isForBabyPet())
            {
                useItem(pet, item, activeChar);
                return;
            }
      else
      {
        activeChar.sendPacket(new SystemMessage(SystemMessageId.ITEM_NOT_FOR_PETS));
                return;
      }
    }
    else if (L2PetDataTable.isPetFood(itemId))
    {
      if (L2PetDataTable.isWolf(pet.getNpcId()) && L2PetDataTable.isWolfFood(itemId))
      {
        feed(activeChar, pet, item);
        return;
      }
      if (L2PetDataTable.isSinEater(pet.getNpcId()) && L2PetDataTable.isSinEaterFood(itemId))
      {
        feed(activeChar, pet, item);
        return;
      }
      else if (L2PetDataTable.isHatchling(pet.getNpcId()) && L2PetDataTable.isHatchlingFood(itemId))
      {
        feed(activeChar, pet, item);
        return;
      }
      else if (L2PetDataTable.isStrider(pet.getNpcId()) && L2PetDataTable.isStriderFood(itemId))
      {
        feed(activeChar, pet, item);
        return;
      }
      else if (L2PetDataTable.isWyvern(pet.getNpcId()) && L2PetDataTable.isWyvernFood(itemId))
      {
        feed(activeChar, pet, item);
        return;
      }
      else if (L2PetDataTable.isBaby(pet.getNpcId()) && L2PetDataTable.isBabyFood(itemId))
      {
        feed(activeChar, pet, item);
      }
    }

      IItemHandler handler = ItemHandler.getInstance().getItemHandler(item.getItemId());

      if (handler != null)
    {
      useItem(pet, item, activeChar);
    }
View Full Code Here

            player.setRace(1, 0);
            sm = new SystemMessage(SystemMessageId.ACQUIRED);
            sm.addNumber(_raceNumber);
            sm.addItemName(4443);
            player.sendPacket(sm);
            L2ItemInstance item = new L2ItemInstance(IdFactory.getInstance().getNextId(), 4443);
            item.setCount(1);
            item.setEnchantLevel(_raceNumber);
            item.setCustomType1(ticket);
            item.setCustomType2(_cost[priceId - 1] / 100);
            player.getInventory().addItem("Race", item, player, this);
            InventoryUpdate iu = new InventoryUpdate();
            iu.addItem(item);
            L2ItemInstance adenaupdate = player.getInventory().getItemByItemId(57);
            iu.addModifiedItem(adenaupdate);
            player.sendPacket(iu);
            return;
        }
        html.replace("1race", String.valueOf(_raceNumber));
View Full Code Here

                    break;
                case 6:
                    int passes = Olympiad.getInstance().getNoblessePasses(player.getObjectId());
                    if (passes > 0)
                    {
                        L2ItemInstance item = player.getInventory().addItem("Olympiad", GATE_PASS, passes, player, this);

                        InventoryUpdate iu = new InventoryUpdate();
                        iu.addModifiedItem(item);
                        player.sendPacket(iu);

                        SystemMessage sm = new SystemMessage(SystemMessageId.EARNED_ITEM);
                        sm.addNumber(passes);
                        sm.addItemName(item.getItemId());
                        player.sendPacket(sm);
                    }
                    else
                    {
                        player.sendMessage("Not enough points, or not currently in Valdation Period");
View Full Code Here

        player.sendPacket(sm);
        continue;
      }

      // Add item to Inventory and adjust update packet
      L2ItemInstance itemDel = null;
      L2ItemInstance itemAdd = null;
      if (player.getInventory().getItemByObjectId(objId) != null)
      {
        // check if player have correct items count
        L2ItemInstance item = player.getInventory().getItemByObjectId(objId);
        if (item.getCount() < count)
          continue;

        itemDel = player.getInventory().destroyItem("Manor", objId, count, player, manorManager);
        if (itemDel == null)
          continue;
View Full Code Here

    {
      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;
            }

            if (playerIU != null)
            {
          if (newItem.getCount() > count) playerIU.addModifiedItem(newItem);
            else playerIU.addNewItem(newItem);
            }
    }

        // Send updated item list to the player
View Full Code Here

        }

        int foodId = L2PetDataTable.getFoodItemId(getTemplate().npcId);
        if (foodId == 0) return;

        L2ItemInstance food = null;
        food = getInventory().getItemByItemId(foodId);

        if ((food != null) && (getCurrentFed() < (0.55 * getMaxFed())))
        {
          if (destroyItem("Feed", food.getObjectId(), 1, null, false))
          {
            setCurrentFed(getCurrentFed() + (100));
            if (getOwner() != null)
            {
              SystemMessage sm = new SystemMessage(SystemMessageId.PET_TOOK_S1_BECAUSE_HE_WAS_HUNGRY);
View Full Code Here

     * @param itemId : ID of the item to check enchantment
     * @return int
     */
    public int getEnchantLevel(int itemId)
    {
        L2ItemInstance enchanteditem = getPlayer().getInventory().getItemByItemId(itemId);

        if (enchanteditem == null)
            return 0;

        return enchanteditem.getEnchantLevel();
    }
View Full Code Here

TOP

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

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.