Package net.sf.l2j.gameserver.model

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


    if (activeChar.isAlikeDead()) return;

        boolean ss = false;
        boolean bss = false;

        L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();

        if (weaponInst != null)
        {
            if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
            {
                bss = true;
                weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
            }
            else if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_SPIRITSHOT)
            {
                ss = true;
                weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
            }
        }
    for (int index = 0; index < targets.length; index++)
    {
      target = (L2Character) targets[index];
View Full Code Here


    {
      //Fishing poles are not installed
      player.sendPacket(new SystemMessage(SystemMessageId.FISHING_POLE_NOT_EQUIPPED));
      return;
    }
    L2ItemInstance lure = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND);
    if (lure == null)
    {
        //Bait not equiped.
      player.sendPacket(new SystemMessage(SystemMessageId.BAIT_ON_HOOK_BEFORE_FISHING));
            return;
    }
    player.SetLure(lure);
    L2ItemInstance lure2 = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND);

    if (lure2 == null || lure2.getCount() < 1) //Not enough bait.
    {
        player.sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_BAIT));
      player.sendPacket(new ItemList(player,false));
    }
    else //Has enough bait, consume 1 and update inventory. Start fishing follows.
View Full Code Here

        return;
      }

      // If player doesn't own this item : Add this L2ItemInstance to Inventory and set properties lastchanged to ADDED and _wear to True
            // If player already own this item : Return its L2ItemInstance (will not be destroy because property _wear set to False)
      L2ItemInstance item = player.getInventory().addWearItem("Wear", itemId, player, merchant);

            // Equip player with this item (set its location)
            player.getInventory().equipItemAndRecord(item);

            // Add this Item in the InventoryUpdate Server->Client Packet
View Full Code Here

  @Override
  protected void runImpl()
  {
        L2PcInstance activeChar = getClient().getActiveChar();
      if (activeChar == null) return;
        L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);

        if (item == null
            || _count == 0
            || !activeChar.validateItemManipulation(_objectId, "drop")
            || (!Config.ALLOW_DISCARDITEM && !activeChar.isGM())
            || !item.isDropable())
        {
          activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_DISCARD_THIS_ITEM));
          return;
        }
        if(item.getItemType() == L2EtcItemType.QUEST)
        {
          return;
        }
        int itemId = item.getItemId();

        // Cursed Weapons cannot be dropped
        if (CursedWeaponsManager.getInstance().isCursed(itemId))
          return;

        if(_count > item.getCount())
        {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_DISCARD_THIS_ITEM));
      return;
        }

        if(_count < 0)
        {
          Util.handleIllegalPlayerAction(activeChar,"[RequestDropItem] count <= 0! ban! oid: "+_objectId+" owner: "+activeChar.getName(),IllegalPlayerAction.PUNISH_KICK);
          return;
        }

        if(!item.isStackable() && _count > 1)
        {
          Util.handleIllegalPlayerAction(activeChar,"[RequestDropItem] count > 1 but item is not stackable! ban! oid: "+_objectId+" owner: "+activeChar.getName(),IllegalPlayerAction.PUNISH_KICK);
          return;
        }


        if (Config.GM_DISABLE_TRANSACTION && activeChar.getAccessLevel() >= Config.GM_TRANSACTION_MIN && activeChar.getAccessLevel() <= Config.GM_TRANSACTION_MAX)
        {
            activeChar.sendMessage("Transactions are disable for your Access Level");
            activeChar.sendPacket(new SystemMessage(SystemMessageId.NOTHING_HAPPENED));
            return;
        }

    if (activeChar.isProcessingTransaction() || activeChar.getPrivateStoreType() != 0)
        {
            activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_TRADE_DISCARD_DROP_ITEM_WHILE_IN_SHOPMODE));
            return;
        }
    if (activeChar.isFishing())
        {
      //You can't mount, dismount, break and drop items while fishing
            activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_DO_WHILE_FISHING_2));
            return;
        }

    // Cannot discard item that the skill is consumming
    if (activeChar.isCastingNow())
    {
      if (activeChar.getCurrentSkill() != null && activeChar.getCurrentSkill().getSkill().getItemConsumeId() == item.getItemId())
      {
              activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_DISCARD_THIS_ITEM));
              return;
      }
    }

    if (L2Item.TYPE2_QUEST == item.getItem().getType2() && !activeChar.isGM())
    {
      if (Config.DEBUG) _log.finest(activeChar.getObjectId()+":player tried to drop quest item");
            activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_DISCARD_EXCHANGE_ITEM));
            return;
    }

    if (!activeChar.isInsideRadius(_x, _y, 150, false) || Math.abs(_z - activeChar.getZ()) > 50)
    {
      if (Config.DEBUG) _log.finest(activeChar.getObjectId()+": trying to drop too far away");
            activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_DISCARD_DISTANCE_TOO_FAR));
        return;
    }

    if (Config.DEBUG) _log.fine("requested drop item " + _objectId + "("+ item.getCount()+") at "+_x+"/"+_y+"/"+_z);

    if (item.isEquipped())
    {
      // Remove augementation boni on unequip
            if (item.isAugmented())
              item.getAugmentation().removeBoni(activeChar);

      L2ItemInstance[] unequiped = activeChar.getInventory().unEquipItemInBodySlotAndRecord(item.getItem().getBodyPart());
      InventoryUpdate iu = new InventoryUpdate();
      for (int i = 0; i < unequiped.length; i++)
      {
        activeChar.checkSSMatch(null, unequiped[i]);

        iu.addModifiedItem(unequiped[i]);
      }
      activeChar.sendPacket(iu);
      activeChar.broadcastUserInfo();

      ItemList il = new ItemList(activeChar, true);
      activeChar.sendPacket(il);
    }

    L2ItemInstance dropedItem = activeChar.dropItem("Drop", _objectId, _count, _x, _y, _z, null, false);

    if (Config.DEBUG) _log.fine("dropping " + _objectId + " item("+_count+") at: " + _x + " " + _y + " " + _z);

    // activeChar.broadcastUserInfo();

    if (activeChar.isGM())
    {
      String target = (activeChar.getTarget() != null?activeChar.getTarget().getName():"no-target");
      GMAudit.auditGMAction(activeChar.getName(), "drop", target, dropedItem.getItemId() + " - " +dropedItem.getName());
    }

        if (dropedItem != null && dropedItem.getItemId() == 57 && dropedItem.getCount() >= 1000000)
        {
            String msg = "Character ("+activeChar.getName()+") has dropped ("+dropedItem.getCount()+")adena at ("+_x+","+_y+","+_z+")";
            _log.warning(msg);
            GmListTable.broadcastMessageToGMs(msg);
        }
  }
View Full Code Here

      return false;
    }
   
    if (count > 0)
    {
      L2ItemInstance adenaItem = _inventory.getAdenaInstance();
      _inventory.reduceAdena(process, count, this, reference);
     
      // Send update packet
      if (!Config.FORCE_INVENTORY_UPDATE)
      {
View Full Code Here

      return false;
    }
   
    if (count > 0)
    {
      L2ItemInstance ancientAdenaItem = _inventory.getAncientAdenaInstance();
      _inventory.reduceAncientAdena(process, count, this, reference);
     
      if (!Config.FORCE_INVENTORY_UPDATE)
      {
        InventoryUpdate iu = new InventoryUpdate();
View Full Code Here

          sendPacket(sm);
        }
      }
     
      // Add the item to inventory
      L2ItemInstance newitem = _inventory.addItem(process, item, this, reference);
     
      // Send inventory update packet
      if (!Config.FORCE_INVENTORY_UPDATE)
      {
        InventoryUpdate playerIU = new InventoryUpdate();
        playerIU.addItem(newitem);
        sendPacket(playerIU);
      }
      else
      {
        sendPacket(new ItemList(this, false));
      }
     
      // Update current load as well
      StatusUpdate su = new StatusUpdate(getObjectId());
      su.addAttribute(StatusUpdate.CUR_LOAD, getCurrentLoad());
      sendPacket(su);
     
      // Cursed Weapon
      if (CursedWeaponsManager.getInstance().isCursed(newitem.getItemId()))
      {
        CursedWeaponsManager.getInstance().activate(this, newitem);
      }
     
      // If over capacity, trop the item
View Full Code Here

      // Auto use herbs - autoloot
      if (ItemTable.getInstance().createDummyItem(itemId).getItemType() == L2EtcItemType.HERB) // If item is herb dont add it to iv :]
      {
        if (!isCastingNow())
        {
          L2ItemInstance herb = new L2ItemInstance(_charId, itemId);
          IItemHandler handler = ItemHandler.getInstance().getItemHandler(herb.getItemId());
          if (handler == null)
          {
            _log.warning("No item handler registered for Herb - item ID " + herb.getItemId() + ".");
          }
          else
          {
            handler.useItem(this, herb);
            if (_herbstask >= 100)
            {
              _herbstask -= 100;
            }
          }
        }
        else
        {
          _herbstask += 100;
          ThreadPoolManager.getInstance().scheduleAi(new HerbTask(process, itemId, count, reference, sendMessage), _herbstask);
        }
      }
      else
      {
        // Add the item to inventory
        L2ItemInstance item = _inventory.addItem(process, itemId, count, this, reference);
       
        // Send inventory update packet
        if (!Config.FORCE_INVENTORY_UPDATE)
        {
          InventoryUpdate playerIU = new InventoryUpdate();
          playerIU.addItem(item);
          sendPacket(playerIU);
        }
        else
        {
          sendPacket(new ItemList(this, false));
        }
       
        // Update current load as well
        StatusUpdate su = new StatusUpdate(getObjectId());
        su.addAttribute(StatusUpdate.CUR_LOAD, getCurrentLoad());
        sendPacket(su);
       
        // Cursed Weapon
        if (CursedWeaponsManager.getInstance().isCursed(item.getItemId()))
        {
          CursedWeaponsManager.getInstance().activate(this, item);
        }
       
        // If over capacity, drop the item
View Full Code Here

   * @return boolean informing if the action was successfull
   */
  @Override
  public boolean destroyItem(String process, int objectId, int count, L2Object reference, boolean sendMessage)
  {
    L2ItemInstance item = _inventory.getItemByObjectId(objectId);
   
    if ((item == null) || (item.getCount() < count) || (_inventory.destroyItem(process, objectId, count, this, reference) == null))
    {
      if (sendMessage)
      {
        sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
      }
     
      return false;
    }
   
    // Send inventory update packet
    if (!Config.FORCE_INVENTORY_UPDATE)
    {
      InventoryUpdate playerIU = new InventoryUpdate();
      playerIU.addItem(item);
      sendPacket(playerIU);
    }
    else
    {
      sendPacket(new ItemList(this, false));
    }
   
    // Update current load as well
    StatusUpdate su = new StatusUpdate(getObjectId());
    su.addAttribute(StatusUpdate.CUR_LOAD, getCurrentLoad());
    sendPacket(su);
   
    // Sends message to client if requested
    if (sendMessage)
    {
      SystemMessage sm = new SystemMessage(SystemMessageId.DISSAPEARED_ITEM);
      sm.addNumber(count);
      sm.addItemName(item.getItemId());
      sendPacket(sm);
    }
   
    return true;
  }
View Full Code Here

   * @param sendMessage : boolean Specifies whether to send message to Client about this action
   * @return boolean informing if the action was successfull
   */
  public boolean destroyItemWithoutTrace(String process, int objectId, int count, L2Object reference, boolean sendMessage)
  {
    L2ItemInstance item = _inventory.getItemByObjectId(objectId);
   
    if ((item == null) || (item.getCount() < count))
    {
      if (sendMessage)
      {
        sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
      }
      return false;
    }
   
    // Adjust item quantity
    if (item.getCount() > count)
    {
      synchronized (item)
      {
        item.changeCountWithoutTrace(process, -count, this, reference);
        item.setLastChange(L2ItemInstance.MODIFIED);
       
        // could do also without saving, but let's save approx 1 of 10
        if ((GameTimeController.getGameTicks() % 10) == 0)
        {
          item.updateDatabase();
        }
        _inventory.refreshWeight();
      }
    }
    else
    {
      // Destroy entire item and save to database
      _inventory.destroyItem(process, item, this, reference);
    }
   
    // Send inventory update packet
    if (!Config.FORCE_INVENTORY_UPDATE)
    {
      InventoryUpdate playerIU = new InventoryUpdate();
      playerIU.addItem(item);
      sendPacket(playerIU);
    }
    else
    {
      sendPacket(new ItemList(this, false));
    }
   
    // Update current load as well
    StatusUpdate su = new StatusUpdate(getObjectId());
    su.addAttribute(StatusUpdate.CUR_LOAD, getCurrentLoad());
    sendPacket(su);
   
    // Sends message to client if requested
    if (sendMessage)
    {
      SystemMessage sm = new SystemMessage(SystemMessageId.DISSAPEARED_ITEM);
      sm.addNumber(count);
      sm.addItemName(item.getItemId());
      sendPacket(sm);
    }
   
    return true;
  }
View Full Code Here

TOP

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

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.