Jump to content

Recommended Posts

Posted (edited)
Hello guys, yesterday I saw on a server that mod, and ended up going to some research on it and found it, and there are people there selling this mod, beware! it's FREE !
compatible system with frozen! 
 
what mod do?
you go on the npc, and "put your item for sale" the person who wants to buy go there on NPC, click on its entry and purchase the amount you put!
coreside
Index: com/l2jfrozen/gameserver/GameServer.java
===================================================================
--- com/l2jfrozen/gameserver/GameServer.java (revisÆo 5307)
+++ com/l2jfrozen/gameserver/GameServer.java (c¢pia de trabalho)
@@ -42,6 +42,7 @@
 import com.l2jfrozen.gameserver.datatables.sql.HennaTable;
 
 import com.l2jfrozen.gameserver.datatables.sql.HennaTreeTable;
 
 import com.l2jfrozen.gameserver.datatables.sql.HeroSkillTable;
 
+import com.l2jfrozen.gameserver.datatables.sql.ItemMarketTable;
 
 import com.l2jfrozen.gameserver.datatables.sql.ItemTable;
 
 import com.l2jfrozen.gameserver.datatables.sql.LevelUpData;
 
 import com.l2jfrozen.gameserver.datatables.sql.NobleSkillTable;
 
 
@@ -342,6 +343,7 @@
  
        CastleManorManager.getInstance();
  
        L2Manor.getInstance();
  
        AuctionManager.getInstance();
 
+       ItemMarketTable.getInstance();
 
 
  Util.printSection("Olympiad");
 
  Olympiad.getInstance();
 
  Util.printSection("Dungeons");
 
 
datapack
Index: data/html/marketer/all.htm
===================================================================
--- data/html/marketer/all.htm (revisÆo 0)
+++ data/html/marketer/all.htm (revisÆo 0)
@@ -0,0 +1,12 @@
+<html><body>
+Marketer:<br>
+What kind of item grade?<br>
+<a action="bypass -h npc_%objectId%_See 0">No Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 1">D Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 2">C Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 3">B Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 4">A Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 5">S Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 6">S80 Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 7">All Grades</a><br>
+</body></html>
Index: data/html/marketer/weapon.htm
===================================================================
--- data/html/marketer/weapon.htm (revisÆo 0)
+++ data/html/marketer/weapon.htm (revisÆo 0)
@@ -0,0 +1,12 @@
+<html><body>
+Marketer:<br>
+What kind of item grade?<br>
+<a action="bypass -h npc_%objectId%_See 8">No Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 9">D Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 10">C Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 11">B Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 12">A Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 13">S Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 14">S80 Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 15">All Grades</a><br>
+</body></html>
Index: data/html/marketer/info.htm
===================================================================
--- data/html/marketer/info.htm (revisÆo 0)
+++ data/html/marketer/info.htm (revisÆo 0)
@@ -0,0 +1,8 @@
+<html><body>
+Marketer:<br>
+Well, the service I offer is very simple, you give a certain amount of an item and a price.
+I will sell it for you in the entire world.
+And the most important thing, it's for <font color="00FF00">free</font>! Whether will we someday charge a tax? Only Einhasad knows!
+<br>
+<a action="bypass -h npc_%objectId%_Main">Back.</a>
+</body></html>
Index: data/html/marketer/comfirm.htm
===================================================================
--- data/html/marketer/comfirm.htm (revisÆo 0)
+++ data/html/marketer/comfirm.htm (revisÆo 0)
@@ -0,0 +1,13 @@
+<html><body>
+<table width=270><tr>
+<td valign=top width=35><img src="%itemIcon%" width=32 height=32 align=left></td>
+<td valign=top width=235>
+<table border=0 width=100%>
+<tr><td><font color="A2A0A2">Name:</font> <font color="B09878">%itemName%</font></td></tr>
+<tr><td><font color="A2A0A2">Count:</font> <font color="B09878">%count%</font></td></tr>
+<tr><td><font color="A2A0A2">Price:</font> <font color="B09878">%price%</font></td></tr>
+<tr><td><button value="Comfirm" action="bypass -h npc_%objectId%_AddItem %itemObjId% %count% %iprice%" width=66 height=16 back="L2UI.DefaultButton_click" fore="L2UI.DefaultButton"></td></tr>
+<tr><td><button value="Back" action="bypass -h npc_%objectId%_SelectItem %itemObjId%" width=66 height=16 back="L2UI.DefaultButton_click" fore="L2UI.DefaultButton"></td></tr>
+</table></td>
+</tr></table>
+</body></html>
\ No newline at end of file
Index: data/html/marketer/shot.htm
===================================================================
--- data/html/marketer/shot.htm (revisÆo 0)
+++ data/html/marketer/shot.htm (revisÆo 0)
@@ -0,0 +1,12 @@
+<html><body>
+Marketer:<br>
+What kind of item grade?<br>
+<a action="bypass -h npc_%objectId%_See 32">No Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 33">D Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 34">C Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 35">B Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 36">A Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 37">S Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 38">S80 Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 39">All Grades</a><br>
+</body></html>
Index: data/html/marketer/cash.htm
===================================================================
--- data/html/marketer/cash.htm (revisÆo 0)
+++ data/html/marketer/cash.htm (revisÆo 0)
@@ -0,0 +1,5 @@
+<html><body>
+You have got %money% of Adena.<br>
+<a action="bypass -h npc_%objectId%_Cash">Get the money.</a><br>
+<a action="bypass -h npc_%objectId%_Link marketer/deal.htm">Back.</a><br>
+</body></html>
Index: data/html/marketer/armor.htm
===================================================================
--- data/html/marketer/armor.htm (revisÆo 0)
+++ data/html/marketer/armor.htm (revisÆo 0)
@@ -0,0 +1,12 @@
+<html><body>
+Marketer:<br>
+What kind of item grade?<br>
+<a action="bypass -h npc_%objectId%_See 16">No Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 17">D Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 18">C Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 19">B Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 20">A Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 21">S Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 22">S80 Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 23">All Grades</a><br>
+</body></html>
Index: data/html/marketer/other.htm
===================================================================
--- data/html/marketer/other.htm (revisÆo 0)
+++ data/html/marketer/other.htm (revisÆo 0)
@@ -0,0 +1,12 @@
+<html><body>
+Marketer:<br>
+What kind of item grade?<br>
+<a action="bypass -h npc_%objectId%_See 48">No Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 49">D Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 50">C Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 51">B Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 52">A Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 53">S Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 54">S80 Grade</a><br>
+<a action="bypass -h npc_%objectId%_See 55">All Grades</a><br>
+</body></html>
Index: data/html/marketer/main.htm
===================================================================
--- data/html/marketer/main.htm (revisÆo 0)
+++ data/html/marketer/main.htm (revisÆo 0)
@@ -0,0 +1,8 @@
+<html><body>
+Marketer:<br>
+Welcome adventurer! I am a marketer, people from all the world give me various items to sell.<br>
+Are you interested?<br>
+<a action="bypass -h npc_%objectId%_Link marketer/info.htm">Tell me more.</a><br>
+<a action="bypass -h npc_%objectId%_Link marketer/search.htm">Show me your items.</a><br>
+<a action="bypass -h npc_%objectId%_Link marketer/deal.htm">My Market.</a><br>
+</body></html>
Index: data/html/marketer/deal.htm
===================================================================
--- data/html/marketer/deal.htm (revisÆo 0)
+++ data/html/marketer/deal.htm (revisÆo 0)
@@ -0,0 +1,7 @@
+<html><body>
+Marketer:<br>
+So, how can I help you?<br>
+<a action="bypass -h npc_%objectId%_ListInv">Add an item.</a><br>
+<a action="bypass -h npc_%objectId%_Private">See My Items.</a><br>
+<a action="bypass -h npc_%objectId%_SeeCash">My Cash.</a><br>
+</body></html>
Index: data/html/marketer/search.htm
===================================================================
--- data/html/marketer/search.htm (revisÆo 0)
+++ data/html/marketer/search.htm (revisÆo 0)
@@ -0,0 +1,12 @@
+<html><body>
+Marketer:<br>
+What kind of item would you like to see?<br>
+<a action="bypass -h npc_%objectId%_Link marketer/weapon.htm">Weapons</a><br>
+<a action="bypass -h npc_%objectId%_Link marketer/armor.htm">Armor</a><br>
+<a action="bypass -h npc_%objectId%_See 31">Recipe</a><br>
+<a action="bypass -h npc_%objectId%_Link marketer/shot.htm">Shots</a><br>
+<a action="bypass -h npc_%objectId%_See 47">Spellbooks</a><br>
+<a action="bypass -h npc_%objectId%_See 63">Material</a><br>
+<a action="bypass -h npc_%objectId%_Link marketer/other.htm">Other</a><br>
+<a action="bypass -h npc_%objectId%_Link marketer/all.htm">All Items</a>
+</body></html>
Index: data/html/marketer/addItem.htm
===================================================================
--- data/html/marketer/addItem.htm (revisÆo 0)
+++ data/html/marketer/addItem.htm (revisÆo 0)
@@ -0,0 +1,7 @@
+<html><body>Enter Quantity:<br>
+<edit var="count" width=110> Max of %aval%<br></td></tr>
+Enter Price (for each item):<br>
+<edit var="price" width=110><br></td></tr>
+<tr><td><button value="Enter" action="bypass -h npc_%objectId%_ComfirmAdd %itemObjId% $count $price" width=80 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_ct1.button_df"><br>
+<button value="Cancel" action="bypass -h npc_%objectId%_Link marketer/deal.htm" width=80 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_ct1.button_df">
+</body></html>
Add Item marketable Location:
com.l2jfrozen.gameserver.data tables.sql
 
/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package com.l2jfrozen.gameserver.datatables.sql;
 
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Map;
import java.util.List;
 
import javolution.util.FastMap;
import javolution.util.FastList;
import java.util.logging.Logger;
 
import com.l2jfrozen.util.database.L2DatabaseFactory;
import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
import com.l2jfrozen.gameserver.model.L2ItemMarketModel;
import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
 
public class ItemMarketTable {
 
private static ItemMarketTable _instance = null;
private Map<Integer, String> _itemIcons = null;
private Map<Integer, List<L2ItemMarketModel>> _marketItems = null;
private Map<Integer, Integer> _sellers = null;
private static final Logger                             _log = Logger.getLogger(ItemMarketTable.class.getName());
private ItemMarketTable() {
}
 
public static ItemMarketTable getInstance() {
if (_instance == null) {
_instance = new ItemMarketTable();
_instance.load();
}
return _instance;
}
 
private void load() {
_marketItems = new FastMap<Integer, List<L2ItemMarketModel>>();
Connection con = null;
int mrktCount = 0;
try {
con = L2DatabaseFactory.getInstance().getConnection(false);
PreparedStatement statement = con.prepareStatement("Select * From item_market Order By ownerId");
ResultSet rset = statement.executeQuery();
 
while (rset.next()) { 
int ownerId = rset.getInt("ownerId");
String ownerName = rset.getString("ownerName");
int itemObjId = rset.getInt("itemObjId");
int itemId = rset.getInt("itemId");
String itemName = rset.getString("itemName");
String itemType = rset.getString("itemType");
String l2Type = rset.getString("l2Type");
int itemGrade = rset.getInt("itemGrade");
int enchLvl = rset.getInt("enchLvl");
int count = rset.getInt("_count");
int price = rset.getInt("price");
 
L2ItemMarketModel mrktItem = new L2ItemMarketModel();
mrktItem.setOwnerId(ownerId);
mrktItem.setOwnerName(ownerName);
mrktItem.setItemObjId(itemObjId);
mrktItem.setItemId(itemId);
mrktItem.setItemName(itemName);
mrktItem.setItemType(itemType);
mrktItem.setL2Type(l2Type);
mrktItem.setItemGrade(itemGrade);
mrktItem.setEnchLvl(enchLvl);
mrktItem.setCount(count);
mrktItem.setPrice(price);
if (_marketItems.containsKey(ownerId)) {
List<L2ItemMarketModel> list = _marketItems.get(ownerId);
list.add(mrktItem);
_marketItems.put(ownerId, list);
} else {
List<L2ItemMarketModel> list = new FastList<L2ItemMarketModel>();
list.add(mrktItem);
_marketItems.put(ownerId, list);
}
mrktCount++;
}
 
_log.finest("ItemMarketTable: Loaded "+mrktCount+" market items.");
 
rset.close();
statement.close();
} catch (Exception e) {
_log.warning("Error while loading market items " + e.getMessage());
} finally {
try {
if (con != null) {
con.close();
}
} catch (Exception e) {
}
}
loadSellers();
loadIcons();
}
 
private void loadSellers() {
_sellers = new FastMap<Integer, Integer>();
Connection con = null;
try {
con = L2DatabaseFactory.getInstance().getConnection(false);
PreparedStatement statement = con.prepareStatement("Select * From market_seller");
ResultSet rset = statement.executeQuery();
 
while(rset.next()) {
int sellerId = rset.getInt("sellerId");
int money = rset.getInt("money");
_sellers.put(sellerId, money);
}
 
rset.close();
statement.close();
} catch(Exception e) {
_log.warning("Error while loading market sellers " + e.getMessage());
} finally {
try {
if (con != null) {
con.close();
}
} catch (Exception e) {
}
}
}
 
private void loadIcons() {
_itemIcons = new FastMap<Integer, String>();
Connection con = null;
try {
con = L2DatabaseFactory.getInstance().getConnection(false);
PreparedStatement statement = con.prepareStatement("Select * From market_icons");
ResultSet rset = statement.executeQuery();
 
while(rset.next()) {
int itemId = rset.getInt("itemId");
String itemIcon = rset.getString("itemIcon");
_itemIcons.put(itemId, itemIcon);
}
 
rset.close();
statement.close();
} catch(Exception e) {
_log.warning("Error while loading market icons " + e.getMessage());
} finally {
try {
if (con != null) {
con.close();
}
} catch (Exception e) {
}
}
}
 
public void addItemToMarket(L2ItemMarketModel itemToMarket, L2PcInstance owner) {
synchronized(this) {
if (_marketItems != null && owner != null && itemToMarket != null) {
List<L2ItemMarketModel> list = _marketItems.get(owner.getObjectId());
if (list != null) {
list.add(itemToMarket);
_marketItems.put(owner.getObjectId(), list);
} else {
list = new FastList<L2ItemMarketModel>();
list.add(itemToMarket);
_marketItems.put(owner.getObjectId(), list);
}
ThreadPoolManager.getInstance().scheduleGeneral(new SaveTask(itemToMarket), 2000);
}
}
}
 
public void removeItemFromMarket(int ownerId, int itemObjId, int count) {
L2ItemMarketModel mrktItem = getItem(itemObjId);
List<L2ItemMarketModel> list = getItemsByOwnerId(ownerId);
synchronized (this) {
if (list != null && mrktItem != null && !list.isEmpty()) {
if (mrktItem.getCount() == count) {
list.remove(mrktItem);
_marketItems.put(ownerId, list);
ThreadPoolManager.getInstance().scheduleGeneral(new DeleteTask(mrktItem), 2000);
} else {
list.remove(mrktItem);
mrktItem.setCount(mrktItem.getCount() - count);
list.add(mrktItem);
_marketItems.put(ownerId, list);
ThreadPoolManager.getInstance().scheduleGeneral(new UpdateTask(mrktItem), 2000);
}
}
}
}
 
public void addMoney(int sellerId, int money) {
synchronized(this) {
if (_sellers != null) {
if (_sellers.containsKey(sellerId)) {
int oldMoney = _sellers.get(sellerId);
money += oldMoney;
_sellers.put(sellerId, money);
ThreadPoolManager.getInstance().scheduleGeneral(new AddMoneyTask(sellerId, money), 2000);
} else {
_sellers.put(sellerId, money);
ThreadPoolManager.getInstance().scheduleGeneral(new AddSellerTask(sellerId, money), 2000);
}
}
}
}
 
public int getMoney(int sellerId) {
synchronized(this) {
if (_sellers != null && !_sellers.isEmpty()) {
if (_sellers.containsKey(sellerId)) {
return _sellers.get(sellerId);
} else {
return 0;
}
}
}
return 0;
}
 
public void takeMoney(int sellerId, int amount) {
synchronized(this) {
if (_sellers != null && !_sellers.isEmpty()) {
if (_sellers.containsKey(sellerId)) {
int oldMoney = _sellers.get(sellerId);
if (oldMoney >= amount) {
oldMoney -= amount;
_sellers.put(sellerId, oldMoney);
ThreadPoolManager.getInstance().scheduleGeneral(new AddMoneyTask(sellerId, oldMoney), 2000);
}
}
}
}
}
 
public List<L2ItemMarketModel> getItemsByOwnerId(int ownerId) {
synchronized(this) {
if (_marketItems != null && !_marketItems.isEmpty()) {
return _marketItems.get(ownerId);
}
}
return null;
}
 
public L2ItemMarketModel getItem(int itemObjId) {
List<L2ItemMarketModel> list = getAllItems();
synchronized (this) {
for (L2ItemMarketModel model : list) {
if (model.getItemObjId() == itemObjId) {
return model;
}
}
}
return null;
}
 
public List<L2ItemMarketModel> getAllItems() {
synchronized(this) {
if (_marketItems != null && !_marketItems.isEmpty()) {
List<L2ItemMarketModel> list = new FastList<L2ItemMarketModel>();
for (List<L2ItemMarketModel> lst : _marketItems.values()) {
if (lst != null && !lst.isEmpty()) {
for (L2ItemMarketModel auctItem : lst) {
if (auctItem != null) {
list.add(auctItem);
}
}
}
}
return list;
}
}
return null;
}
 
public String getItemIcon(int itemId) {
if (_itemIcons != null && !_itemIcons.isEmpty()) {
return _itemIcons.get(itemId);
}
return null;
}
 
private static class SaveTask implements Runnable {
 
private final L2ItemMarketModel _marketItem;
// private final static Log _log = LogFactory.getLog(SaveTask.class.getName());
 
public SaveTask(L2ItemMarketModel marketItem) {
this._marketItem = marketItem;
}
 
public void run() {
Connection con = null;
try {
con = L2DatabaseFactory.getInstance().getConnection(false);
PreparedStatement statement = con.prepareStatement("Insert Into item_market Values (?,?,?,?,?,?,?,?,?,?,?)");
statement.setInt(1, _marketItem.getOwnerId());
statement.setString(2, _marketItem.getOwnerName());
statement.setString(3, _marketItem.getItemName());
statement.setInt(4, _marketItem.getEnchLvl());
statement.setInt(5, _marketItem.getItemGrade());
statement.setString(6, _marketItem.getL2Type());
statement.setString(7, _marketItem.getItemType());
statement.setInt(8, _marketItem.getItemId());
statement.setInt(9, _marketItem.getItemObjId());
statement.setInt(10, _marketItem.getCount());
statement.setInt(11, _marketItem.getPrice());
statement.execute();
statement.close();
} catch (Exception e) {
_log.warning("Error while saving market item into DB " + e.getMessage());
} finally {
try {
if (con != null) {
con.close();
}
} catch (Exception e) {
}
}
}
}
 
private static class DeleteTask implements Runnable {
 
private final L2ItemMarketModel _marketItem;
// private final static Log _log = LogFactory.getLog(DeleteTask.class.getName());
 
public DeleteTask(L2ItemMarketModel marketItem) {
this._marketItem = marketItem;
}
 
public void run() {
Connection con = null;
try {
con = L2DatabaseFactory.getInstance().getConnection(false);
PreparedStatement statement = con.prepareStatement("Delete From item_market Where ownerId = ? AND itemObjId = ?");
statement.setInt(1, _marketItem.getOwnerId());
statement.setInt(2, _marketItem.getItemObjId());
statement.execute();
statement.close();
} catch (Exception e) {
_log.warning("Error while deleting market item from DB " + e.getMessage());
} finally {
try {
if (con != null) {
con.close();
}
} catch (Exception e) {
}
}
}
}
 
private static class UpdateTask implements Runnable {
private final L2ItemMarketModel _marketItem;
// private final static Log _log = LogFactory.getLog(UpdateTask.class.getName());
 
public UpdateTask(L2ItemMarketModel marketItem) {
this._marketItem = marketItem;
}
 
public void run() {
Connection con = null;
try {
con = L2DatabaseFactory.getInstance().getConnection(false);
PreparedStatement statement = con.prepareStatement("Update item_market Set _count = ? Where itemObjId = ? AND ownerId = ?");
statement.setInt(1, _marketItem.getCount());
statement.setInt(2, _marketItem.getItemObjId());
statement.setInt(3, _marketItem.getOwnerId());
statement.executeUpdate();
statement.close();
} catch (Exception e) {
_log.warning("Error while updating market item in DB " + e.getMessage());
} finally {
try {
if (con != null) {
con.close();
}
} catch (Exception e) {
}
}
}
}
 
private static class AddMoneyTask implements Runnable {
private final int sellerId;
private final int money;
 
public AddMoneyTask(int sellerId, int money) {
this.sellerId = sellerId;
this.money = money;
}
 
public void run() {
Connection con = null;
try {
con = L2DatabaseFactory.getInstance().getConnection(false);
PreparedStatement statement = con.prepareStatement("Update market_seller Set money = ? Where sellerId = ?");
statement.setInt(1, money);
statement.setInt(2, sellerId);
statement.executeUpdate();
statement.close();
} catch (Exception e) {
_log.warning("Error while adding money in DB " + e.getMessage());
} finally {
try {
if (con != null) {
con.close();
}
} catch (Exception e) {
}
}
}
}
 
private static class AddSellerTask implements Runnable {
private final int sellerId;
private final int money;
 
public AddSellerTask(int sellerId, int money) {
this.sellerId = sellerId;
this.money = money;
}
 
public void run() {
Connection con = null;
try {
con = L2DatabaseFactory.getInstance().getConnection(false);
PreparedStatement statement = con.prepareStatement("Insert Into market_seller(sellerId, money) Values (?,?)");
statement.setInt(1, sellerId);
statement.setInt(2, money);
statement.executeUpdate();
statement.close();
} catch (Exception e) {
_log.warning("Error while adding seller in DB " + e.getMessage());
} finally {
try {
if (con != null) {
con.close();
}
} catch (Exception e) {
}
}
}
}
}
Add L2ItemMarketerInstance the settlement:
com.l2jfrozen.gameserver.model.actor.instance:
 
 
/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package com.l2jfrozen.gameserver.model.actor.instance;
 
import java.util.List;
import java.util.StringTokenizer;
 
import javolution.text.TextBuilder;
import javolution.util.FastList;
 
import com.l2jfrozen.gameserver.ai.CtrlIntention;
import com.l2jfrozen.gameserver.datatables.sql.ItemMarketTable;
import com.l2jfrozen.gameserver.datatables.sql.ItemTable;
import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance;
import com.l2jfrozen.gameserver.model.L2ItemMarketModel;
import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
import com.l2jfrozen.gameserver.network.serverpackets.MyTargetSelected;
import com.l2jfrozen.gameserver.network.serverpackets.ValidateLocation;
import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
import com.l2jfrozen.gameserver.templates.L2EtcItemType;
import com.l2jfrozen.gameserver.templates.L2WeaponType;
import com.l2jfrozen.gameserver.util.Util;
 
public class L2ItemMarketerInstance extends L2FolkInstance {
 
private final int ITEMS_PER_PAGE = 4;
 
//Pack Method : pack (L2_Type << 3) | Grade
//Item L2 Type
private final int ALL = 0x00;
private final int WEAPON = 0x01;
private final int ARMOR = 0x02;
private final int RECIPE  = 0x03;
private final int SHOTS  = 0x04;
private final int BOOK  = 0x05;
private final int OTHER  = 0x06;
private final int MATERIAL = 0x07;
 
//Item Grade
private final int NO_G  = 0x00;
    private final int D_G  = 0x01;
private final int C_G  = 0x02;
private final int B_G  = 0x03;
private final int A_G  = 0x04;
private final int S_G  = 0x05;
private final int S80_G = 0x06;
private final int ALL_G = 0x07;
 
public L2ItemMarketerInstance(int objectId, L2NpcTemplate template) {
        super(objectId, template);
    }
 
@Override
public void onAction(L2PcInstance player) {
if (!canTarget(player)) {
return;
}
// Check if the L2PcInstance already target the L2NpcInstance
if (this != player.getTarget()) {
// Set the target of the L2PcInstance player
player.setTarget(this);
 
// Send a Server->Client packet MyTargetSelected to the L2PcInstance player
MyTargetSelected my = new MyTargetSelected(getObjectId(), 0);
player.sendPacket(my);
 
// Send a Server->Client packet ValidateLocation to correct the L2NpcInstance position and heading on the client
player.sendPacket(new ValidateLocation(this));
} else {
// Calculate the distance between the L2PcInstance and the L2NpcInstance
if (!canInteract(player)) {
// Notify the L2PcInstance AI with AI_INTENTION_INTERACT
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
} else {
showMsgWindow(player);
}
}
// Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
player.sendPacket(ActionFailed.STATIC_PACKET);
}
 
@Override
    public void onBypassFeedback(L2PcInstance player, String command) {
List<L2ItemMarketModel> list = null;
        StringTokenizer st = new StringTokenizer(command, " ");
        String actualCommand = st.nextToken();
if ("Private".equalsIgnoreCase(actualCommand)) {
list = getItemList(player);
int pId = 0;
if (st.hasMoreTokens()) {
pId = new Integer(st.nextToken());
}
showPrivateItemList(list, pId, player);
} else if ("See".equalsIgnoreCase(actualCommand)) {
if (st.hasMoreTokens()) {
int bitmask = new Integer(st.nextToken());
int pgId = 0;
if (st.hasMoreTokens()) {
pgId = new Integer(st.nextToken());
}
list = ItemMarketTable.getInstance().getAllItems();
if (list != null) {
list = filterItemType(bitmask, list);
showItemList(list, pgId, player, bitmask);
} else {
sendMsg("There are no items for you", player);
return;
}
}
} else if ("BuyItem".equalsIgnoreCase(actualCommand)) {
if (st.hasMoreTokens()) {
int itemObjId = Integer.parseInt(st.nextToken());
if (st.hasMoreTokens()) {
int count = new Integer(st.nextToken());
buyItem(player, itemObjId, count);
}
}
} else if ("AddItem".equalsIgnoreCase(actualCommand)) {
if (st.hasMoreTokens()) {
int itemObjId = new Integer(st.nextToken());
if (st.hasMoreTokens()) {
int count = new Integer(st.nextToken());
if (st.hasMoreTokens()) {
int price = new Integer(st.nextToken());
if (price <=0) {
sendMsg("You can't sell an item for 0 or negative number.", player);
return;
}
L2ItemInstance item = player.getInventory().getItemByObjectId(itemObjId);
list = getItemList(player);
if (canAddItem(item, count, list, player)) {
player.destroyItem("Market Add", item.getObjectId(), count, null, true);
addItem(player, item, count, price);
} else {
sendMsg("Unable to add item or incorret item count.", player);
}
}
}
}
} else if ("ListInv".equalsIgnoreCase(actualCommand)) {
int pageId = 0;
if (st.hasMoreTokens()) {
pageId = new Integer(st.nextToken());
}
showInvList(player, pageId);
} else if ("ItemInfo".equalsIgnoreCase(actualCommand)) {
if (st.hasMoreTokens()) {
int pgId = new Integer(st.nextToken());
if (st.hasMoreTokens()) {
int bitmask = new Integer(st.nextToken());
if (st.hasMoreTokens()) {
int itemObjId = new Integer(st.nextToken());
L2ItemMarketModel mrktItem = ItemMarketTable.getInstance().getItem(itemObjId);
if (mrktItem != null) {
showItemInfo(mrktItem, bitmask, pgId, player);
}
}
}
}
} else if ("Main".equalsIgnoreCase(actualCommand)) {
showMsgWindow(player);
} else if ("SelectItem".equalsIgnoreCase(actualCommand)) {
if (st.hasMoreTokens()) {
int itemObjId = new Integer(st.nextToken());
player.sendPacket(ActionFailed.STATIC_PACKET);
String filename = "data/html/marketer/addItem.htm";
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile(filename);
html.replace("%objectId%", String.valueOf(getObjectId()));
L2ItemInstance item = player.getInventory().getItemByObjectId(itemObjId);
html.replace("%aval%", ""+item.getCount());
html.replace("%itemObjId%", String.valueOf(itemObjId));
player.sendPacket(html);
}
} else if ("ItemInfo2".equalsIgnoreCase(actualCommand)) {
if (st.hasMoreTokens()) {
int pgId = new Integer(st.nextToken());
if (st.hasMoreTokens()) {
int itemObjId = new Integer(st.nextToken());
L2ItemMarketModel mrktItem = ItemMarketTable.getInstance().getItem(itemObjId);
if (mrktItem != null) {
showItemInfo2(mrktItem, pgId, player);
}
}
}
} else if ("TakeItem".equalsIgnoreCase(actualCommand)) {
if (st.hasMoreTokens()) {
int itemObjId = new Integer(st.nextToken());
L2ItemMarketModel mrktItem = ItemMarketTable.getInstance().getItem(itemObjId);
if (mrktItem != null && player.getObjectId() == mrktItem.getOwnerId()) {
ItemMarketTable.getInstance().removeItemFromMarket(mrktItem.getOwnerId(), mrktItem.getItemObjId(), mrktItem.getCount());
L2ItemInstance item = ItemTable.getInstance().createItem("Market Remove", mrktItem.getItemId(), mrktItem.getCount(), player);
item.setEnchantLevel(mrktItem.getEnchLvl());
player.getInventory().addItem("Market Buy", item, player, null);
sendMsg(mrktItem.getItemName()+" removed succesfully.", player);
}
}
} else if ("SeeCash".equalsIgnoreCase(actualCommand)) {
player.sendPacket(ActionFailed.STATIC_PACKET);
String filename = "data/html/marketer/cash.htm";
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile(filename);
html.replace("%objectId%", String.valueOf(getObjectId()));
int money = ItemMarketTable.getInstance().getMoney(player.getObjectId());
html.replace("%money%", Util.formatAdena(money));
player.sendPacket(html);
} else if ("Cash".equalsIgnoreCase(actualCommand)) {
int amount = ItemMarketTable.getInstance().getMoney(player.getObjectId());
ItemMarketTable.getInstance().takeMoney(player.getObjectId(), amount);
player.getInventory().addAdena("Market Cash", amount, player, null);
sendMsg("You've earned "+Util.formatAdena(amount)+" Gold Bar", player);
} else if ("ComfirmAdd".equalsIgnoreCase(actualCommand)) {
if (st.hasMoreTokens()) {
int itemObjId = new Integer(st.nextToken());
L2ItemInstance item = player.getInventory().getItemByObjectId(itemObjId);
if (item == null) {
return;
}
 
if (st.hasMoreTokens()) {
int count = new Integer(st.nextToken());
if (count <= 0 || item.getCount() < count) {
sendMsg("Item count must be a valid value.", player);
return;
}
if (st.hasMoreTokens()) {
int price = new Integer(st.nextToken());
if (price <= 0) {
sendMsg("Price must be a valid value.", player);
return;
}
player.sendPacket(ActionFailed.STATIC_PACKET);
String filename = "data/html/marketer/comfirm.htm";
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile(filename);
html.replace("%objectId%", String.valueOf(getObjectId()));
html.replace("%count%", ""+count);
html.replace("%itemName%", item.getName()+" +"+item.getEnchantLevel());
html.replace("%itemIcon%", getItemIcon(item.getItemId()));
html.replace("%price%", Util.formatAdena(price));
html.replace("%iprice%", Util.formatAdena(price));
html.replace("%itemObjId%", ""+itemObjId);
player.sendPacket(html);
}
}
}
}
super.onBypassFeedback(player, command);
    }
 
private void showMsgWindow(L2PcInstance player) {
player.sendPacket(ActionFailed.STATIC_PACKET);
String filename = "data/html/marketer/main.htm";
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile(filename);
html.replace("%objectId%", String.valueOf(getObjectId()));
player.sendPacket(html);
}
 
private void addItem(L2PcInstance player, L2ItemInstance item, int count, int price) {
L2ItemMarketModel itemModel = new L2ItemMarketModel();
itemModel.setOwnerId(player.getObjectId());
itemModel.setOwnerName(player.getName());
itemModel.setItemObjId(item.getObjectId());
itemModel.setItemId(item.getItemId());
itemModel.setPrice(price);
itemModel.setCount(count);
itemModel.setItemType(item.getItem().getItemType().toString());
itemModel.setEnchLvl(item.getEnchantLevel());
if (itemModel.getEnchLvl() > 0) {
itemModel.setItemName(item.getItemName()+" +"+itemModel.getEnchLvl());
} else {
itemModel.setItemName(item.getItemName());
}
itemModel.setItemGrade(item.getItem().getCrystalType());
if (item.isEquipable()) {
if (item.getItemType() == L2WeaponType.NONE) {
itemModel.setL2Type("Armor");
} else {
itemModel.setL2Type("Weapon");
}
 
} else if (item.isEquipable()) {
itemModel.setL2Type("Armor");
} else {
if (item.getItemType() == L2EtcItemType.MATERIAL) {
itemModel.setL2Type("Material");
} else if (item.getItemType() == L2EtcItemType.RECEIPE) {
itemModel.setL2Type("Recipe");
} else if (item.getItemType() == L2EtcItemType.SPELLBOOK) {
itemModel.setL2Type("Spellbook");
} else if (item.getItemType() == L2EtcItemType.SHOT) {
itemModel.setL2Type("Shot");
} else {
itemModel.setL2Type("Other");
}
}
ItemMarketTable.getInstance().addItemToMarket(itemModel, player);
sendMsg("You added "+count+" <font color=\"LEVEL\">"+item.getItemName()+"</font>.", player);
}
 
private boolean canAddItem(L2ItemInstance item, int count, List<L2ItemMarketModel> list, L2PcInstance activeChar) {
if (activeChar != null && activeChar.getActiveTradeList() != null) {
return false;
}
if (activeChar != null && activeChar.isProcessingTransaction()) {
return false;
}
if (list != null && !list.isEmpty()) {
for (L2ItemMarketModel model : list) {
if (model != null) {
if (model.getItemId() == item.getItemId()) {
return false;
}
}
}
}
 
return (item.getItemType() != L2EtcItemType.HERB && item.getCount() >= count && item.getItem().getDuration() == -1 && item.getItemId() != 3470 && item.isTradeable() && !item.isEquipped() && !item.isAugmented());
}
 
private boolean canAddItem(L2ItemInstance item) {
return canAddItem(item, 0, null, null);
}
 
private String getItemIcon(int itemId) {
return "Icon." + ItemMarketTable.getInstance().getItemIcon(itemId);
}
 
private List<L2ItemMarketModel> getItemList(L2PcInstance player) {
return ItemMarketTable.getInstance().getItemsByOwnerId(player.getObjectId());
}
 
private void buyItem(L2PcInstance player, int itemObjId, int count) {
     L2ItemMarketModel mrktItem = ItemMarketTable.getInstance().getItem(itemObjId);
     if (mrktItem != null && mrktItem.getCount() >= count && (count > 0)) { 
L2ItemInstance adena = player.getInventory().getItemByItemId(3470);
if (adena.getCount() >= (mrktItem.getPrice() * count)) {
int itemId  = mrktItem.getItemId();
int price = mrktItem.getPrice() * count;
ItemMarketTable.getInstance().removeItemFromMarket(mrktItem.getOwnerId(), mrktItem.getItemObjId(), count);
player.destroyItem("Market Buy", adena.getObjectId(), price, null, true);
ItemMarketTable.getInstance().addMoney(mrktItem.getOwnerId(), price);
L2ItemInstance item = ItemTable.getInstance().createItem("Market Buy", itemId, count, player);
item.setEnchantLevel(mrktItem.getEnchLvl());
player.getInventory().addItem("Market Buy", item, player, null);
sendMsg("You bought "+count+" <font color=\"LEVEL\">"+mrktItem.getItemName()+"</font>.", player);
return;
}
sendMsg("You don't have enought Gold Bars.", player);
return;
}
sendMsg("Incorrect item count.", player);
}
 
private List<L2ItemMarketModel> filterItemType(int mask, List<L2ItemMarketModel> list) {
List<L2ItemMarketModel> mrktList = new FastList<L2ItemMarketModel>();
int itype = mask >> 3;
switch(itype) {
case ALL:
return filterItemGrade(mask, list);
case WEAPON:
for (L2ItemMarketModel model : list) {
if (model != null) {
if (model.getL2Type().equalsIgnoreCase("Weapon")) {
mrktList.add(model);
}
}
}
return filterItemGrade(mask, mrktList);
case ARMOR:
for (L2ItemMarketModel model : list) {
if (model != null) {
if (model.getL2Type().equalsIgnoreCase("Armor")) {
mrktList.add(model);
}
}
}
return filterItemGrade(mask, mrktList);
case RECIPE:
for (L2ItemMarketModel model : list) {
if (model != null) {
if (model.getL2Type().equalsIgnoreCase("Recipe")) {
mrktList.add(model);
}
}
}
return mrktList;
case BOOK:
for (L2ItemMarketModel model : list) {
if (model != null) {
if (model.getL2Type().equalsIgnoreCase("Spellbook")) {
mrktList.add(model);
}
}
}
return mrktList;
case SHOTS:
for (L2ItemMarketModel model : list) {
if (model != null) {
if (model.getL2Type().equalsIgnoreCase("Shot")) {
mrktList.add(model);
}
}
}
return filterItemGrade(mask, mrktList);
case OTHER:
for (L2ItemMarketModel model : list) {
if (model != null) {
if (model.getL2Type().equalsIgnoreCase("Other")) {
mrktList.add(model);
}
}
}
return filterItemGrade(mask, mrktList);
case MATERIAL:
for (L2ItemMarketModel model : list) {
if (model != null) {
if (model.getL2Type().equalsIgnoreCase("Material")) {
mrktList.add(model);
}
}
}
return mrktList;
}
 
return filterItemGrade(mask, list);
}
 
private List<L2ItemMarketModel> filterItemGrade(int mask, List<L2ItemMarketModel> list) {
List<L2ItemMarketModel> mrktList = new FastList<L2ItemMarketModel>();
int igrade = mask & 7;
switch(igrade) {
case ALL_G:
return list;
case NO_G:
for (L2ItemMarketModel model : list) {
if (model != null) {
if (model.getItemGrade() == NO_G) {
mrktList.add(model);
}
}
}
return mrktList;
case D_G:
for (L2ItemMarketModel model : list) {
if (model != null) {
if (model.getItemGrade() == D_G) {
mrktList.add(model);
}
}
}
return mrktList;
case C_G:
for (L2ItemMarketModel model : list) {
if (model != null) {
if (model.getItemGrade() == C_G) {
mrktList.add(model);
}
}
}
return mrktList;
case B_G:
for (L2ItemMarketModel model : list) {
if (model != null) {
if (model.getItemGrade() == B_G) {
mrktList.add(model);
}
}
}
return mrktList;
case A_G:
for (L2ItemMarketModel model : list) {
if (model != null) {
if (model.getItemGrade() == A_G) {
mrktList.add(model);
}
}
}
return mrktList;
case S_G:
for (L2ItemMarketModel model : list) {
if (model != null) {
if (model.getItemGrade() == S_G) {
mrktList.add(model);
}
}
}
return mrktList;
case S80_G:
for (L2ItemMarketModel model : list) {
if (model != null) {
if (model.getItemGrade() == S80_G) {
mrktList.add(model);
}
}
}
return mrktList;
}
return list;
}
 
private List<L2ItemInstance> filterInventory(L2ItemInstance[] inv) {
List<L2ItemInstance> filteredInventory = new FastList<L2ItemInstance>();
for(L2ItemInstance item : inv) {
if (canAddItem(item)) {
filteredInventory.add(item);
}
}
return filteredInventory;
}
 
private List<L2ItemMarketModel> filterList(List<L2ItemMarketModel> list, L2PcInstance player) {
List<L2ItemMarketModel> filteredList = new FastList<L2ItemMarketModel>();
if (!list.isEmpty()) {
for(L2ItemMarketModel model : list) {
if (model != null && model.getOwnerId() != player.getObjectId()) {
filteredList.add(model);
}
}
}
return filteredList;
}
 
private void showInvList(L2PcInstance player, int pageId) {
int itemsOnPage = ITEMS_PER_PAGE;
List<L2ItemInstance> list = filterInventory(player.getInventory().getItems());
int pages = list.size() / itemsOnPage;
if (list.isEmpty()) {
sendMsg("Your inventory is empty.", player);
return;
}
if (list.size() > pages * itemsOnPage) {
pages++;
}
if (pageId > pages) { 
pageId = pages;
}
int itemStart = pageId * itemsOnPage;
int itemEnd = list.size();
if (itemEnd - itemStart > itemsOnPage) {
itemEnd = itemStart + itemsOnPage;
}
NpcHtmlMessage npcReply = new NpcHtmlMessage(1);
TextBuilder reply = new TextBuilder("<html><body>");
reply.append("<center>Items in Inventory</center>");
reply.append("<img src=\"L2UI.SquareWhite\" width=270 height=1> <img src=\"L2UI.SquareBlank\" width=1 height=3>");
reply.append("<table width=270><tr>");
reply.append("<td width=66><button value=\"Back\" action=\"bypass -h npc_"+getObjectId()+((pageId==0)?"_Main ":"_ListInv ")+(pageId-1)+"\" width=66 height=16 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"></td>");
reply.append("<td width=138></td>");
reply.append("<td width=66>"+((pageId+1<pages)?"<button value=\"Next\" action=\"bypass -h npc_"+getObjectId()+"_ListInv "+(pageId+1)+"\" width=66 height=16 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\">":"")+"</td>");
reply.append("</tr></table>");
reply.append("<br>");
for (int i = itemStart; i < itemEnd; i++) {
L2ItemInstance item = list.get(i);
if (item == null) {
continue;
}
 
String itemIcon = getItemIcon(item.getItemId());
reply.append("<br>");
reply.append("<table width=270><tr>");
reply.append("<td valign=top width=35><button value=\"\" action=\"bypass -h npc_"+getObjectId()+"_SelectItem "+item.getObjectId()+"\" width=32 height=32 back=\""+itemIcon +"\" fore=\""+itemIcon +"\"></td>");
reply.append("<td valign=top width=235>");
reply.append("<table border=0 width=100%>");
reply.append("<tr><td><font color=\"A2A0A2\">"+item.getItemName()+" +"+item.getEnchantLevel()+"</font></td></tr>");
reply.append("<tr><td><font color=\"A2A0A2\">Quantity:</font> <font color=\"B09878\">"+item.getCount()+"</font></td></tr></table></td>");
reply.append("</tr></table>");
reply.append("<br>");
}
reply.append("</body></html>");
npcReply.setHtml(reply.toString());
player.sendPacket(npcReply);
}
 
private void showItemList(List<L2ItemMarketModel> list, int pageId, L2PcInstance player, int mask) {
int itemsOnPage = ITEMS_PER_PAGE;
list = filterList(list, player);
if (list.isEmpty()) {
sendMsg("There are no items for you", player);
return;
}
int pages = list.size() / itemsOnPage;
if (list.size() > pages * itemsOnPage) {
pages++;
}
if (pageId > pages) { 
pageId = pages;
}
int itemStart = pageId * itemsOnPage;
int itemEnd = list.size();
if (itemEnd - itemStart > itemsOnPage) {
itemEnd = itemStart + itemsOnPage;
}
NpcHtmlMessage npcReply = new NpcHtmlMessage(1);
TextBuilder reply = new TextBuilder("<html><body>");
reply.append("<center>Market</center>");
reply.append("<img src=\"L2UI.SquareWhite\" width=270 height=1> <img src=\"L2UI.SquareBlank\" width=1 height=3>");
reply.append("<table width=270><tr>");
reply.append("<td width=66><button value=\"Back\" action=\"bypass -h npc_"+getObjectId()+((pageId==0)?"_Main ":"_See ")+mask+" "+(pageId-1)+"\" width=66 height=16 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"></td>");
reply.append("<td width=138></td>");
reply.append("<td width=66>"+((pageId+1<pages)?"<button value=\"Next\" action=\"bypass -h npc_"+getObjectId()+"_See "+mask+" "+(pageId+1)+"\" width=66 height=16 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\">":"")+"</td>");
reply.append("</tr></table>");
reply.append("<br>");
 
for (int i = itemStart; i < itemEnd; i++) {
L2ItemMarketModel mrktItem = list.get(i);
if (mrktItem == null) {
continue;
}
 
if (mrktItem.getOwnerId() == player.getObjectId()) {
continue;
}
 
int _price = mrktItem.getPrice();
if (_price == 0) {
continue;
}
 
int _grade = mrktItem.getItemGrade();
String itemIcon = getItemIcon(mrktItem.getItemId());
reply.append("<br>");
reply.append("<table width=270><tr>");
reply.append("<td valign=top width=35><button value=\"\" action=\"bypass -h npc_"+getObjectId()+"_ItemInfo "+pageId+" "+mask+" "+mrktItem.getItemObjId()+"\" width=32 height=32 back=\""+itemIcon +"\" fore=\""+itemIcon +"\"></td>");
reply.append("<td valign=top width=235>");
reply.append("<table border=0 width=100%>");
reply.append("<tr><td><font color=\"A2A0A2\">"+mrktItem.getItemName()+"["+mrktItem.getCount()+"]"+"</font></td></tr>");
if ((mask & 7) == ALL_G) {
reply.append("<tr><td><font color=\"A2A0A2\">"+"Grade:"+getGrade(mrktItem.getItemGrade())+"</font></td></tr>");
}
reply.append("<tr><td><font color=\"A2A0A2\">Price:</font> <font color=\"B09878\">"+Util.formatAdena(mrktItem.getPrice())+"</font></td></tr></table></td>");
reply.append("</tr></table>");
reply.append("<br>");
}
 
reply.append("</body></html>");
npcReply.setHtml(reply.toString());
player.sendPacket(npcReply);
}
 
private void showItemInfo(L2ItemMarketModel mrktItem, int mask, int pageId, L2PcInstance player) {
NpcHtmlMessage npcReply = new NpcHtmlMessage(1);
TextBuilder reply = new TextBuilder("<html><body>");
reply.append("<center>Info</center>");
reply.append("<img src=\"L2UI.SquareWhite\" width=270 height=1> <img src=\"L2UI.SquareBlank\" width=1 height=3>");
reply.append("<table width=270><tr>");
reply.append("<td width=66><button value=\"Back\" action=\"bypass -h npc_"+getObjectId()+"_See "+mask+" "+pageId+"\" width=66 height=16 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"></td>");
reply.append("<td width=138></td>");
reply.append("</tr></table>");
reply.append("<br>");
reply.append("<table width=270><tr>");
reply.append("<td valign=top width=35><img src="+getItemIcon(mrktItem.getItemId())+" width=32 height=32 align=left></td>");
reply.append("<td valign=top width=235>");
reply.append("<table border=0 width=100%>");
reply.append("<tr><td><font color=\"A2A0A2\">Name:</font> <font color=\"B09878\">"+mrktItem.getItemName()+"</font><font color=\"A2A0A2\">[<font color=\"B09878\">"+mrktItem.getCount()+"</font>]</td></tr>");
reply.append("<tr><td><font color=\"A2A0A2\">Price:</font> <font color=\"B09878\">"+Util.formatAdena(mrktItem.getPrice())+"</font><font color=\"A2A0A2\">     Seller:</font> <font color=\"B09878\">"+mrktItem.getOwnerName()+"</font></td></tr>");
reply.append("<tr><td><edit var=\"count\" width=110></td></tr>");
reply.append("<tr><td><button value=\"Buy\" action=\"bypass -h npc_"+getObjectId()+"_BuyItem "+mrktItem.getItemObjId()+" $count\" width=66 height=16 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"></td></tr></table></td>");
reply.append("</tr></table>");
reply.append("</body></html>");
npcReply.setHtml(reply.toString());
player.sendPacket(npcReply);
}
 
private void showPrivateItemList(List<L2ItemMarketModel> list, int pageId, L2PcInstance player) {
int itemsOnPage = ITEMS_PER_PAGE;
if (list == null || list.isEmpty()) {
sendMsg("There are no items for you", player);
return;
}
int pages = list.size() / itemsOnPage;
if (list.size() > pages * itemsOnPage) {
pages++;
}
if (pageId > pages) { 
pageId = pages;
}
int itemStart = pageId * itemsOnPage;
int itemEnd = list.size();
if (itemEnd - itemStart > itemsOnPage) {
itemEnd = itemStart + itemsOnPage;
}
NpcHtmlMessage npcReply = new NpcHtmlMessage(1);
TextBuilder reply = new TextBuilder("<html><body>");
reply.append("<center>Private</center>");
reply.append("<img src=\"L2UI.SquareWhite\" width=270 height=1> <img src=\"L2UI.SquareBlank\" width=1 height=3>");
reply.append("<table width=270><tr>");
reply.append("<td width=66><button value=\"Back\" action=\"bypass -h npc_"+getObjectId()+((pageId==0)?"_Main ":"_Private ")+(pageId-1)+"\" width=66 height=16 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"></td>");
reply.append("<td width=138></td>");
reply.append("<td width=66>"+((pageId+1<pages)?"<button value=\"Next\" action=\"bypass -h npc_"+getObjectId()+"_Private "+(pageId+1)+"\" width=66 height=16 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\">":"")+"</td>");
reply.append("</tr></table>");
reply.append("<br>");
 
for (int i = itemStart; i < itemEnd; i++) {
L2ItemMarketModel mrktItem = list.get(i);
if (mrktItem == null) {
continue;
}
 
int _price = mrktItem.getPrice();
if (_price == 0) {
continue;
}
 
String itemIcon = getItemIcon(mrktItem.getItemId());
reply.append("<br>");
reply.append("<table width=270><tr>");
reply.append("<td valign=top width=35><button value=\"\" action=\"bypass -h npc_"+getObjectId()+"_ItemInfo2 "+pageId+" "+mrktItem.getItemObjId()+"\" width=32 height=32 back=\""+itemIcon +"\" fore=\""+itemIcon +"\"></td>");
reply.append("<td valign=top width=235>");
reply.append("<table border=0 width=100%>");
reply.append("<tr><td><font color=\"A2A0A2\">"+mrktItem.getItemName()+"["+mrktItem.getCount()+"]"+"</font></td></tr>");
reply.append("<tr><td><font color=\"A2A0A2\">Price:</font> <font color=\"B09878\">"+Util.formatAdena(mrktItem.getPrice())+"</font></td></tr></table></td>");
reply.append("</tr></table>");
reply.append("<br>");
}
 
reply.append("</body></html>");
npcReply.setHtml(reply.toString());
player.sendPacket(npcReply);
}
 
private void sendMsg(String message, L2PcInstance player) {
player.sendPacket(ActionFailed.STATIC_PACKET);
NpcHtmlMessage npcReply = new NpcHtmlMessage(1);
TextBuilder reply = new TextBuilder("<html><body>");
reply.append(message);
reply.append("<br><a action=\"bypass -h npc_"+getObjectId()+"_Main\">Back</a>");
reply.append("</body></html>");
npcReply.setHtml(reply.toString());
player.sendPacket(npcReply);
}
 
private void showItemInfo2(L2ItemMarketModel mrktItem, int pageId, L2PcInstance player) {
NpcHtmlMessage npcReply = new NpcHtmlMessage(1);
TextBuilder reply = new TextBuilder("<html><body>");
reply.append("<center>Info</center>");
reply.append("<img src=\"L2UI.SquareWhite\" width=270 height=1> <img src=\"L2UI.SquareBlank\" width=1 height=3>");
reply.append("<table width=270><tr>");
reply.append("<td width=66><button value=\"Back\" action=\"bypass -h npc_"+getObjectId()+"_Private "+pageId+"\" width=66 height=16 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"></td>");
reply.append("<td width=138></td>");
reply.append("</tr></table>");
reply.append("<br>");
reply.append("<table width=270><tr>");
reply.append("<td valign=top width=35><img src="+getItemIcon(mrktItem.getItemId())+" width=32 height=32 align=left></td>");
reply.append("<td valign=top width=235>");
reply.append("<table border=0 width=100%>");
reply.append("<tr><td><font color=\"A2A0A2\">Name:</font> <font color=\"B09878\">"+mrktItem.getItemName()+"</font><font color=\"A2A0A2\">[<font color=\"B09878\">"+mrktItem.getCount()+"</font>]</td></tr>");
reply.append("<tr><td><font color=\"A2A0A2\">Price:</font> <font color=\"B09878\">"+Util.formatAdena(mrktItem.getPrice())+"</font><font color=\"A2A0A2\"></td></tr>");
reply.append("<tr><td><button value=\"Remove\" action=\"bypass -h npc_"+getObjectId()+"_TakeItem "+mrktItem.getItemObjId()+"\" width=66 height=16 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"></td></tr></table></td>");
reply.append("</tr></table>");
reply.append("</body></html>");
npcReply.setHtml(reply.toString());
player.sendPacket(npcReply);
}
 
private String getGrade(int grade) {
switch(grade) {
case D_G:
return "D Grade";
case C_G:
return "C Grade";
case B_G:
return "B Grade";
case A_G:
return "A Grade";
case S_G:
return "S Grade";
case S80_G:
return "S80 Grade";
default:
return "No Grade";
}
}
}
Add L2ItemMarketModel the settlement:
com.l2jfrozen.gameserver.model:
 
 
/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package com.l2jfrozen.gameserver.model;
 
public class L2ItemMarketModel {
 
private int ownerId;
private int enchLvl;
private int itemId;
private int itemGrade;
private int itemObjId;
private int price;
private int count;
private String ownerName = null;
private String itemName = null;
private String itemType = null;
private String l2Type = null;
 
public void setOwnerId(int ownerId) {
this.ownerId = ownerId;
}
 
public void setOwnerName(String ownerName) {
this.ownerName = ownerName;
}
 
public void setItemId(int itemId) {
this.itemId = itemId;
}
 
public void setItemObjId(int itemObjId) {
this.itemObjId = itemObjId;
}
 
public void setItemName(String itemName) {
this.itemName = itemName;
}
 
public void setEnchLvl(int enchLvl) {
this.enchLvl = enchLvl;
}
 
public void setItemGrade(int itemGrade) {
this.itemGrade = itemGrade;
}
 
public void setItemType(String itemType) {
this.itemType = itemType;
}
 
public void setL2Type(String l2Type) {
this.l2Type = l2Type;
}
 
public void setPrice(int price) {
this.price = price;
}
 
public void setCount(int count) {
this.count = count;
}
 
public int getOwnerId() {
return ownerId;
}
 
public String getOwnerName() {
return ownerName;
}
 
public int getItemId() {
return itemId;
}
 
public int getItemObjId() {
return itemObjId;
}
 
public String getItemName() {
return itemName;
}
 
public int getEnchLvl() {
return enchLvl;
}
 
public int getItemGrade() {
return itemGrade;
}
 
public String getItemType() {
return itemType;
}
 
public String getL2Type() {
return l2Type;
}
 
public int getPrice() {
return price;
}
 
public int getCount() {
return count;
}
 
} 

Sql part:

 

http://www.mediafire.com/download/k57kshzbh2nxuk3/market.sql

 

 

let's not forget that when you create the npc with the type:

  ~ ~ L2ItemMarketer ok?
 
credits: U3 Games (. He was told by our friend the topics below thank have researched on it.)

 

Some pic:

 

 

 

 

http://www.mediafire.com/convkey/cc0e/vjt15wmdm88s8gozg.jpg?size_id=7

http://www.mediafire.com/convkey/6dab/s3sc6b314mjwimbzg.jpg?size_id=7

http://www.mediafire.com/convkey/06cd/6axbioj2lva74qrzg.jpg?size_id=7

http://www.mediafire.com/convkey/969c/nzntdetjtnmk6z1zg.jpg?size_id=7

Edited by Tachi
Posted (edited)

Very insteresting you can check out and this one http://www.4shared.com/rar/5T1hoBbD/Item_Market_frozen_edit__.html

 

Its pretty good give many options 

Search Weapons,armors,jewerls,etc,misc,accessories,grades,D,C,B,A,S,no grades

Allow player put item on sale,allow player to get the item from shop back when they want etc /// 

 

I paste this not to flame you must check it out and maybe new ideas will come up ..

 

BTW excelent code dude !! :)

 

PS.Here is the post on mxc click me

Edited by L2LostWard
Posted

Very insteresting you can check out and this one http://www.4shared.com/rar/5T1hoBbD/Item_Market_frozen_edit__.html

 

Its pretty good give many options 

Search Weapons,armors,jewerls,etc,misc,accessories,grades,D,C,B,A,S,no grades

Allow player put item on sale,allow player to get the item from shop back when they want etc /// 

 

I paste this not to flame you must check it out and maybe new ideas will come up ..

 

BTW excelent code dude !! :)

 

PS.Here is the post on mxc click me

ty man i know this mod' and i think is nice to be online in many server's

 

I think it's exciting that someone can change a weapon augmented for another augmented wepoan :)

Posted

Too much db connections, Java 6 writting style, and it would benefit from using CBoard.

 

The filter section can be shortcuted by 73784733 with correct use of Java 8 streams.

yes you're right, but I have given to share what I found and I thought it useful
 
people like you, who know Java can tell which variant is better :)
Posted

 

yes you're right, but I have given to share what I found and I thought it useful
 
people like you, who know Java can tell which variant is better :)

 

 

I don't blame you, or even code author, I simply point to possible optimizations. Do whatever you want from here.

Posted

I don't blame you, or even code author, I simply point to possible optimizations. Do whatever you want from here.

I know that I did not say that I've blamed myself but I shared what I found :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...