Package lineage2.gameserver.data.xml.holder.BuyListHolder

Examples of lineage2.gameserver.data.xml.holder.BuyListHolder.NpcTradeList


  public void onEvtDead(Creature killer)
  {
    final NpcInstance actor = getActor();
    super.onEvtDead(killer);
    actor.deleteMe();
    ThreadPoolManager.getInstance().schedule(new RunnableImpl()
    {
      @Override
      public void runImpl()
      {
        final NpcTemplate template = NpcHolder.getInstance().getTemplate(18602);
View Full Code Here


          getZone("[soi_hos_attack_attackup_5]").setActive(false);
          spawnRoom(6);
        }
      }
      else if(self.getNpcId() == Yehan)
        ThreadPoolManager.getInstance().schedule(new RunnableImpl(){
          @Override
          public void runImpl() throws Exception
          {
            spawnRoom(7);
            setReenterTime(System.currentTimeMillis());
View Full Code Here

   * @param time String
   * @param shutdownMode int
   */
  public void schedule(String time, int shutdownMode)
  {
    SchedulingPattern cronTime;
    try
    {
      cronTime = new SchedulingPattern(time);
    }
    catch (InvalidPatternException e)
    {
      return;
    }
    int seconds = (int) ((cronTime.next(System.currentTimeMillis()) / 1000L) - (System.currentTimeMillis() / 1000L));
    schedule(seconds, shutdownMode);
  }
View Full Code Here

  {
    _instance = this;
    _serverStarted = time();
    _listeners = new GameServerListenerList();
    new File("./log/").mkdir();
    version = new Version(GameServer.class);
    _log.info("=================================================");
    _log.info("Revision: ................ " + version.getRevisionNumber());
    _log.info("Build date: .............. " + version.getBuildDate());
    _log.info("Compiler version: ........ " + version.getBuildJdk());
    _log.info("=================================================");
View Full Code Here

    {
      synchronized (this)
      {
        if (_ai == null)
        {
          _ai = new ClonePlayerAI(this);
        }
      }
    }
    return (ClonePlayerAI) _ai;
  }
View Full Code Here

    }
    catch (Exception e)
    {
      _log.error("Unable to create ai of doorId " + _id, e);
    }
    return new DoorAI(door);
  }
View Full Code Here

    if (!activeChar.isGM() && ((merchant == null) || !isValidMerchant || !activeChar.isInRange(merchant, Creature.INTERACTION_DISTANCE)))
    {
      activeChar.sendActionFailed();
      return;
    }
    NpcTradeList list = BuyListHolder.getInstance().getBuyList(_listId);
    if (list == null)
    {
      activeChar.sendActionFailed();
      return;
    }
    long totalPrice = 0;
    Map<Integer, Integer> itemList = new HashMap<>();
    try
    {
      for (int i = 0; i < _count; i++)
      {
        int itemId = _items[i];
        if (list.getItemByItemId(itemId) == null)
        {
          activeChar.sendActionFailed();
          return;
        }
        ItemTemplate template = ItemHolder.getInstance().getTemplate(itemId);
View Full Code Here

        {
          handler.onBypassCommand(player, pBypass);
        }
      }
      player.setIsBBSUse(true);
      NpcTradeList list = BuyListHolder.getInstance().getBuyList(-1);
      player.sendPacket(new ExBuySellList.BuyList(list, player, 0.), new ExBuySellList.SellRefundList(player, false));
      player.sendChanges();
      return;
    }
    else if (bypass.startsWith("_bbsscripts"))
View Full Code Here

    if (!activeChar.isGM() && ((merchant == null) || !isValidMerchant || !activeChar.isInRange(merchant, Creature.INTERACTION_DISTANCE)))
    {
      activeChar.sendActionFailed();
      return;
    }
    NpcTradeList list = BuyListHolder.getInstance().getBuyList(_listId);
    if (list == null)
    {
      activeChar.sendActionFailed();
      return;
    }
    int slots = 0;
    long weight = 0;
    long totalPrice = 0;
    long tax = 0;
    double taxRate = 0;
    Castle castle = null;
    if (merchant != null)
    {
      castle = merchant.getCastle(activeChar);
      if (castle != null)
      {
        taxRate = castle.getTaxRate();
      }
    }
    List<TradeItem> buyList = new ArrayList<TradeItem>(_count);
    List<TradeItem> tradeList = list.getItems();
    try
    {
      loop:
      for (int i = 0; i < _count; i++)
      {
        int itemId = _items[i];
        long count = _itemQ[i];
        long price = 0;
        for (TradeItem ti : tradeList)
        {
          if (ti.getItemId() == itemId)
          {
            if (ti.isCountLimited() && (ti.getCurrentValue() < count))
            {
              continue loop;
            }
            price = ti.getOwnersPrice();
          }
        }
        if ((price == 0) && (!activeChar.isGM() || !activeChar.getPlayerAccess().UseGMShop))
        {
          activeChar.sendActionFailed();
          return;
        }
        totalPrice = SafeMath.addAndCheck(totalPrice, SafeMath.mulAndCheck(count, price));
        TradeItem ti = new TradeItem();
        ti.setItemId(itemId);
        ti.setCount(count);
        ti.setOwnersPrice(price);
        weight = SafeMath.addAndCheck(weight, SafeMath.mulAndCheck(count, ti.getItem().getWeight()));
        if (!ti.getItem().isStackable() || (activeChar.getInventory().getItemByItemId(itemId) == null))
        {
          slots++;
        }
        buyList.add(ti);
      }
      tax = (long) (totalPrice * taxRate);
      totalPrice = SafeMath.addAndCheck(totalPrice, tax);
      if (!activeChar.getInventory().validateWeight(weight))
      {
        sendPacket(Msg.YOU_HAVE_EXCEEDED_THE_WEIGHT_LIMIT);
        return;
      }
      if (!activeChar.getInventory().validateCapacity(slots))
      {
        sendPacket(Msg.YOUR_INVENTORY_IS_FULL);
        return;
      }
      if (!activeChar.reduceAdena(totalPrice))
      {
        activeChar.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
        return;
      }
      for (TradeItem ti : buyList)
      {
        activeChar.getInventory().addItem(ti.getItemId(), ti.getCount());
      }
      list.updateItems(buyList);
      if (castle != null)
      {
        if ((tax > 0) && (castle.getOwnerId() > 0) && (activeChar.getReflection() == ReflectionManager.DEFAULT))
        {
          castle.addToTreasury(tax, true, false);
View Full Code Here

      val = Integer.parseInt(command);
    }
    catch (Exception e)
    {
    }
    NpcTradeList list = BuyListHolder.getInstance().getBuyList(val);
    if (list != null)
    {
      activeChar.sendPacket(new ExBuySellList.BuyList(list, activeChar, 0.), new ExBuySellList.SellRefundList(activeChar, false));
    }
    activeChar.sendActionFailed();
View Full Code Here

TOP

Related Classes of lineage2.gameserver.data.xml.holder.BuyListHolder.NpcTradeList

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.