Package com.l2jfrozen.gameserver.model

Examples of com.l2jfrozen.gameserver.model.L2TradeList


    replyMSG = null;
  }

  private void showShopList(L2PcInstance activeChar, int tradeListID, int page)
  {
    L2TradeList tradeList = TradeController.getInstance().getBuyList(tradeListID);

    if(page > tradeList.getItems().size() / PAGE_LIMIT + 1 || page < 1)
      return;

    NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
    TextBuilder html = itemListHtml(tradeList, page);
View Full Code Here


          ResultSet rset = statement.executeQuery();
          if(rset.next())
          {
            LimitedItem = false;
            dummyItemCount++;
            L2TradeList buy1 = new L2TradeList(rset1.getInt("shop_id"));

            int itemId = rset.getInt("item_id");
            int price = rset.getInt("price");
            int count = rset.getInt("count");
            int currentCount = rset.getInt("currentCount");
            int time = rset.getInt("time");

            L2ItemInstance item = ItemTable.getInstance().createDummyItem(itemId);

            if(item == null)
            {
              rset.close();
              statement.close();

              rset = null;
              statement = null;
              continue;
            }

            if(count > -1)
            {
              item.setCountDecrease(true);
              LimitedItem = true;
            }

            item.setPriceToSell(price);
            item.setTime(time);
            item.setInitCount(count);

            if(currentCount > -1)
            {
              item.setCount(currentCount);
            }
            else
            {
              item.setCount(count);
            }

            buy1.addItem(item);
            item = null;
            buy1.setNpcId(rset1.getString("npc_id"));

            try
            {
              while(rset.next()) //TODO aici
              {
                dummyItemCount++;
                itemId = rset.getInt("item_id");
                price = rset.getInt("price");
                count = rset.getInt("count");
                time = rset.getInt("time");
                currentCount = rset.getInt("currentCount");
                L2ItemInstance item2 = ItemTable.getInstance().createDummyItem(itemId);

                if(item2 == null)
                {
                  continue;
                }

                if(count > -1)
                {
                  item2.setCountDecrease(true);
                  LimitedItem = true;
                }
                item2.setPriceToSell(price);
                item2.setTime(time);
                item2.setInitCount(count);
                if(currentCount > -1)
                {
                  item2.setCount(currentCount);
                }
                else
                {
                  item2.setCount(count);
                }
                buy1.addItem(item2);
              }
            }
            catch(Exception e)
            {
              if(Config.ENABLE_ALL_EXCEPTIONS)
                e.printStackTrace();
             
              _log.warning("TradeController: Problem with buylist " + buy1.getListId() + " item " + itemId);
            }
            if(LimitedItem)
            {
              _listsTaskItem.put(new Integer(buy1.getListId()), buy1);
            }
            else
            {
              _lists.put(new Integer(buy1.getListId()), buy1);
            }

            _nextListId = Math.max(_nextListId, buy1.getListId() + 1);
            buy1 = null;
          }

          rset.close();
          statement.close();

          rset = null;
          statement = null;
        }
        rset1.close();
        statement1.close();

        rset1 = null;
        statement1 = null;

        if(Config.DEBUG)
        {
          _log.fine("created " + dummyItemCount + " Dummy-Items for buylists");
        }

        _log.config("TradeController: Loaded " + _lists.size() + " Buylists.");
        _log.config("TradeController: Loaded " + _listsTaskItem.size() + " Limited Buylists.");
        /*
         *  Restore Task for reinitialyze count of buy item
         */
        try
        {
          int time = 0;
          long savetimer = 0;
          long currentMillis = System.currentTimeMillis();

          PreparedStatement statement2 = con.prepareStatement("SELECT DISTINCT time, savetimer FROM merchant_buylists WHERE time <> 0 ORDER BY time");
          ResultSet rset2 = statement2.executeQuery();

          while(rset2.next())
          {
            time = rset2.getInt("time");
            savetimer = rset2.getLong("savetimer");
            if(savetimer - currentMillis > 0)
            {
              ThreadPoolManager.getInstance().scheduleGeneral(new RestoreCount(time), savetimer - System.currentTimeMillis());
            }
            else
            {
              ThreadPoolManager.getInstance().scheduleGeneral(new RestoreCount(time), 0);
            }
          }
          rset2.close();
          statement2.close();

          rset2 = null;
          statement2 = null;
        }
        catch(Exception e)
        {
          _log.warning("TradeController: Could not restore Timer for Item count.");
          e.printStackTrace();
        }
      }
      catch(Exception e)
      {
        // problem with initializing spawn, go to next one
        _log.warning("TradeController: Buylists could not be initialized.");
        e.printStackTrace();
      }
      finally
      {
        CloseUtil.close(con);
        con = null;
      }
      /*
       * If enabled, initialize the custom buylist
       */
      if(Config.CUSTOM_MERCHANT_TABLES)// Custom merchat Tabels
      {
        try
        {
          int initialSize = _lists.size();
          con = L2DatabaseFactory.getInstance().getConnection(false);

          PreparedStatement statement1 = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[]
          {
              "shop_id", "npc_id"
          }) + " FROM custom_merchant_shopids");

          ResultSet rset1 = statement1.executeQuery();

          while(rset1.next())
          {
            PreparedStatement statement = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[]
            {
                "item_id", "price", "shop_id", "order", "count", "time", "currentCount"
            }) + " FROM custom_merchant_buylists WHERE shop_id=? ORDER BY " + L2DatabaseFactory.getInstance().safetyString(new String[]
            {
              "order"
            }) + " ASC");

            statement.setString(1, String.valueOf(rset1.getInt("shop_id")));
            ResultSet rset = statement.executeQuery();

            if(rset.next())
            {
              LimitedItem = false;
              dummyItemCount++;
              L2TradeList buy1 = new L2TradeList(rset1.getInt("shop_id"));
              int itemId = rset.getInt("item_id");
              int price = rset.getInt("price");
              int count = rset.getInt("count");
              int currentCount = rset.getInt("currentCount");
              int time = rset.getInt("time");
              L2ItemInstance item = ItemTable.getInstance().createDummyItem(itemId);
              if(item == null)
              {
                rset.close();
                statement.close();

                rset = null;
                statement = null;
                continue;
              }

              if(count > -1)
              {
                item.setCountDecrease(true);
                LimitedItem = true;
              }
              item.setPriceToSell(price);
              item.setTime(time);
              item.setInitCount(count);

              if(currentCount > -1)
              {
                item.setCount(currentCount);
              }
              else
              {
                item.setCount(count);
              }

              buy1.addItem(item);
              item = null;
              buy1.setNpcId(rset1.getString("npc_id"));

              try
              {
                while(rset.next())
                {
                  dummyItemCount++;
                  itemId = rset.getInt("item_id");
                  price = rset.getInt("price");
                  count = rset.getInt("count");
                  time = rset.getInt("time");
                  currentCount = rset.getInt("currentCount");
                  L2ItemInstance item2 = ItemTable.getInstance().createDummyItem(itemId);
                  if(item2 == null)
                  {
                    continue;
                  }
                  if(count > -1)
                  {
                    item2.setCountDecrease(true);
                    LimitedItem = true;
                  }
                  item2.setPriceToSell(price);
                  item2.setTime(time);
                  item2.setInitCount(count);
                  if(currentCount > -1)
                  {
                    item2.setCount(currentCount);
                  }
                  else
                  {
                    item2.setCount(count);
                  }
                  buy1.addItem(item2);

                  item2 = null;
                }
              }
              catch(Exception e)
              {
                if(Config.ENABLE_ALL_EXCEPTIONS)
                  e.printStackTrace();
               
                _log.warning("TradeController: Problem with buylist " + buy1.getListId() + " item " + itemId);
              }
              if(LimitedItem)
              {
                _listsTaskItem.put(new Integer(buy1.getListId()), buy1);
              }
              else
              {
                _lists.put(new Integer(buy1.getListId()), buy1);
              }
              _nextListId = Math.max(_nextListId, buy1.getListId() + 1);

              buy1 = null;
            }

            rset.close();
View Full Code Here

  {
    int itemCreated = 0;
    StringTokenizer st = new StringTokenizer(line, ";");

    int listId = Integer.parseInt(st.nextToken());
    L2TradeList buy1 = new L2TradeList(listId);
    while(st.hasMoreTokens())
    {
      int itemId = Integer.parseInt(st.nextToken());
      int price = Integer.parseInt(st.nextToken());
      L2ItemInstance item = ItemTable.getInstance().createDummyItem(itemId);
      item.setPriceToSell(price);
      buy1.addItem(item);
      itemCreated++;
    }
    st = null;

    _lists.put(new Integer(buy1.getListId()), buy1);
    buy1 = null;
    return itemCreated;
  }
View Full Code Here

    player.tempInvetoryDisable();
    if(Config.DEBUG)
    {
      _log.fine("Showing buylist");
    }
    L2TradeList list = TradeController.getInstance().getBuyList(val);
    if(list != null && list.getNpcId().equals(String.valueOf(getNpcId())))
    {
      BuyList bl = new BuyList(list, player.getAdena(), 0);
      player.sendPacket(bl);
      list = null;
      bl = null;
View Full Code Here

    player.tempInvetoryDisable();
    if(Config.DEBUG)
    {
      _log.fine("Showing buylist");
    }
    L2TradeList list = TradeController.getInstance().getBuyList(val);

    if(list != null && list.getNpcId().equals(String.valueOf(getNpcId())))
    {
      BuyList bl = new BuyList(list, player.getAdena(), taxRate);
      player.sendPacket(bl);
      list = null;
      bl = null;
View Full Code Here

            else
            {
              buy = Integer.parseInt(val + "2");
            }
          }
          L2TradeList list = TradeController.getInstance().getBuyList(buy);
          if(list != null && list.getNpcId().equals(String.valueOf(getNpcId())))
          {
            BuyList bl = new BuyList(list, player.getAdena(), 0);
            player.sendPacket(bl);
          }
          else
View Full Code Here

        final PreparedStatement statement = con.prepareStatement("SELECT item_id, price, shop_id, order, count, time, currentCount FROM " +
            (custom ? "custom_merchant_buylists" : "merchant_buylists") + " WHERE shop_id=? ORDER BY order ASC");
        statement.setString(1, String.valueOf(rset1.getInt("shop_id")));
        final ResultSet rset = statement.executeQuery();

        L2TradeList buylist = new L2TradeList(rset1.getInt("shop_id"));

        buylist.setNpcId(rset1.getString("npc_id"));
        int _itemId = 0;
        int _itemCount = 0;
        int _price = 0;

        if(!buylist.isGm() && NpcTable.getInstance().getTemplate(rset1.getInt("npc_id")) == null)
        {
          _log.warning("TradeListTable: Merchant id {} with {} buylist {} not exist. "+ rset1.getString("npc_id")+" "+ buylist.getListId());
        }

        try
        {
          while(rset.next())
          {
            _itemId = rset.getInt("item_id");
            _price = rset.getInt("price");
            int count = rset.getInt("count");
            int currentCount = rset.getInt("currentCount");
            int time = rset.getInt("time");

            L2ItemInstance buyItem = ItemTable.getInstance().createDummyItem(_itemId);

            if(buyItem == null)
            {
              continue;
            }

            _itemCount++;

            if(count > -1)
            {
              buyItem.setCountDecrease(true);
            }
            buyItem.setPriceToSell(_price);
            buyItem.setTime(time);
            buyItem.setInitCount(count);

            if(currentCount > -1)
            {
              buyItem.setCount(currentCount);
            }
            else
            {
              buyItem.setCount(count);
            }

            buylist.addItem(buyItem);

            if(!buylist.isGm() && buyItem.getReferencePrice() > _price)
            {
              _log.warning("TradeListTable: Reference price of item {} in buylist {} higher then sell price. "+ _itemId+" "+ buylist.getListId());
            }
          }
        }
        catch(Exception e)
        {
          _log.severe("TradeListTable: Problem with buylist {}. "+ buylist.getListId()+" "+ e);
        }

        if(_itemCount > 0)
        {
          _lists.put(buylist.getListId(), buylist);
          _nextListId = Math.max(_nextListId, buylist.getListId() + 1);
        }
        else
        {
          _log.warning("TradeListTable: Empty buylist {}."+ buylist.getListId());
        }

        statement.close();
        rset.close();
      }
View Full Code Here

    if(Config.DEBUG)
    {
      _log.fine("Showing buylist :" + player.getName() + " List ID :" + val);
    }

    L2TradeList list = TradeController.getInstance().getBuyList(val);

    if(list != null && list.getNpcId().equals(String.valueOf(getNpcId())))
    {
      BuyList bl = new BuyList(list, player.getAdena(), taxRate);
      player.sendPacket(bl);
      list = null;
      bl = null;
View Full Code Here

TOP

Related Classes of com.l2jfrozen.gameserver.model.L2TradeList

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.