Код:
Index: /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/serverpackets/ExBrBuyProduct.java
===================================================================
--- /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/serverpackets/ExBrBuyProduct.java (revision 27)
+++ /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/serverpackets/ExBrBuyProduct.java (revision 27)
@@ -0,0 +1,41 @@
+package com.l2jserver.gameserver.network.serverpackets;
+
+/**
+ * Author: VISTALL
+ * Company: J Develop Station
+ * Date: 2:02:35/10.04.2010
+ * thx l2jfree
+ */
+public class ExBrBuyProduct extends L2GameServerPacket
+{
+ private static final String TYPE = "[S] FE:D8 ExBrBuyProduct";
+
+ public static final int RESULT_OK = 1; // ok
+ public static final int RESULT_NOT_ENOUGH_POINTS = -1;
+ public static final int RESULT_WRONG_PRODUCT = -2; // also -5
+ public static final int RESULT_INVENTORY_FULL = -4;
+ public static final int RESULT_SALE_PERIOD_ENDED = -7; // also -8
+ public static final int RESULT_WRONG_USER_STATE = -9; // also -11
+ public static final int RESULT_WRONG_PRODUCT_ITEM = -10;
+
+ private final int _result;
+
+ public ExBrBuyProduct(int result)
+ {
+ _result = result;
+ }
+
+ @Override
+ protected void writeImpl()
+ {
+ writeC(0xFE);
+ writeH(0xD8);
+ writeD(_result);
+ }
+
+ @Override
+ public String getType()
+ {
+ return TYPE;
+ }
+}
Index: /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/serverpackets/ExBrProductList.java
===================================================================
--- /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/serverpackets/ExBrProductList.java (revision 27)
+++ /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/serverpackets/ExBrProductList.java (revision 27)
@@ -0,0 +1,48 @@
+package com.l2jserver.gameserver.network.serverpackets;
+
+import com.l2jserver.gameserver.datatables.ProductItemTable;
+import com.l2jserver.gameserver.model.L2ProductItem;
+
+import java.util.Collection;
+
+/**
+ * Author: VISTALL
+ * Company: J Develop Station
+ * Date: 1:50:38/10.04.2010
+ */
+public class ExBrProductList extends L2GameServerPacket
+{
+ private static final String TYPE = "[S] FE:D6 ExBrProductList";
+
+ @Override
+ protected void writeImpl()
+ {
+ writeC(0xFE);
+ writeH(0xD6);
+ Collection<L2ProductItem> items = ProductItemTable.getInstance().getAllItems();
+ writeD(items.size());
+
+ for (L2ProductItem template : items)
+ {
+ writeD(template.getProductId());
+ writeH(template.getCategory());
+ writeH(template.getPoints());
+ writeD(0);
+ writeD(0);
+ writeD(0);
+ writeD(0);
+ writeH(0);
+ writeH(0);
+ writeH(0);
+ writeH(0);
+ writeC(0);
+ writeH(0);
+ }
+ }
+
+ @Override
+ public String getType()
+ {
+ return TYPE;
+ }
+}
Index: /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/serverpackets/ExBrGamePoint.java
===================================================================
--- /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/serverpackets/ExBrGamePoint.java (revision 27)
+++ /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/serverpackets/ExBrGamePoint.java (revision 27)
@@ -0,0 +1,43 @@
+package com.l2jserver.gameserver.network.serverpackets;
+
+import com.l2jserver.Config;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ * Author: VISTALL
+ * Company: J Develop Station
+ * Date: 0:05:02/10.04.2010
+ */
+public class ExBrGamePoint extends L2GameServerPacket
+{
+ private static final String TYPE = "[S] FE:D5 ExBrGamePoint";
+
+ private int _objId;
+ private long _points;
+
+ public ExBrGamePoint(L2PcInstance player)
+ {
+ _objId = player.getObjectId();
+
+ if(Config.GAME_POINT_ITEM_ID == -1)
+ _points = player.getGamePoints();
+ else
+ _points = player.getInventory().getInventoryItemCount(Config.GAME_POINT_ITEM_ID, -100);
+ }
+
+ @Override
+ public void writeImpl()
+ {
+ writeC(0xFE);
+ writeH(0xD5);
+ writeD(_objId);
+ writeQ(_points);
+ writeD(0);
+ }
+
+ @Override
+ public String getType()
+ {
+ return TYPE;
+ }
+}
Index: /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/serverpackets/ExBrProductInfo.java
===================================================================
--- /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/serverpackets/ExBrProductInfo.java (revision 27)
+++ /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/serverpackets/ExBrProductInfo.java (revision 27)
@@ -0,0 +1,50 @@
+package com.l2jserver.gameserver.network.serverpackets;
+
+import com.l2jserver.gameserver.datatables.ProductItemTable;
+import com.l2jserver.gameserver.model.L2ProductItem;
+import com.l2jserver.gameserver.model.L2ProductItemComponent;
+
+/**
+ * Author: VISTALL
+ * Company: J Develop Station
+ * Date: 2:50:11/10.04.2010
+ */
+public class ExBrProductInfo extends L2GameServerPacket
+{
+ private static final String TYPE = "[S] FE:D7 ExBrProductInfo";
+
+ private L2ProductItem _productId;
+
+ public ExBrProductInfo(int id)
+ {
+ _productId = ProductItemTable.getInstance().getProduct(id);
+ }
+
+ @Override
+ protected void writeImpl()
+ {
+ if(_productId == null)
+ return;
+
+ writeC(0xFE);
+ writeH(0xD7);
+
+ writeD(_productId.getProductId()); //product id
+ writeD(_productId.getPoints()); // points
+ writeD(_productId.getComponents().size()); //size
+
+ for (L2ProductItemComponent com : _productId.getComponents())
+ {
+ writeD(com.getItemId()); //item id
+ writeD(com.getCount()); //quality
+ writeD(com.getWeight()); //weight
+ writeD(com.isDropable() ? 1 : 0); //0 - dont drop/trade
+ }
+ }
+
+ @Override
+ public String getType()
+ {
+ return TYPE;
+ }
+}
Index: /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/clientpackets/RequestBrBuyProduct.java
===================================================================
--- /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/clientpackets/RequestBrBuyProduct.java (revision 27)
+++ /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/clientpackets/RequestBrBuyProduct.java (revision 27)
@@ -0,0 +1,125 @@
+package com.l2jserver.gameserver.network.clientpackets;
+
+import com.l2jserver.Config;
+import com.l2jserver.gameserver.datatables.ItemTable;
+import com.l2jserver.gameserver.datatables.ProductItemTable;
+import com.l2jserver.gameserver.model.L2ProductItem;
+import com.l2jserver.gameserver.model.L2ProductItemComponent;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.network.serverpackets.ExBrBuyProduct;
+import com.l2jserver.gameserver.network.serverpackets.ExBrGamePoint;
+import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;
+import com.l2jserver.gameserver.templates.item.L2Item;
+
+/**
+ * Author: VISTALL
+ * Company: J Develop Station
+ * Date: 2:57:47/10.04.2010
+ */
+public class RequestBrBuyProduct extends L2GameClientPacket
+{
+ private static final String TYPE = "[C] D0 8C RequestBrBuyProduct";
+
+ private int _productId;
+ private int _count;
+
+ @Override
+ protected void readImpl()
+ {
+ _productId = readD();
+ _count = readD();
+ }
+
+ @Override
+ protected void runImpl()
+ {
+ L2PcInstance player = getClient().getActiveChar();
+ if(player == null)
+ {
+ return;
+ }
+
+ if(_count > 99 || _count < 0)
+ {
+ return;
+ }
+
+ L2ProductItem product = ProductItemTable.getInstance().getProduct(_productId);
+ if(product == null)
+ {
+ player.sendPacket(new ExBrBuyProduct(ExBrBuyProduct.RESULT_WRONG_PRODUCT));
+ return;
+ }
+
+ long totalPoints = product.getPoints() * _count;
+
+ if(totalPoints < 0)
+ {
+ player.sendPacket(new ExBrBuyProduct(ExBrBuyProduct.RESULT_WRONG_PRODUCT));
+ return;
+ }
+
+ final long gamePointSize = Config.GAME_POINT_ITEM_ID == -1 ? player.getGamePoints() : player.getInventory().getInventoryItemCount(Config.GAME_POINT_ITEM_ID, -1);
+
+ if(totalPoints > gamePointSize)
+ {
+ player.sendPacket(new ExBrBuyProduct(ExBrBuyProduct.RESULT_NOT_ENOUGH_POINTS));
+ return;
+ }
+
+ int totalWeight = 0;
+ for(L2ProductItemComponent com : product.getComponents())
+ {
+ totalWeight += com.getWeight();
+ }
+ totalWeight *= _count;
+
+ int totalCount = 0;
+
+ for(L2ProductItemComponent com : product.getComponents())
+ {
+ L2Item item = ItemTable.getInstance().getTemplate(com.getItemId());
+ if(item == null)
+ {
+ player.sendPacket(new ExBrBuyProduct(ExBrBuyProduct.RESULT_WRONG_PRODUCT));
+ return; //what
+ }
+ totalCount += item.isStackable() ? 1 : com.getCount() * _count;
+ }
+
+ if(!player.getInventory().validateCapacity(totalCount) || !player.getInventory().validateWeight(totalWeight))
+ {
+ player.sendPacket(new ExBrBuyProduct(ExBrBuyProduct.RESULT_INVENTORY_FULL));
+ return;
+ }
+
+ for (L2ProductItemComponent $comp : product.getComponents())
+ {
+ player.getInventory().addItem("Buy Product" + _productId, $comp.getItemId(), $comp.getCount() * _count, player, null);
+ }
+
+ if(Config.GAME_POINT_ITEM_ID == -1)
+ {
+ player.setGamePoints(player.getGamePoints() - totalPoints);
+ }
+ else
+ {
+ player.getInventory().destroyItemByItemId("Buy Product" + _productId, Config.GAME_POINT_ITEM_ID, totalPoints, player, null);
+ }
+
+ StatusUpdate su = new StatusUpdate(player);
+ su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
+ player.sendPacket(su);
+
+ player.sendPacket(new ExBrGamePoint(player));
+ player.sendPacket(new ExBrBuyProduct(ExBrBuyProduct.RESULT_OK));
+
+ //player.sendPacket(new ItemList(player, true));
+ }
+
+ @Override
+ public String getType()
+ {
+ return TYPE;
+ }
+}
Index: /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/clientpackets/RequestBrProductList.java
===================================================================
--- /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/clientpackets/RequestBrProductList.java (revision 27)
+++ /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/clientpackets/RequestBrProductList.java (revision 27)
@@ -0,0 +1,38 @@
+package com.l2jserver.gameserver.network.clientpackets;
+
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.network.serverpackets.ExBrProductList;
+
+/**
+ * Author: VISTALL
+ * Company: J Develop Station
+ * Date: 1:50:38/10.04.2010
+ */
+public class RequestBrProductList extends L2GameClientPacket
+{
+ private static final String TYPE = "[C] D0:8A RequestBrProductList";
+
+ @Override
+ protected void readImpl()
+ {
+
+ }
+
+ @Override
+ protected void runImpl()
+ {
+ L2PcInstance player= getClient().getActiveChar();
+ if(player == null)
+ {
+ return;
+ }
+
+ player.sendPacket(new ExBrProductList());
+ }
+
+ @Override
+ public String getType()
+ {
+ return TYPE;
+ }
+}
Index: /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/clientpackets/RequestBrRecentProductList.java
===================================================================
--- /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/clientpackets/RequestBrRecentProductList.java (revision 27)
+++ /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/clientpackets/RequestBrRecentProductList.java (revision 27)
@@ -0,0 +1,28 @@
+package com.l2jserver.gameserver.network.clientpackets;
+
+/**
+ * @author Ragnarok
+ */
+
+public class BrRecentProductList extends L2GameClientPacket
+{
+ public BrRecentProductList()
+ {
+ }
+
+ @Override
+ public void readImpl()
+ {
+ }
+
+ @Override
+ public void runImpl()
+ {
+ }
+
+ @Override
+ public String getType()
+ {
+ return "[C] d0:8D BrRecentProductList";
+ }
+}
Index: /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/clientpackets/RequestBrProductInfo.java
===================================================================
--- /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/clientpackets/RequestBrProductInfo.java (revision 27)
+++ /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/clientpackets/RequestBrProductInfo.java (revision 27)
@@ -0,0 +1,40 @@
+package com.l2jserver.gameserver.network.clientpackets;
+
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.network.serverpackets.ExBrProductInfo;
+
+/**
+ * Author: VISTALL
+ * Company: J Develop Station
+ * Date: 13:19:12/25.04.2010
+ */
+public class RequestBrProductInfo extends L2GameClientPacket
+{
+ private static final String TYPE = "[C] D0:8B RequestBrProductInfo";
+
+ private int _productId;
+
+ @Override
+ protected void readImpl()
+ {
+ _productId = readD();
+ }
+
+ @Override
+ protected void runImpl()
+ {
+ L2PcInstance player= getClient().getActiveChar();
+ if(player == null)
+ {
+ return;
+ }
+
+ player.sendPacket(new ExBrProductInfo(_productId));
+ }
+
+ @Override
+ public String getType()
+ {
+ return TYPE;
+ }
+}
Index: /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/clientpackets/RequestBrGamePoint.java
===================================================================
--- /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/clientpackets/RequestBrGamePoint.java (revision 27)
+++ /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/clientpackets/RequestBrGamePoint.java (revision 27)
@@ -0,0 +1,35 @@
+package com.l2jserver.gameserver.network.clientpackets;
+
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.network.serverpackets.ExBrGamePoint;
+
+/**
+ * Author: VISTALL
+ * Company: J Develop Station
+ * Date: 0:36:26/10.04.2010
+ */
+public class RequestBrGamePoint extends L2GameClientPacket
+{
+ private static final String TYPE = "[C] D0:89 RequestBrGamePoint";
+
+ @Override
+ protected void readImpl()
+ {
+
+ }
+
+ @Override
+ protected void runImpl()
+ {
+ L2PcInstance player = getClient().getActiveChar();
+ if(player == null)
+ return;
+ player.sendPacket(new ExBrGamePoint(player));
+ }
+
+ @Override
+ public String getType()
+ {
+ return TYPE;
+ }
+}
Index: /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/L2GamePacketHandler.java
===================================================================
--- /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/L2GamePacketHandler.java (revision 26)
+++ /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/network/L2GamePacketHandler.java (revision 27)
@@ -1094,17 +1094,17 @@
break;
case 0x89:
- // RequestBRGamePoint
+ msg = new RequestBrGamePoint();
break;
case 0x8A:
- // RequestBRProductList
+ msg = new RequestBrProductList();
break;
case 0x8B:
- // RequestBRProductInfo
+ msg = new RequestBrProductInfo();
break;
case 0x8C:
- // RequestBRBuyProduct
+ msg = new RequestBrBuyProduct();
break;
case 0x8D:
- // RequestBRRecentProductList
+ msg = new RequestBrRecentProductList();
break;
case 0x8E:
Index: /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (revision 26)
+++ /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (revision 27)
@@ -296,7 +296,7 @@
// Character Character SQL String Definitions:
- private static final String INSERT_CHARACTER = "INSERT INTO characters (account_name,charId,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp,face,hairStyle,hairColor,sex,exp,sp,karma,fame,pvpkills,pkkills,clanid,race,classid,deletetime,cancraft,title,title_color,accesslevel,online,isin7sdungeon,clan_privs,wantspeace,base_class,newbie,nobless,power_grade,createTime) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
- private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,fame=?,pvpkills=?,pkkills=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,bookmarkslot=?,vitality_points=?,language=?,pc_point=? WHERE charId=?";
- private static final String RESTORE_CHARACTER = "SELECT account_name, charId, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, fame, pvpkills, pkkills, clanid, race, classid, deletetime, cancraft, title, title_color, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, punish_level, punish_timer, newbie, nobless, power_grade, subpledge, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,bookmarkslot,vitality_points,createTime,language,pc_point FROM characters WHERE charId=?";
+ private static final String INSERT_CHARACTER = "INSERT INTO characters (account_name,charId,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp,face,hairStyle,hairColor,sex,exp,sp,karma,fame,pvpkills,pkkills,clanid,race,classid,deletetime,cancraft,title,title_color,accesslevel,online,isin7sdungeon,clan_privs,wantspeace,base_class,newbie,nobless,power_grade,createTime) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
+ private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,fame=?,pvpkills=?,pkkills=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,bookmarkslot=?,vitality_points=?,language=?,pc_point=?,game_points=? WHERE charId=?";
+ private static final String RESTORE_CHARACTER = "SELECT account_name, charId, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, fame, pvpkills, pkkills, clanid, race, classid, deletetime, cancraft, title, title_color, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, punish_level, punish_timer, newbie, nobless, power_grade, subpledge, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,bookmarkslot,vitality_points,createTime,language,pc_point,game_points FROM characters WHERE charId=?";
// Character Teleport Bookmark:
@@ -821,4 +821,6 @@
private int _multiSociaAction = 0;
+ private long _gamePoints;
+
private int _movieId = 0;
@@ -7094,5 +7096,5 @@
statement.setInt(35, isNoble() ? 1 :0);
statement.setLong(36, 0);
- statement.setLong(37,getPCCafePoint());
+ statement.setLong(37,getPCCafePoint());
statement.setLong(38,getCreateTime());
@@ -7296,4 +7298,6 @@
// Set PC Bang Points
player.setPCCafePoint(rset.getInt("pc_point"));
+
+ player.setGamePoints(rset.getInt("game_points"));
// Retrieve the name and ID of the other characters assigned to this account.
@@ -7757,5 +7761,6 @@
statement.setString(52, getLang());
statement.setInt(53, getPCCafePoint());
- statement.setInt(54, getObjectId());
+ statement.setLong(54, getGamePoints());
+ statement.setInt(55, getObjectId());
statement.execute();
@@ -15514,3 +15519,12 @@
return _lastCategory;
}
+ public long getGamePoints()
+ {
+ return _gamePoints;
+ }
+
+ public void setGamePoints(long gamePoints)
+ {
+ _gamePoints = gamePoints;
+ }
}
Index: /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/model/L2ProductItemComponent.java
===================================================================
--- /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/model/L2ProductItemComponent.java (revision 27)
+++ /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/model/L2ProductItemComponent.java (revision 27)
@@ -0,0 +1,57 @@
+package com.l2jserver.gameserver.model;
+
+import com.l2jserver.gameserver.datatables.ItemTable;
+import com.l2jserver.gameserver.templates.item.L2Item;
+
+/**
+ * Author: VISTALL
+ * Company: ihgap
+ * Date: 11:53:22/25.04.2010
+ */
+public class L2ProductItemComponent
+{
+ private final int _itemId;
+ private final int _count;
+
+ private final int _weight;
+ private final boolean _dropable;
+
+ public L2ProductItemComponent(int item_id, int count)
+ {
+ _itemId = item_id;
+ _count = count;
+
+ L2Item item = ItemTable.getInstance().getTemplate(item_id);
+ if(item != null)
+ {
+ _weight = item.getWeight();
+ _dropable = item.isDropable();
+ }
+ else
+ {
+ //FIX ME what the mother facker???
+ _weight = 0;
+ _dropable = true;
+ }
+ }
+
+ public int getItemId()
+ {
+ return _itemId;
+ }
+
+ public int getCount()
+ {
+ return _count;
+ }
+
+ public int getWeight()
+ {
+ return _weight;
+ }
+
+ public boolean isDropable()
+ {
+ return _dropable;
+ }
+}
Index: /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/model/L2ProductItem.java
===================================================================
--- /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/model/L2ProductItem.java (revision 27)
+++ /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/model/L2ProductItem.java (revision 27)
@@ -0,0 +1,53 @@
+package com.l2jserver.gameserver.model;
+
+import java.util.ArrayList;
+
+/**
+ * Author: VISTALL
+ * Company: ihgap
+ * Date: 11:52:33/25.04.2010
+ */
+public class L2ProductItem
+{
+ private final int _productId;
+ private final int _category;
+ private final int _points;
+ private ArrayList<L2ProductItemComponent> _components;
+
+ public L2ProductItem(int productId, int category, int points)
+ {
+ _productId = productId;
+ _category = category;
+ _points = points;
+ }
+
+ public void setComponents(ArrayList<L2ProductItemComponent> a)
+ {
+ _components = a;
+ }
+
+ public ArrayList<L2ProductItemComponent> getComponents()
+ {
+ if(_components == null)
+ {
+ _components = new ArrayList<L2ProductItemComponent>();
+ }
+
+ return _components;
+ }
+
+ public int getProductId()
+ {
+ return _productId;
+ }
+
+ public int getCategory()
+ {
+ return _category;
+ }
+
+ public int getPoints()
+ {
+ return _points;
+ }
+}
Index: /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/GameServer.java
===================================================================
--- /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/GameServer.java (revision 26)
+++ /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/GameServer.java (revision 27)
@@ -151,4 +151,5 @@
MultiSell.getInstance();
RecipeController.getInstance();
+ ProductItemTable.getInstance();
ArmorSetsTable.getInstance();
FishTable.getInstance();
Index: /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/datatables/ProductItemTable.java
===================================================================
--- /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/datatables/ProductItemTable.java (revision 27)
+++ /trunk/GameServer_HighFive/java/com/l2jserver/gameserver/datatables/ProductItemTable.java (revision 27)
@@ -0,0 +1,116 @@
+package com.l2jserver.gameserver.datatables;
+
+import java.sql.*;
+import java.util.*;
+
+import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.gameserver.model.L2ProductItem;
+import com.l2jserver.gameserver.model.L2ProductItemComponent;
+import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
+
+/**
+ * Author: VISTALL
+ * Company: ihgap
+ * Date: 11:56:55/25.04.2010
+ */
+public class ProductItemTable
+{
+ private static java.util.logging.Logger _log = java.util.logging.Logger.getLogger(L2PetInstance.class.getName());
+ private Map<Integer, L2ProductItem> _itemsList = new TreeMap<Integer, L2ProductItem>();
+
+ public static final ProductItemTable getInstance()
+ {
+ return SingletonHolder._instance;
+ }
+
+ private ProductItemTable()
+ {
+ load();
+
+ _log.info(String.format("ProductItemTable: loaded %d product item", _itemsList.size()));
+ }
+
+ private void load()
+ {
+ Connection con = null;
+ try
+ {
+ con = L2DatabaseFactory.getInstance().getConnection();
+ PreparedStatement statement = con.prepareStatement("SELECT * FROM product_items ORDER BY product_id");
+ ResultSet rset = statement.executeQuery();
+
+ while (rset.next())
+ {
+ int productId = rset.getInt("product_id");
+ int category = rset.getInt("category");
+ int points = rset.getInt("points");
+
+ L2ProductItem pr = new L2ProductItem(productId,category, points);
+ pr.setComponents(loadComponents(productId));
+
+ _itemsList.put(productId, pr);
+ }
+ rset.close();
+ statement.close();
+ }
+ catch (Exception e)
+ {
+ _log.warning("Exception: error while loading product items " + e);
+ }
+ finally
+ {
+ L2DatabaseFactory.close(con);
+ }
+ }
+
+ private ArrayList<L2ProductItemComponent> loadComponents(int product_id)
+ {
+ ArrayList<L2ProductItemComponent> a = new ArrayList<L2ProductItemComponent>();
+
+ Connection con = null;
+ try
+ {
+ con = L2DatabaseFactory.getInstance().getConnection();
+ PreparedStatement statement = con.prepareStatement("SELECT * FROM product_item_components WHERE product_id=" + product_id);
+ ResultSet rset = statement.executeQuery();
+
+ while (rset.next())
+ {
+ int item_id = rset.getInt("item_id");
+ int count = rset.getInt("count");
+
+ L2ProductItemComponent component = new L2ProductItemComponent(item_id, count);
+ a.add(component);
+ }
+ rset.close();
+ statement.close();
+ }
+ catch (Exception e)
+ {
+ _log.warning("Exception: error while loading product item components for product: " + product_id + e);
+ }
+ finally
+ {
+ L2DatabaseFactory.close(con);
+ }
+
+ return a;
+ }
+
+
+ public Collection<L2ProductItem> getAllItems()
+ {
+ return _itemsList.values();
+ }
+
+ public L2ProductItem getProduct(int id)
+ {
+ return _itemsList.get(id);
+ }
+
+ @SuppressWarnings("synthetic-access")
+ private static class SingletonHolder
+ {
+ protected static final ProductItemTable _instance = new ProductItemTable();
+ }
+}
Index: /trunk/GameServer_HighFive/java/com/l2jserver/Config.java
===================================================================
--- /trunk/GameServer_HighFive/java/com/l2jserver/Config.java (revision 26)
+++ /trunk/GameServer_HighFive/java/com/l2jserver/Config.java (revision 27)
@@ -1051,4 +1051,6 @@
public static String RENAME_NPC_FEE;
+ public static int GAME_POINT_ITEM_ID;
+
// GrandBoss Settings
@@ -2746,4 +2748,5 @@
RENAME_NPC_MIN_LEVEL = Integer.parseInt(customSettings.getProperty("RenameNpcMinLevel", "40"));
RENAME_NPC_FEE = customSettings.getProperty("RenameNpcFee", "57,250000");
+ GAME_POINT_ITEM_ID = Integer.parseInt(customSettings.getProperty("GamePointItemId", "-300"));
}
catch (Exception e)