Показать сообщение отдельно
Непрочитано 07.01.2011, 11:06   #83
Аватар для Deazer

По умолчанию Re: Item Mall/Prime Shop что такое и с чем его едят?

Реализация взято из l2f и переделано ,им собственно и спасибо , для себя делал тоже отталкиваясь от их кода - не копипастил !

Item Mall для серверов типа l2f/l2p/l2open/l2nextgen/sunwars/шайтан и т.д.

Портировал код на феникс по много численным просьбам и выкладываю собственно ... портировал не абсолютно все (RequestBR_GamePoint - Листнер на количество не отображается но консьюмит итемы ровно , так что не писяйте. Для себя доделал все и корректно , но простите за бесплатно даже котята не рождаются) в коде используется за базовый итем для продажи Coin of Lack id=4037

VISTALL вот вот вот вот вот вот вот вот вот вот вот вот вот вот вот вот вот вот вот вотвот вот вот вот вот вот вот вот вот вотвот вот вот вот вот вот вот вот вот вотвот вот вот вот вот вот вот вот вот вотвот вот вот вот вот вот вот вот вот вот и ГЦ с новым статусом на форуме

В выделенным жирным классы рвет пробелами - непонятно почему , видимо ошибка форума.

1)l2p\gameserver\instancemanager\PrimeShopManager.ja va
Код HTML:
package l2p.gameserver.instancemanager;

import l2p.Config;
import l2p.database.DatabaseUtils;
import l2p.database.FiltredPreparedStatement;
import l2p.database.L2DatabaseFactory;
import l2p.database.ThreadConnection;
import l2p.gameserver.model.L2Player;
import l2p.gameserver.model.items.L2ItemInstance;
import l2p.gameserver.serverpackets.*;
import l2p.util.ValueSortMap;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

import javax.xml.parsers.DocumentBuilderFactory;
import java.io.File;
import java.sql.ResultSet;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;

public class PrimeShopManager {
    private static Logger _log = Logger.getLogger(PrimeShopManager.class.getName());

    private static PrimeShopManager _instance;

    public final int BR_BUY_SUCCESS = 1;
    public final int BR_BUY_LACK_OF_POINT = -1;
    public final int BR_BUY_INVALID_PRODUCT = -2;
    public final int BR_BUY_USER_CANCEL = -3;
    public final int BR_BUY_INVENTROY_OVERFLOW = -4;
    public final int BR_BUY_CLOSED_PRODUCT = -5;
    public final int BR_BUY_SERVER_ERROR = -6;
    public final int BR_BUY_BEFORE_SALE_DATE = -7;
    public final int BR_BUY_AFTER_SALE_DATE = -8;
    public final int BR_BUY_INVALID_USER = -9;
    public final int BR_BUY_INVALID_ITEM = -10;
    public final int BR_BUY_INVALID_USER_STATE = -11;
    public final int BR_BUY_NOT_DAY_OF_WEEK = -12;
    public final int BR_BUY_NOT_TIME_OF_DAY = -13;
    public final int BR_BUY_SOLD_OUT = -14;
    public final int MAX_BUY_COUNT = 99;
    public final int CURRENCY_ID = 4037;
    private HashMap<Integer, ItemMallItemTemplate> brTemplates;
    private HashMap<Integer, ItemMallItem> shop;
    protected ExBR_ProductList list;
    private ConcurrentHashMap<Integer, List<ItemMallItem>> recentList;

    public static PrimeShopManager getInstance() {
        if (_instance == null)
            _instance = new PrimeShopManager();
        return _instance;
    }

    private PrimeShopManager() {
        brTemplates = new HashMap<Integer, ItemMallItemTemplate>();
        shop = new HashMap<Integer, ItemMallItem>();
        list = null;
        recentList = new ConcurrentHashMap<Integer, List<ItemMallItem>>();
        load();
    }

    public void requestBuyItem(L2Player player, int brId, int count) {
        if (count > MAX_BUY_COUNT)
            count = MAX_BUY_COUNT;
        if (count < 1)
            count = 1;

        ItemMallItem item = shop.get(brId);
        if (item == null) {
            sendResult(player, BR_BUY_INVALID_PRODUCT);
            return;
        }

        if (player.getInventory().getCountOf(CURRENCY_ID) < item.price * count) {
            sendResult(player, BR_BUY_LACK_OF_POINT);
            return;
        }

        Calendar cal = Calendar.getInstance();
        if (item.iStartSale > 0 && (item.iStartSale > (int) (cal.getTimeInMillis() / 1000))) {
            sendResult(player, BR_BUY_BEFORE_SALE_DATE);
            return;
        }

        if (item.iEndSale > 0 && (item.iEndSale < (int) (cal.getTimeInMillis() / 1000))) {
            sendResult(player, BR_BUY_AFTER_SALE_DATE);
            return;
        }

        if (item.iStartHour != 0 || item.iStartMin != 0 || item.iEndHour != 0 || item.iEndMin != 0) {
            if ((item.iStartHour > cal.get(Calendar.HOUR_OF_DAY) && item.iStartMin > cal.get(Calendar.HOUR_OF_DAY)) ||
                    (item.iEndHour < cal.get(Calendar.HOUR_OF_DAY) && item.iEndMin < cal.get(Calendar.HOUR_OF_DAY))) {
                sendResult(player, BR_BUY_NOT_TIME_OF_DAY);
                return;
            }
        }

        if (item.isLimited() && (item.limit() || item.iMaxStock - item.iStock < count)) {
            sendResult(player, BR_BUY_SOLD_OUT);
            return;
        }

        player.getInventory().destroyItemByItemId(CURRENCY_ID, (item.price * count), true);

        player.sendMessage("You have successfully used your " + (item.price * count) + " points.");

        L2ItemInstance dummy = new L2ItemInstance(0, item.template.itemId);
        if (dummy.isStackable()) {
            if (!player.getInventory().validateWeight(dummy.getItem().getWeight() * item.count * count)) {
                sendResult(player, BR_BUY_INVENTROY_OVERFLOW);
                return;
            }

            if (player.getInventory().getItemByItemId(item.template.itemId) == null && !player.getInventory().validateCapacity(1)) {
                sendResult(player, BR_BUY_INVENTROY_OVERFLOW);
                return;
            }

             player.getInventory().addItem(item.template.itemId, 1);
            player.sendPacket(new SystemMessage(53).addItemName(item.template.itemId).addNumber(count));
        } else {
            if (!player.getInventory().validateCapacity(item.count * count) || !player.getInventory().validateWeight(dummy.getItem().getWeight() * item.count * count)) {
                sendResult(player, BR_BUY_INVENTROY_OVERFLOW);
                return;
            }

            for (int i = 0; i < count * item.count; i++) {
                  player.getInventory().addItem(item.template.itemId, 1);
                player.sendPacket(new SystemMessage(54).addItemName(item.template.itemId));
            }
        }

        if (item.isLimited()) {
            synchronized (item) {
                item.iStock += count;
            }
        }
        item.iSale += count;
        if (recentList.get(player.getObjectId()) == null) {
            List<ItemMallItem> charList = new ArrayList<ItemMallItem>();
            charList.add(item);
            recentList.put(player.getObjectId(), charList);
        } else {
            recentList.get(player.getObjectId()).add(item);
        }

        sendResult(player, BR_BUY_SUCCESS);
    }

    public void load() {
        loadTempaltes();
        loadShop();
    }

    public void loadTempaltes() {
        brTemplates = new HashMap<Integer, ItemMallItemTemplate>();
        try {
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            factory.setValidating(false);
            factory.setIgnoringComments(true);

            final File file = new File(Config.DATAPACK_ROOT + "/data/prime_shop.xml");
            final Document doc = factory.newDocumentBuilder().parse(file);

            for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
                if ("list".equalsIgnoreCase(n.getNodeName())) {
                    for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
                        if ("item".equalsIgnoreCase(d.getNodeName())) {
                            NamedNodeMap attrs = d.getAttributes();

                            int brId = Integer.parseInt(attrs.getNamedItem("brId").getNodeValue());
                            int itemId = 0;
                            try {
                                itemId = Integer.parseInt(attrs.getNamedItem("itemId").getNodeValue());
                            } catch (NumberFormatException e) {
                            }
                            if (itemId == 0)
                                continue;

                            int cat = Integer.parseInt(attrs.getNamedItem("category").getNodeValue());

                            ItemMallItemTemplate csit = new ItemMallItemTemplate();
                            csit.brId = brId;
                            csit.itemId = itemId;
                            csit.category = cat;

                            brTemplates.put(csit.itemId, csit);
                        }
                }
        } catch (Exception e) {
            _log.severe("ItemShop: Error parsing prime_shop.xml file. ");
            e.printStackTrace();
        }

        _log.info("ItemShop: loaded " + brTemplates.size() + " item templates.");
    }

    @SuppressWarnings("unchecked")
    public void loadShop() {
        shop = new HashMap<Integer, ItemMallItem>();
        ThreadConnection con = null;
        FiltredPreparedStatement statement = null;
        ResultSet result = null;
        try {
            con = L2DatabaseFactory.getInstance().getConnection();
            statement = con.prepareStatement("SELECT * FROM prime_shop WHERE onSale=1 ORDER BY ord");
            result = statement.executeQuery();
            while (result.next()) {
                int vsm = result.getInt("itemId");

                ItemMallItemTemplate template = brTemplates.get(vsm);

                if (template == null) {
                    _log.warning("ItemShop: item template for " + vsm + " was not found. skipping.");
                    continue;
                }

                ItemMallItem item = new ItemMallItem(template);
                item.count = result.getInt("count");
                item.price = result.getInt("price");
                item.order = result.getInt("ord");
                item.iCategory2 = result.getInt("iCategory2");
                item.iStartSale = result.getInt("iStartSale");
                item.iEndSale = result.getInt("iEndSale");
                item.iStartHour = result.getInt("iStartHour");
                item.iStartMin = result.getInt("iStartMin");
                item.iEndHour = result.getInt("iEndHour");
                item.iEndMin = result.getInt("iEndMin");
                item.iStock = result.getInt("iStock");
                item.iMaxStock = result.getInt("iMaxStock");

                L2ItemInstance dummy = new L2ItemInstance(0, vsm);
                item.iWeight = dummy.getItem().getWeight();
                item.iDropable = dummy.getItem().isDropable();
                shop.put(item.template.brId, item);
            }
        } catch (final Exception e) {
            _log.warning("ItemMall: error load() " + e);
        } finally {
            DatabaseUtils.closeDatabaseCSR(con, statement, result);
        }
        _log.info("ItemMall: loaded " + shop.size() + " items available for trading.");
        list = new ExBR_ProductList();
        ValueSortMap vsm = new ValueSortMap();
        Map<ItemMallItem, Integer> data = new LinkedHashMap<ItemMallItem, Integer>();

        for (ItemMallItem imi : shop.values()) {
            data.put(imi, imi.order);
        }

        data = vsm.sortMapByValue(data, true);
        list.col = data.keySet();
    }

    public void saveData() {
        ThreadConnection con = null;
        FiltredPreparedStatement statement = null;
        try {
            con = L2DatabaseFactory.getInstance().getConnection();
            for (ItemMallItem imi : shop.values()) {
                if (imi.isLimited()) {
                    statement = con.prepareStatement("UPDATE prime_shop set iStock=? where ord=?");
                    statement.setInt(1, imi.iStock);
                    statement.setInt(2, imi.order);
                    statement.executeUpdate();
                    statement.close();
                }
            }
            System.out.println("ItemMall: Data saved.");
        } catch (final Exception e) {
            System.out.println("ItemMall: error in saveData() " + e);
        } finally {
            DatabaseUtils.closeDatabaseCS(con, statement);
        }
    }

    public void sendResult(L2Player player, int code) {
        player.sendPacket(new ExBR_BuyProductResult(code));
    }


    public void showList(L2Player player) {
        player.sendPacket(list);
    }

    public void showItemInfo(L2Player player, int brId) {
        ItemMallItem item = shop.get(brId);
        if (item == null) {
            sendResult(player, BR_BUY_INVALID_ITEM);
            return;
        }

        player.sendPacket(new ExBR_ProductInfo(item));
    }

    public class ItemMallItem {
        public ItemMallItemTemplate template = null;
        public int count;
        public int price;
        public int order;
        public int iSale = 0;
        public int iDayWeek;
        public int iCategory2;
        public int iStartSale;
        public int iEndSale;
        public int iStartHour;
        public int iStartMin;
        public int iEndHour;
        public int iEndMin;
        public int iStock;
        public int iMaxStock;

        public int iWeight;
        public boolean iDropable;

        public ItemMallItem(ItemMallItemTemplate t) {
            template = t;
        }

        public boolean limit() {
            return iStock >= iMaxStock;
        }

        public boolean isLimited() {
            return iMaxStock > 0;
        }
    }

    public class ItemMallItemTemplate {
        public int brId;
        public int itemId;
        public int category;
    }

    public void recentProductList(L2Player player) {
        player.sendPacket(new ExBR_RecentProductListPacket(player.getObjectId()));
    }

    public List<ItemMallItem> getRecentListByOID(int objId) {
        return recentList.get(objId) == null ? new ArrayList<ItemMallItem>() : recentList.get(objId);
    }
}
2)l2p\gameserver\clientpackets\RequestBR_BuyProduct. java
Код HTML:
package l2p.gameserver.clientpackets;

import l2p.gameserver.instancemanager.PrimeShopManager;
import l2p.gameserver.model.L2Player;

public class RequestBR_BuyProduct extends L2GameClientPacket {
    private int iProductID;
    private int iAmount;

    public void readImpl() {
        iProductID = readD();
        iAmount = readD();
    }

    public void runImpl() {
        L2Player player = getClient().getActiveChar();

        if (player == null)
            return;
        else
            PrimeShopManager.getInstance().requestBuyItem(player, iProductID, iAmount);
    }
}
3)l2p\gameserver\clientpackets\RequestBR_GamePoint.j ava
Код HTML:
package l2p.gameserver.clientpackets;


import l2p.gameserver.instancemanager.PrimeShopManager;
import l2p.gameserver.model.L2Player;

public class RequestBR_GamePoint extends L2GameClientPacket {
    @Override
    public void readImpl() {
    }

    @Override
    public void runImpl() {
        L2Player activeChar = getClient().getActiveChar();

        if (activeChar == null)
            return;
    }
}
4)l2p\gameserver\clientpackets\RequestBR_ProductInfo .java
Код HTML:
package l2p.gameserver.clientpackets;

import l2p.gameserver.instancemanager.PrimeShopManager;
import l2p.gameserver.model.L2Player;

public class RequestBR_ProductInfo extends L2GameClientPacket {
    private int iProductID;

    public void readImpl() {
        iProductID = readD();
    }

    public void runImpl() {
        L2Player player = getClient().getActiveChar();

        if (player == null)
            return;
        else
            PrimeShopManager.getInstance().showItemInfo(player, iProductID);
    }
}
5)l2p\gameserver\clientpackets\RequestBR_ProductList .java
Код HTML:
package l2p.gameserver.clientpackets;

import l2p.gameserver.instancemanager.PrimeShopManager;
import l2p.gameserver.model.L2Player;

public class RequestBR_ProductList extends L2GameClientPacket {
    @Override
    public void readImpl() {
    }

    @Override
    public void runImpl() {
        L2Player player = getClient().getActiveChar();

        if (player == null)
            return;
        else
            PrimeShopManager.getInstance().showList(player);
    }
}
6)l2p\gameserver\clientpackets\RequestBR_ProductList .java
Код HTML:
package l2p.gameserver.clientpackets;

import l2p.gameserver.instancemanager.PrimeShopManager;
import l2p.gameserver.model.L2Player;


public class RequestBR_RecentProductList extends L2GameClientPacket {
    public void readImpl() {

    }

    public void runImpl() {
        L2Player player = getClient().getActiveChar();
        if (player == null)
            return;
        PrimeShopManager.getInstance().recentProductList(player);
    }
}
Переходим к сервер сайд пакетам

Опкоды для Епилога Спасибо Висталлу за то что указал на хронику.

Код HTML:
ExBR_BuyProduct
            writeEx(0xCC);
ExBR_GamePoint
             writeEx(0xB8);
ExBR_ProductInfo
            writeEx(0xCB);
ExBR_ProductList
            writeEx(0xCA);
ExBR_RecentProductList                                                                                     
            writeEx(0xD1);
7)l2p\gameserver\serverpackets\ExBR_ProductInfo.java
Код HTML:
package l2p.gameserver.serverpackets;

import l2p.gameserver.instancemanager.PrimeShopManager.ItemMallItem;

public class ExBR_ProductInfo extends L2GameServerPacket {
    private ItemMallItem _item;

    public ExBR_ProductInfo(ItemMallItem item) {
        _item = item;
    }

    @Override
    protected void writeImpl() {
        writeC(0xFE);
        writeH(0xCB);

        writeD(_item.template.brId);
        writeD(_item.price);
        writeD(1);
        writeD(_item.template.itemId);
        writeD(_item.count);
        writeD(_item.iWeight);
        writeD(_item.iDropable ? 1 : 0);
    }
}

8)l2p\gameserver\serverpackets\ExBR_ProductList.java
Код HTML:
package l2p.gameserver.serverpackets;

import l2p.Config;
import l2p.gameserver.instancemanager.PrimeShopManager.ItemMallItem;

import java.util.Collection;

public class ExBR_ProductList extends L2GameServerPacket {
    public Collection<ItemMallItem> col;

    @Override
    protected void writeImpl() {
        writeC(EXTENDED_PACKET);
        writeH(0xCA);
        writeD(col.size());

        for (ItemMallItem cs : col) {
            writeD(cs.template.brId);
            writeH(cs.template.category);
            writeD(cs.price);
            int cat = 0;
            if (cs.iSale >= Config.colUp) {
                switch (cs.iCategory2) {
                    case 0:
                    case 2:
                        cat = 2;
                        break;
                    case 1:
                        cat = 3;
                        break;
                }
            }
            writeD(cat);
            if (cs.iStartSale > 0 && cs.iEndSale > 0) {
                writeD(cs.iStartSale);
                writeD(cs.iEndSale);
            } else {
                writeD(0x12CEDE40);
                writeD(0x7ECE3CD0);
            }
            writeC(0x7F);
            writeC(cs.iStartHour);
            writeC(cs.iStartMin);
            writeC(cs.iEndHour);
            writeC(cs.iEndMin);
            writeD(cs.iStock);
            writeD(cs.iMaxStock);
        }

    }
}
8) l2p\gameserver\serverpackets\ExBR_RecentProductLis tPacket.java
Код HTML:
package l2p.gameserver.serverpackets;

import l2p.gameserver.instancemanager.PrimeShopManager;

import java.util.List;


public class ExBR_RecentProductListPacket extends L2GameServerPacket {
    List<PrimeShopManager.ItemMallItem> list;

    public ExBR_RecentProductListPacket(int objId) {
        list = PrimeShopManager.getInstance().getRecentListByOID(objId);
    }

    @Override
    protected void writeImpl() {
        writeC(0xFE);
        writeH(0xD1);
        writeD(list.size());
        for (PrimeShopManager.ItemMallItem item : list) {
            writeD(item.template.brId);
            writeH(item.template.category);
            writeD(item.price);
            int cat = 0;
            if (item.iSale >= 2) {
                switch (item.iCategory2) {
                    case 0:
                    case 2:
                        cat = 2;
                        break;
                    case 1:
                        cat = 3;
                        break;
                }
            }
            writeD(cat);
            if (item.iStartSale > 0 && item.iEndSale > 0) {
                writeD(item.iStartSale);
                writeD(item.iEndSale);
            } else {
                writeD(0x12CEDE40);
                writeD(0x7ECE3CD0);
            }
            writeC(0x7F);
            writeC(item.iStartHour);
            writeC(item.iStartMin);
            writeC(item.iEndHour);
            writeC(item.iEndMin);
            writeD(item.iStock);
            writeD(item.iMaxStock);
        }
    }
}
9) l2p\gameserver\serverpackets\ExBR_BuyProductResult .java

Код HTML:
package l2p.gameserver.serverpackets;

public class ExBR_BuyProductResult extends L2GameServerPacket {
    private int _code;

    public ExBR_BuyProductResult(int code) {
        _code = code;
    }

    @Override
    protected void writeImpl() {
        writeC(0xFE);
        writeH(0xCC);
        writeD(_code);
    }
}


10)Утила сорта l2p\util\ValueSortMap.java
Код HTML:
package l2p.util;


import java.util.*;

/**
 * This class is used to show how you can sort a java.uti.Map for values. This also
 * takes care of null and duplicate values present in the map.
 */
@SuppressWarnings("unchecked")
public class ValueSortMap
{
	public Map<Integer, Integer> sortThis(Map<Integer, Integer> map, boolean asc)
	{
		return sortMapByValue(map, asc);
	}

	/**
	 * This method returns the new LinkedHashMap sorted with values for passed Comparater.
	 * If null values exist they will be put in the last of the returned LinkedHashMap.
	 * If there are duplicate values they will come together at the values ordering order
	 * but ordering between same multiple values is ramdom. Passed Map will be intect.
	 * @param inMap Map to be sorted
	 * @param comparator Values will be sorted as per passed Comparater
	 * @return LinkedHashMap Sorted new LinkedHashMap
	 */
	public static LinkedHashMap sortMapByValue(Map inMap, Comparator comparator)
	{
		return sortMapByValue(inMap, comparator, null);
	}

	/**
	 * This method returns the new LinkedHashMap sorted with values for passed ascendingOrder.
	 * If null values exist they will be put in the last for true value of ascendingOrder or
	 * will be put on top of the returned LinkedHashMap for false value of ascendingOrder.
	 * If there are duplicate values they will come together at the values ordering order
	 * but ordering between same multiple values is ramdom. Passed Map will be intect.
	 * @param inMap Map to be sorted
	 * @param ascendingOrder Values will be sorted as per value of ascendingOrder
	 * @return LinkedHashMap Sorted new LinkedHashMap
	 */
	public static LinkedHashMap sortMapByValue(Map inMap, boolean ascendingOrder)
	{
		return sortMapByValue(inMap, null, new Boolean(ascendingOrder));
	}

	/**
	 * This method returns the new LinkedHashMap sorted with values in ascending order.
	 * If null values exist they will be put in the last of the returned LinkedHashMap.
	 * If there are duplicate values they will come together at the values ordering order
	 * but ordering between same multiple values is ramdom. Passed Map will be intect.
	 * @param inMap Map to be sorted
	 * @return LinkedHashMap Sorted new LinkedHashMap
	 */
	public static LinkedHashMap sortMapByValue(Map inMap)
	{
		return sortMapByValue(inMap, null, null);
	}

	/**
	 * This method returns the new LinkedHashMap sorted with values. Values will be sorted
	 * as value of passed comparator if ascendingOrder is null or in order of passed
	 * ascendingOrder if it is not null.
	 * If null values exist they will be put in the last for true value of ascendingOrder or
	 * will be put on top of the returned LinkedHashMap for false value of ascendingOrder.
	 * If there are duplicate values they will come together at the values ordering order
	 * but ordering between same multiple values is ramdom. Passed Map will be intect.
	 * @param inMap Map to be sorted
	 * @param comparator Values will be sorted as per passed Comparater
	 * @param ascendingOrder Values will be sorted as per value of ascendingOrder
	 * @return LinkedHashMap Sorted new LinkedHashMap
	 */
	private static LinkedHashMap sortMapByValue(Map inMap, Comparator comparator, Boolean ascendingOrder)
	{
		int iSize = inMap.size();

		// Create new LinkedHashMap that need to be returned
		LinkedHashMap sortedMap = new LinkedHashMap(iSize);

		Collection values = inMap.values();
		ArrayList valueList = new ArrayList(values); // To get List of all values in passed Map
		HashSet distinctValues = new HashSet(values); // To know the distinct values in passed Map

		// Do handing for null values. remove them from the list that will be used for sorting
		int iNullValueCount = 0; // Total number of null values present in passed Map
		if(distinctValues.contains(null))
		{
			distinctValues.remove(null);
			for(int i = 0; i < valueList.size(); i++)
			{
				if(valueList.get(i) == null)
				{
					valueList.remove(i);
					iNullValueCount++;
					i--;
					continue;
				}
			}
		}

		// Sort the values of the passed Map
		if(ascendingOrder == null)
		{
			// If Boolean ascendingOrder is null, use passed comparator for order of sorting values
			Collections.sort(valueList, comparator);
		}
		else if(ascendingOrder.booleanValue())
		{
			// If Boolean ascendingOrder is not null and is true, sort values in ascending order
			Collections.sort(valueList);
		}
		else
		{
			// If Boolean ascendingOrder is not null and is false, sort values in descending order
			Collections.sort(valueList);
			Collections.reverse(valueList);
		}

		// Check if there are multiple same values exist in passed Map (not considering null values)
		boolean bAllDistinct = true;
		if(iSize != (distinctValues.size() + iNullValueCount))
			bAllDistinct = false;

		Object key = null, value = null, sortedValue;
		Set keySet = null;
		Iterator itKeyList = null;
		HashMap hmTmpMap = new HashMap(iSize);
		HashMap hmNullValueMap = new HashMap();

		if(bAllDistinct)
		{
			// There are no multiple same values in the passed map (without consedring null)
			keySet = inMap.keySet();
			itKeyList = keySet.iterator();
			while(itKeyList.hasNext())
			{
				key = itKeyList.next();
				value = inMap.get(key);

				if(value != null)
					hmTmpMap.put(value, key); // Prepare new temp HashMap with value=key combination
				else
					hmNullValueMap.put(key, value); // Keep all null values in a new temp Map
			}

			if(ascendingOrder != null && !ascendingOrder.booleanValue())
			{
				// As it is descending order, Add Null Values in first place of the LinkedHasMap
				sortedMap.putAll(hmNullValueMap);
			}

			// Put all not null values in returning LinkedHashMap
			for(int i = 0; i < valueList.size(); i++)
			{
				value = valueList.get(i);
				key = hmTmpMap.get(value);

				sortedMap.put(key, value);
			}

			if(ascendingOrder == null || ascendingOrder.booleanValue())
			{
				// Add Null Values in the last of the LinkedHasMap
				sortedMap.putAll(hmNullValueMap);
			}
		}
		else
		{
			// There are some multiple values (with out considering null)
			keySet = inMap.keySet();
			itKeyList = keySet.iterator();
			while(itKeyList.hasNext())
			{
				key = itKeyList.next();
				value = inMap.get(key);

				if(value != null)
					hmTmpMap.put(key, value); // Prepare new temp HashMap with key=value combination
				else
					hmNullValueMap.put(key, value); // Keep all null values in a new temp Map
			}

			if(ascendingOrder != null && !ascendingOrder.booleanValue())
			{
				// As it is descending order, Add Null Values in first place of the LinkedHasMap
				sortedMap.putAll(hmNullValueMap);
			}

			// Put all not null values in returning LinkedHashMap
			for(int i = 0; i < valueList.size(); i++)
			{
				sortedValue = valueList.get(i);

				// Search this value in temp HashMap and if found remove it
				keySet = hmTmpMap.keySet();
				itKeyList = keySet.iterator();
				while(itKeyList.hasNext())
				{
					key = itKeyList.next();
					value = hmTmpMap.get(key);
					if(value.equals(sortedValue))
					{
						sortedMap.put(key, value);
						hmTmpMap.remove(key);
						break;
					}
				}
			}

			if(ascendingOrder == null || ascendingOrder.booleanValue())
			{
				// Add Null Values in the last of the LinkedHasMap
				sortedMap.putAll(hmNullValueMap);
			}
		}

		return sortedMap;
	}
}
12)Переходим к стадии регистрации пакетов.
Все остальные введены в феникс не позднее 13к+ ревы
Код HTML:
                           case 0x7f:
                              msg = new RequestBR_GamePoint();
                              break;
                           case 0x80:
                                msg = new RequestBR_ProductList();
                                break;
                            case 0x81:
                                msg = new RequestBR_ProductInfo();
                                break;
                            case 0x82:
                                msg = new RequestBR_BuyProduct();
                                break;
                            case 0x83:
                                msg = new RequestBR_RecentProductList();
                                break;
13)2p\Config.java
Код HTML:
public static int colUp; // item mall
colUp = getIntProperty(servicesSettings, "IMup", 2);

Переходим к части датапака и собственно самой простой

14)l2p\gameserver\data\prime_shop.xml
Код HTML:
<?xml version='1.0' encoding='utf-8'?>
<list>
	<item brId="1080001" itemId="22000" name="Small fortuna box" category="5" />
	<item brId="1080002" itemId="22001" name="Middle fortuna box" category="5" />
	<item brId="1080003" itemId="22002" name="Large fortuna box" category="5" />
	<item brId="1080004" itemId="22003" name="Small fortuna cube" category="5" />
	<item brId="1080005" itemId="22004" name="Middle fortuna cube" category="5" />
	<item brId="1080006" itemId="22005" name="Large fortuna cube" category="5" />
	<item brId="1080007" itemId="22025" name="Powerful Healing Potion" category="5" />
	<item brId="1080008" itemId="22026" name="High-grade Healing Potion" category="5" />
</list>
15) Sql часть
Код HTML:
-- ----------------------------
-- Table structure for prime_shop
-- ----------------------------
DROP TABLE IF EXISTS `prime_shop`;
CREATE TABLE `prime_shop` (
  `ord` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `itemId` int(11) NOT NULL,
  `count` int(11) NOT NULL DEFAULT '1',
  `price` int(11) NOT NULL DEFAULT '0',
  `iCategory2` int(1) NOT NULL DEFAULT '0',
  `onSale` int(1) NOT NULL DEFAULT '1',
  `iStartSale` int(9) NOT NULL DEFAULT '0',
  `iEndSale` int(9) NOT NULL DEFAULT '0',
  `iStartHour` int(2) NOT NULL DEFAULT '0',
  `iStartMin` int(2) NOT NULL DEFAULT '0',
  `iEndHour` int(2) NOT NULL DEFAULT '23',
  `iEndMin` int(2) NOT NULL DEFAULT '59',
  `iStock` int(11) NOT NULL DEFAULT '0',
  `iMaxStock` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`ord`,`itemId`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

INSERT INTO `prime_shop` VALUES 
('1', 'Small fortuna box', '22000', '1', '135', '0', '1', '0', '0', '0', '0', '23', '59', '0', '0'),
('2', 'Middle fortuna box', '22001', '1', '270', '0', '1', '0', '0', '0', '0', '23', '59', '0', '0'),
('3', 'Large fortuna box', '22002', '1', '405', '0', '1', '0', '0', '0', '0', '23', '59', '0', '0'),
('4', 'small fortuna cube', '22003', '1', '81', '0', '1', '0', '0', '0', '0', '23', '59', '0', '0'),
('5', 'Middle fortuna cube', '22004', '1', '216', '0', '1', '0', '0', '0', '0', '23', '59', '0', '0'),
('6', 'Large fortuna cube', '22005', '1', '324', '0', '1', '0', '0', '0', '0', '23', '59', '0', '0'),
('7', 'Powerful Healing Potion', '22025', '1', '3', '0', '1', '0', '0', '0', '0', '23', '59', '0', '0'),
('8', 'Rune of Feather', '22066', '1', '68', '0', '1', '0', '0', '0', '0', '23', '59', '0', '0'),
('9', 'High-grade Healing Potion', '22026', '1', '1', '0', '1', '0', '0', '0', '0', '23', '59', '0', '0');

Теперь НЕ ЗАБУДЬТЕ ВКЛЮЧИТЬ ЕГО В КЛИЕНТЕ !
Будет работать как на евро клиенте так и на руссоффе.
Lineage2/system/l2.ini открываем и вставляем. ->
Код HTML:
[PrimeShop]
UsePrimeShop=true


Вот вам и айтем мол и с чем его едят Больше только разговоров ....... уже даже и америкосы ( кхе хе ... пендосы) подтянусь ЫЫЫ вистал попыривал своими партизанскими штуками аля ойй епрррр я свой код не шарю

PS
Вуаля ! У Вас на сервере есть Item Mall !

Добавлено через 47 минут
Цитата:
Сообщение от SunnyX Посмотреть сообщение
Самый главный вопрос который нужно было разместить на первом посте - с каких хроник эта плюшка доступна.
от Chaotic Throne 2.

Добавлено через 1 час 3 минуты
Цитата:
Сообщение от saYRam Посмотреть сообщение
Also Official L2jServer? If so, what do i have to do?
look for a good programmer , when the Slavs will to enslave the worlds

PSS Юзайте на здоровье.Все работает качественно.

Последний раз редактировалось Deazer; 07.01.2011 в 15:49. Причина: Добавлено сообщение
Deazer вне форума Ответить с цитированием
Сказали спасибо: