· 6 years ago · Sep 28, 2019, 05:37 AM
1### Eclipse Workspace Patch 1.0
2#P L2J_SunriseProject_Core
3Index: java/l2r/gameserver/communitybbs/Managers/RegionBBSManager.java
4===================================================================
5--- java/l2r/gameserver/communitybbs/Managers/RegionBBSManager.java (revision 173)
6+++ java/l2r/gameserver/communitybbs/Managers/RegionBBSManager.java (working copy)
7@@ -18,20 +18,641 @@
8 */
9 package l2r.gameserver.communitybbs.Managers;
10
11+import java.util.Arrays;
12+import java.util.Comparator;
13+import java.util.LinkedList;
14+import java.util.List;
15+import java.util.Map;
16+import java.util.StringTokenizer;
17+
18+import l2r.gameserver.cache.HtmCache;
19+import l2r.gameserver.data.xml.impl.ItemData;
20+import l2r.gameserver.data.xml.impl.RecipeData;
21+import l2r.gameserver.enums.PrivateStoreType;
22+import l2r.gameserver.model.L2ManufactureItem;
23+import l2r.gameserver.model.L2RecipeList;
24+import l2r.gameserver.model.L2World;
25+import l2r.gameserver.model.TradeItem;
26+import l2r.gameserver.model.TradeList;
27 import l2r.gameserver.model.actor.instance.L2PcInstance;
28+import l2r.gameserver.model.items.L2Item;
29+import l2r.gameserver.model.items.type.CrystalType;
30+import l2r.gameserver.network.serverpackets.ActionFailed;
31+import l2r.gameserver.network.serverpackets.RadarControl;
32+import l2r.gameserver.util.HtmlUtils;
33+import l2r.gameserver.util.MapUtils;
34
35-public class RegionBBSManager extends BaseBBSManager
36+public class RegionBBSManager extends TopBBSManager
37 {
38+ // @formatter:off
39+ private static final int[][] _towns = new int[][] { {1010005, 19, 21}, {1010006, 20, 22}, {1010007, 22, 22}, {1010013, 22, 19}, {1010023, 24, 18}, {1010049, 23, 24}, {1010199, 24, 16}, {1010200, 21, 16}, {1010574, 22, 13}};
40+ private static final String[] _regionTypes = { "&$596;", "&$597;", "&$665;" };
41+ private static final String[] _elements = { "&$1622;", "&$1623;", "&$1624;", "&$1625;", "&$1626;", "&$1627;" };
42+ private static final String[] _grade = { "&$1291;", "&$1292;", "&$1293;", "&$1294;", "&$1295;", "S80 Grade", "S84 Grade" };
43+ private static final int SELLER_PER_PAGE = 12;
44+ private static byte AttrFire = 0;
45+ private static byte AttrWater = 1;
46+ private static byte AttrWind = 2;
47+ private static byte AttrEarth = 3;
48+ private static byte AttrHoly = 4;
49+ private static byte AttrDark = 5;
50+
51+ private static final String _pageRegionTpl = "data/html/CommunityBoard/region/bbs_regiontpl.htm";
52+ private static final String _pageRegionSTpl = "data/html/CommunityBoard/region/bbs_region_stpl.htm";
53+ private static final String _pageRegionStoreTpl = "data/html/CommunityBoard/region/bbs_region_storetpl.htm";
54+ private static final String _pageRegionList = "data/html/CommunityBoard/region/bbs_region_list.htm";
55+ private static final String _pageRegionSelers = "data/html/CommunityBoard/region/bbs_region_sellers.htm";
56+ private static final String _pageRegionView = "data/html/CommunityBoard/region/bbs_region_view.htm";
57+ // @formatter:on
58+
59 @Override
60- public void cbByPass(String command, L2PcInstance activeChar)
61+ public void cbByPass(String command, L2PcInstance player)
62 {
63+ StringTokenizer st = new StringTokenizer(command, ";");
64+
65+ if (command.equals("_bbsloc"))
66+ {
67+ String tpl = HtmCache.getInstance().getHtm(player, _pageRegionTpl);
68+ StringBuilder rl = new StringBuilder("");
69+
70+ for (int townId = 0; townId < _towns.length; townId++)
71+ {
72+ int[] town = _towns[townId];
73+
74+ String reg = tpl.replace("%region_bypass%", "_bbsregion;" + String.valueOf(townId));
75+ reg = reg.replace("%region_name%", HtmlUtils.htmlNpcString(town[0]));
76+ reg = reg.replace("%region_desc%", "&$498;: &$1157;, &$1434;, &$645;.");
77+ reg = reg.replace("%region_type%", "l2ui.bbs_folder");
78+ int sellers = 0;
79+
80+ int rx = town[1];
81+ int ry = town[2];
82+ int offset = 0;
83+
84+ for (L2PcInstance seller : L2World.getInstance().getPlayers())
85+ {
86+ int tx = MapUtils.regionX(seller);
87+ int ty = MapUtils.regionY(seller);
88+
89+ if ((tx >= (rx - offset)) && (tx <= (rx + offset)) && (ty >= (ry - offset)) && (ty <= (ry + offset)))
90+ {
91+ if (seller.getPrivateStoreType() != PrivateStoreType.NONE)
92+ {
93+ sellers++;
94+ }
95+ }
96+ }
97+ reg = reg.replace("%sellers_count%", String.valueOf(sellers));
98+ rl.append(reg);
99+ }
100+
101+ String html = HtmCache.getInstance().getHtm(player, _pageRegionList);
102+ html = html.replace("%REGION_LIST%", rl.toString());
103+
104+ separateAndSend(html, player);
105+ }
106+ else if (command.startsWith("_bbsregion"))
107+ {
108+ st.nextToken();
109+ String tpl = HtmCache.getInstance().getHtm(player, _pageRegionTpl);
110+ int townId = Integer.parseInt(st.nextToken());
111+ StringBuilder rl = new StringBuilder("");
112+ int[] town = _towns[townId];
113+
114+ for (int type = 0; type < _regionTypes.length; type++)
115+ {
116+ String reg = tpl.replace("%region_bypass%", "_bbsreglist;" + townId + ";" + type + ";1;0;");
117+ reg = reg.replace("%region_name%", _regionTypes[type]);
118+ reg = reg.replace("%region_desc%", _regionTypes[type] + ".");
119+ reg = reg.replace("%region_type%", "l2ui.bbs_board");
120+ int sellers = 0;
121+
122+ int rx = town[1];
123+ int ry = town[2];
124+ int offset = 0;
125+
126+ for (L2PcInstance seller : L2World.getInstance().getPlayers())
127+ {
128+ int tx = MapUtils.regionX(seller);
129+ int ty = MapUtils.regionY(seller);
130+
131+ if ((tx >= (rx - offset)) && (tx <= (rx + offset)) && (ty >= (ry - offset)) && (ty <= (ry + offset)))
132+ {
133+ if ((type == 0) && ((seller.getPrivateStoreType() == PrivateStoreType.SELL) || (seller.getPrivateStoreType() == PrivateStoreType.PACKAGE_SELL)))
134+ {
135+ sellers++;
136+ }
137+ else if ((type == 1) && (seller.getPrivateStoreType() == PrivateStoreType.BUY))
138+ {
139+ sellers++;
140+ }
141+ else if ((type == 2) && (seller.getPrivateStoreType() == PrivateStoreType.MANUFACTURE))
142+ {
143+ sellers++;
144+ }
145+ }
146+ }
147+
148+ reg = reg.replace("%sellers_count%", String.valueOf(sellers));
149+ rl.append(reg);
150+ }
151+
152+ String html = HtmCache.getInstance().getHtm(player, _pageRegionList);
153+ html = html.replace("%REGION_LIST%", rl.toString());
154+
155+ separateAndSend(html, player);
156+ }
157+ else if (command.startsWith("_bbsreglist"))
158+ {
159+ st.nextToken();
160+ int townId = Integer.parseInt(st.nextToken());
161+ int type = Integer.parseInt(st.nextToken());
162+ int page = Integer.parseInt(st.nextToken());
163+ int byItem = Integer.parseInt(st.nextToken());
164+ String search = st.hasMoreTokens() ? st.nextToken().toLowerCase() : "";
165+ int[] town = _towns[townId];
166+
167+ List<L2PcInstance> sellers = getSellersList(townId, type, search, byItem == 1);
168+
169+ int start = (page - 1) * SELLER_PER_PAGE;
170+ int end = Math.min(page * SELLER_PER_PAGE, sellers.size());
171+
172+ String html = HtmCache.getInstance().getHtm(player, _pageRegionSelers);
173+
174+ if (page == 1)
175+ {
176+ html = html.replace("%ACTION_GO_LEFT%", "");
177+ html = html.replace("%GO_LIST%", "");
178+ html = html.replace("%NPAGE%", "1");
179+ }
180+ else
181+ {
182+ html = html.replace("%ACTION_GO_LEFT%", "bypass _bbsreglist;" + townId + ";" + type + ";" + (page - 1) + ";" + byItem + ";" + search);
183+ html = html.replace("%NPAGE%", String.valueOf(page));
184+ StringBuilder goList = new StringBuilder("");
185+ for (int i = page > 10 ? page - 10 : 1; i < page; i++)
186+ {
187+ goList.append("<td><a action=\"bypass _bbsreglist;").append(townId).append(";").append(type).append(";").append(i).append(";").append(byItem).append(";").append(search).append("\"> ").append(i).append(" </a> </td>\n\n");
188+ }
189+
190+ html = html.replace("%GO_LIST%", goList.toString());
191+ }
192+
193+ int pages = Math.max(sellers.size() / SELLER_PER_PAGE, 1);
194+ if (sellers.size() > (pages * SELLER_PER_PAGE))
195+ {
196+ pages++;
197+ }
198+
199+ if (pages > page)
200+ {
201+ html = html.replace("%ACTION_GO_RIGHT%", "bypass _bbsreglist;" + townId + ";" + type + ";" + (page + 1) + ";" + byItem + ";" + search);
202+ int ep = Math.min(page + 10, pages);
203+ StringBuilder goList = new StringBuilder("");
204+ for (int i = page + 1; i <= ep; i++)
205+ {
206+ goList.append("<td><a action=\"bypass _bbsreglist;").append(townId).append(";").append(type).append(";").append(i).append(";").append(byItem).append(";").append(search).append("\"> ").append(i).append(" </a> </td>\n\n");
207+ }
208+
209+ html = html.replace("%GO_LIST2%", goList.toString());
210+ }
211+ else
212+ {
213+ html = html.replace("%ACTION_GO_RIGHT%", "");
214+ html = html.replace("%GO_LIST2%", "");
215+ }
216+
217+ StringBuilder seller_list = new StringBuilder("");
218+ String tpl = HtmCache.getInstance().getHtm(player, _pageRegionSTpl);
219+
220+ for (int i = start; i < end; i++)
221+ {
222+ L2PcInstance seller = sellers.get(i);
223+ TradeList tl = null;
224+ if (seller.getPrivateStoreType() == PrivateStoreType.BUY)
225+ {
226+ tl = seller.getBuyList();
227+ }
228+ else
229+ {
230+ tl = seller.getSellList();
231+ }
232+
233+ Map<Integer, L2ManufactureItem> cl = seller.getManufactureItems();
234+
235+ if ((tl == null) && (cl == null))
236+ {
237+ continue;
238+ }
239+
240+ String stpl = tpl;
241+ stpl = stpl.replace("%view_bypass%", "bypass _bbsregview;" + townId + ";" + type + ";" + page + ";" + seller.getObjectId() + ";" + byItem + ";" + search);
242+ stpl = stpl.replace("%seller_name%", seller.getName());
243+ String title = "N/A";
244+ if (type == 0)
245+ {
246+ title = (tl != null) && (tl.getTitle() != null) && !tl.getTitle().isEmpty() ? tl.getTitle() : "N/A";
247+ }
248+ else if (type == 1)
249+ {
250+ title = (tl != null) && (tl.getTitle() != null) && !tl.getTitle().isEmpty() ? tl.getTitle() : "N/A";
251+ }
252+ else if ((type == 2) && (seller.getPrivateStoreType() == PrivateStoreType.MANUFACTURE))
253+ {
254+ title = (cl != null) && (seller.getStoreName() != null) && !seller.getStoreName().isEmpty() ? seller.getStoreName() : "-";
255+ }
256+
257+ title = title.replace("<", "");
258+ title = title.replace(">", "");
259+ title = title.replace("&", "");
260+ title = title.replace("$", "");
261+
262+ if (title.isEmpty())
263+ {
264+ title = "N/A";
265+ }
266+
267+ stpl = stpl.replace("%seller_title%", title);
268+
269+ seller_list.append(stpl);
270+ }
271+
272+ html = html.replace("%SELLER_LIST%", seller_list.toString());
273+ html = html.replace("%search_bypass%", "_bbsregsearch_" + townId + "_" + type);
274+ html = html.replace("%TREE%", " > <a action=\"bypass _bbsregion;" + townId + "\"><font color=\"aa9977\"> " + HtmlUtils.htmlNpcString(town[0]) + "</font></a> > " + _regionTypes[type]);
275+
276+ separateAndSend(html, player);
277+ }
278+ else if (command.startsWith("_bbsregview"))
279+ {
280+ st.nextToken();
281+ int townId = Integer.parseInt(st.nextToken());
282+ int type = Integer.parseInt(st.nextToken());
283+ int page = Integer.parseInt(st.nextToken());
284+ int objectId = Integer.parseInt(st.nextToken());
285+ int byItem = Integer.parseInt(st.nextToken());
286+ String search = st.hasMoreTokens() ? st.nextToken().toLowerCase() : "";
287+ int[] town = _towns[townId];
288+
289+ L2PcInstance seller = L2World.getInstance().getPlayer(objectId);
290+ if ((seller == null) || (seller.getPrivateStoreType() == PrivateStoreType.NONE))
291+ {
292+ cbByPass("_bbsreglist;" + townId + ";" + type + ";" + page + ";" + byItem + ";" + search, player);
293+ return;
294+ }
295+
296+ String title = "-";
297+ String tpl = HtmCache.getInstance().getHtm(player, _pageRegionStoreTpl);
298+ StringBuilder sb = new StringBuilder("");
299+
300+ if (type < 2)
301+ {
302+ TradeList sl = type == 0 ? seller.getSellList() : seller.getBuyList();
303+
304+ if (sl == null)
305+ {
306+ cbByPass("_bbsreglist;" + townId + ";" + type + ";" + page + ";" + byItem + ";" + search, player);
307+ return;
308+ }
309+
310+ if ((type == 0) && (sl.getTitle() != null) && !sl.getTitle().isEmpty())
311+ {
312+ title = sl.getTitle();
313+ }
314+ else if ((type == 1) && (sl.getTitle() != null) && !sl.getTitle().isEmpty())
315+ {
316+ title = sl.getTitle();
317+ }
318+
319+ for (TradeItem ti : sl.getItems())
320+ {
321+ L2Item item = ItemData.getInstance().getTemplate(ti.getItem().getId());
322+ if (item != null)
323+ {
324+ String stpl = tpl.replace("%item_name%", ti.getItem().getName() + (ti.getItem().isEquipable() && (ti.getEnchant() > 0) ? " +" + ti.getEnchant() : ""));
325+ stpl = stpl.replace("%item_img%", item.getIcon());
326+ stpl = stpl.replace("%item_count%", String.valueOf(ti.getCount()));
327+ stpl = stpl.replace("%item_price%", String.format("%,3d", ti.getPrice()).replace(" ", ","));
328+
329+ String desc = "";
330+ if (item.getCrystalType() != CrystalType.NONE)
331+ {
332+ desc = _grade[item.getCrystalType().getId() - 1];
333+ desc += item.getCrystalCount() > 0 ? " Crystals: " + item.getCrystalCount() + "; " : "; ";
334+ }
335+
336+ if (item.isEquipable())
337+ {
338+ if ((ti.getAttackElementType() >= 0) && (ti.getAttackElementPower() > 0))
339+ {
340+ desc += "&$1620;: " + _elements[ti.getAttackElementType()] + " +" + ti.getAttackElementPower();
341+ }
342+ else if ((ti.getElementDefAttr(AttrFire) > 0) || (ti.getElementDefAttr(AttrWater) > 0) || (ti.getElementDefAttr(AttrWind) > 0) || (ti.getElementDefAttr(AttrEarth) > 0) || (ti.getElementDefAttr(AttrHoly) > 0) || (ti.getElementDefAttr(AttrDark) > 0))
343+ {
344+ desc += "&$1651;:";
345+ if (ti.getElementDefAttr(AttrFire) > 0)
346+ {
347+ desc += " &$1622; +" + ti.getElementDefAttr(AttrFire) + "; ";
348+ }
349+ if (ti.getElementDefAttr(AttrWater) > 0)
350+ {
351+ desc += " &$1623; +" + ti.getElementDefAttr(AttrWater) + "; ";
352+ }
353+ if (ti.getElementDefAttr(AttrWind) > 0)
354+ {
355+ desc += " &$1624; +" + ti.getElementDefAttr(AttrWind) + "; ";
356+ }
357+ if (ti.getElementDefAttr(AttrEarth) > 0)
358+ {
359+ desc += " &$1625; +" + ti.getElementDefAttr(AttrEarth) + "; ";
360+ }
361+ if (ti.getElementDefAttr(AttrHoly) > 0)
362+ {
363+ desc += " &$1626; +" + ti.getElementDefAttr(AttrHoly) + "; ";
364+ }
365+ if (ti.getElementDefAttr(AttrDark) > 0)
366+ {
367+ desc += " &$1627; +" + ti.getElementDefAttr(AttrDark) + "; ";
368+ }
369+ }
370+ }
371+ if (item.isStackable())
372+ {
373+ desc += "Stackable; ";
374+ }
375+
376+ // FIXME
377+ /**
378+ * if (item.isSealedItem()) { desc += "Sealed; "; } if (item.isShadowItem()) { desc += "Shadow item; "; } if (item.isTimeItem()) { desc += "Temporal; "; }
379+ */
380+
381+ stpl = stpl.replace("%item_desc%", desc);
382+ sb.append(stpl);
383+ }
384+ }
385+ }
386+ else
387+ {
388+ Map<Integer, L2ManufactureItem> cl = seller.getManufactureItems();
389+ if (cl == null)
390+ {
391+ cbByPass("_bbsreglist;" + townId + ";" + type + ";" + page + ";" + byItem + ";" + search, player);
392+ return;
393+ }
394+
395+ if ((title = seller.getStoreName()) == null)
396+ {
397+ title = "-";
398+ }
399+
400+ for (L2ManufactureItem mi : seller.getManufactureItems().values())
401+ {
402+ L2RecipeList rec = RecipeData.getInstance().getRecipeByItemId(mi.getRecipeId() - 1);
403+ if (rec == null)
404+ {
405+ continue;
406+ }
407+ L2Item item = ItemData.getInstance().getTemplate(rec.getId());
408+ if (item == null)
409+ {
410+ continue;
411+ }
412+ String stpl = tpl.replace("%item_name%", item.getName());
413+ stpl = stpl.replace("%item_img%", item.getIcon());
414+ stpl = stpl.replace("%item_count%", "N/A");
415+ stpl = stpl.replace("%item_price%", String.format("%,3d", mi.getCost()).replace(" ", ","));
416+ String desc = "";
417+ if (item.getCrystalType() != CrystalType.NONE)
418+ {
419+ desc = _grade[item.getCrystalType().getId() - 1] + (item.getCrystalCount() > 0 ? " Crystals: " + item.getCrystalCount() + "; " : "; ");
420+ }
421+
422+ if (item.isStackable())
423+ {
424+ desc = "Stackable; ";
425+ }
426+
427+ // FIXME
428+ /**
429+ * if (item.isSealedItem()) { desc += "Sealed; "; }
430+ */
431+
432+ stpl = stpl.replace("%item_desc%", desc);
433+ sb.append(stpl);
434+ }
435+ }
436+
437+ String html = HtmCache.getInstance().getHtm(player, _pageRegionView);
438+
439+ html = html.replace("%sell_type%", _regionTypes[type]);
440+
441+ title = title.replace("<", "");
442+ title = title.replace(">", "");
443+ title = title.replace("&", "");
444+ title = title.replace("$", "");
445+ if (title.isEmpty())
446+ {
447+ title = "-";
448+ }
449+ html = html.replace("%title%", title);
450+ html = html.replace("%char_name%", seller.getName());
451+ html = html.replace("%object_id%", String.valueOf(seller.getObjectId()));
452+ html = html.replace("%STORE_LIST%", sb.toString());
453+ html = html.replace("%list_bypass%", "_bbsreglist;" + townId + ";" + type + ";" + page + ";" + byItem + ";" + search);
454+ html = html.replace("%TREE%", " > <a action=\"bypass _bbsregion;" + townId + "\">" + HtmlUtils.htmlNpcString(town[0]) + "</a> > <a action=\"bypass _bbsreglist;" + townId + ";" + type + ";" + page + ";" + byItem + "\">" + _regionTypes[type] + "</a> > " + seller.getName());
455+
456+ separateAndSend(html, player);
457+ }
458+ else if (command.startsWith("_bbsregtarget"))
459+ {
460+ st.nextToken();
461+ int objectId = Integer.parseInt(st.nextToken());
462+ L2PcInstance seller = L2World.getInstance().getPlayer(objectId);
463+ if (seller != null)
464+ {
465+ player.sendPacket(new RadarControl(0, 2, seller.getLocation().getX(), seller.getLocation().getY(), seller.getLocation().getZ()));
466+
467+ if (player.getKnownList().getKnownObject(seller.getObjectId()) != null)
468+ {
469+ player.setTarget(seller);
470+ seller.broadcastRelationChanged2();
471+ }
472+ }
473+ else
474+ {
475+ player.sendPacket(ActionFailed.STATIC_PACKET);
476+ }
477+ }
478+
479+ return;
480+ }
481
482+ @SuppressWarnings("synthetic-access")
483+ private static List<L2PcInstance> getSellersList(int townId, int type, String search, boolean byItem)
484+ {
485+ List<L2PcInstance> list = new LinkedList<>();
486+ int town[] = _towns[townId];
487+ int rx = town[1];
488+ int ry = town[2];
489+ int offset = 0;
490+
491+ for (L2PcInstance seller : L2World.getInstance().getPlayers())
492+ {
493+ int tx = MapUtils.regionX(seller);
494+ int ty = MapUtils.regionY(seller);
495+
496+ if ((tx >= (rx - offset)) && (tx <= (rx + offset)) && (ty >= (ry - offset)) && (ty <= (ry + offset)))
497+ {
498+ TradeItem[] tl = null;
499+ if (seller.getPrivateStoreType() == PrivateStoreType.BUY)
500+ {
501+ tl = seller.getBuyList().getItems();
502+ }
503+ else
504+ {
505+ tl = seller.getSellList().getItems();
506+ }
507+
508+ Map<Integer, L2ManufactureItem> cl = seller.getManufactureItems();
509+ if (seller.getPrivateStoreType() != PrivateStoreType.NONE)
510+ {
511+ if ((type == 0) && (tl != null) && ((seller.getPrivateStoreType() == PrivateStoreType.SELL) || (seller.getPrivateStoreType() == PrivateStoreType.PACKAGE_SELL)))
512+ {
513+ list.add(seller);
514+ }
515+ else if ((type == 1) && (tl != null) && (seller.getPrivateStoreType() == PrivateStoreType.BUY))
516+ {
517+ list.add(seller);
518+ }
519+ else if ((type == 2) && (cl != null) && (seller.getPrivateStoreType() == PrivateStoreType.MANUFACTURE))
520+ {
521+ list.add(seller);
522+ }
523+ }
524+ }
525+ }
526+
527+ if (!search.isEmpty() && !list.isEmpty())
528+ {
529+ List<L2PcInstance> s_list = new LinkedList<>();
530+ for (L2PcInstance seller : list)
531+ {
532+ TradeList tl = null;
533+ if (seller.getPrivateStoreType() == PrivateStoreType.BUY)
534+ {
535+ tl = seller.getBuyList();
536+ }
537+ else
538+ {
539+ tl = seller.getSellList();
540+ }
541+ Map<Integer, L2ManufactureItem> cl = seller.getManufactureItems();
542+ if (byItem)
543+ {
544+ if (((type == 0) || (type == 1)) && (tl != null))
545+ {
546+ TradeItem[] sl = type == 0 ? seller.getSellList().getItems() : seller.getBuyList().getItems();
547+ if (sl != null)
548+ {
549+ for (TradeItem ti : sl)
550+ {
551+ L2Item item = ItemData.getInstance().getTemplate(ti.getItem().getId());
552+ if ((item != null) && (item.getName() != null) && item.getName().toLowerCase().contains(search))
553+ {
554+ s_list.add(seller);
555+ break;
556+ }
557+ }
558+ }
559+ }
560+ else if ((type == 2) && (cl != null))
561+ {
562+ for (L2ManufactureItem mi : seller.getManufactureItems().values())
563+ {
564+ L2RecipeList recipe = RecipeData.getInstance().getRecipeList(mi.getRecipeId() - 1);
565+ if (recipe != null)
566+ {
567+ L2Item item = ItemData.getInstance().getTemplate(recipe.getId());
568+ if ((item != null) && (item.getName() != null) && item.getName().toLowerCase().contains(search))
569+ {
570+ s_list.add(seller);
571+ break;
572+ }
573+ }
574+ }
575+ }
576+ }
577+ else if ((type == 0) && (tl != null) && (tl.getTitle() != null) && tl.getTitle().toLowerCase().contains(search))
578+ {
579+ s_list.add(seller);
580+ }
581+ else if ((type == 1) && (tl != null) && (tl.getTitle() != null) && tl.getTitle().toLowerCase().contains(search))
582+ {
583+ s_list.add(seller);
584+ }
585+ else if ((type == 2) && (cl != null) && (seller.hasManufactureShop()) && (seller.getStoreName() != null) && seller.getStoreName().toLowerCase().contains(search))
586+ {
587+ s_list.add(seller);
588+ }
589+ }
590+ list = s_list;
591+ }
592+
593+ if (!list.isEmpty())
594+ {
595+ L2PcInstance[] players = new L2PcInstance[list.size()];
596+ list.toArray(players);
597+ Arrays.sort(players, new PlayersComparator<L2PcInstance>());
598+ list.clear();
599+ list.addAll(Arrays.asList(players));
600+ }
601+
602+ return list;
603 }
604
605 @Override
606- public void parsewrite(String url, String ar1, String ar2, String ar3, String ar4, String ar5, L2PcInstance activeChar)
607+ public void parsewrite(String url, String arg1, String arg2, String arg3, String arg4, String arg5, L2PcInstance player)
608 {
609+ StringTokenizer st = new StringTokenizer(url, "_");
610+ String cmd = st.nextToken();
611+ if ("bbsregsearch".equals(cmd))
612+ {
613+ int townId = Integer.parseInt(st.nextToken());
614+ int type = Integer.parseInt(st.nextToken());
615+ String byItem = "Item".equals(arg4) ? "1" : "0";
616+
617+ if (arg3 == null)
618+ {
619+ arg3 = "";
620+ }
621+
622+ arg3 = arg3.replace("<", "");
623+ arg3 = arg3.replace(">", "");
624+ arg3 = arg3.replace("&", "");
625+ arg3 = arg3.replace("$", "");
626+
627+ if (arg3.length() > 30)
628+ {
629+ arg3 = arg3.substring(0, 30);
630+ }
631+
632+ cbByPass("_bbsreglist;" + townId + ";" + type + ";1;" + byItem + ";" + arg3, player);
633+ }
634+ }
635
636+ private static class PlayersComparator<T> implements Comparator<T>
637+ {
638+ @Override
639+ public int compare(Object o1, Object o2)
640+ {
641+ if ((o1 instanceof L2PcInstance) && (o2 instanceof L2PcInstance))
642+ {
643+ L2PcInstance p1 = (L2PcInstance) o1;
644+ L2PcInstance p2 = (L2PcInstance) o2;
645+ return p1.getName().compareTo(p2.getName());
646+ }
647+ return 0;
648+ }
649 }
650
651 public static RegionBBSManager getInstance()
652@@ -43,4 +664,4 @@
653 {
654 protected static final RegionBBSManager _instance = new RegionBBSManager();
655 }
656-}
657\ No newline at end of file
658+}
659Index: java/l2r/features/auctionEngine/house/managers/holder/HouseItem.java
660===================================================================
661--- java/l2r/features/auctionEngine/house/managers/holder/HouseItem.java (revision 0)
662+++ java/l2r/features/auctionEngine/house/managers/holder/HouseItem.java (working copy)
663@@ -0,0 +1,44 @@
664+package l2r.features.auctionEngine.house.managers.holder;
665+
666+public class HouseItem
667+{
668+ private final int _ownerId;
669+ private final int _itemId;
670+ private final int _count;
671+ private final long _salePrice;
672+ private final long _expirationTime;
673+
674+ public HouseItem(int ownerId, int itemId, int count, long salePrice, long expirationTime)
675+ {
676+ _ownerId = ownerId;
677+ _itemId = itemId;
678+ _count = count;
679+ _salePrice = salePrice;
680+ _expirationTime = expirationTime;
681+ }
682+
683+ public int getOwnerId()
684+ {
685+ return _ownerId;
686+ }
687+
688+ public int getItemId()
689+ {
690+ return _itemId;
691+ }
692+
693+ public int getCount()
694+ {
695+ return _count;
696+ }
697+
698+ public long getSalePrice()
699+ {
700+ return _salePrice;
701+ }
702+
703+ public long getExpirationTime()
704+ {
705+ return _expirationTime;
706+ }
707+}
708\ No newline at end of file
709Index: java/l2r/features/auctionEngine/templates/AuctionHouse.java
710===================================================================
711--- java/l2r/features/auctionEngine/templates/AuctionHouse.java (revision 0)
712+++ java/l2r/features/auctionEngine/templates/AuctionHouse.java (working copy)
713@@ -0,0 +1,187 @@
714+/*
715+ * This program is free software: you can redistribute it and/or modify it under
716+ * the terms of the GNU General Public License as published by the Free Software
717+ * Foundation, either version 3 of the License, or (at your option) any later
718+ * version.
719+ *
720+ * This program is distributed in the hope that it will be useful, but WITHOUT
721+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
722+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
723+ * details.
724+ *
725+ * You should have received a copy of the GNU General Public License along with
726+ * this program. If not, see <http://www.gnu.org/licenses/>.
727+ */
728+package l2r.features.auctionEngine.templates;
729+
730+import java.util.ArrayList;
731+import java.util.List;
732+import java.util.Map;
733+
734+import l2r.features.auctionEngine.house.managers.AuctionHouseGenerator;
735+import l2r.features.auctionEngine.managers.AuctionHouseManager.AuctionHouseEntrance;
736+import l2r.features.auctionEngine.templates.AuctionConditions.AuctionCondition;
737+import l2r.features.auctionEngine.templates.AuctionConditions.AuctionConditionArmorType;
738+import l2r.features.auctionEngine.templates.AuctionConditions.AuctionConditionEtcType;
739+import l2r.features.auctionEngine.templates.AuctionConditions.AuctionConditionForPet;
740+import l2r.features.auctionEngine.templates.AuctionConditions.AuctionConditionHandler;
741+import l2r.features.auctionEngine.templates.AuctionConditions.AuctionConditionIcon;
742+import l2r.features.auctionEngine.templates.AuctionConditions.AuctionConditionName;
743+import l2r.features.auctionEngine.templates.AuctionConditions.AuctionConditionSkill;
744+import l2r.features.auctionEngine.templates.AuctionConditions.AuctionConditionSlot;
745+import l2r.features.auctionEngine.templates.AuctionConditions.AuctionConditionWeaponType;
746+import l2r.gameserver.model.items.L2Item;
747+import l2r.gameserver.model.items.instance.L2ItemInstance;
748+import l2r.gameserver.model.items.type.ArmorType;
749+import l2r.gameserver.model.items.type.EtcItemType;
750+import l2r.gameserver.model.items.type.WeaponType;
751+
752+/**
753+ * List of available categories for the Auction House This is not static, can be modified as you wish. Edit the current ones, delete, add, etc
754+ * @author GodFather
755+ */
756+public enum AuctionHouse
757+{
758+ // Structure: Name, Category, Conditions
759+ ITEM_PET_WEAPON("Pet Weapon", "Pet Goods", new AuctionConditionSlot(L2Item.SLOT_R_HAND), new AuctionConditionForPet(true)),
760+ ITEM_PET_ARMOR("Pet Armor", "Pet Goods", new AuctionConditionSlot(L2Item.SLOT_CHEST), new AuctionConditionForPet(true)),
761+ ITEM_PET_JEWEL("Pet Jewel", "Pet Goods", new AuctionConditionSlot(L2Item.SLOT_NECK), new AuctionConditionForPet(true)),
762+ ITEM_PET_COLLAR("Pet Collar", "Pet Goods", new AuctionConditionEtcType(EtcItemType.PET_COLLAR)),
763+ ITEM_PET_SUPPLIES("Pet Supplies", "Pet Goods", new AuctionConditionForPet(true)),
764+
765+ ITEM_WEAPON_ONE_HANDED_SWORD("1-H Sword", "Weapon", new AuctionConditionWeaponType(AuctionHouseGenerator.NORMAL_WEAPON, WeaponType.SWORD)),
766+ ITEM_WEAPON_ONE_HANDED_MAGIC_SWORD("1-H Magic Sword", "Weapon", new AuctionConditionWeaponType(AuctionHouseGenerator.MAGICAL_WEAPON, WeaponType.SWORD)),
767+ ITEM_WEAPON_DAGGER("Dagger", "Weapon", new AuctionConditionWeaponType(AuctionHouseGenerator.NORMAL_WEAPON, WeaponType.DAGGER)),
768+ ITEM_WEAPON_RAPIER("Rapier", "Weapon", new AuctionConditionWeaponType(AuctionHouseGenerator.NORMAL_WEAPON, WeaponType.RAPIER)),
769+ ITEM_WEAPON_ANCIENT_SWORD("Ancient Sword", "Weapon", new AuctionConditionWeaponType(AuctionHouseGenerator.NORMAL_WEAPON, WeaponType.ANCIENTSWORD)),
770+ ITEM_WEAPON_DUAL_SWORD("Dual Sword", "Weapon", new AuctionConditionWeaponType(AuctionHouseGenerator.NORMAL_WEAPON, WeaponType.DUAL)),
771+ ITEM_WEAPON_DUAL_DAGGER("Dual Dagger", "Weapon", new AuctionConditionWeaponType(AuctionHouseGenerator.NORMAL_WEAPON, WeaponType.DUALDAGGER)),
772+ ITEM_WEAPON_ONE_HANDED_BLUNT("Blunt", "Weapon", new AuctionConditionWeaponType(AuctionHouseGenerator.NORMAL_WEAPON, WeaponType.BLUNT)),
773+ ITEM_WEAPON_ONE_HANDED_MAGIC_BLUNT("Magic Blunt", "Weapon", new AuctionConditionWeaponType(AuctionHouseGenerator.MAGICAL_WEAPON, WeaponType.BLUNT)),
774+ ITEM_WEAPON_BOW("Bow", "Weapon", new AuctionConditionWeaponType(AuctionHouseGenerator.NORMAL_WEAPON, WeaponType.BOW)),
775+ ITEM_WEAPON_CROSSBOW("Crossbow", "Weapon", new AuctionConditionWeaponType(AuctionHouseGenerator.NORMAL_WEAPON, WeaponType.CROSSBOW)),
776+ ITEM_WEAPON_POLE("Pole", "Weapon", new AuctionConditionWeaponType(AuctionHouseGenerator.NORMAL_WEAPON, WeaponType.POLE)),
777+ ITEM_WEAPON_FIST("Fists", "Weapon", new AuctionConditionWeaponType(AuctionHouseGenerator.NORMAL_WEAPON, WeaponType.DUALFIST)),
778+ ITEM_WEAPON_OTHER("Other", "Weapon", new AuctionConditionWeaponType(AuctionHouseGenerator.NORMAL_WEAPON, WeaponType.ETC)),
779+
780+ ITEM_ARMOR_HELMET("Helmet", "Armor", new AuctionConditionSlot(L2Item.SLOT_HEAD)),
781+ ITEM_ARMOR_UPPER_PIECE("Upper Piece", "Armor", new AuctionConditionSlot(L2Item.SLOT_CHEST)),
782+ ITEM_ARMOR_LOWER_PIECE("Lower Piece", "Armor", new AuctionConditionSlot(L2Item.SLOT_LEGS)),
783+ ITEM_ARMOR_FULL_BODY("Full Body", "Armor", new AuctionConditionSlot(L2Item.SLOT_FULL_ARMOR)),
784+ ITEM_ARMOR_GLOVES("Gloves", "Armor", new AuctionConditionSlot(L2Item.SLOT_GLOVES)),
785+ ITEM_ARMOR_BOOTS("Boots", "Armor", new AuctionConditionSlot(L2Item.SLOT_FEET)),
786+ ITEM_ARMOR_SHIELD("Shield", "Armor", new AuctionConditionSlot(L2Item.SLOT_L_HAND), new AuctionConditionArmorType(ArmorType.SHIELD)),
787+ ITEM_ARMOR_SIGIL("Sigil", "Armor", new AuctionConditionSlot(L2Item.SLOT_L_HAND), new AuctionConditionArmorType(ArmorType.SIGIL)),
788+ ITEM_ARMOR_UNDERWEAR("Underwear", "Armor", new AuctionConditionSlot(L2Item.SLOT_UNDERWEAR)),
789+ ITEM_ARMOR_CLOAK("Cloak", "Armor", new AuctionConditionSlot(L2Item.SLOT_BACK)),
790+
791+ ITEM_ACCESORY_RING("Ring", "Accesory", new AuctionConditionSlot(L2Item.SLOT_LR_FINGER)),
792+ ITEM_ACCESORY_EARRING("Earring", "Accesory", new AuctionConditionSlot(L2Item.SLOT_LR_EAR)),
793+ ITEM_ACCESORY_NECKLACE("Necklace", "Accesory", new AuctionConditionSlot(L2Item.SLOT_NECK)),
794+ ITEM_ACCESORY_BELT("Belt", "Accesory", new AuctionConditionSlot(L2Item.SLOT_BELT)),
795+ ITEM_ACCESORY_BRACELET("Bracelet", "Accesory", new AuctionConditionSlot(L2Item.SLOT_LR_HAND)),
796+ ITEM_ACCESORY_HAIR("Hair Accesory", "Accesory", new AuctionConditionSlot(L2Item.SLOT_HAIR, L2Item.SLOT_HAIR2, L2Item.SLOT_HAIRALL)),
797+
798+ ITEM_SUPPLY_POTION("Potion", "Supplies", new AuctionConditionEtcType(EtcItemType.POTION)),
799+ ITEM_SUPPLY_SCROLL_ENCHANT_WEAPON("Scroll: Enchant Weapon", "Supplies", new AuctionConditionEtcType(EtcItemType.SCRL_ENCHANT_WP, EtcItemType.BLESS_SCRL_ENCHANT_WP, EtcItemType.ANCIENT_CRYSTAL_ENCHANT_WP, EtcItemType.SCRL_INC_ENCHANT_PROP_WP)),
800+ ITEM_SUPPLY_SCROLL_ENCHANT_ARMOR("Scroll: Enchant Armor", "Supplies", new AuctionConditionEtcType(EtcItemType.SCRL_ENCHANT_AM, EtcItemType.BLESS_SCRL_ENCHANT_AM, EtcItemType.ANCIENT_CRYSTAL_ENCHANT_AM, EtcItemType.SCRL_INC_ENCHANT_PROP_AM)),
801+ ITEM_SUPPLY_SCROLL_OTHER("Scroll: Other", "Supplies", new AuctionConditionEtcType(EtcItemType.SCROLL)),
802+ ITEM_SUPPLY_SOULSHOT("Soulshot", "Supplies", new AuctionConditionHandler("SoulShots", "BeastSoulShot")),
803+ ITEM_SUPPLY_SPIRITSHOT("Spiritshot", "Supplies", new AuctionConditionHandler("SpiritShot", "BeastSpiritShot")),
804+
805+ ITEM_ETC_ATTRIBUTE_STONE("Attribute Stone", "Etc", new AuctionConditionHandler("EnchantAttribute")),
806+ ITEM_ETC_LIFE_STONE("Life Stone", "Etc", new AuctionConditionIcon("icon.etc_mineral")),
807+ ITEM_ETC_SOUL_CRYSTAL("Soul Crystal", "Etc", new AuctionConditionSkill(2096)),
808+ ITEM_ETC_SPELLBOOK("Spellbook", "Etc", new AuctionConditionIcon("icon.etc_spell_books_element_")),
809+ ITEM_ETC_CRYSTAL("Crystal", "Etc", new AuctionConditionName("Crystal:")),
810+ ITEM_ETC_GEMSTONE("Gemstone", "Etc", new AuctionConditionEtcType(EtcItemType.MATERIAL), new AuctionConditionName("Gemstone")),
811+ ITEM_ETC_POUCH("Magic Pouch", "Etc", new AuctionConditionIcon("icon.pouch_")),
812+ ITEM_ETC_PIN("Magic Pin", "Etc", new AuctionConditionIcon("icon.icon.pin_")),
813+ ITEM_ETC_MAGIC_ORNAMENT("Magic Ornament", "Etc", new AuctionConditionIcon("icon.etc_belt_deco_")),
814+ ITEM_ETC_MAGIC_CLIP("Magic Rune Clip", "Etc", new AuctionConditionIcon("icon.etc_rune_clip_")),
815+ ITEM_ETC_DYE("Dyes", "Etc", new AuctionConditionEtcType(EtcItemType.DYE)),
816+ ITEM_ETC_RECIPE("Recipe", "Etc", new AuctionConditionEtcType(EtcItemType.RECIPE)),
817+ ITEM_ETC_CRAFTING_INGREDIENTS("Crafting Ingredients", "Etc", new AuctionConditionEtcType(EtcItemType.MATERIAL)),
818+ ITEM_ETC_OTHER("Other Items", "Etc");
819+
820+ private final String _name;
821+ private final String _category;
822+ private final List<AuctionCondition> _conditions = new ArrayList<>();
823+
824+ private AuctionHouse(String name, String category)
825+ {
826+ _name = name;
827+ _category = category;
828+ }
829+
830+ private AuctionHouse(String name, String category, AuctionCondition... conditions)
831+ {
832+ _name = name;
833+ _category = category;
834+
835+ for (AuctionCondition cond : conditions)
836+ {
837+ _conditions.add(cond);
838+ }
839+ }
840+
841+ public int getTopId()
842+ {
843+ return ordinal();
844+ }
845+
846+ public String getTopName()
847+ {
848+ return _name;
849+ }
850+
851+ public String getCategory()
852+ {
853+ return _category;
854+ }
855+
856+ public List<AuctionCondition> getConditions()
857+ {
858+ return _conditions;
859+ }
860+
861+ /**
862+ * Generates a list of entries on a map of Class AuctionHouseEntrance
863+ * @param rankings
864+ */
865+ public static void generateEntrances(Map<Integer, AuctionHouseEntrance> rankings)
866+ {
867+ for (AuctionHouse rank : AuctionHouse.values())
868+ {
869+ rankings.put(rank.getTopId(), new AuctionHouseEntrance(rank.getTopId(), rank.getTopName(), rank.getCategory()));
870+ }
871+ }
872+
873+ /**
874+ * @param item
875+ * @return Returns the entry id that the item should be included. For that every condition is checked
876+ */
877+ public static AuctionHouse getEntranceIdFromItem(L2ItemInstance item)
878+ {
879+ boolean found;
880+ for (AuctionHouse rank : AuctionHouse.values())
881+ {
882+ found = true;
883+ for (AuctionCondition cond : rank.getConditions())
884+ {
885+ if (!cond.checkCondition(item, rank))
886+ {
887+ found = false;
888+ break;
889+ }
890+ }
891+
892+ if (found)
893+ {
894+ return rank;
895+ }
896+ }
897+
898+ return ITEM_ETC_OTHER;
899+ }
900+}
901Index: java/l2r/gameserver/communitybbs/Managers/AuctionBBSManager.java
902===================================================================
903--- java/l2r/gameserver/communitybbs/Managers/AuctionBBSManager.java (revision 0)
904+++ java/l2r/gameserver/communitybbs/Managers/AuctionBBSManager.java (working copy)
905@@ -0,0 +1,82 @@
906+/*
907+ * This program is free software: you can redistribute it and/or modify it under
908+ * the terms of the GNU General Public License as published by the Free Software
909+ * Foundation, either version 3 of the License, or (at your option) any later
910+ * version.
911+ *
912+ * This program is distributed in the hope that it will be useful, but WITHOUT
913+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
914+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
915+ * details.
916+ *
917+ * You should have received a copy of the GNU General Public License along with
918+ * this program. If not, see <http://www.gnu.org/licenses/>.
919+ */
920+package l2r.gameserver.communitybbs.Managers;
921+
922+import l2r.Config;
923+import l2r.features.auctionEngine.managers.AuctionHouseManager;
924+import l2r.gameserver.enums.ZoneIdType;
925+import l2r.gameserver.model.actor.instance.L2PcInstance;
926+
927+/**
928+ * Manager of Community Server custom his is to put all of the customs system bypasses without touching the other elemental
929+ * @author vGodFather
930+ */
931+public class AuctionBBSManager extends BaseBBSManager
932+{
933+ public String BBS_COMMAND = "_bbslink";
934+
935+ @Override
936+ public void cbByPass(String command, L2PcInstance activeChar)
937+ {
938+ // Jailed players can not use Elemental BBs Manager
939+ if (activeChar.isJailed())
940+ {
941+ return;
942+ }
943+
944+ // Processes the bypass for the auction house
945+ if (command.startsWith(BBS_COMMAND))
946+ {
947+ // You can only access the auction house from a peace zone (bypassed from gms)
948+ if (Config.AUCTION_HOUSE_ONLY_PEACE_ZONE && !activeChar.isGM() && !activeChar.isInsideZone(ZoneIdType.PEACE))
949+ {
950+ activeChar.sendMessage("The Auction House System cannot be used outside peace zone");
951+ return;
952+ }
953+
954+ final String content = AuctionHouseManager.getInstance().processBypass(activeChar, command);
955+
956+ if (command.contains(";search "))
957+ {
958+ String searchInput = command.substring(command.indexOf(";search ") + 8);
959+ if (searchInput.contains(";"))
960+ {
961+ searchInput = searchInput.substring(0, searchInput.indexOf(";"));
962+ }
963+
964+ send1001(content, activeChar);
965+ send1002(activeChar, "", searchInput, "");
966+ return;
967+ }
968+ separateAndSend(content, activeChar);
969+ }
970+ }
971+
972+ @Override
973+ public void parsewrite(String url, String ar1, String ar2, String ar3, String ar4, String ar5, L2PcInstance activeChar)
974+ {
975+
976+ }
977+
978+ public static AuctionBBSManager getInstance()
979+ {
980+ return SingletonHolder._instance;
981+ }
982+
983+ private static class SingletonHolder
984+ {
985+ protected static final AuctionBBSManager _instance = new AuctionBBSManager();
986+ }
987+}
988Index: java/l2r/gameserver/communitybbs/SunriseBoards/TopOnlinePlayers.java
989===================================================================
990--- java/l2r/gameserver/communitybbs/SunriseBoards/TopOnlinePlayers.java (revision 173)
991+++ java/l2r/gameserver/communitybbs/SunriseBoards/TopOnlinePlayers.java (working copy)
992@@ -31,14 +31,12 @@
993
994 private void addChar(String name, String cname, String onTime)
995 {
996- _list.append("<table width=680 bgcolor=111111 height=16 border=0 cellspacing=0 cellpadding=0>");
997 _list.append("<tr>");
998- _list.append("<td FIXWIDTH=40>" + _counter + "</td");
999- _list.append("<td fixwidth=160>" + name + "</td");
1000- _list.append("<td fixwidth=160>" + cname + "</td>");
1001- _list.append("<td align=center fixwidth=160>" + onTime + "</td>");
1002+ _list.append("<td valign=\"top\" align=\"center\">" + _counter + "</td");
1003+ _list.append("<td valign=\"top\" align=\"center\">" + name + "</td");
1004+ _list.append("<td valign=\"top\" align=\"center\">" + cname + "</td>");
1005+ _list.append("<td valign=\"top\" align=\"center\">" + onTime + "</td>");
1006 _list.append("</tr>");
1007- _list.append("</tr></table><img src=\"L2UI.Squaregray\" width=\"680\" height=\"1\">");
1008 }
1009
1010 public String getPlayerRunTime(int secs)
1011Index: java/l2r/features/auctionEngine/managers/AuctionHouseManager.java
1012===================================================================
1013--- java/l2r/features/auctionEngine/managers/AuctionHouseManager.java (revision 0)
1014+++ java/l2r/features/auctionEngine/managers/AuctionHouseManager.java (working copy)
1015@@ -0,0 +1,2306 @@
1016+/*
1017+ * This program is free software: you can redistribute it and/or modify it under
1018+ * the terms of the GNU General Public License as published by the Free Software
1019+ * Foundation, either version 3 of the License, or (at your option) any later
1020+ * version.
1021+ *
1022+ * This program is distributed in the hope that it will be useful, but WITHOUT
1023+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1024+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1025+ * details.
1026+ *
1027+ * You should have received a copy of the GNU General Public License along with
1028+ * this program. If not, see <http://www.gnu.org/licenses/>.
1029+ */
1030+package l2r.features.auctionEngine.managers;
1031+
1032+import java.text.DateFormat;
1033+import java.text.DecimalFormat;
1034+import java.util.ArrayList;
1035+import java.util.Collections;
1036+import java.util.Comparator;
1037+import java.util.Date;
1038+import java.util.Iterator;
1039+import java.util.LinkedList;
1040+import java.util.List;
1041+import java.util.Locale;
1042+import java.util.Map;
1043+import java.util.Map.Entry;
1044+import java.util.StringTokenizer;
1045+import java.util.TreeMap;
1046+import java.util.concurrent.ConcurrentHashMap;
1047+
1048+import l2r.Config;
1049+import l2r.features.auctionEngine.house.managers.AuctionHouseGenerator;
1050+import l2r.features.auctionEngine.house.managers.holder.HouseItem;
1051+import l2r.features.auctionEngine.itemcontainer.AuctionHouseItem;
1052+import l2r.features.auctionEngine.templates.AuctionHouse;
1053+import l2r.gameserver.ThreadPoolManager;
1054+import l2r.gameserver.communitybbs.Managers.AuctionBBSManager;
1055+import l2r.gameserver.data.sql.CharNameTable;
1056+import l2r.gameserver.enums.ItemLocation;
1057+import l2r.gameserver.enums.PrivateStoreType;
1058+import l2r.gameserver.instancemanager.MailManager;
1059+import l2r.gameserver.model.Elementals;
1060+import l2r.gameserver.model.L2World;
1061+import l2r.gameserver.model.StatsSet;
1062+import l2r.gameserver.model.actor.instance.L2PcInstance;
1063+import l2r.gameserver.model.entity.Message;
1064+import l2r.gameserver.model.itemcontainer.Inventory;
1065+import l2r.gameserver.model.itemcontainer.ItemContainer;
1066+import l2r.gameserver.model.itemcontainer.Mail;
1067+import l2r.gameserver.model.items.instance.L2ItemInstance;
1068+import l2r.gameserver.model.items.type.CrystalType;
1069+import l2r.gameserver.network.SystemMessageId;
1070+import l2r.gameserver.network.serverpackets.InventoryUpdate;
1071+import l2r.gameserver.network.serverpackets.ItemList;
1072+import l2r.gameserver.network.serverpackets.ShowBoard;
1073+import l2r.gameserver.network.serverpackets.StatusUpdate;
1074+import l2r.gameserver.network.serverpackets.SystemMessage;
1075+import l2r.gameserver.util.Util;
1076+
1077+import org.slf4j.Logger;
1078+import org.slf4j.LoggerFactory;
1079+
1080+/**
1081+ * Manager for the Auction House This does all the needed functions, checks, etc
1082+ * @author GodFather
1083+ */
1084+public class AuctionHouseManager
1085+{
1086+ protected static final Logger _log = LoggerFactory.getLogger(AuctionHouseManager.class);
1087+
1088+ private static final DecimalFormat DECIMAL_FORMATTER = new DecimalFormat("#,##0");
1089+ private static final DateFormat DATE_FORMATTER = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT, new Locale("en", "US"));
1090+
1091+ public static final boolean NORMAL_WEAPON = false;
1092+ public static final boolean MAGICAL_WEAPON = true;
1093+
1094+ protected final Map<Integer, AuctionHouseEntrance> _entrancesById = new ConcurrentHashMap<>();
1095+ private final Map<String, List<Integer>> _entrancesByCategory = new TreeMap<>();
1096+
1097+ private final Map<Integer, AuctionHouseItem> _containersByCharId = new ConcurrentHashMap<>();
1098+
1099+ protected AuctionHouseManager()
1100+ {
1101+ AuctionHouse.generateEntrances(_entrancesById);
1102+
1103+ loadItems();
1104+ }
1105+
1106+ public void loadItems()
1107+ {
1108+ int itemCount = 0;
1109+ for (HouseItem auction : AuctionHouseGenerator.getInstance().loadItems())
1110+ {
1111+ if (!_containersByCharId.containsKey(auction.getOwnerId()))
1112+ {
1113+ AuctionHouseItem container = new AuctionHouseItem(auction.getOwnerId());
1114+ container.restore();
1115+ _containersByCharId.put(auction.getOwnerId(), container);
1116+ }
1117+
1118+ final L2ItemInstance item = (L2ItemInstance) L2World.getInstance().findObject(auction.getItemId());
1119+ if (item == null)
1120+ {
1121+ _log.error(getClass().getSimpleName() + ": The item (" + auction.getItemId() + ") doesnt exist in the auction. It exists in other location");
1122+ continue;
1123+ }
1124+
1125+ AuctionHouse entrance = AuctionHouse.getEntranceIdFromItem(item);
1126+ _entrancesById.get(entrance.getTopId()).addItem(new AuctionHouseEntranceItem(entrance.getTopId(), auction.getOwnerId(), item, auction.getCount(), auction.getSalePrice(), auction.getExpirationTime()));
1127+ itemCount++;
1128+ }
1129+
1130+ _log.info(getClass().getSimpleName() + ": Loaded " + itemCount + " items on sale in the Auction House");
1131+
1132+ for (AuctionHouseEntrance rank : _entrancesById.values())
1133+ {
1134+ if (!_entrancesByCategory.containsKey(rank.getCategory()))
1135+ {
1136+ _entrancesByCategory.put(rank.getCategory(), new ArrayList<Integer>());
1137+ }
1138+
1139+ _entrancesByCategory.get(rank.getCategory()).add(rank.getTopId());
1140+ }
1141+ }
1142+
1143+ public AuctionHouseEntrance getEntranceById(int topId)
1144+ {
1145+ return _entrancesById.get(topId);
1146+ }
1147+
1148+ public Map<Integer, AuctionHouseEntrance> getAllEntrances()
1149+ {
1150+ return _entrancesById;
1151+ }
1152+
1153+ public Map<String, List<Integer>> getEntranceByCategory()
1154+ {
1155+ return _entrancesByCategory;
1156+ }
1157+
1158+ public String processBypass(L2PcInstance activeChar, String command)
1159+ {
1160+ if (command.equals("" + AuctionBBSManager.getInstance().BBS_COMMAND + ""))
1161+ {
1162+ try
1163+ {
1164+ return makeServerAuctionsHtm(activeChar, -1, null);
1165+ }
1166+ catch (Exception e)
1167+ {
1168+ }
1169+ }
1170+ else if (command.startsWith("" + AuctionBBSManager.getInstance().BBS_COMMAND + ";server;"))
1171+ {
1172+ try
1173+ {
1174+ StringTokenizer st = new StringTokenizer(command, ";");
1175+ st.nextToken();
1176+ st.nextToken();
1177+ final int idTop = Integer.parseInt(st.nextToken());
1178+
1179+ return makeServerAuctionsHtm(activeChar, idTop, AuctionHouseGenerator.getInstance().processBypass(command));
1180+ }
1181+ catch (Exception e)
1182+ {
1183+ return makeServerAuctionsHtm(activeChar, -1, null);
1184+ }
1185+ }
1186+ else if (command.startsWith("" + AuctionBBSManager.getInstance().BBS_COMMAND + ";my"))
1187+ {
1188+ try
1189+ {
1190+ StringTokenizer st = new StringTokenizer(command, ";");
1191+ st.nextToken();
1192+ st.nextToken();
1193+
1194+ return makeMyAuctionsHtm(activeChar, AuctionHouseGenerator.getInstance().processBypass(command));
1195+ }
1196+ catch (Exception e)
1197+ {
1198+ return makeMyAuctionsHtm(activeChar, null);
1199+ }
1200+ }
1201+ else if (command.startsWith("" + AuctionBBSManager.getInstance().BBS_COMMAND + ";purchase;"))
1202+ {
1203+ try
1204+ {
1205+ StringTokenizer st = new StringTokenizer(command, ";");
1206+ st.nextToken();
1207+ st.nextToken();
1208+ final int idTop = Integer.parseInt(st.nextToken());
1209+
1210+ return makePurchaseHtm(activeChar, idTop, AuctionHouseGenerator.getInstance().processBypass(command));
1211+ }
1212+ catch (Exception e)
1213+ {
1214+ return makeServerAuctionsHtm(activeChar, -1, null);
1215+ }
1216+ }
1217+
1218+ return null;
1219+ }
1220+
1221+ public String makeServerAuctionsHtm(L2PcInstance activeChar, int topId, StatsSet set)
1222+ {
1223+ String content = AuctionHouseGenerator.getInstance().getServerAuctionHtml();
1224+ if (content == null)
1225+ {
1226+ return "<html><body><br><br><center>Auction House Server Html is missing!!!!!</center></body></html>";
1227+ }
1228+
1229+ final int MAX_ENTRANCES_PER_PAGE = 9;
1230+ final AuctionHouseEntrance top = getEntranceById(topId);
1231+ final String category = (set != null ? set.getString("category", null) : null);
1232+ final String rankSelected = (set != null ? set.getString("rank", "All") : "All");
1233+ String searchSelected = (set != null ? set.getString("search", null) : null);
1234+ if (searchSelected != null)
1235+ {
1236+ searchSelected = searchSelected.toLowerCase();
1237+ }
1238+ final String order = (set != null ? set.getString("order", "NameAsc") : "NameAsc");
1239+
1240+ final List<AuctionHouseEntranceItem> items = new ArrayList<>();
1241+ if (top != null)
1242+ {
1243+ final long currentTime = System.currentTimeMillis();
1244+ final Iterator<AuctionHouseEntranceItem> it = top.getItems().iterator();
1245+ AuctionHouseEntranceItem item;
1246+ while (it.hasNext())
1247+ {
1248+ item = it.next();
1249+ if (item == null)
1250+ {
1251+ continue;
1252+ }
1253+
1254+ if (item.isRemoved())
1255+ {
1256+ continue;
1257+ }
1258+
1259+ if (item.getEndTime() < currentTime)
1260+ {
1261+ returnItemToOwner(item);
1262+ continue;
1263+ }
1264+
1265+ switch (rankSelected)
1266+ {
1267+ case "NG":
1268+ if (item.getItemInstance().getItem().getCrystalType() != CrystalType.NONE)
1269+ {
1270+ continue;
1271+ }
1272+ break;
1273+ case "D":
1274+ if (item.getItemInstance().getItem().getCrystalType() != CrystalType.D)
1275+ {
1276+ continue;
1277+ }
1278+ break;
1279+ case "C":
1280+ if (item.getItemInstance().getItem().getCrystalType() != CrystalType.C)
1281+ {
1282+ continue;
1283+ }
1284+ break;
1285+ case "B":
1286+ if (item.getItemInstance().getItem().getCrystalType() != CrystalType.B)
1287+ {
1288+ continue;
1289+ }
1290+ break;
1291+ case "A":
1292+ if (item.getItemInstance().getItem().getCrystalType() != CrystalType.A)
1293+ {
1294+ continue;
1295+ }
1296+ break;
1297+ case "S":
1298+ if (item.getItemInstance().getItem().getCrystalType() != CrystalType.S)
1299+ {
1300+ continue;
1301+ }
1302+ break;
1303+ case "S80":
1304+ if (item.getItemInstance().getItem().getCrystalType() != CrystalType.S80)
1305+ {
1306+ continue;
1307+ }
1308+ break;
1309+ case "S84":
1310+ if (item.getItemInstance().getItem().getCrystalType() != CrystalType.S84)
1311+ {
1312+ continue;
1313+ }
1314+ break;
1315+ }
1316+
1317+ if ((searchSelected != null) && !item.getItemInstance().getItem().getName().toLowerCase().contains(searchSelected))
1318+ {
1319+ continue;
1320+ }
1321+
1322+ items.add(item);
1323+ }
1324+ }
1325+ else if ((category != null) && _entrancesByCategory.containsKey(category))
1326+ {
1327+ final long currentTime = System.currentTimeMillis();
1328+ AuctionHouseEntranceItem item;
1329+ for (int allTopId : _entrancesByCategory.get(category))
1330+ {
1331+ final Iterator<AuctionHouseEntranceItem> it = getEntranceById(allTopId).getItems().iterator();
1332+
1333+ while (it.hasNext())
1334+ {
1335+ item = it.next();
1336+ if (item == null)
1337+ {
1338+ continue;
1339+ }
1340+
1341+ if (item.isRemoved())
1342+ {
1343+ continue;
1344+ }
1345+
1346+ if (item.getEndTime() < currentTime)
1347+ {
1348+ returnItemToOwner(item);
1349+ continue;
1350+ }
1351+
1352+ switch (rankSelected)
1353+ {
1354+ case "NG":
1355+ if (item.getItemInstance().getItem().getCrystalType() != CrystalType.NONE)
1356+ {
1357+ continue;
1358+ }
1359+ break;
1360+ case "D":
1361+ if (item.getItemInstance().getItem().getCrystalType() != CrystalType.D)
1362+ {
1363+ continue;
1364+ }
1365+ break;
1366+ case "C":
1367+ if (item.getItemInstance().getItem().getCrystalType() != CrystalType.C)
1368+ {
1369+ continue;
1370+ }
1371+ break;
1372+ case "B":
1373+ if (item.getItemInstance().getItem().getCrystalType() != CrystalType.B)
1374+ {
1375+ continue;
1376+ }
1377+ break;
1378+ case "A":
1379+ if (item.getItemInstance().getItem().getCrystalType() != CrystalType.A)
1380+ {
1381+ continue;
1382+ }
1383+ break;
1384+ case "S":
1385+ if (item.getItemInstance().getItem().getCrystalType() != CrystalType.S)
1386+ {
1387+ continue;
1388+ }
1389+ break;
1390+ case "S80":
1391+ if (item.getItemInstance().getItem().getCrystalType() != CrystalType.S80)
1392+ {
1393+ continue;
1394+ }
1395+ break;
1396+ case "S84":
1397+ if (item.getItemInstance().getItem().getCrystalType() != CrystalType.S84)
1398+ {
1399+ continue;
1400+ }
1401+ break;
1402+ }
1403+
1404+ if ((searchSelected != null) && !item.getItemInstance().getItem().getName().toLowerCase().contains(searchSelected))
1405+ {
1406+ continue;
1407+ }
1408+
1409+ items.add(item);
1410+ }
1411+ }
1412+ }
1413+
1414+ if ((order != null) && !items.isEmpty())
1415+ {
1416+ switch (order)
1417+ {
1418+ case "NameAsc":
1419+ Collections.sort(items, NAME_ASC_COMPARATOR);
1420+ break;
1421+ case "NameDesc":
1422+ Collections.sort(items, NAME_DESC_COMPARATOR);
1423+ break;
1424+ case "RankAsc":
1425+ Collections.sort(items, RANK_ASC_COMPARATOR);
1426+ break;
1427+ case "RankDesc":
1428+ Collections.sort(items, RANK_DESC_COMPARATOR);
1429+ break;
1430+ case "CountAsc":
1431+ Collections.sort(items, COUNT_ASC_COMPARATOR);
1432+ break;
1433+ case "CountDesc":
1434+ Collections.sort(items, COUNT_DESC_COMPARATOR);
1435+ break;
1436+ case "PriceAsc":
1437+ Collections.sort(items, PRICE_ASC_COMPARATOR);
1438+ break;
1439+ case "PriceDesc":
1440+ Collections.sort(items, PRICE_DESC_COMPARATOR);
1441+ break;
1442+ }
1443+ }
1444+
1445+ final int entrancesSize = items.size();
1446+ final int maxPageN = (entrancesSize - 1) / MAX_ENTRANCES_PER_PAGE;
1447+ final StringBuilder valores = new StringBuilder();
1448+ boolean changeColor = false;
1449+
1450+ content = content.replace("%itemCount%", "<font color=8a7c62>(" + entrancesSize + ")</font>");
1451+
1452+ final int ITEMS_TABLE_WIDTH = 565;
1453+ final int currentPage = (set != null ? Math.min(maxPageN, set.getInt("page", 0)) : 0);
1454+ final int selectedItemId = (set != null ? set.getInt("selectedItemId", -1) : -1);
1455+ for (int i = currentPage * MAX_ENTRANCES_PER_PAGE; i < ((currentPage * MAX_ENTRANCES_PER_PAGE) + MAX_ENTRANCES_PER_PAGE); i++)
1456+ {
1457+ if (entrancesSize > i)
1458+ {
1459+ if (items.get(i).getCharId() == activeChar.getObjectId())
1460+ {
1461+ valores.append("<table width=" + ITEMS_TABLE_WIDTH + " height=36 cellspacing=-1 bgcolor=" + (changeColor ? "171612" : "23221e") + ">");
1462+ valores.append("<tr>");
1463+ valores.append("<td width=42 valign=top><img src=" + items.get(i).getItemInstance().getItem().getIcon() + " width=32 height=32></td>");
1464+ }
1465+ else if (items.get(i).getObjectId() == selectedItemId)
1466+ {
1467+ valores.append("<table width=" + ITEMS_TABLE_WIDTH + " height=36 cellspacing=-1 bgcolor=999a45>");
1468+ valores.append("<tr>");
1469+ valores.append("<td width=42 valign=top><img src=" + items.get(i).getItemInstance().getItem().getIcon() + " width=32 height=32></td>");
1470+ }
1471+ else
1472+ {
1473+ valores.append("<table width=" + ITEMS_TABLE_WIDTH + " height=36 cellspacing=-1 bgcolor=" + (changeColor ? "171612" : "23221e") + ">");
1474+ valores.append("<tr>");
1475+ valores.append("<td width=42 valign=top><button value=\"\" width=32 height=32 action=\"bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";server;" + topId + (category != null ? ";category" + category : "") + (order != null ? ";order" + order : "") + ";selectedItemId" + items.get(i).getObjectId() + ";page" + currentPage + ";rank " + rankSelected + (searchSelected != null ? ";search " + searchSelected : "") + "\" fore=" + items.get(i).getItemInstance().getItem().getIcon() + " back=" + items.get(i).getItemInstance().getItem().getIcon() + "></td>");
1476+ }
1477+
1478+ valores.append("<td fixwidth=250>" + getCompleteItemName(items.get(i).getItemInstance(), true, false) + "</td>");
1479+ valores.append("<td width=60 align=center>" + items.get(i).getItemInstance().getItem().getCrystalName() + "</td>");
1480+ valores.append("<td width=100 align=center>" + DECIMAL_FORMATTER.format(items.get(i).getQuantity()).replace(".", ",") + "</td>");
1481+ valores.append("<td width=130 align=center><font color=777978>" + DECIMAL_FORMATTER.format(items.get(i).getPrice()).replace(".", ",") + "</font></td>");
1482+ valores.append("<td width=10 align=right></td>");
1483+ valores.append("</tr>");
1484+ valores.append("</table>");
1485+ changeColor = !changeColor;
1486+ }
1487+ else
1488+ {
1489+ valores.append("<table width=" + ITEMS_TABLE_WIDTH + " height=36 cellspacing=-1 bgcolor=" + (changeColor ? "171612" : "23221e") + ">");
1490+ valores.append("<tr>");
1491+ valores.append("<td width=42><font color=" + (changeColor ? "151412" : "242320") + ">.</font></td>");
1492+ /**
1493+ * valores.append("<td width=250></td>"); valores.append("<td width=60></td>"); valores.append("<td width=100></td>"); valores.append("<td width=130></td>"); valores.append("<td width=10></td>");
1494+ */
1495+ valores.append("<td width=550></td>");
1496+
1497+ valores.append("</tr>");
1498+ valores.append("</table>");
1499+ changeColor = !changeColor;
1500+ }
1501+ }
1502+
1503+ final int initialPage = Math.max(0, currentPage - 10);
1504+ final int finalPage = Math.min(maxPageN, currentPage + 10);
1505+ valores.append("<table width=" + ITEMS_TABLE_WIDTH + " height=38 cellspacing=-1 bgcolor=" + (changeColor ? "171612" : "23221e") + ">");
1506+ valores.append("<tr>");
1507+ valores.append("<td width=" + ((ITEMS_TABLE_WIDTH - ((finalPage - initialPage) + ((finalPage - initialPage) * 30) + 40)) / 2) + " height=16></td>");
1508+ valores.append("<td width=20></td>");
1509+ for (int i = initialPage; i <= finalPage; i++)
1510+ {
1511+ if (i != initialPage)
1512+ {
1513+ valores.append("<td width=1></td>");
1514+ }
1515+
1516+ valores.append("<td width=30></td>");
1517+ }
1518+ valores.append("<td width=20></td>");
1519+ valores.append("<td width=" + ((ITEMS_TABLE_WIDTH - ((finalPage - initialPage) + ((finalPage - initialPage) * 30) + 40)) / 2) + "></td>");
1520+ valores.append("</tr>");
1521+ valores.append("<tr>");
1522+ if (currentPage > 0)
1523+ {
1524+ valores.append("<td fixheight=10 align=right><button value=\"\" width=16 height=16 action=\"bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";server;" + topId + (category != null ? ";category" + category : "") + (order != null ? ";order" + order : "") + ";page0;rank " + rankSelected + (searchSelected != null ? ";search " + searchSelected : "") + "\" fore=L2UI_CH3.shortcut_prev_down back=L2UI_CH3.shortcut_prev></td>");
1525+ valores.append("<td align=right><button value=\"\" width=16 height=16 action=\"bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";server;" + topId + (category != null ? ";category" + category : "") + (order != null ? ";order" + order : "") + ";page" + (currentPage - 1) + ";rank " + rankSelected + (searchSelected != null ? ";search " + searchSelected : "") + "\" fore=L2UI_CH3.shortcut_prev_down back=L2UI_CH3.shortcut_prev></td>");
1526+ }
1527+ else
1528+ {
1529+ valores.append("<td fixheight=10 align=right><button value=\"\" width=16 height=16 action=\"\" fore=L2UI_CH3.shortcut_prev back=L2UI_CH3.shortcut_prev></td>");
1530+ valores.append("<td align=right><button value=\"\" width=16 height=16 action=\"\" fore=L2UI_CH3.shortcut_prev back=L2UI_CH3.shortcut_prev></td>");
1531+ }
1532+ for (int i = initialPage; i <= finalPage; i++)
1533+ {
1534+ if (i != initialPage)
1535+ {
1536+ valores.append("<td align=center valign=middle><img src=L2UI.SquareGray width=1 height=12></td>");
1537+ }
1538+
1539+ if (i == currentPage)
1540+ {
1541+ valores.append("<td align=center valign=middle><font color=bab43e>" + (i + 1) + "</font></td>");
1542+ }
1543+ else
1544+ {
1545+ valores.append("<td align=center valign=middle>" + (i + 1) + "</td>");
1546+ }
1547+ }
1548+ if (currentPage < maxPageN)
1549+ {
1550+ valores.append("<td><button value=\"\" width=16 height=16 action=\"bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";server;" + topId + (category != null ? ";category" + category : "") + (order != null ? ";order" + order : "") + ";page" + (currentPage + 1) + ";rank " + rankSelected + (searchSelected != null ? ";search " + searchSelected : "") + "\" fore=L2UI_CH3.shortcut_next_down back=L2UI_CH3.shortcut_next_down></td>");
1551+ valores.append("<td><button value=\"\" width=16 height=16 action=\"bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";server;" + topId + (category != null ? ";category" + category : "") + (order != null ? ";order" + order : "") + ";page" + maxPageN + ";rank " + rankSelected + (searchSelected != null ? ";search " + searchSelected : "") + "\" fore=L2UI_CH3.shortcut_next_down back=L2UI_CH3.shortcut_next_down></td>");
1552+ }
1553+ else
1554+ {
1555+ valores.append("<td><button value=\"\" width=16 height=16 action=\"\" fore=L2UI_CH3.shortcut_next back=L2UI_CH3.shortcut_next></td>");
1556+ valores.append("<td><button value=\"\" width=16 height=16 action=\"\" fore=L2UI_CH3.shortcut_next back=L2UI_CH3.shortcut_next></td>");
1557+ }
1558+ valores.append("</tr>");
1559+ valores.append("</table>");
1560+
1561+ final String purchaseButtonName;
1562+ final String purchaseButtonAction;
1563+ if (selectedItemId >= 0)
1564+ {
1565+ purchaseButtonName = "Purchase";
1566+ purchaseButtonAction = "bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";purchase;" + topId + ";selectedItemId" + selectedItemId + (category != null ? ";category" + category : "") + (order != null ? ";order" + order : "") + ";page" + (currentPage + 1) + ";rank " + rankSelected + (searchSelected != null ? ";search " + searchSelected : "");
1567+ }
1568+ else
1569+ {
1570+ purchaseButtonName = "Purchase";
1571+ purchaseButtonAction = "";
1572+ }
1573+
1574+ final StringBuilder categorias = new StringBuilder();
1575+ int freeCategoryHeight = 382;
1576+
1577+ for (Entry<String, List<Integer>> tops : getEntranceByCategory().entrySet())
1578+ {
1579+ String catName = tops.getKey();
1580+ switch (catName)
1581+ {
1582+ case "Accesory":
1583+ catName += " ";
1584+ break;
1585+ case "Armor":
1586+ catName += " ";
1587+ break;
1588+ case "Etc":
1589+ catName += " ";
1590+ break;
1591+ case "Supplies":
1592+ catName += " ";
1593+ break;
1594+ case "Weapon":
1595+ catName += " ";
1596+ break;
1597+ }
1598+
1599+ if (((top != null) && tops.getKey().equalsIgnoreCase(top.getCategory())) || ((category != null) && tops.getKey().equalsIgnoreCase(category)))
1600+ {
1601+ categorias.append("<tr>");
1602+ categorias.append("<td fixwidth=10 fixheight=10 valign=top><button value=\"\" width=16 height=16 action=\"bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";server;-1\" fore=L2UI_CH3.QuestWndMinusBtn back=L2UI_CH3.QuestWndMinusBtn></td>");
1603+ if ((category != null) && category.equalsIgnoreCase(tops.getKey()))
1604+ {
1605+ categorias.append("<td width=140 valign=top><button value=\"" + catName + "\" width=60 height=13 action=\"\" fore=\"\" back=\"\"></td>");
1606+ }
1607+ else
1608+ {
1609+ categorias.append("<td width=140 valign=top><button value=\"" + catName + "\" width=60 height=13 action=\"bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";server;-1;category" + tops.getKey() + ";rank " + rankSelected + (searchSelected != null ? ";search " + searchSelected : "") + "\" fore=\"\" back=\"\"></td>");
1610+ }
1611+ categorias.append("</tr>");
1612+
1613+ freeCategoryHeight -= 38;
1614+
1615+ for (Integer rankId : tops.getValue())
1616+ {
1617+ categorias.append("<tr>");
1618+ categorias.append("<td></td>");
1619+ categorias.append("<td>");
1620+ categorias.append("<table width=140 cellspacing=0 bgcolor=" + (topId == rankId ? "726c42" : (changeColor ? "171612" : "23221e")) + ">");
1621+ categorias.append("<tr>");
1622+ if (topId == rankId)
1623+ {
1624+ categorias.append("<td fixheight=13><button value=\"" + getEntranceById(rankId).getTopName() + "\" width=140 height=13 action=\"\" fore=\"\" back=\"\"></td>");
1625+ }
1626+ else
1627+ {
1628+ categorias.append("<td fixheight=13><button value=\"" + getEntranceById(rankId).getTopName() + "\" width=140 height=13 action=\"bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";server;" + rankId + ";rank " + rankSelected + (searchSelected != null ? ";search " + searchSelected : "") + "\" fore=\"\" back=\"\"></td>");
1629+ }
1630+ categorias.append("</tr>");
1631+ categorias.append("<tr>");
1632+ categorias.append("<td fixheight=2></td>");
1633+ categorias.append("</tr>");
1634+ categorias.append("</table>");
1635+ categorias.append("</td>");
1636+ categorias.append("</tr>");
1637+ changeColor = !changeColor;
1638+
1639+ freeCategoryHeight -= 15;
1640+ }
1641+
1642+ categorias.append("<tr>");
1643+ categorias.append("<td fixheight=2></td>");
1644+ categorias.append("<td></td>");
1645+ categorias.append("</tr>");
1646+
1647+ freeCategoryHeight -= 2;
1648+ }
1649+ else
1650+ {
1651+ categorias.append("<tr>");
1652+ categorias.append("<td fixwidth=10 fixheight=10 valign=top><button value=\"\" width=16 height=16 action=\"bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";server;-1;category" + tops.getKey() + ";rank " + rankSelected + (searchSelected != null ? ";search " + searchSelected : "") + "\" fore=L2UI_CH3.QuestWndPlusBtn back=L2UI_CH3.QuestWndPlusBtn></td>");
1653+ if ((category != null) && category.equalsIgnoreCase(tops.getKey()))
1654+ {
1655+ categorias.append("<td width=140 valign=top><button value=\"" + catName + "\" width=60 height=13 action=\"\" fore=\"\" back=\"\"></td>");
1656+ }
1657+ else
1658+ {
1659+ categorias.append("<td width=140 valign=top><button value=\"" + catName + "\" width=60 height=13 action=\"bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";server;-1;category" + tops.getKey() + ";rank " + rankSelected + (searchSelected != null ? ";search " + searchSelected : "") + "\" fore=\"\" back=\"\"></td>");
1660+ }
1661+ categorias.append("</tr>");
1662+
1663+ if ((top == null) && (category == null))
1664+ {
1665+ freeCategoryHeight -= 19;
1666+ }
1667+ else
1668+ {
1669+ freeCategoryHeight -= 16;
1670+ }
1671+ }
1672+ }
1673+
1674+ categorias.append("<tr>");
1675+ categorias.append("<td height=" + Math.min(382 - (getEntranceByCategory().size() * 19) - 2, freeCategoryHeight) + "></td>");
1676+ categorias.append("<td></td>");
1677+ categorias.append("</tr>");
1678+
1679+ final String searchButtonAction = "bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";server;" + topId + (category != null ? ";category" + category : "") + ";rank " + rankSelected + " ;search $search";
1680+
1681+ final String applyButtonAction = "bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";server;" + topId + (category != null ? ";category" + category : "") + ";rank $rank " + (searchSelected != null ? ";search " + searchSelected : "");
1682+
1683+ final String refreshButtonAction = "bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";server;" + topId + (category != null ? ";category" + category : "") + (order != null ? ";order" + order : "") + ";page" + currentPage + ";rank " + rankSelected + (searchSelected != null ? ";search " + searchSelected : "");
1684+
1685+ final String itemOrderAction = "bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";server;" + topId + (category != null ? ";category" + category : "") + ((order == null) || order.equalsIgnoreCase("NameDesc") ? ";orderNameAsc" : ";orderNameDesc") + ";page" + currentPage + ";rank " + rankSelected + (searchSelected != null ? ";search " + searchSelected : "");
1686+ final String rankOrderAction = "bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";server;" + topId + (category != null ? ";category" + category : "") + ((order == null) || order.equalsIgnoreCase("RankDesc") ? ";orderRankAsc" : ";orderRankDesc") + ";page" + currentPage + ";rank " + rankSelected + (searchSelected != null ? ";search " + searchSelected : "");
1687+ final String countOrderAction = "bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";server;" + topId + (category != null ? ";category" + category : "") + ((order == null) || order.equalsIgnoreCase("CountDesc") ? ";orderCountAsc" : ";orderCountDesc") + ";page" + currentPage + ";rank " + rankSelected + (searchSelected != null ? ";search " + searchSelected : "");
1688+ final String priceOrderAction = "bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";server;" + topId + (category != null ? ";category" + category : "") + ((order == null) || order.equalsIgnoreCase("PriceDesc") ? ";orderPriceAsc" : ";orderPriceDesc") + ";page" + currentPage + ";rank " + rankSelected + (searchSelected != null ? ";search " + searchSelected : "");
1689+
1690+ content = content.replace("%selectedGrade%", rankSelected);
1691+ content = content.replace("%categorias%", categorias.toString());
1692+ content = content.replace("%tablas%", valores.toString());
1693+ content = content.replace("%adenaCount%", "\"" + DECIMAL_FORMATTER.format(activeChar.getInventory().getAdena()).replace(".", ",") + "\"");
1694+ content = content.replace("%applyButtonAction%", applyButtonAction);
1695+ content = content.replace("%searchButtonAction%", searchButtonAction);
1696+ content = content.replace("%refreshButtonAction%", refreshButtonAction);
1697+ content = content.replace("%purchaseButtonName%", purchaseButtonName);
1698+ content = content.replace("%purchaseButtonAction%", purchaseButtonAction);
1699+ content = content.replace("%itemOrderAction%", itemOrderAction);
1700+ content = content.replace("%rankOrderAction%", rankOrderAction);
1701+ content = content.replace("%countOrderAction%", countOrderAction);
1702+ content = content.replace("%priceOrderAction%", priceOrderAction);
1703+ content = content.replace("%bbsCommand%", AuctionBBSManager.getInstance().BBS_COMMAND);
1704+ return content;
1705+ }
1706+
1707+ public String makePurchaseHtm(L2PcInstance activeChar, int topId, StatsSet set) throws Exception
1708+ {
1709+ String content = AuctionHouseGenerator.getInstance().getPurchaseHtml();
1710+ if (content == null)
1711+ {
1712+ return "<html><body><br><br><center>Auction House Purchase Html is missing!!!!!</center></body></html>";
1713+ }
1714+
1715+ if (set == null)
1716+ {
1717+ throw new Exception();
1718+ }
1719+
1720+ final int selectedItemId = set.getInt("selectedItemId", -1);
1721+ if (selectedItemId < 1)
1722+ {
1723+ throw new Exception();
1724+ }
1725+
1726+ final String category = set.getString("category", null);
1727+ AuctionHouseEntranceItem item = null;
1728+
1729+ if ((category != null) && _entrancesByCategory.containsKey(category))
1730+ {
1731+ boolean isFound = false;
1732+ for (int allTopId : _entrancesByCategory.get(category))
1733+ {
1734+ for (AuctionHouseEntranceItem items : getEntranceById(allTopId).getItems())
1735+ {
1736+ if (items.getObjectId() == selectedItemId)
1737+ {
1738+ item = items;
1739+ isFound = true;
1740+ break;
1741+ }
1742+ }
1743+ if (isFound)
1744+ {
1745+ break;
1746+ }
1747+ }
1748+ }
1749+ else
1750+ {
1751+ final AuctionHouseEntrance top = getEntranceById(topId);
1752+ if (top == null)
1753+ {
1754+ throw new Exception();
1755+ }
1756+
1757+ for (AuctionHouseEntranceItem items : top.getItems())
1758+ {
1759+ if (items.getObjectId() == selectedItemId)
1760+ {
1761+ item = items;
1762+ break;
1763+ }
1764+ }
1765+ }
1766+
1767+ if ((item == null) || (item.getQuantity() < 1) || (item.getItemInstance() == null) || item.isRemoved())
1768+ {
1769+ throw new Exception();
1770+ }
1771+
1772+ final String rankSelected = set.getString("rank", "All");
1773+ final String searchSelected = set.getString("search", null);
1774+ final String order = set.getString("order", null);
1775+ final int page = set.getInt("page", 0);
1776+ final boolean isStackable = item.getItemInstance().isStackable();
1777+ final int purchaseCount = Math.min(item.getQuantity(), set.getInt("purchaseCount", 1));
1778+
1779+ if (set.getBoolean("confirm", false))
1780+ {
1781+ purchaseItem(activeChar, set, item, purchaseCount);
1782+ return makeServerAuctionsHtm(activeChar, topId, set);
1783+ }
1784+
1785+ final String purchaseButtonName;
1786+ final String purchaseButtonAction;
1787+ final String cancelButtonName;
1788+ final String cancelButtonAction;
1789+ if (set.getBoolean("apply", false))
1790+ {
1791+ purchaseButtonName = "Confirm Purchase";
1792+ purchaseButtonAction = "bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";purchase;" + topId + (category != null ? ";category" + category : "") + (order != null ? ";order" + order : "") + ";confirm;selectedItemId" + selectedItemId + ";purchaseCount " + purchaseCount + ";page" + page + ";rank " + rankSelected + (searchSelected != null ? ";search " + searchSelected : "");
1793+ cancelButtonName = "Edit Purchase";
1794+ cancelButtonAction = "bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";purchase;" + topId + (category != null ? ";category" + category : "") + (order != null ? ";order" + order : "") + ";selectedItemId" + selectedItemId + ";page" + page + ";rank " + rankSelected + (searchSelected != null ? ";search " + searchSelected : "");
1795+ }
1796+ else
1797+ {
1798+ purchaseButtonName = "Apply";
1799+ if (!isStackable || (item.getQuantity() == 1))
1800+ {
1801+ purchaseButtonAction = "bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";purchase;" + topId + (category != null ? ";category" + category : "") + (order != null ? ";order" + order : "") + ";apply;selectedItemId" + selectedItemId + ";purchaseCount 1;page" + page + ";rank " + rankSelected + (searchSelected != null ? ";search " + searchSelected : "");
1802+ }
1803+ else
1804+ {
1805+ purchaseButtonAction = "bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";purchase;" + topId + (category != null ? ";category" + category : "") + (order != null ? ";order" + order : "") + ";apply;selectedItemId" + selectedItemId + ";purchaseCount $quantity ;page" + page + ";rank " + rankSelected + (searchSelected != null ? ";search " + searchSelected : "");
1806+ }
1807+ cancelButtonName = "Cancel Purchase";
1808+ cancelButtonAction = "bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";server;" + topId + (category != null ? ";category" + category : "") + ";selectedItemId" + selectedItemId + ";page" + page + ";rank " + rankSelected + (searchSelected != null ? ";search " + searchSelected : "");
1809+ }
1810+
1811+ final StringBuilder itemSelected = new StringBuilder();
1812+ itemSelected.append("<tr>");
1813+ itemSelected.append("<td width=35 valign=middle><img src=" + item.getItemInstance().getItem().getIcon() + " width=32 height=32></td>");
1814+ itemSelected.append("<td width=5></td>");
1815+ itemSelected.append("<td fixwidth=225 align=center>" + getCompleteItemName(item.getItemInstance(), true, false) + (item.getQuantity() > 1 ? " X" + item.getQuantity() : "") + "</td>");
1816+ itemSelected.append("</tr>");
1817+
1818+ final String quantity;
1819+ final String salePrice;
1820+ final String totalPrice;
1821+
1822+ if (set.getBoolean("apply", false))
1823+ {
1824+ quantity = "<button value=\"" + DECIMAL_FORMATTER.format(purchaseCount).replace(".", ",") + "\" width=160 height=20 action=\"\" fore=L2UI_CT1.Windows_DF_TooltipBG back=L2UI_CT1.Windows_DF_TooltipBG>";
1825+ salePrice = DECIMAL_FORMATTER.format(item.getPrice()).replace(".", ",");
1826+ totalPrice = DECIMAL_FORMATTER.format(purchaseCount * item.getPrice()).replace(".", ",");
1827+ }
1828+ else
1829+ {
1830+ if (!isStackable || (item.getQuantity() == 1))
1831+ {
1832+ quantity = "<button value=\"1\" width=160 height=20 action=\"\" fore=L2UI_CT1.Windows_DF_TooltipBG back=L2UI_CT1.Windows_DF_TooltipBG>";
1833+ }
1834+ else
1835+ {
1836+ quantity = "<edit var=quantity width=160 height=10>";
1837+ }
1838+ salePrice = DECIMAL_FORMATTER.format(item.getPrice()).replace(".", ",");
1839+ totalPrice = DECIMAL_FORMATTER.format(item.getPrice()).replace(".", ",");
1840+ }
1841+
1842+ final String itemName = getCompleteItemName(item.getItemInstance(), true, true);
1843+ final String sellerName = CharNameTable.getInstance().getNameById(item.getCharId());
1844+
1845+ final String itemGrade;
1846+ switch (item.getItemInstance().getItem().getCrystalType())
1847+ {
1848+ case D:
1849+ itemGrade = "<td fixwidth=16 fixheight=16><img src=L2UI_CT1.Icon_DF_ItemGrade_D width=16 height=16></td>";
1850+ break;
1851+ case C:
1852+ itemGrade = "<td fixwidth=16 fixheight=16><img src=L2UI_CT1.Icon_DF_ItemGrade_C width=16 height=16></td>";
1853+ break;
1854+ case B:
1855+ itemGrade = "<td fixwidth=16 fixheight=16><img src=L2UI_CT1.Icon_DF_ItemGrade_B width=16 height=16></td>";
1856+ break;
1857+ case A:
1858+ itemGrade = "<td fixwidth=16 fixheight=16><img src=L2UI_CT1.Icon_DF_ItemGrade_A width=16 height=16></td>";
1859+ break;
1860+ case S:
1861+ itemGrade = "<td fixwidth=16 fixheight=16><img src=L2UI_CT1.Icon_DF_ItemGrade_S width=16 height=16></td>";
1862+ break;
1863+ case S80:
1864+ itemGrade = "<td fixwidth=16 fixheight=16><img src=L2UI_CT1.Icon_DF_ItemGrade_S width=16 height=16></td><td fixwidth=16 fixheight=16><img src=L2UI_CT1.Icon_DF_ItemGrade_80 width=16 height=16></td>";
1865+ break;
1866+ case S84:
1867+ itemGrade = "<td fixwidth=16 fixheight=16><img src=L2UI_CT1.Icon_DF_ItemGrade_S width=16 height=16></td><td fixwidth=16 fixheight=16><img src=L2UI_CT1.Icon_DF_ItemGrade_84 width=16 height=16></td>";
1868+ break;
1869+ default:
1870+ itemGrade = "<td></td>";
1871+ break;
1872+ }
1873+
1874+ final String itemStats;
1875+ if (item.getItemInstance().isWeapon())
1876+ {
1877+ itemStats = "<tr><td height=25 align=center><font color=888a89>P. Atk:</font> <font color=a09675>" + (int) item.getItemInstance().getItem().getValueFromStatFunc(activeChar, item.getItemInstance(), "pAtk", "0x08") + "</font></td></tr>" + "<tr><td height=25 align=center><font color=888a89>M. Atk:</font> <font color=a09675>" + (int) item.getItemInstance().getItem().getValueFromStatFunc(activeChar, item.getItemInstance(), "mAtk", "0x08") + "</font></td></tr>";
1878+ }
1879+ else if (item.getItemInstance().getItem().isJewel())
1880+ {
1881+ itemStats = "<tr><td height=25 align=center><font color=888a89>M. Def:</font> <font color=a09675>" + (int) item.getItemInstance().getItem().getValueFromStatFunc(activeChar, item.getItemInstance(), "mDef", "0x10") + "</font></td></tr>";
1882+ }
1883+ else if (item.getItemInstance().isArmor())
1884+ {
1885+ itemStats = "<tr><td height=25 align=center><font color=888a89>P. Def:</font> <font color=a09675>" + (int) item.getItemInstance().getItem().getValueFromStatFunc(activeChar, item.getItemInstance(), "pDef", "0x10") + "</font></td></tr>";
1886+ }
1887+ else
1888+ {
1889+ itemStats = "";
1890+ }
1891+
1892+ final StringBuilder itemElements = new StringBuilder();
1893+ if (item.getItemInstance().getAttackElementPower() > 0)
1894+ {
1895+ itemElements.append("<tr><td height=20 align=center>");
1896+ itemElements.append(Elementals.getElementName(item.getItemInstance().getAttackElementType()) + " P. Atk " + item.getItemInstance().getAttackElementPower());
1897+ itemElements.append("</td></tr>");
1898+ itemElements.append("<tr><td height=10 align=center>");
1899+ switch (item.getItemInstance().getAttackElementType())
1900+ {
1901+ case Elementals.WATER:
1902+ itemElements.append("<img src=L2UI_CT1.Gauge_DF_Attribute_Water width=100 height=8>");
1903+ break;
1904+ case Elementals.DARK:
1905+ itemElements.append("<img src=L2UI_CT1.Gauge_DF_Attribute_Dark width=100 height=8>");
1906+ break;
1907+ case Elementals.EARTH:
1908+ itemElements.append("<img src=L2UI_CT1.Gauge_DF_Attribute_Earth width=100 height=8>");
1909+ break;
1910+ case Elementals.FIRE:
1911+ itemElements.append("<img src=L2UI_CT1.Gauge_DF_Attribute_Fire width=100 height=8>");
1912+ break;
1913+ case Elementals.HOLY:
1914+ itemElements.append("<img src=L2UI_CT1.Gauge_DF_Attribute_Divine width=100 height=8>");
1915+ break;
1916+ case Elementals.WIND:
1917+ itemElements.append("<img src=L2UI_CT1.Gauge_DF_Attribute_Wind width=100 height=8>");
1918+ break;
1919+ }
1920+ itemElements.append("</td></tr>");
1921+ itemElements.append("<tr><td height=5></td></tr>");
1922+ }
1923+ for (byte i = 0; i < 6; i++)
1924+ {
1925+ if (item.getItemInstance().getElementDefAttr(i) > 0)
1926+ {
1927+ itemElements.append("<tr><td height=20 align=center>");
1928+ itemElements.append(Elementals.getElementName(i) + " P. Def " + item.getItemInstance().getElementDefAttr(i));
1929+ itemElements.append("</td></tr>");
1930+ itemElements.append("<tr><td height=10 align=center>");
1931+ switch (i)
1932+ {
1933+ case Elementals.WATER:
1934+ itemElements.append("<img src=L2UI_CT1.Gauge_DF_Attribute_Water width=100 height=8>");
1935+ break;
1936+ case Elementals.DARK:
1937+ itemElements.append("<img src=L2UI_CT1.Gauge_DF_Attribute_Dark width=100 height=8>");
1938+ break;
1939+ case Elementals.EARTH:
1940+ itemElements.append("<img src=L2UI_CT1.Gauge_DF_Attribute_Earth width=100 height=8>");
1941+ break;
1942+ case Elementals.FIRE:
1943+ itemElements.append("<img src=L2UI_CT1.Gauge_DF_Attribute_Fire width=100 height=8>");
1944+ break;
1945+ case Elementals.HOLY:
1946+ itemElements.append("<img src=L2UI_CT1.Gauge_DF_Attribute_Divine width=100 height=8>");
1947+ break;
1948+ case Elementals.WIND:
1949+ itemElements.append("<img src=L2UI_CT1.Gauge_DF_Attribute_Wind width=100 height=8>");
1950+ break;
1951+ }
1952+ itemElements.append("</td></tr>");
1953+ itemElements.append("<tr><td height=5></td></tr>");
1954+ }
1955+ }
1956+
1957+ content = content.replace("%itemSelected%", itemSelected.toString());
1958+ content = content.replace("%adenaCount%", DECIMAL_FORMATTER.format(activeChar.getInventory().getAdena()).replace(".", ","));
1959+ content = content.replace("%cancelButtonName%", cancelButtonName);
1960+ content = content.replace("%cancelButtonAction%", cancelButtonAction);
1961+ content = content.replace("%purchaseButtonName%", purchaseButtonName);
1962+ content = content.replace("%purchaseButtonAction%", purchaseButtonAction);
1963+ content = content.replace("%quantity%", quantity);
1964+ content = content.replace("%salePrice%", salePrice);
1965+ content = content.replace("%totalPrice%", totalPrice);
1966+ content = content.replace("%itemName%", itemName);
1967+ content = content.replace("%itemGrade%", itemGrade);
1968+ content = content.replace("%sellerName%", (sellerName != null ? sellerName : ""));
1969+ content = content.replace("%itemStats%", itemStats);
1970+ content = content.replace("%itemElements%", itemElements.toString());
1971+ return content;
1972+ }
1973+
1974+ public String makeMyAuctionsHtm(L2PcInstance activeChar, StatsSet set)
1975+ {
1976+ String content = AuctionHouseGenerator.getInstance().getMyAuctionHtml();
1977+ if (content == null)
1978+ {
1979+ return "<html><body><br><br><center>Auction House Player Html is missing!!!!!</center></body></html>";
1980+ }
1981+
1982+ if ((set != null) && set.getBoolean("create", false))
1983+ {
1984+ createNewAuction(activeChar, set);
1985+ }
1986+ else if ((set != null) && (set.getInt("cancelConfirm", -1) >= 0))
1987+ {
1988+ cancelAuction(activeChar, set);
1989+ }
1990+
1991+ final int MAX_ITEMS_PER_LINE = 5;
1992+ final StringBuilder valores = new StringBuilder();
1993+ boolean changeColor = false;
1994+
1995+ final List<AuctionHouseEntranceItem> items = new ArrayList<>();
1996+ for (AuctionHouseEntrance entrance : getAllEntrances().values())
1997+ {
1998+ for (AuctionHouseEntranceItem item : entrance.getItems())
1999+ {
2000+ if ((item != null) && (item.getCharId() == activeChar.getObjectId()) && !item.isRemoved())
2001+ {
2002+ items.add(item);
2003+ }
2004+ }
2005+ }
2006+
2007+ content = content.replace("%itemCount%", "<font color=8a7c62>(" + items.size() + "/10)</font>");
2008+
2009+ final int selectedAuction = (set != null ? set.getInt("selectedAuction", -1) : -1);
2010+ for (int i = 0; i < 10; i++)
2011+ {
2012+ if (items.size() > i)
2013+ {
2014+ if (items.get(i).getObjectId() == selectedAuction)
2015+ {
2016+ valores.append("<table height=36 cellspacing=-1 bgcolor=999a45>");
2017+ valores.append("<tr>");
2018+ valores.append("<td width=38 valign=middle><img src=" + items.get(i).getItemInstance().getItem().getIcon() + " width=32 height=32></td>");
2019+ }
2020+ else
2021+ {
2022+ valores.append("<table height=36 valign=middle cellspacing=-1 bgcolor=" + (changeColor ? "171612" : "23221e") + ">");
2023+ valores.append("<tr>");
2024+ valores.append("<td width=38 valign=middle><button value=\"\" width=32 height=32 action=\"bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";my;selectedAuction" + items.get(i).getObjectId() + "\" fore=" + items.get(i).getItemInstance().getItem().getIcon() + " back=" + items.get(i).getItemInstance().getItem().getIcon() + "></td>");
2025+ }
2026+ valores.append("<td fixwidth=192>" + getCompleteItemName(items.get(i).getItemInstance(), false, true) + "</td>");
2027+ valores.append("<td width=60 align=center>" + items.get(i).getItemInstance().getItem().getCrystalName() + "</td>");
2028+ valores.append("<td width=80 align=center>" + DECIMAL_FORMATTER.format(items.get(i).getQuantity()).replace(".", ",") + "</td>");
2029+ valores.append("<td width=100 align=center>" + DECIMAL_FORMATTER.format(items.get(i).getPrice()).replace(".", ",") + "</td>");
2030+ valores.append("<td width=80 align=center>" + items.get(i).getRemainingTimeString() + "</td>");
2031+ valores.append("</tr>");
2032+ valores.append("</table>");
2033+ changeColor = !changeColor;
2034+ }
2035+ else
2036+ {
2037+ valores.append("<table height=36 cellspacing=-1 bgcolor=" + (changeColor ? "171612" : "23221e") + ">");
2038+ valores.append("<tr>");
2039+ valores.append("<td width=38><font color=" + (changeColor ? "151412" : "242320") + ">.</font></td>");
2040+ valores.append("<td width=192></td>");
2041+ valores.append("<td width=60></td>");
2042+ valores.append("<td width=80></td>");
2043+ valores.append("<td width=100></td>");
2044+ valores.append("<td width=80></td>");
2045+ valores.append("</tr>");
2046+ valores.append("</table>");
2047+ changeColor = !changeColor;
2048+ }
2049+ }
2050+
2051+ final String cancelButtonName;
2052+ final String cancelButtonAction;
2053+ if (selectedAuction >= 0)
2054+ {
2055+ if ((set != null) && (set.getInt("cancel", -1) >= 0))
2056+ {
2057+ cancelButtonName = "Confirm Cancel";
2058+ cancelButtonAction = "bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";my;cancelConfirm" + selectedAuction;
2059+ }
2060+ else
2061+ {
2062+ cancelButtonName = "Cancel Auction";
2063+ cancelButtonAction = "bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";my;selectedAuction" + selectedAuction + ";cancel" + selectedAuction;
2064+ }
2065+ }
2066+ else
2067+ {
2068+ cancelButtonName = "Cancel Auction";
2069+ cancelButtonAction = "";
2070+ }
2071+
2072+ final StringBuilder inventario = new StringBuilder();
2073+
2074+ final List<L2ItemInstance> sellList = new ArrayList<>();
2075+ for (L2ItemInstance item : activeChar.getInventory().getItems())
2076+ {
2077+ if (!item.isEquipped() && item.isSellable() && item.isTradeable() && (item.getId() != Inventory.ADENA_ID) && ((activeChar.getSummon() == null) || (item.getObjectId() != activeChar.getSummon().getControlObjectId())))
2078+ {
2079+ sellList.add(item);
2080+ }
2081+ }
2082+
2083+ final int maxPage = (int) Math.ceil((double) sellList.size() / MAX_ITEMS_PER_LINE) - 3;
2084+ int selectedQuantity = (set != null ? set.getInt("quantity", 0) : 0);
2085+ int selectedItemId = (set != null ? set.getInt("itemId", 0) : 0);
2086+ long selectedSalePrice = (set != null ? set.getLong("saleprice", 0) : 0);
2087+ int currentPage = (set != null ? Math.min(maxPage, set.getInt("page", -1)) : -1);
2088+ int selectedItemIndex = 0;
2089+ String itemName = "";
2090+ String itemIcon = "<img src=\"\" width=32 height=32>";
2091+ long itemCount = 1;
2092+ boolean isStackable = false;
2093+
2094+ if ((currentPage > -1) && ((currentPage * MAX_ITEMS_PER_LINE) <= sellList.size()) && (selectedItemId < 1))
2095+ {
2096+ selectedItemIndex = currentPage * MAX_ITEMS_PER_LINE;
2097+ itemIcon = "<img src=" + sellList.get(selectedItemIndex).getItem().getIcon() + " width=32 height=32>";
2098+ itemName = getCompleteItemName(sellList.get(selectedItemIndex), true, false);
2099+ itemCount = sellList.get(selectedItemIndex).getCount();
2100+ isStackable = sellList.get(selectedItemIndex).isStackable();
2101+ selectedItemId = sellList.get(selectedItemIndex).getObjectId();
2102+
2103+ if (selectedQuantity > itemCount)
2104+ {
2105+ selectedQuantity = (int) itemCount;
2106+ }
2107+
2108+ if (selectedSalePrice < (sellList.get(selectedItemIndex).getReferencePrice() / 2))
2109+ {
2110+ selectedSalePrice = sellList.get(selectedItemIndex).getReferencePrice() / 2;
2111+ }
2112+ }
2113+ else
2114+ {
2115+ for (int i = 0; i < sellList.size(); i++)
2116+ {
2117+ if ((selectedItemId == 0) || (sellList.get(i).getObjectId() == selectedItemId))
2118+ {
2119+ selectedItemIndex = i;
2120+ itemIcon = "<img src=" + sellList.get(i).getItem().getIcon() + " width=32 height=32>";
2121+ itemName = getCompleteItemName(sellList.get(i), true, false);
2122+ itemCount = sellList.get(i).getCount();
2123+ isStackable = sellList.get(i).isStackable();
2124+ if ((currentPage < 0) || ((currentPage * MAX_ITEMS_PER_LINE) > sellList.size()))
2125+ {
2126+ currentPage = Math.max(0, Math.min(maxPage, i / MAX_ITEMS_PER_LINE));
2127+ }
2128+ selectedItemId = sellList.get(i).getObjectId();
2129+
2130+ if (selectedQuantity > itemCount)
2131+ {
2132+ selectedQuantity = (int) itemCount;
2133+ }
2134+
2135+ if (selectedSalePrice < (sellList.get(i).getReferencePrice() / 2))
2136+ {
2137+ selectedSalePrice = sellList.get(i).getReferencePrice() / 2;
2138+ }
2139+ break;
2140+ }
2141+ }
2142+ }
2143+ if (currentPage < 0)
2144+ {
2145+ currentPage = 0;
2146+ }
2147+
2148+ final int startIndex = currentPage * MAX_ITEMS_PER_LINE;
2149+ for (int i = startIndex; i < sellList.size(); i++)
2150+ {
2151+ if ((i - startIndex) >= (MAX_ITEMS_PER_LINE * 3))
2152+ {
2153+ break;
2154+ }
2155+
2156+ if ((i % MAX_ITEMS_PER_LINE) == 0)
2157+ {
2158+ inventario.append("<tr>");
2159+ }
2160+
2161+ inventario.append("<td fixwidth=42 height=42 valign=top>");
2162+ if (i == selectedItemIndex)
2163+ {
2164+ inventario.append("<table width=42 height=42 cellpadding=5 cellspacing=0 background=BranchSys.br_icon_limited><tr><td align=center valign=middle>");
2165+ inventario.append("<button value=\"\" width=32 height=32 action=\"\" fore=" + sellList.get(i).getItem().getIcon() + " back=" + sellList.get(i).getItem().getIcon() + ">");
2166+ inventario.append("</td></tr></table>");
2167+ }
2168+ else
2169+ {
2170+ inventario.append("<table width=42 height=42 cellpadding=5 cellspacing=0><tr><td align=center valign=middle>");
2171+ inventario.append("<button value=\"\" width=32 height=32 action=\"bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";my;itemId" + sellList.get(i).getObjectId() + ";page" + currentPage + "\" fore=" + sellList.get(i).getItem().getIcon() + " back=" + sellList.get(i).getItem().getIcon() + ">");
2172+ inventario.append("</td></tr></table>");
2173+ }
2174+ inventario.append("</td>");
2175+
2176+ if ((i + 1) == sellList.size())
2177+ {
2178+ for (int z = 0; z < Math.round(MAX_ITEMS_PER_LINE - (i % MAX_ITEMS_PER_LINE) - 1); z++)
2179+ {
2180+ inventario.append("<td fixwidth=42 height=42 valign=top><button value=\"\" width=32 height=32 action=\"\" fore=\"\" back=\"\"></td>");
2181+ }
2182+ }
2183+
2184+ if ((((i + 1) % MAX_ITEMS_PER_LINE) == 0) || ((i - startIndex) >= (MAX_ITEMS_PER_LINE * 3)))
2185+ {
2186+ inventario.append("</tr>");
2187+ }
2188+
2189+ if ((i + 1) == sellList.size())
2190+ {
2191+ if (sellList.size() <= MAX_ITEMS_PER_LINE)
2192+ {
2193+ inventario.append("<tr>");
2194+ inventario.append("<td fixwidth=42 height=42 valign=top></td>");
2195+ inventario.append("</tr>");
2196+ inventario.append("<tr>");
2197+ inventario.append("<td fixwidth=42 height=42 valign=top></td>");
2198+ inventario.append("</tr>");
2199+ }
2200+ else if (sellList.size() <= (MAX_ITEMS_PER_LINE * 2))
2201+ {
2202+ inventario.append("<tr>");
2203+ inventario.append("<td fixwidth=42 height=42 valign=top></td>");
2204+ inventario.append("</tr>");
2205+ }
2206+ }
2207+ }
2208+
2209+ final StringBuilder flechasInventario = new StringBuilder();
2210+ flechasInventario.append("<table cellpadding=-2 cellspacing=3>");
2211+ flechasInventario.append("<tr>");
2212+ flechasInventario.append("<td width=4></td>");
2213+ if (currentPage < 1)
2214+ {
2215+ flechasInventario.append("<td fixheight=16><button value=\"\" width=16 height=16 action=\"\" fore=L2UI_CH3.joypad_shortcut back=L2UI_CH3.joypad_shortcut></td>");
2216+ }
2217+ else
2218+ {
2219+ flechasInventario.append("<td fixheight=16><button value=\"\" width=16 height=16 action=\"bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";my;page0" + (selectedItemId > 0 ? ";itemId" + selectedItemId : "") + "\" fore=L2UI_CH3.joypad_shortcut_over back=L2UI_CH3.joypad_shortcut_over></td>");
2220+ }
2221+ flechasInventario.append("</tr>");
2222+ flechasInventario.append("<tr>");
2223+ flechasInventario.append("<td></td>");
2224+ if (currentPage < 1)
2225+ {
2226+ flechasInventario.append("<td fixheight=16><button value=\"\" width=16 height=16 action=\"\" fore=L2UI_CH3.shortcut_nextv back=L2UI_CH3.shortcut_nextv></td>");
2227+ }
2228+ else
2229+ {
2230+ flechasInventario.append("<td fixheight=16><button value=\"\" width=16 height=16 action=\"bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";my;page" + (currentPage - 1) + (selectedItemId > 0 ? ";itemId" + selectedItemId : "") + "\" fore=L2UI_CH3.shortcut_nextv_over back=L2UI_CH3.shortcut_nextv_over></td>");
2231+ }
2232+ flechasInventario.append("</tr>");
2233+ flechasInventario.append("<tr>");
2234+ flechasInventario.append("<td></td>");
2235+ flechasInventario.append("<td height=58></td>");
2236+ flechasInventario.append("</tr>");
2237+ flechasInventario.append("<tr>");
2238+ flechasInventario.append("<td></td>");
2239+ if (currentPage >= maxPage)
2240+ {
2241+ flechasInventario.append("<td fixheight=16><button value=\"\" width=16 height=16 action=\"\" fore=L2UI_CH3.shortcut_prevv back=L2UI_CH3.shortcut_prevv></td>");
2242+ }
2243+ else
2244+ {
2245+ flechasInventario.append("<td fixheight=16><button value=\"\" width=16 height=16 action=\"bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";my;page" + (currentPage + 1) + (selectedItemId > 0 ? ";itemId" + selectedItemId : "") + "\" fore=L2UI_CH3.shortcut_prevv_over back=L2UI_CH3.shortcut_prevv_over></td>");
2246+ }
2247+ flechasInventario.append("</tr>");
2248+ flechasInventario.append("<tr>");
2249+ flechasInventario.append("<td></td>");
2250+ if (currentPage >= maxPage)
2251+ {
2252+ flechasInventario.append("<td fixheight=16><button value=\"\" width=16 height=16 action=\"\" fore=L2UI_CH3.joypad_shortcut back=L2UI_CH3.joypad_shortcut></td>");
2253+ }
2254+ else
2255+ {
2256+ flechasInventario.append("<td fixheight=16><button value=\"\" width=16 height=16 action=\"bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";my;page" + maxPage + (selectedItemId > 0 ? ";itemId" + selectedItemId : "") + "\" fore=L2UI_CH3.joypad_shortcut_over back=L2UI_CH3.joypad_shortcut_over></td>");
2257+ }
2258+ flechasInventario.append("</tr>");
2259+ flechasInventario.append("</table>");
2260+
2261+ final StringBuilder itemSelected = new StringBuilder();
2262+ itemSelected.append("<tr>");
2263+ itemSelected.append("<td><table width=60 height=48 cellpadding=7 cellspacing=0 background=L2UI_ct1.ShortcutWnd_DF_Select><tr><td align=center valign=middle>" + itemIcon + "</td></tr></table></td>");
2264+ itemSelected.append("<td width=5></td>");
2265+ itemSelected.append("<td fixwidth=120>" + itemName + (itemCount > 1 ? " X" + itemCount : "") + "</td>");
2266+ itemSelected.append("</tr>");
2267+
2268+ final String auctionButtonName;
2269+ final String auctionButtonAction;
2270+ final String quantity;
2271+ final String salePrice;
2272+ final String duration;
2273+ final String totalPrice;
2274+ final String saleFee;
2275+
2276+ if ((selectedItemId > 0) && (set != null) && set.getBoolean("apply", false))
2277+ {
2278+ auctionButtonName = "Auction Item";
2279+ auctionButtonAction = "bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";my;itemId" + selectedItemId + ";create;quantity " + selectedQuantity + " ;saleprice " + selectedSalePrice + " ;duration " + set.getLong("duration", 1);
2280+
2281+ quantity = "<button value=\"" + DECIMAL_FORMATTER.format(selectedQuantity).replace(".", ",") + "\" width=120 height=20 action=\"\" fore=L2UI_CT1.Windows_DF_TooltipBG back=L2UI_CT1.Windows_DF_TooltipBG>";
2282+ salePrice = "<button value=\"" + DECIMAL_FORMATTER.format(selectedSalePrice).replace(".", ",") + "\" width=120 height=20 action=\"\" fore=L2UI_CT1.Windows_DF_TooltipBG back=L2UI_CT1.Windows_DF_TooltipBG>";
2283+ duration = "<button value=\"" + set.getInt("duration", 1) + " day(s)\" width=120 height=20 action=\"\" fore=L2UI_CT1.Windows_DF_TooltipBG back=L2UI_CT1.Windows_DF_TooltipBG>";
2284+ totalPrice = DECIMAL_FORMATTER.format(selectedQuantity * selectedSalePrice).replace(".", ",");
2285+
2286+ saleFee = DECIMAL_FORMATTER.format(Math.max(10000, selectedQuantity * selectedSalePrice * set.getInt("duration", 1) * Config.AUCTION_HOUSE_SALE_FEE)).replace(".", ",");
2287+ }
2288+ else if (selectedItemId > 0)
2289+ {
2290+ auctionButtonName = "Apply";
2291+
2292+ if (!isStackable || (itemCount == 1))
2293+ {
2294+ auctionButtonAction = "bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";my;itemId" + selectedItemId + ";apply;quantity 1 ;saleprice $saleprice ;duration $duration";
2295+ quantity = "<button value=\"1\" width=120 height=20 action=\"\" fore=L2UI_CT1.Windows_DF_TooltipBG back=L2UI_CT1.Windows_DF_TooltipBG>";
2296+ }
2297+ else
2298+ {
2299+ auctionButtonAction = "bypass " + AuctionBBSManager.getInstance().BBS_COMMAND + ";my;itemId" + selectedItemId + ";apply;quantity $quantity ;saleprice $saleprice ;duration $duration";
2300+ quantity = "<edit var=quantity width=120 height=10>";
2301+ }
2302+ salePrice = "<edit var=saleprice width=120 height=10>";
2303+ duration = "<combobox width=120 height=10 var=duration list=\"1 day(s);2 day(s);3 day(s);4 day(s);5 day(s);6 day(s);7 day(s);8 day(s);9 day(s)\">";
2304+ totalPrice = "0";
2305+ saleFee = "10,000";
2306+ }
2307+ else
2308+ {
2309+ auctionButtonName = "Auction Item";
2310+ auctionButtonAction = "";
2311+ quantity = "<edit var=quantity width=120 height=10>";
2312+ salePrice = "<edit var=saleprice width=120 height=10>";
2313+ duration = "<combobox width=120 height=10 var=duration list=\"1 day(s);2 day(s);3 day(s);4 day(s);5 day(s);6 day(s);7 day(s);8 day(s);9 day(s)\">";
2314+ totalPrice = "0";
2315+ saleFee = "10,000";
2316+ }
2317+
2318+ content = content.replace("%inventario%", inventario.toString());
2319+ content = content.replace("%inventarioFlechas%", flechasInventario.toString());
2320+ content = content.replace("%itemSelected%", itemSelected.toString());
2321+ content = content.replace("%tablas%", valores.toString());
2322+ content = content.replace("%adenaCount%", DECIMAL_FORMATTER.format(activeChar.getInventory().getAdena()).replace(".", ","));
2323+ content = content.replace("%auctionButtonName%", auctionButtonName);
2324+ content = content.replace("%auctionButtonAction%", auctionButtonAction);
2325+ content = content.replace("%cancelButtonName%", cancelButtonName);
2326+ content = content.replace("%cancelButtonAction%", cancelButtonAction);
2327+ content = content.replace("%quantity%", quantity);
2328+ content = content.replace("%salePrice%", salePrice);
2329+ content = content.replace("%duration%", duration);
2330+ content = content.replace("%totalPrice%", totalPrice);
2331+ content = content.replace("%saleFee%", saleFee);
2332+ content = content.replace("%bbsCommand%", AuctionBBSManager.getInstance().BBS_COMMAND);
2333+ return content;
2334+ }
2335+
2336+ private synchronized void createNewAuction(L2PcInstance activeChar, StatsSet set)
2337+ {
2338+ if (!activeChar.getClient().getFloodProtectors().getTransaction().tryPerformAction("createAuction"))
2339+ {
2340+ return;
2341+ }
2342+
2343+ if (!activeChar.getAccessLevel().allowTransaction())
2344+ {
2345+ activeChar.sendMessage("Transactions are disabled for your Access Level");
2346+ return;
2347+ }
2348+
2349+ if (activeChar.getActiveTradeList() != null)
2350+ {
2351+ activeChar.sendMessage("You cant create an auction while having an active exchange");
2352+ return;
2353+ }
2354+
2355+ if (activeChar.isEnchanting())
2356+ {
2357+ activeChar.sendMessage("You cant create an auction while enchanting");
2358+ return;
2359+ }
2360+
2361+ if (activeChar.getPrivateStoreType() != PrivateStoreType.NONE)
2362+ {
2363+ activeChar.sendMessage("You cant create an auction while in Private Store");
2364+ return;
2365+ }
2366+
2367+ if (activeChar.isJailed())
2368+ {
2369+ activeChar.sendMessage("You cant create an auction while in Jail");
2370+ return;
2371+ }
2372+
2373+ if (activeChar.isTeleporting() || activeChar.isCastingNow() || activeChar.isAttackingNow())
2374+ {
2375+ activeChar.sendMessage("You cant create an auction while casting/attacking");
2376+ return;
2377+ }
2378+
2379+ final int itemId = set.getInt("itemId", 0);
2380+ if (itemId < 1)
2381+ {
2382+ return;
2383+ }
2384+
2385+ final int quantity = set.getInt("quantity", 0);
2386+ if ((quantity < 1) || (quantity > 1000000))
2387+ {
2388+ activeChar.sendMessage("Wrong Auction Item Quantity");
2389+ return;
2390+ }
2391+
2392+ final long salePrice = set.getLong("saleprice", 0);
2393+ if ((salePrice < 1) || (salePrice > 10000000000L))
2394+ {
2395+ activeChar.sendMessage("Wrong Auction Sale Price");
2396+ return;
2397+ }
2398+
2399+ final int duration = set.getInt("duration", 1);
2400+ if ((duration < 1) || (duration > 9))
2401+ {
2402+ activeChar.sendMessage("Wrong Auction Duration");
2403+ return;
2404+ }
2405+
2406+ final long saleFee = (long) Math.max(10000, quantity * salePrice * duration * Config.AUCTION_HOUSE_SALE_FEE);
2407+ if (activeChar.getAdena() < saleFee)
2408+ {
2409+ activeChar.sendMessage("Not enough adena to pay the Auction Fee");
2410+ return;
2411+ }
2412+
2413+ final L2ItemInstance item = activeChar.checkItemManipulation(itemId, quantity, "Auction");
2414+ if ((item == null) || !item.isSellable() || !item.isTradeable() || item.isEquipped())
2415+ {
2416+ activeChar.sendMessage("Not a valid item for Auction");
2417+ return;
2418+ }
2419+
2420+ synchronized (_entrancesById)
2421+ {
2422+ int auctionedItemsN = 0;
2423+ for (AuctionHouseEntrance entrance : _entrancesById.values())
2424+ {
2425+ for (AuctionHouseEntranceItem it : entrance.getItems())
2426+ {
2427+ if (it.getObjectId() == item.getObjectId())
2428+ {
2429+ activeChar.sendMessage("This item is already in auction");
2430+ return;
2431+ }
2432+
2433+ if (it.getCharId() == activeChar.getObjectId())
2434+ {
2435+ auctionedItemsN++;
2436+
2437+ // Stackables items can only be made once sold, because they share the objectId as stacked. So there can only be a sale of a stackable
2438+ if (item.isStackable() && (it.getItemInstance().getId() == item.getId()))
2439+ {
2440+ activeChar.sendMessage("You cannot auction this item because its an stackable item and its already in auction by you");
2441+ activeChar.sendMessage("If you still want to auction this item, you must cancel your sale first");
2442+ return;
2443+ }
2444+ }
2445+ }
2446+ }
2447+
2448+ if (auctionedItemsN >= 10)
2449+ {
2450+ activeChar.sendMessage("You can only have 10 auctions maximum at the same time");
2451+ return;
2452+ }
2453+
2454+ if (!activeChar.reduceAdena("Auction", saleFee, null, true))
2455+ {
2456+ activeChar.sendMessage("Not enough adena to pay the Auction Fee");
2457+ return;
2458+ }
2459+
2460+ final AuctionHouseItem container;
2461+ if (!_containersByCharId.containsKey(activeChar.getObjectId()))
2462+ {
2463+ container = new AuctionHouseItem(activeChar.getObjectId());
2464+ _containersByCharId.put(activeChar.getObjectId(), container);
2465+ }
2466+ else
2467+ {
2468+ container = _containersByCharId.get(activeChar.getObjectId());
2469+ }
2470+
2471+ final L2ItemInstance newItem = activeChar.getInventory().transferItem("AuctionHouse", itemId, quantity, container, activeChar, "AuctionHouse");
2472+ if (newItem == null)
2473+ {
2474+ activeChar.sendMessage("An error has ocurred while recieving your item. Please report to a Game Master");
2475+ _log.warn("Error recieving item for auction house of " + activeChar.getName() + " (newitem == null)");
2476+ return;
2477+ }
2478+ newItem.setItemLocation(container.getBaseLocation());
2479+
2480+ final InventoryUpdate playerIU = Config.FORCE_INVENTORY_UPDATE ? null : new InventoryUpdate();
2481+ if (playerIU != null)
2482+ {
2483+ if ((item.getCount() > 0) && (item != newItem))
2484+ {
2485+ playerIU.addModifiedItem(item);
2486+ }
2487+ else
2488+ {
2489+ playerIU.addRemovedItem(item);
2490+ }
2491+ }
2492+
2493+ if (playerIU != null)
2494+ {
2495+ activeChar.sendPacket(playerIU);
2496+ }
2497+ else
2498+ {
2499+ activeChar.sendPacket(new ItemList(activeChar, false));
2500+ }
2501+
2502+ final StatusUpdate su = new StatusUpdate(activeChar);
2503+ su.addAttribute(StatusUpdate.CUR_LOAD, activeChar.getCurrentLoad());
2504+ activeChar.sendPacket(su);
2505+
2506+ addNewAuctionToDB(activeChar, newItem, quantity, salePrice, duration);
2507+ }
2508+ }
2509+
2510+ private synchronized void cancelAuction(L2PcInstance activeChar, StatsSet set)
2511+ {
2512+ if (!activeChar.getClient().getFloodProtectors().getTransaction().tryPerformAction("cancelAuction"))
2513+ {
2514+ return;
2515+ }
2516+
2517+ if (!activeChar.getAccessLevel().allowTransaction())
2518+ {
2519+ activeChar.sendMessage("Transactions are disabled for your Access Level");
2520+ return;
2521+ }
2522+
2523+ if (activeChar.getActiveTradeList() != null)
2524+ {
2525+ activeChar.sendMessage("You cant cancel an auction while having an active exchange");
2526+ return;
2527+ }
2528+
2529+ if (activeChar.isEnchanting())
2530+ {
2531+ activeChar.sendMessage("You cant cancel an auction while enchanting");
2532+ return;
2533+ }
2534+
2535+ if (activeChar.getPrivateStoreType() != PrivateStoreType.NONE)
2536+ {
2537+ activeChar.sendMessage("You cant cancel an auction while in Private Store");
2538+ return;
2539+ }
2540+
2541+ if (activeChar.isJailed())
2542+ {
2543+ activeChar.sendMessage("You cant cancel an auction while in Jail");
2544+ return;
2545+ }
2546+
2547+ if (activeChar.isTeleporting() || activeChar.isCastingNow() || activeChar.isAttackingNow())
2548+ {
2549+ activeChar.sendMessage("You cant cancel an auction while casting/attacking");
2550+ return;
2551+ }
2552+
2553+ synchronized (_entrancesById)
2554+ {
2555+ final int cancelObjectId = set.getInt("cancelConfirm", -1);
2556+ for (AuctionHouseEntrance entrance : _entrancesById.values())
2557+ {
2558+ for (AuctionHouseEntranceItem item : entrance.getItems())
2559+ {
2560+ if (item.getCharId() != activeChar.getObjectId())
2561+ {
2562+ continue;
2563+ }
2564+
2565+ if (item.getObjectId() != cancelObjectId)
2566+ {
2567+ continue;
2568+ }
2569+
2570+ final ItemContainer container = _containersByCharId.get(activeChar.getObjectId());
2571+ if ((container == null) || (container.getSize() == 0))
2572+ {
2573+ activeChar.sendMessage("You cant cancel this auction. Something is missing");
2574+ return;
2575+ }
2576+
2577+ if (item.getItemInstance().getOwnerId() != activeChar.getObjectId())
2578+ {
2579+ Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to get not own item from cancelled attachment!", Config.DEFAULT_PUNISH);
2580+ return;
2581+ }
2582+
2583+ if (item.getItemInstance().getItemLocation() != ItemLocation.AUCTION)
2584+ {
2585+ Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to get items not from mail !", Config.DEFAULT_PUNISH);
2586+ return;
2587+ }
2588+
2589+ final long weight = item.getItemInstance().getCount() * item.getItemInstance().getItem().getWeight();
2590+ int slots = 0;
2591+ if (!item.getItemInstance().isStackable())
2592+ {
2593+ slots += item.getItemInstance().getCount();
2594+ }
2595+ else if (activeChar.getInventory().getItemByItemId(item.getItemInstance().getId()) == null)
2596+ {
2597+ slots++;
2598+ }
2599+
2600+ if (!activeChar.getInventory().validateCapacity(slots))
2601+ {
2602+ activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANT_CANCEL_INVENTORY_FULL));
2603+ return;
2604+ }
2605+
2606+ if (!activeChar.getInventory().validateWeight(weight))
2607+ {
2608+ activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANT_CANCEL_INVENTORY_FULL));
2609+ return;
2610+ }
2611+
2612+ final InventoryUpdate playerIU = Config.FORCE_INVENTORY_UPDATE ? null : new InventoryUpdate();
2613+
2614+ final long count = item.getItemInstance().getCount();
2615+ final L2ItemInstance newItem = container.transferItem(container.getName(), item.getObjectId(), count, activeChar.getInventory(), activeChar, null);
2616+ if (newItem == null)
2617+ {
2618+ activeChar.sendMessage("You cant cancel this auction. Something is wrong. Report to a Game Master");
2619+ return;
2620+ }
2621+
2622+ if (playerIU != null)
2623+ {
2624+ if (newItem.getCount() > count)
2625+ {
2626+ playerIU.addModifiedItem(newItem);
2627+ }
2628+ else
2629+ {
2630+ playerIU.addNewItem(newItem);
2631+ }
2632+ }
2633+
2634+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_ACQUIRED_S2_S1);
2635+ sm.addItemName(item.getItemInstance().getId());
2636+ sm.addLong(count);
2637+ activeChar.sendPacket(sm);
2638+
2639+ if (playerIU != null)
2640+ {
2641+ activeChar.sendPacket(playerIU);
2642+ }
2643+ else
2644+ {
2645+ activeChar.sendPacket(new ItemList(activeChar, false));
2646+ }
2647+
2648+ final StatusUpdate su = new StatusUpdate(activeChar);
2649+ su.addAttribute(StatusUpdate.CUR_LOAD, activeChar.getCurrentLoad());
2650+ activeChar.sendPacket(su);
2651+
2652+ modifyAuctionItemCountToDB(item, -1);
2653+
2654+ activeChar.sendMessage("Auction cancelled succesfully");
2655+
2656+ set.set("itemId", 0);
2657+ set.set("page", 0);
2658+ return;
2659+ }
2660+ }
2661+ }
2662+
2663+ activeChar.sendMessage("The selected auction couldn't be cancelled");
2664+ }
2665+
2666+ private synchronized void purchaseItem(L2PcInstance activeChar, StatsSet set, AuctionHouseEntranceItem item, int purchaseCount)
2667+ {
2668+ if (item == null)
2669+ {
2670+ activeChar.sendMessage("The selected auction couldn't be purchased");
2671+ return;
2672+ }
2673+
2674+ if (!activeChar.getClient().getFloodProtectors().getTransaction().tryPerformAction("purchaseItem"))
2675+ {
2676+ return;
2677+ }
2678+
2679+ if (!activeChar.getAccessLevel().allowTransaction())
2680+ {
2681+ activeChar.sendMessage("Transactions are disabled for your Access Level");
2682+ return;
2683+ }
2684+
2685+ if (activeChar.getActiveTradeList() != null)
2686+ {
2687+ activeChar.sendMessage("You cant purchase an item while having an active exchange");
2688+ return;
2689+ }
2690+
2691+ if (activeChar.isEnchanting())
2692+ {
2693+ activeChar.sendMessage("You cant purchase an item while while enchanting");
2694+ return;
2695+ }
2696+
2697+ if (activeChar.getPrivateStoreType() != PrivateStoreType.NONE)
2698+ {
2699+ activeChar.sendMessage("You cant purchase an item while in Private Store");
2700+ return;
2701+ }
2702+
2703+ if (activeChar.isJailed())
2704+ {
2705+ activeChar.sendMessage("You cant purchase an item while in Jail");
2706+ return;
2707+ }
2708+
2709+ if (activeChar.isTeleporting() || activeChar.isCastingNow() || activeChar.isAttackingNow())
2710+ {
2711+ activeChar.sendMessage("You cant purchase an item while casting/attacking");
2712+ return;
2713+ }
2714+
2715+ synchronized (_entrancesById)
2716+ {
2717+ if (item.getCharId() == activeChar.getObjectId())
2718+ {
2719+ activeChar.sendMessage("You cant purchase your own items!");
2720+ return;
2721+ }
2722+
2723+ final int purchaseObjectId = set.getInt("selectedItemId", -1);
2724+ if (item.getObjectId() != purchaseObjectId)
2725+ {
2726+ activeChar.sendMessage("Invalid item");
2727+ return;
2728+ }
2729+
2730+ final ItemContainer container = _containersByCharId.get(item.getCharId());
2731+ if ((container == null) || (container.getSize() == 0))
2732+ {
2733+ activeChar.sendMessage("You cant purchase this item. Something is missing");
2734+ return;
2735+ }
2736+
2737+ if (item.getItemInstance().getItemLocation() != ItemLocation.AUCTION)
2738+ {
2739+ Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to get items not from mail !", Config.DEFAULT_PUNISH);
2740+ return;
2741+ }
2742+
2743+ if (activeChar.getAdena() < (item.getPrice() * purchaseCount))
2744+ {
2745+ activeChar.sendMessage("Not enough adena to purchase this item");
2746+ return;
2747+ }
2748+
2749+ final long weight = purchaseCount * item.getItemInstance().getItem().getWeight();
2750+ int slots = 0;
2751+ if (!item.getItemInstance().isStackable())
2752+ {
2753+ slots += purchaseCount;
2754+ }
2755+ else if (activeChar.getInventory().getItemByItemId(item.getItemInstance().getId()) == null)
2756+ {
2757+ slots++;
2758+ }
2759+
2760+ if (!activeChar.getInventory().validateCapacity(slots))
2761+ {
2762+ activeChar.sendMessage("You cant purchase this item. You dont have enough slots");
2763+ return;
2764+ }
2765+
2766+ if (!activeChar.getInventory().validateWeight(weight))
2767+ {
2768+ activeChar.sendMessage("You cant purchase this item. You dont have enough weight available");
2769+ return;
2770+ }
2771+
2772+ if (!activeChar.reduceAdena("AuctionHouse", item.getPrice() * purchaseCount, null, true))
2773+ {
2774+ activeChar.sendMessage("Not enough adena to purchase this item");
2775+ return;
2776+ }
2777+
2778+ final InventoryUpdate playerIU = Config.FORCE_INVENTORY_UPDATE ? null : new InventoryUpdate();
2779+ final L2ItemInstance newItem = container.transferItem(container.getName(), item.getObjectId(), purchaseCount, activeChar.getInventory(), activeChar, null);
2780+ if (newItem == null)
2781+ {
2782+ activeChar.sendMessage("You cant purchase this item. Something is wrong. Report to a Game Master");
2783+ return;
2784+ }
2785+
2786+ if (playerIU != null)
2787+ {
2788+ if (newItem.getCount() > purchaseCount)
2789+ {
2790+ playerIU.addModifiedItem(newItem);
2791+ }
2792+ else
2793+ {
2794+ playerIU.addNewItem(newItem);
2795+ }
2796+ }
2797+
2798+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_ACQUIRED_S2_S1);
2799+ sm.addItemName(item.getItemInstance().getId());
2800+ sm.addLong(purchaseCount);
2801+ activeChar.sendPacket(sm);
2802+
2803+ if (playerIU != null)
2804+ {
2805+ activeChar.sendPacket(playerIU);
2806+ }
2807+ else
2808+ {
2809+ activeChar.sendPacket(new ItemList(activeChar, false));
2810+ }
2811+
2812+ final StatusUpdate su = new StatusUpdate(activeChar);
2813+ su.addAttribute(StatusUpdate.CUR_LOAD, activeChar.getCurrentLoad());
2814+ activeChar.sendPacket(su);
2815+
2816+ final String message = "The player " + activeChar.getName() + " has bought " + item.getItemInstance().getItem().getName() + "\nQuantity: " + DECIMAL_FORMATTER.format(purchaseCount).replace(".", ",") + "\nTotal: " + DECIMAL_FORMATTER.format(item.getPrice() * purchaseCount).replace(".", ",") + " Adena" + "\nDate: " + DATE_FORMATTER.format(new Date(System.currentTimeMillis())) + "\n\nThanks for using our Auction House system";
2817+ Message msg = new Message(item.getCharId(), "Auction House Sell", message, Message.SendBySystem.NONE);
2818+ Mail attachments = msg.createAttachments();
2819+ attachments.addItem("AuctionHouse", Inventory.ADENA_ID, item.getPrice() * purchaseCount, null, null);
2820+ MailManager.getInstance().sendMessage(msg);
2821+
2822+ modifyAuctionItemCountToDB(item, item.getQuantity() - purchaseCount);
2823+
2824+ activeChar.sendMessage("You have succesfully purchased " + newItem.getItem().getName());
2825+ }
2826+ }
2827+
2828+ private synchronized void returnItemToOwner(AuctionHouseEntranceItem item)
2829+ {
2830+ if (item.isRemoved())
2831+ {
2832+ return;
2833+ }
2834+
2835+ item.setIsRemoved(true);
2836+
2837+ final ItemContainer container = _containersByCharId.get(item.getCharId());
2838+ if ((container == null) || (container.getSize() == 0))
2839+ {
2840+ return;
2841+ }
2842+
2843+ if (item.getItemInstance().getItemLocation() != ItemLocation.AUCTION)
2844+ {
2845+ _log.warn(getClass().getSimpleName() + ": The item " + item.getObjectId() + " that is being returned to the owner doesnt belong to the auction house");
2846+ return;
2847+ }
2848+
2849+ ThreadPoolManager.getInstance().scheduleGeneral(new ReturnItemsToOwnerThread(container, item), 100);
2850+ }
2851+
2852+ private class ReturnItemsToOwnerThread implements Runnable
2853+ {
2854+ private final ItemContainer _container;
2855+ private final AuctionHouseEntranceItem _item;
2856+
2857+ public ReturnItemsToOwnerThread(ItemContainer container, AuctionHouseEntranceItem item)
2858+ {
2859+ _container = container;
2860+ _item = item;
2861+ }
2862+
2863+ @Override
2864+ public void run()
2865+ {
2866+ synchronized (_entrancesById)
2867+ {
2868+ final String message = "Your item couldn't be sold on the set period, so it's now returning to you\nThanks for using our Auction House system";
2869+ final Message msg = new Message(_item.getCharId(), "Auction House Return", message, Message.SendBySystem.NONE);
2870+ final Mail attachments = msg.createAttachments();
2871+ final L2ItemInstance newItem = _container.transferItem("AuctionHouse", _item.getObjectId(), _item.getQuantity(), attachments, null, null);
2872+ if (newItem == null)
2873+ {
2874+ _log.warn(getClass().getSimpleName() + ": Error adding attachment item " + _item.getObjectId() + " for char " + _item.getCharId() + " (newitem == null)");
2875+ return;
2876+ }
2877+ newItem.setItemLocation(newItem.getItemLocation(), msg.getId());
2878+
2879+ MailManager.getInstance().sendMessage(msg);
2880+
2881+ modifyAuctionItemCountToDB(_item, -1);
2882+ }
2883+ }
2884+ }
2885+
2886+ private void addNewAuctionToDB(L2PcInstance activeChar, L2ItemInstance item, int quantity, long salePrice, int duration)
2887+ {
2888+ final AuctionHouse entrance = AuctionHouse.getEntranceIdFromItem(item);
2889+ final AuctionHouseEntranceItem newItem = new AuctionHouseEntranceItem(entrance.getTopId(), activeChar.getObjectId(), item, quantity, salePrice, System.currentTimeMillis() + (duration * 24 * 60 * 60 * 1000));
2890+ _entrancesById.get(entrance.getTopId()).addItem(newItem);
2891+
2892+ AuctionHouseGenerator.getInstance().addNewAuctionToDB(newItem.getObjectId(), newItem.getCharId(), newItem.getQuantity(), newItem.getPrice(), newItem.getEndTime());
2893+ }
2894+
2895+ protected void modifyAuctionItemCountToDB(AuctionHouseEntranceItem item, int newCount)
2896+ {
2897+ item.setQuantity(newCount);
2898+
2899+ if (item.getQuantity() <= 0)
2900+ {
2901+ _entrancesById.get(item.getTopId()).getItems().remove(item);
2902+
2903+ AuctionHouseGenerator.getInstance().deleteItemFromDB(item.getObjectId());
2904+ }
2905+ else
2906+ {
2907+ AuctionHouseGenerator.getInstance().updateItemCountToDB(item.getObjectId(), item.getQuantity());
2908+ }
2909+ }
2910+
2911+ private String getCompleteItemName(L2ItemInstance item, boolean showCompleteInfo, boolean showIcons)
2912+ {
2913+ if (showIcons)
2914+ {
2915+ final StringBuilder builder = new StringBuilder();
2916+
2917+ if (item.getEnchantLevel() > 0)
2918+ {
2919+ builder.append("<font color=a09675>+" + item.getEnchantLevel() + "</font> ");
2920+ }
2921+
2922+ final String[] parts = item.getItem().getName().split(" - ");
2923+ if (parts.length > 2)
2924+ {
2925+ builder.append("<font color=fcf900>" + parts[0] + " - " + parts[1] + "</font> <font color=d3aa4e>" + parts[2] + "</font> ");
2926+ }
2927+ else if (parts.length > 1)
2928+ {
2929+ builder.append(parts[0] + " <font color=d3aa4e>" + parts[1] + "</font> ");
2930+ }
2931+ else
2932+ {
2933+ builder.append(parts[0] + " ");
2934+ }
2935+
2936+ return builder.toString();
2937+ }
2938+
2939+ if (showCompleteInfo)
2940+ {
2941+ final StringBuilder builder = new StringBuilder();
2942+
2943+ if (item.getEnchantLevel() > 0)
2944+ {
2945+ builder.append("<font color=a09675>+" + item.getEnchantLevel() + "</font> ");
2946+ }
2947+
2948+ final String[] parts = item.getItem().getName().split(" - ");
2949+ if (parts.length > 2)
2950+ {
2951+ builder.append("<font color=fcf900>" + parts[0] + " - " + parts[1] + "</font> <font color=d3aa4e>" + parts[2] + "</font> ");
2952+ }
2953+ else if (parts.length > 1)
2954+ {
2955+ builder.append(parts[0] + " <font color=d3aa4e>" + parts[1] + "</font> ");
2956+ }
2957+ else
2958+ {
2959+ builder.append(parts[0] + " ");
2960+ }
2961+
2962+ if (item.getAttackElementPower() > 0)
2963+ {
2964+ switch (item.getAttackElementType())
2965+ {
2966+ case Elementals.WATER:
2967+ builder.append("<font color=396191>Water +");
2968+ break;
2969+ case Elementals.DARK:
2970+ builder.append("<font color=52544b>Dark +");
2971+ break;
2972+ case Elementals.EARTH:
2973+ builder.append("<font color=68692f>Earth +");
2974+ break;
2975+ case Elementals.FIRE:
2976+ builder.append("<font color=914e39>Fire +");
2977+ break;
2978+ case Elementals.HOLY:
2979+ builder.append("<font color=7a878b>Holy +");
2980+ break;
2981+ case Elementals.WIND:
2982+ builder.append("<font color=324461>Wind +");
2983+ break;
2984+ }
2985+ builder.append(item.getAttackElementPower() + "</font>");
2986+ }
2987+ for (byte i = 0; i < 6; i++)
2988+ {
2989+ if (item.getElementDefAttr(i) > 0)
2990+ {
2991+ switch (i)
2992+ {
2993+ case Elementals.WATER:
2994+ builder.append("<font color=396191>Water +");
2995+ break;
2996+ case Elementals.DARK:
2997+ builder.append("<font color=52544b>Dark +");
2998+ break;
2999+ case Elementals.EARTH:
3000+ builder.append("<font color=68692f>Earth +");
3001+ break;
3002+ case Elementals.FIRE:
3003+ builder.append("<font color=914e39>Fire +");
3004+ break;
3005+ case Elementals.HOLY:
3006+ builder.append("<font color=7a878b>Holy +");
3007+ break;
3008+ case Elementals.WIND:
3009+ builder.append("<font color=324461>Wind +");
3010+ break;
3011+ }
3012+ builder.append(item.getElementDefAttr(i) + "</font> ");
3013+ }
3014+ }
3015+
3016+ return builder.toString();
3017+ }
3018+
3019+ return (item.getEnchantLevel() > 0 ? "+" + item.getEnchantLevel() + " " : "") + item.getItem().getName();
3020+ }
3021+
3022+ public static AuctionHouseManager getInstance()
3023+ {
3024+ return SingletonHolder._instance;
3025+ }
3026+
3027+ private static class SingletonHolder
3028+ {
3029+ protected static final AuctionHouseManager _instance = new AuctionHouseManager();
3030+ }
3031+
3032+ public static class AuctionHouseEntrance
3033+ {
3034+ private final int _topId;
3035+ private final String _name;
3036+ private final String _category;
3037+ private final ArrayList<AuctionHouseEntranceItem> _items = new ArrayList<>();
3038+
3039+ public AuctionHouseEntrance(int topId, String name, String category)
3040+ {
3041+ _topId = topId;
3042+ _name = name;
3043+ _category = category;
3044+ }
3045+
3046+ public int getTopId()
3047+ {
3048+ return _topId;
3049+ }
3050+
3051+ public String getTopName()
3052+ {
3053+ return _name;
3054+ }
3055+
3056+ public String getCategory()
3057+ {
3058+ return _category;
3059+ }
3060+
3061+ public void addItem(AuctionHouseEntranceItem item)
3062+ {
3063+ _items.add(item);
3064+ }
3065+
3066+ public void cleanItems()
3067+ {
3068+ _items.clear();
3069+ }
3070+
3071+ public ArrayList<AuctionHouseEntranceItem> getItems()
3072+ {
3073+ return _items;
3074+ }
3075+ }
3076+
3077+ public static class AuctionHouseEntranceItem
3078+ {
3079+ private final int _topId;
3080+ private final int _charId;
3081+ private final int _objectId;
3082+ private final L2ItemInstance _item;
3083+ private int _quantity;
3084+ private final long _price;
3085+ private final long _endTime;
3086+ private volatile boolean _isRemoved = false;
3087+
3088+ public AuctionHouseEntranceItem(int topId, int charId, L2ItemInstance item, int quantity, long price, long endTime)
3089+ {
3090+ _topId = topId;
3091+ _charId = charId;
3092+ _objectId = item.getObjectId();
3093+ _item = item;
3094+ _quantity = quantity;
3095+ _price = price;
3096+ _endTime = endTime;
3097+ }
3098+
3099+ public void setQuantity(int count)
3100+ {
3101+ _quantity = count;
3102+ }
3103+
3104+ public int getTopId()
3105+ {
3106+ return _topId;
3107+ }
3108+
3109+ public int getCharId()
3110+ {
3111+ return _charId;
3112+ }
3113+
3114+ public int getObjectId()
3115+ {
3116+ return _objectId;
3117+ }
3118+
3119+ public L2ItemInstance getItemInstance()
3120+ {
3121+ return _item;
3122+ }
3123+
3124+ public int getQuantity()
3125+ {
3126+ return _quantity;
3127+ }
3128+
3129+ public long getPrice()
3130+ {
3131+ return _price;
3132+ }
3133+
3134+ public long getEndTime()
3135+ {
3136+ return _endTime;
3137+ }
3138+
3139+ public String getRemainingTimeString()
3140+ {
3141+ final long diffTime = _endTime - System.currentTimeMillis();
3142+ if (diffTime < (60 * 60 * 1000))
3143+ {
3144+ return (int) (diffTime / 60000) + " Minutes";
3145+ }
3146+ if (diffTime < (24 * 60 * 60 * 1000))
3147+ {
3148+ return (int) (diffTime / 3600000) + " Hours";
3149+ }
3150+
3151+ return (int) (diffTime / 86400000) + " Days";
3152+ }
3153+
3154+ public void setIsRemoved(boolean val)
3155+ {
3156+ _isRemoved = val;
3157+ }
3158+
3159+ public boolean isRemoved()
3160+ {
3161+ return _isRemoved;
3162+ }
3163+ }
3164+
3165+ // Sorting comparators
3166+ private static final Comparator<AuctionHouseEntranceItem> NAME_ASC_COMPARATOR = (left, right) -> left.getItemInstance().getItem().getName().compareTo(right.getItemInstance().getItem().getName());
3167+
3168+ private static final Comparator<AuctionHouseEntranceItem> NAME_DESC_COMPARATOR = (left, right) -> -left.getItemInstance().getItem().getName().compareTo(right.getItemInstance().getItem().getName());
3169+
3170+ private static final Comparator<AuctionHouseEntranceItem> RANK_ASC_COMPARATOR = (left, right) ->
3171+ {
3172+ if (left.getItemInstance().getItem().getCrystalType().getId() > right.getItemInstance().getItem().getCrystalType().getId())
3173+ {
3174+ return 1;
3175+ }
3176+ if (left.getItemInstance().getItem().getCrystalType().getId() < right.getItemInstance().getItem().getCrystalType().getId())
3177+ {
3178+ return -1;
3179+ }
3180+ return 0;
3181+ };
3182+
3183+ private static final Comparator<AuctionHouseEntranceItem> RANK_DESC_COMPARATOR = (left, right) ->
3184+ {
3185+ if (left.getItemInstance().getItem().getCrystalType().getId() > right.getItemInstance().getItem().getCrystalType().getId())
3186+ {
3187+ return -1;
3188+ }
3189+ if (left.getItemInstance().getItem().getCrystalType().getId() < right.getItemInstance().getItem().getCrystalType().getId())
3190+ {
3191+ return 1;
3192+ }
3193+ return 0;
3194+ };
3195+
3196+ private static final Comparator<AuctionHouseEntranceItem> COUNT_ASC_COMPARATOR = (left, right) ->
3197+ {
3198+ if (left.getQuantity() > right.getQuantity())
3199+ {
3200+ return 1;
3201+ }
3202+ if (left.getQuantity() < right.getQuantity())
3203+ {
3204+ return -1;
3205+ }
3206+ return 0;
3207+ };
3208+
3209+ private static final Comparator<AuctionHouseEntranceItem> COUNT_DESC_COMPARATOR = (left, right) ->
3210+ {
3211+ if (left.getQuantity() > right.getQuantity())
3212+ {
3213+ return -1;
3214+ }
3215+ if (left.getQuantity() < right.getQuantity())
3216+ {
3217+ return 1;
3218+ }
3219+ return 0;
3220+ };
3221+
3222+ private static final Comparator<AuctionHouseEntranceItem> PRICE_ASC_COMPARATOR = (left, right) ->
3223+ {
3224+ if (left.getPrice() > right.getPrice())
3225+ {
3226+ return 1;
3227+ }
3228+ if (left.getPrice() < right.getPrice())
3229+ {
3230+ return -1;
3231+ }
3232+ return 0;
3233+ };
3234+
3235+ private static final Comparator<AuctionHouseEntranceItem> PRICE_DESC_COMPARATOR = (left, right) ->
3236+ {
3237+ if (left.getPrice() > right.getPrice())
3238+ {
3239+ return -1;
3240+ }
3241+ if (left.getPrice() < right.getPrice())
3242+ {
3243+ return 1;
3244+ }
3245+ return 0;
3246+ };
3247+
3248+ public void showCBHtml(String html, L2PcInstance acha)
3249+ {
3250+ if (html == null)
3251+ {
3252+ return;
3253+ }
3254+ if (html.length() < 4096)
3255+ {
3256+ acha.sendPacket(new ShowBoard(html, "101"));
3257+ acha.sendPacket(new ShowBoard(null, "102"));
3258+ acha.sendPacket(new ShowBoard(null, "103"));
3259+
3260+ }
3261+ else if (html.length() < 8192)
3262+ {
3263+ acha.sendPacket(new ShowBoard(html.substring(0, 4096), "101"));
3264+ acha.sendPacket(new ShowBoard(html.substring(4096), "102"));
3265+ acha.sendPacket(new ShowBoard(null, "103"));
3266+
3267+ }
3268+ else if (html.length() < 16384)
3269+ {
3270+ acha.sendPacket(new ShowBoard(html.substring(0, 4096), "101"));
3271+ acha.sendPacket(new ShowBoard(html.substring(4096, 8192), "102"));
3272+ acha.sendPacket(new ShowBoard(html.substring(8192), "103"));
3273+ }
3274+ }
3275+
3276+ /**
3277+ * @param html
3278+ * @param acha
3279+ */
3280+ public void send1001(String html, L2PcInstance acha)
3281+ {
3282+ acha.sendPacket(new ShowBoard(html, "1001"));
3283+ }
3284+
3285+ /**
3286+ * @param acha
3287+ */
3288+ protected void send1002(L2PcInstance acha)
3289+ {
3290+ send1002(acha, " ", " ", "0");
3291+ }
3292+
3293+ /**
3294+ * @param activeChar
3295+ * @param string
3296+ * @param string2
3297+ * @param string3
3298+ */
3299+ public void send1002(L2PcInstance activeChar, String string, String string2, String string3)
3300+ {
3301+ List<String> _arg = new LinkedList<>();
3302+ _arg.add("0");
3303+ _arg.add("0");
3304+ _arg.add("0");
3305+ _arg.add("0");
3306+ _arg.add("0");
3307+ _arg.add("0");
3308+ _arg.add(activeChar.getName());
3309+ _arg.add(Integer.toString(activeChar.getObjectId()));
3310+ _arg.add(activeChar.getAccountName());
3311+ _arg.add("9");
3312+ _arg.add(string2);
3313+ _arg.add(string2);
3314+ _arg.add(string);
3315+ _arg.add(string3);
3316+ _arg.add(string3);
3317+ _arg.add("0");
3318+ _arg.add("0");
3319+ activeChar.sendPacket(new ShowBoard(_arg));
3320+ }
3321+}
3322Index: java/l2r/gameserver/communitybbs/BoardsManager.java
3323===================================================================
3324--- java/l2r/gameserver/communitybbs/BoardsManager.java (revision 173)
3325+++ java/l2r/gameserver/communitybbs/BoardsManager.java (working copy)
3326@@ -22,11 +22,14 @@
3327 import java.util.concurrent.ConcurrentHashMap;
3328
3329 import l2r.Config;
3330+import l2r.gameserver.communitybbs.Managers.AuctionBBSManager;
3331 import l2r.gameserver.communitybbs.Managers.ClanBBSManager;
3332 import l2r.gameserver.communitybbs.Managers.DonateBBSManager;
3333 import l2r.gameserver.communitybbs.Managers.FavoriteBBSManager;
3334+import l2r.gameserver.communitybbs.Managers.FriendsBBSManager;
3335 import l2r.gameserver.communitybbs.Managers.MailBBSManager;
3336 import l2r.gameserver.communitybbs.Managers.PostBBSManager;
3337+import l2r.gameserver.communitybbs.Managers.RegionBBSManager;
3338 import l2r.gameserver.communitybbs.Managers.ServicesBBSManager;
3339 import l2r.gameserver.communitybbs.Managers.TopBBSManager;
3340 import l2r.gameserver.communitybbs.Managers.TopicBBSManager;
3341@@ -52,6 +55,11 @@
3342 return;
3343 }
3344
3345+ if (command.startsWith(AuctionBBSManager.getInstance().BBS_COMMAND))
3346+ {
3347+ AuctionBBSManager.getInstance().cbByPass(command, activeChar);
3348+ }
3349+
3350 if (SunriseEvents.cbBypass(activeChar, command))
3351 {
3352 return;
3353@@ -99,17 +107,17 @@
3354 {
3355 TopBBSManager.getInstance().cbByPass(command, activeChar);
3356 }
3357- else if (command.startsWith("_maillist"))
3358+ else if (command.startsWith("_maillist_0_1_0_"))
3359 {
3360 MailBBSManager.getInstance().cbByPass(command, activeChar);
3361 }
3362 else if (command.startsWith("_friendlist_0_") || command.startsWith("_bbs_friends") || command.startsWith("_bbsfriends"))
3363 {
3364-
3365+ FriendsBBSManager.getInstance().cbByPass(command, activeChar);
3366 }
3367- else if (command.startsWith("_bbsloc"))
3368+ else if (command.startsWith("_bbsloc") || command.startsWith("_bbsreg"))
3369 {
3370- // RegionBBSManager.getInstance().cbByPass(command, activeChar);
3371+ RegionBBSManager.getInstance().cbByPass(command, activeChar);
3372 }
3373 else if (command.startsWith("_bbsgetfav") || command.startsWith("bbs_add_fav") || command.startsWith("_bbsdelfav_"))
3374 {
3375Index: java/l2r/gameserver/LoginServerThread.java
3376===================================================================
3377--- java/l2r/gameserver/LoginServerThread.java (revision 173)
3378+++ java/l2r/gameserver/LoginServerThread.java (working copy)
3379@@ -85,9 +85,7 @@
3380 protected static final Logger _log = LoggerFactory.getLogger(LoginServerThread.class);
3381 protected static final java.util.logging.Logger _logAccounting = java.util.logging.Logger.getLogger("accounting");
3382
3383- /**
3384- * @see l2r.loginserver.L2LoginServer#PROTOCOL_REV
3385- */
3386+ /** @see l2r.loginserver.L2LoginServer#PROTOCOL_REV */
3387 private static final int REVISION = 0x0106;
3388 private final String _hostname;
3389 private final int _port;
3390@@ -144,15 +142,6 @@
3391 _maxPlayer = Config.MAXIMUM_ONLINE_USERS;
3392 }
3393
3394- /**
3395- * Gets the single instance of LoginServerThread.
3396- * @return single instance of LoginServerThread
3397- */
3398- public static LoginServerThread getInstance()
3399- {
3400- return SingletonHolder._instance;
3401- }
3402-
3403 @Override
3404 public void run()
3405 {
3406@@ -354,7 +343,7 @@
3407 }
3408 catch (UnknownHostException e)
3409 {
3410- _log.warn("", e);
3411+ _log.warn("Unknown host!", e);
3412 }
3413 catch (SocketException e)
3414 {
3415@@ -816,6 +805,15 @@
3416 }
3417 }
3418
3419+ /**
3420+ * Gets the single instance of LoginServerThread.
3421+ * @return single instance of LoginServerThread
3422+ */
3423+ public static LoginServerThread getInstance()
3424+ {
3425+ return SingletonHolder._instance;
3426+ }
3427+
3428 private static class SingletonHolder
3429 {
3430 protected static final LoginServerThread _instance = new LoginServerThread();
3431Index: java/l2r/Config.java
3432===================================================================
3433--- java/l2r/Config.java (revision 942)
3434+++ java/l2r/Config.java (working copy)
3435@@ -141,6 +141,9 @@
3436 // sunrise
3437 public static final String CHAMPION_MOBS_CONFIG = "./config/sunrise/ChampionMobs.ini";
3438
3439+ // elemental
3440+ public static final String ELEMENTAL_FILE = "./config/extra/elemental/auction.ini";
3441+
3442 // --------------------------------------------------
3443 // L2J Variable Definitions
3444 // --------------------------------------------------
3445@@ -1257,6 +1260,12 @@
3446 public static int CHS_FAME_AMOUNT;
3447 public static int CHS_FAME_FREQUENCY;
3448
3449+ // --------------------------------------------------
3450+ // Elemental Settings
3451+ // --------------------------------------------------
3452+ public static boolean AUCTION_HOUSE_ONLY_PEACE_ZONE;
3453+ public static double AUCTION_HOUSE_SALE_FEE;
3454+
3455 /**
3456 * This class initializes all global variables for configuration.<br>
3457 * If the key doesn't appear in properties file, a default value is set by this class. {@link #CONFIGURATION_FILE} (properties file) for configuring your server.
3458@@ -2829,6 +2838,12 @@
3459 final PropertiesParser itemMallSettigns = new PropertiesParser(ITEM_MALL_CONFIG_FILE);
3460
3461 GAME_POINT_ITEM_ID = itemMallSettigns.getInt("GamePointItemId", -1);
3462+
3463+ // Elemental Configs
3464+ final PropertiesParser ElementalSettings = new PropertiesParser(ELEMENTAL_FILE);
3465+
3466+ AUCTION_HOUSE_ONLY_PEACE_ZONE = ElementalSettings.getBoolean("AuctionHouseOnlyPeaceZone", true);
3467+ AUCTION_HOUSE_SALE_FEE = ElementalSettings.getDouble("AuctionHouseSaleFee", 0.5) / 100;
3468 }
3469 else if (Server.serverMode == Server.MODE_LOGINSERVER)
3470 {
3471Index: java/l2r/features/auctionEngine/house/managers/AuctionHouseGenerator.java
3472===================================================================
3473--- java/l2r/features/auctionEngine/house/managers/AuctionHouseGenerator.java (revision 0)
3474+++ java/l2r/features/auctionEngine/house/managers/AuctionHouseGenerator.java (working copy)
3475@@ -0,0 +1,316 @@
3476+package l2r.features.auctionEngine.house.managers;
3477+
3478+import java.sql.Connection;
3479+import java.sql.PreparedStatement;
3480+import java.sql.ResultSet;
3481+import java.util.ArrayList;
3482+import java.util.List;
3483+import java.util.StringTokenizer;
3484+
3485+import l2r.L2DatabaseFactory;
3486+import l2r.features.auctionEngine.house.managers.holder.HouseItem;
3487+import l2r.gameserver.communitybbs.Managers.AuctionBBSManager;
3488+import l2r.gameserver.model.StatsSet;
3489+import l2r.util.Files;
3490+
3491+import org.slf4j.Logger;
3492+import org.slf4j.LoggerFactory;
3493+
3494+public final class AuctionHouseGenerator
3495+{
3496+ private static final Logger _log = LoggerFactory.getLogger(AuctionHouseGenerator.class);
3497+ public static final boolean NORMAL_WEAPON = false;
3498+ public static final boolean MAGICAL_WEAPON = true;
3499+ private static String serverAuctionHtml = "data/html/CommunityBoard/Elemental/server.htm";
3500+ private static String playerAuctionHtml = "data/html/CommunityBoard/Elemental/player.htm";
3501+ private static String purchaseAuctionHtml = "data/html/CommunityBoard/Elemental/purchase.htm";
3502+
3503+ public AuctionHouseGenerator()
3504+ {
3505+ _log.info("Initializing Auction House Htmls.");
3506+
3507+ if ((serverAuctionHtml != null) && (playerAuctionHtml != null) && (purchaseAuctionHtml != null))
3508+ {
3509+ _log.info("Auction House Htmls initialized.");
3510+ }
3511+ else
3512+ {
3513+ _log.info("Failed to initialize Auction house htmls.");
3514+ }
3515+ }
3516+
3517+ public final List<HouseItem> loadItems()
3518+ {
3519+ ArrayList<HouseItem> items = new ArrayList<>();
3520+
3521+ try (Connection con = L2DatabaseFactory.getInstance().getConnection())
3522+ {
3523+ PreparedStatement statement = con.prepareStatement("SELECT * FROM auction_house WHERE itemId > 0");
3524+ ResultSet rset = statement.executeQuery();
3525+ while (rset.next())
3526+ {
3527+ int itemId;
3528+ int ownerId;
3529+ int count;
3530+ long salePrice;
3531+ long expirationTime;
3532+
3533+ itemId = rset.getInt("itemId");
3534+ ownerId = rset.getInt("ownerId");
3535+ count = rset.getInt("count");
3536+ salePrice = rset.getLong("sale_price");
3537+ expirationTime = rset.getLong("expiration_time");
3538+
3539+ items.add(new HouseItem(ownerId, itemId, count, salePrice, expirationTime));
3540+ }
3541+ }
3542+ catch (Exception e)
3543+ {
3544+ _log.error(AuctionHouseGenerator.class.getName() + ": An error was generated while loading auction items on sale from DB: " + e);
3545+ }
3546+
3547+ return items;
3548+ }
3549+
3550+ public final StatsSet processBypass(String command)
3551+ {
3552+ if (command.startsWith(AuctionBBSManager.getInstance().BBS_COMMAND + ";server;"))
3553+ {
3554+ StringTokenizer st = new StringTokenizer(command, ";");
3555+ String token;
3556+ StatsSet set = new StatsSet();
3557+ while (st.hasMoreTokens())
3558+ {
3559+ if ((token = st.nextToken()).startsWith("page"))
3560+ {
3561+ set.set("page", token.substring(4));
3562+ }
3563+ else if (token.startsWith("rank"))
3564+ {
3565+ set.set("rank", token.substring(5).trim());
3566+ }
3567+ else if (token.startsWith("category"))
3568+ {
3569+ set.set("category", token.substring(8).trim());
3570+ }
3571+ else if (token.startsWith("search "))
3572+ {
3573+ set.set("search", token.substring(7).trim().toLowerCase());
3574+ }
3575+ else if (token.startsWith("selectedItemId"))
3576+ {
3577+ set.set("selectedItemId", token.substring(14));
3578+ }
3579+ else if (token.startsWith("order"))
3580+ {
3581+ set.set("order", token.substring(5));
3582+ }
3583+ }
3584+ return set;
3585+ }
3586+ if (command.startsWith(AuctionBBSManager.getInstance().BBS_COMMAND + ";my"))
3587+ {
3588+ StringTokenizer st = new StringTokenizer(command, ";");
3589+ String token;
3590+ StatsSet set = new StatsSet();
3591+ while (st.hasMoreTokens())
3592+ {
3593+ if ((token = st.nextToken()).startsWith("itemId"))
3594+ {
3595+ set.set("itemId", token.substring(6));
3596+ }
3597+ else if (token.startsWith("page"))
3598+ {
3599+ set.set("page", token.substring(4));
3600+ }
3601+ else if (token.startsWith("selectedAuction"))
3602+ {
3603+ set.set("selectedAuction", token.substring(15));
3604+ }
3605+ else if (token.startsWith("apply"))
3606+ {
3607+ set.set("apply", true);
3608+ }
3609+ else if (token.startsWith("create"))
3610+ {
3611+ set.set("create", true);
3612+ }
3613+ else if (token.startsWith("cancelConfirm"))
3614+ {
3615+ set.set("cancelConfirm", token.substring(13));
3616+ }
3617+ else if (token.startsWith("cancel"))
3618+ {
3619+ set.set("cancel", token.substring(6));
3620+ }
3621+ else if (token.startsWith("quantity"))
3622+ {
3623+ long temp = Integer.parseInt(token.substring(9).trim());
3624+ set.set("quantity", temp);
3625+ if (temp > 1000000)
3626+ {
3627+ set.set("quantity", 1000000);
3628+ }
3629+ else if (temp < 1L)
3630+ {
3631+ set.set("quantity", 1);
3632+ }
3633+ }
3634+ else if (token.startsWith("saleprice"))
3635+ {
3636+ long temp = Long.parseLong(token.substring(10).trim());
3637+ set.set("saleprice", temp);
3638+ if (temp > 10000000000L)
3639+ {
3640+ set.set("saleprice", 10000000000L);
3641+ }
3642+ else if (temp < 1)
3643+ {
3644+ set.set("saleprice", 1);
3645+ }
3646+ }
3647+ else if (token.startsWith("duration"))
3648+ {
3649+ long temp = Integer.parseInt(token.substring(9, 10).trim());
3650+ set.set("duration", Integer.parseInt(token.substring(9, 10).trim()));
3651+ if (temp < 1)
3652+ {
3653+ set.set("duration", 1);
3654+ }
3655+ else if (temp > 9L)
3656+ {
3657+ set.set("duration", 9);
3658+ }
3659+ }
3660+ }
3661+ return set;
3662+ }
3663+ if (command.startsWith(AuctionBBSManager.getInstance().BBS_COMMAND + ";purchase;"))
3664+ {
3665+ StringTokenizer st = new StringTokenizer(command, ";");
3666+ String token;
3667+ StatsSet set = new StatsSet();
3668+ while (st.hasMoreTokens())
3669+ {
3670+ if ((token = st.nextToken()).startsWith("page"))
3671+ {
3672+ set.set("page", token.substring(4));
3673+ }
3674+ else if (token.startsWith("rank"))
3675+ {
3676+ set.set("rank", token.substring(5).trim());
3677+ }
3678+ else if (token.startsWith("category"))
3679+ {
3680+ set.set("category", token.substring(8).trim());
3681+ }
3682+ else if (token.startsWith("search "))
3683+ {
3684+ set.set("search", token.substring(7).trim().toLowerCase());
3685+ }
3686+ else if (token.startsWith("selectedItemId"))
3687+ {
3688+ set.set("selectedItemId", token.substring(14));
3689+ }
3690+ else if (token.startsWith("order"))
3691+ {
3692+ set.set("order", token.substring(5));
3693+ }
3694+ else if (token.startsWith("apply"))
3695+ {
3696+ set.set("apply", true);
3697+ }
3698+ else if (token.startsWith("confirm"))
3699+ {
3700+ set.set("confirm", true);
3701+ }
3702+ else if (token.startsWith("purchaseCount"))
3703+ {
3704+ try
3705+ {
3706+ set.set("purchaseCount", token.substring(14).trim());
3707+ }
3708+ catch (Exception _ex)
3709+ {
3710+ set.set("purchaseCount", 1);
3711+ }
3712+ }
3713+ }
3714+ return set;
3715+ }
3716+
3717+ return null;
3718+ }
3719+
3720+ public final void addNewAuctionToDB(int itemId, int charId, int count, long price, long endTime)
3721+ {
3722+ try (Connection con = L2DatabaseFactory.getInstance().getConnection();
3723+ PreparedStatement statement = con.prepareStatement("INSERT INTO auction_house VALUES (?,?,?,?,?)");)
3724+ {
3725+ statement.setInt(1, itemId);
3726+ statement.setInt(2, charId);
3727+ statement.setInt(3, count);
3728+ statement.setLong(4, price);
3729+ statement.setLong(5, endTime);
3730+ statement.execute();
3731+ }
3732+ catch (Exception e)
3733+ {
3734+ _log.warn(AuctionHouseGenerator.class.getName() + ": The auction couldnt be deleted from the DB: " + e);
3735+ }
3736+ }
3737+
3738+ public final void updateItemCountToDB(int itemId, int itemCount)
3739+ {
3740+ try (Connection con = L2DatabaseFactory.getInstance().getConnection();
3741+ PreparedStatement statement = con.prepareStatement("UPDATE auction_house SET count=? WHERE itemId=?"))
3742+ {
3743+ statement.setInt(1, itemCount);
3744+ statement.setInt(2, itemId);
3745+ statement.executeUpdate();
3746+ }
3747+ catch (Exception e)
3748+ {
3749+ _log.warn(AuctionHouseGenerator.class.getName() + ": The Auction item couldnt be updated to the DB: " + e);
3750+ }
3751+ }
3752+
3753+ public final void deleteItemFromDB(int itemId)
3754+ {
3755+ try (Connection con = L2DatabaseFactory.getInstance().getConnection();
3756+ PreparedStatement statement = con.prepareStatement("DELETE FROM auction_house WHERE itemId=?"))
3757+ {
3758+ statement.setInt(1, itemId);
3759+ statement.execute();
3760+ }
3761+ catch (Exception e)
3762+ {
3763+ _log.warn(AuctionHouseGenerator.class.getName() + ": The auction couldnt be deleted from the DB: " + e);
3764+ }
3765+ }
3766+
3767+ public final String getServerAuctionHtml()
3768+ {
3769+ return Files.read(serverAuctionHtml);
3770+ }
3771+
3772+ public final String getMyAuctionHtml()
3773+ {
3774+ return Files.read(playerAuctionHtml);
3775+ }
3776+
3777+ public final String getPurchaseHtml()
3778+ {
3779+ return Files.read(purchaseAuctionHtml);
3780+ }
3781+
3782+ private static class SingletonHolder
3783+ {
3784+ protected static final AuctionHouseGenerator _instance = new AuctionHouseGenerator();
3785+ }
3786+
3787+ public static AuctionHouseGenerator getInstance()
3788+ {
3789+ return SingletonHolder._instance;
3790+ }
3791+}
3792\ No newline at end of file
3793Index: java/l2r/gameserver/model/BlockList.java
3794===================================================================
3795--- java/l2r/gameserver/model/BlockList.java (revision 173)
3796+++ java/l2r/gameserver/model/BlockList.java (working copy)
3797@@ -160,7 +160,7 @@
3798 _owner.setMessageRefusal(state);
3799 }
3800
3801- private List<Integer> getBlockList()
3802+ public List<Integer> getBlockList()
3803 {
3804 return _blockList;
3805 }
3806Index: java/l2r/gameserver/communitybbs/SunriseBoards/RaidList.java
3807===================================================================
3808--- java/l2r/gameserver/communitybbs/SunriseBoards/RaidList.java (revision 173)
3809+++ java/l2r/gameserver/communitybbs/SunriseBoards/RaidList.java (working copy)
3810@@ -76,18 +76,12 @@
3811
3812 private void addRaidToList(int pos, String npcname, int rlevel, int mindelay, int maxdelay, boolean rstatus)
3813 {
3814- _list.append("<table border=0 cellspacing=0 cellpadding=0 bgcolor=111111 width=680 height=" + SmartCommunityConfigs.RAID_LIST_ROW_HEIGHT + ">");
3815 _list.append("<tr>");
3816- _list.append("<td FIXWIDTH=5></td>");
3817- _list.append("<td FIXWIDTH=20>" + pos + "</td>");
3818- _list.append("<td FIXWIDTH=270>" + npcname + "</td>");
3819- _list.append("<td FIXWIDTH=50>" + rlevel + "</td>");
3820- _list.append("<td FIXWIDTH=120 align=center>" + mindelay + " - " + maxdelay + "</td>");
3821- _list.append("<td FIXWIDTH=50 align=center>" + ((rstatus) ? "<font color=99FF00>Alive</font>" : "<font color=CC0000>Dead</font>") + "</td>");
3822- _list.append("<td FIXWIDTH=5></td>");
3823+ _list.append("<td FIXWIDTH=25 align=center>" + rlevel + "</td>");
3824+ _list.append("<td FIXWIDTH=100>" + npcname + "</td>");
3825+ _list.append("<td FIXWIDTH=60>" + mindelay + " - " + maxdelay + "</td>");
3826+ _list.append("<td FIXWIDTH=25>" + ((rstatus) ? "<font color=99FF00>Alive</font>" : "<font color=CC0000>Dead</font>") + "</td>");
3827 _list.append("</tr>");
3828- _list.append("</table>");
3829- _list.append("<img src=\"L2UI.Squaregray\" width=\"680\" height=\"1\">");
3830 }
3831
3832 @Override
3833Index: dist/game/config/extra/elemental/auction.ini
3834===================================================================
3835--- dist/game/config/extra/elemental/auction.ini (revision 0)
3836+++ dist/game/config/extra/elemental/auction.ini (working copy)
3837@@ -0,0 +1,11 @@
3838+# ---------------------------------------------------------------------------
3839+# Auction House Settings
3840+# ---------------------------------------------------------------------------
3841+
3842+# If its enabled, Auction House can only be used when inside Peace Zone
3843+AuctionHouseOnlyPeaceZone = True
3844+
3845+# Fee charged when creating a new auction in the Auction House
3846+# This is charged when creating a new auction only, and the final value is calculated: Count x Sale Price * Days * AuctionHouseSaleFee
3847+# Default 0.5%
3848+AuctionHouseSaleFee = 0.5
3849\ No newline at end of file
3850Index: java/l2r/gameserver/communitybbs/Managers/TopBBSManager.java
3851===================================================================
3852--- java/l2r/gameserver/communitybbs/Managers/TopBBSManager.java (revision 173)
3853+++ java/l2r/gameserver/communitybbs/Managers/TopBBSManager.java (working copy)
3854@@ -213,14 +213,6 @@
3855 content = content.replace("%online%", Integer.toString(L2World.getInstance().getAllPlayersCount() + SmartCommunityConfigs.EXTRA_PLAYERS_COUNT));
3856 content = content.replace("%servercapacity%", Integer.toString(Config.MAXIMUM_ONLINE_USERS));
3857 content = content.replace("%serverruntime%", getServerRunTime());
3858- if (SmartCommunityConfigs.ALLOW_REAL_ONLINE_STATS)
3859- {
3860- content = content.replace("%serveronline%", getRealOnline());
3861- }
3862- else
3863- {
3864- content = content.replace("%serveronline%", "");
3865- }
3866 break;
3867 case "instances":
3868 // Queen Ant
3869Index: java/l2r/gameserver/network/serverpackets/RelationChanged.java
3870===================================================================
3871--- java/l2r/gameserver/network/serverpackets/RelationChanged.java (revision 173)
3872+++ java/l2r/gameserver/network/serverpackets/RelationChanged.java (working copy)
3873@@ -22,6 +22,7 @@
3874 import java.util.List;
3875
3876 import l2r.gameserver.model.actor.L2Playable;
3877+import l2r.gameserver.model.actor.instance.L2PcInstance;
3878
3879 /**
3880 * @author Luca Baldi
3881@@ -65,6 +66,33 @@
3882 _invisible = activeChar.isInvisible();
3883 }
3884
3885+ public RelationChanged(L2Playable activeChar, int relation, L2PcInstance attacker)
3886+ {
3887+ _singled = new Relation();
3888+ _singled._objId = activeChar.getObjectId();
3889+ _singled._relation = relation;
3890+ _singled._autoAttackable = activeChar.isAutoAttackable(attacker) ? 1 : 0;
3891+ _singled._karma = activeChar.getKarma();
3892+ _singled._pvpFlag = activeChar.getPvpFlag();
3893+ _invisible = activeChar.isInvisible();
3894+ }
3895+
3896+ public static void sendRelationChanged(L2PcInstance target, L2PcInstance attacker)
3897+ {
3898+ if ((target == null) || (attacker == null))
3899+ {
3900+ return;
3901+ }
3902+
3903+ int currentRelation = target.getRelation(attacker);
3904+
3905+ attacker.sendPacket(new RelationChanged(target, currentRelation, attacker));
3906+ if (target.getSummon() != null)
3907+ {
3908+ attacker.sendPacket(new RelationChanged(target.getSummon(), currentRelation, attacker));
3909+ }
3910+ }
3911+
3912 public RelationChanged()
3913 {
3914 _multi = new ArrayList<>();
3915Index: java/l2r/features/auctionEngine/itemcontainer/AuctionHouseItem.java
3916===================================================================
3917--- java/l2r/features/auctionEngine/itemcontainer/AuctionHouseItem.java (revision 0)
3918+++ java/l2r/features/auctionEngine/itemcontainer/AuctionHouseItem.java (working copy)
3919@@ -0,0 +1,125 @@
3920+/*
3921+ * This program is free software: you can redistribute it and/or modify it under
3922+ * the terms of the GNU General Public License as published by the Free Software
3923+ * Foundation, either version 3 of the License, or (at your option) any later
3924+ * version.
3925+ *
3926+ * This program is distributed in the hope that it will be useful, but WITHOUT
3927+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
3928+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
3929+ * details.
3930+ *
3931+ * You should have received a copy of the GNU General Public License along with
3932+ * this program. If not, see <http://www.gnu.org/licenses/>.
3933+ */
3934+package l2r.features.auctionEngine.itemcontainer;
3935+
3936+import java.sql.Connection;
3937+import java.sql.PreparedStatement;
3938+import java.sql.ResultSet;
3939+
3940+import l2r.L2DatabaseFactory;
3941+import l2r.gameserver.enums.ItemLocation;
3942+import l2r.gameserver.model.L2World;
3943+import l2r.gameserver.model.actor.instance.L2PcInstance;
3944+import l2r.gameserver.model.itemcontainer.ItemContainer;
3945+import l2r.gameserver.model.items.instance.L2ItemInstance;
3946+
3947+/**
3948+ * ItemContainers to store items of the character that are in the auction house Behaves like mails
3949+ * @author GodFather
3950+ */
3951+public class AuctionHouseItem extends ItemContainer
3952+{
3953+ private final int _ownerId;
3954+
3955+ public AuctionHouseItem(int objectId)
3956+ {
3957+ _ownerId = objectId;
3958+ }
3959+
3960+ @Override
3961+ public String getName()
3962+ {
3963+ return "AuctionHouse";
3964+ }
3965+
3966+ @Override
3967+ public L2PcInstance getOwner()
3968+ {
3969+ return null;
3970+ }
3971+
3972+ @Override
3973+ public ItemLocation getBaseLocation()
3974+ {
3975+ return ItemLocation.AUCTION;
3976+ }
3977+
3978+ @Override
3979+ protected void addItem(L2ItemInstance item)
3980+ {
3981+ super.addItem(item);
3982+ item.setItemLocation(getBaseLocation());
3983+ }
3984+
3985+ /*
3986+ * Allow saving of the items without owner
3987+ */
3988+ @Override
3989+ public void updateDatabase()
3990+ {
3991+ for (L2ItemInstance item : _items)
3992+ {
3993+ if (item != null)
3994+ {
3995+ item.updateDatabase(true);
3996+ }
3997+ }
3998+ }
3999+
4000+ @Override
4001+ public void restore()
4002+ {
4003+ try (Connection con = L2DatabaseFactory.getInstance().getConnection();
4004+ PreparedStatement statement = con.prepareStatement("SELECT object_id, item_id, count, enchant_level, loc, loc_data, custom_type1, custom_type2, mana_left, time FROM items WHERE owner_id=? AND loc=?"))
4005+ {
4006+ statement.setInt(1, getOwnerId());
4007+ statement.setString(2, getBaseLocation().name());
4008+ try (ResultSet inv = statement.executeQuery())
4009+ {
4010+ L2ItemInstance item;
4011+ while (inv.next())
4012+ {
4013+ item = L2ItemInstance.restoreFromDb(getOwnerId(), inv);
4014+ if (item == null)
4015+ {
4016+ continue;
4017+ }
4018+
4019+ L2World.getInstance().storeObject(item);
4020+
4021+ // If stackable item is found just add to current quantity
4022+ if (item.isStackable() && (getItemByItemId(item.getId()) != null))
4023+ {
4024+ addItem("Restore", item, null, null);
4025+ }
4026+ else
4027+ {
4028+ addItem(item);
4029+ }
4030+ }
4031+ }
4032+ }
4033+ catch (Exception e)
4034+ {
4035+ _log.warn("could not restore container:", e);
4036+ }
4037+ }
4038+
4039+ @Override
4040+ public int getOwnerId()
4041+ {
4042+ return _ownerId;
4043+ }
4044+}
4045\ No newline at end of file
4046Index: java/l2r/gameserver/model/CharSelectInfoPackage.java
4047===================================================================
4048--- java/l2r/gameserver/model/CharSelectInfoPackage.java (revision 173)
4049+++ java/l2r/gameserver/model/CharSelectInfoPackage.java (working copy)
4050@@ -52,7 +52,6 @@
4051 private int _pkKills = 0;
4052 private int _pvpKills = 0;
4053 private int _augmentationId = 0;
4054- private int _transformId = 0;
4055 private int _x = 0;
4056 private int _y = 0;
4057 private int _z = 0;
4058@@ -340,16 +339,6 @@
4059 return _pvpKills;
4060 }
4061
4062- public int getTransformId()
4063- {
4064- return _transformId;
4065- }
4066-
4067- public void setTransformId(int id)
4068- {
4069- _transformId = id;
4070- }
4071-
4072 public int getX()
4073 {
4074 return _x;
4075Index: java/l2r/gameserver/GameServer.java
4076===================================================================
4077--- java/l2r/gameserver/GameServer.java (revision 173)
4078+++ java/l2r/gameserver/GameServer.java (working copy)
4079@@ -33,6 +33,7 @@
4080 import l2r.L2DatabaseFactory;
4081 import l2r.Server;
4082 import l2r.UPnPService;
4083+import l2r.features.auctionEngine.managers.AuctionHouseManager;
4084 import l2r.gameserver.cache.HtmCache;
4085 import l2r.gameserver.dao.factory.impl.DAOFactory;
4086 import l2r.gameserver.data.EventDroplist;
4087@@ -408,6 +409,9 @@
4088 MailManager.getInstance();
4089 }
4090
4091+ // Auction House Manager
4092+ AuctionHouseManager.getInstance();
4093+
4094 Runtime.getRuntime().addShutdownHook(Shutdown.getInstance());
4095
4096 _log.info("IdFactory: Free ObjectID's remaining: " + IdFactory.getInstance().size());
4097Index: java/l2r/gameserver/communitybbs/SunriseBoards/TopPkPlayers.java
4098===================================================================
4099--- java/l2r/gameserver/communitybbs/SunriseBoards/TopPkPlayers.java (revision 173)
4100+++ java/l2r/gameserver/communitybbs/SunriseBoards/TopPkPlayers.java (working copy)
4101@@ -31,13 +31,12 @@
4102
4103 private void addChar(String name, String cname, int pk)
4104 {
4105- _list.append("<table width=680 bgcolor=111111 height=16 border=0 cellspacing=0 cellpadding=0>");
4106 _list.append("<tr>");
4107- _list.append("<td FIXWIDTH=40>" + _counter + "</td");
4108- _list.append("<td fixwidth=160>" + name + "</td");
4109- _list.append("<td fixwidth=160>" + cname + "</td>");
4110- _list.append("<td align=center fixwidth=80>" + pk + "</td>");
4111- _list.append("</tr></table><img src=\"L2UI.Squaregray\" width=\"680\" height=\"1\">");
4112+ _list.append("<td valign=\"top\" align=\"center\">" + _counter + "</td");
4113+ _list.append("<td valign=\"top\" align=\"center\">" + name + "</td");
4114+ _list.append("<td valign=\"top\" align=\"center\">" + cname + "</td>");
4115+ _list.append("<td valign=\"top\" align=\"center\">" + pk + "</td>");
4116+ _list.append("</tr>");
4117 }
4118
4119 @Override
4120Index: java/l2r/gameserver/communitybbs/SunriseBoards/TopClan.java
4121===================================================================
4122--- java/l2r/gameserver/communitybbs/SunriseBoards/TopClan.java (revision 173)
4123+++ java/l2r/gameserver/communitybbs/SunriseBoards/TopClan.java (working copy)
4124@@ -35,14 +35,13 @@
4125
4126 private void addClanToList(String clan, String leadername, int clanlevel, int reputation)
4127 {
4128- _list.append("<table width=680 height=16 bgcolor=111111 border=0 cellspacing=0 cellpadding=0>");
4129 _list.append("<tr>");
4130- _list.append("<td FIXWIDTH=40>" + _counter + "</td");
4131- _list.append("<td fixwidth=90>" + clan + "</td");
4132- _list.append("<td fixwidth=85>" + leadername + "</td>");
4133- _list.append("<td fixwidth=45>" + clanlevel + "</td>");
4134- _list.append("<td align=center FIXWIDTH=70>" + reputation + "</td>");
4135- _list.append("</tr></table><img src=\"L2UI.Squaregray\" width=\"680\" height=\"1\">");
4136+ _list.append("<td valign=\"top\" align=\"center\">" + _counter + "</td");
4137+ _list.append("<td valign=\"top\" align=\"center\">" + clan + "</td");
4138+ _list.append("<td valign=\"top\" align=\"center\">" + leadername + "</td>");
4139+ _list.append("<td valign=\"top\" align=\"center\">" + clanlevel + "</td>");
4140+ _list.append("<td valign=\"top\" align=\"center\">" + reputation + "</td>");
4141+ _list.append("</tr>");
4142 }
4143
4144 @Override
4145Index: java/l2r/gameserver/model/actor/knownlist/CharKnownList.java
4146===================================================================
4147--- java/l2r/gameserver/model/actor/knownlist/CharKnownList.java (revision 940)
4148+++ java/l2r/gameserver/model/actor/knownlist/CharKnownList.java (working copy)
4149@@ -285,6 +285,11 @@
4150 return result;
4151 }
4152
4153+ public final L2Object getKnownObject(int objectId)
4154+ {
4155+ return getKnownObjects().get(objectId);
4156+ }
4157+
4158 public final Map<Integer, L2PcInstance> getKnownPlayers()
4159 {
4160 if (_knownPlayers == null)
4161Index: java/l2r/gameserver/model/items/L2Item.java
4162===================================================================
4163--- java/l2r/gameserver/model/items/L2Item.java (revision 945)
4164+++ java/l2r/gameserver/model/items/L2Item.java (working copy)
4165@@ -172,6 +172,9 @@
4166 // vGodFather
4167 private final boolean _mustConsume;
4168
4169+ // Elemental
4170+ private final boolean _isForPet = false;
4171+
4172 /**
4173 * Constructor of the L2Item that fill class variables.<BR>
4174 * <BR>
4175@@ -536,6 +539,130 @@
4176 }
4177
4178 /**
4179+ * Returns true if item is armor or shield.
4180+ * @return true if item is armor or shield, otherwise false
4181+ */
4182+ public boolean isArmorOrShield()
4183+ {
4184+ return _type2 == TYPE2_SHIELD_ARMOR;
4185+ }
4186+
4187+ /**
4188+ * Returns true if item is weapon.
4189+ * @return true if item is weapon, otherwise false
4190+ */
4191+ public boolean isWeapon()
4192+ {
4193+ return _type2 == TYPE2_WEAPON;
4194+ }
4195+
4196+ /**
4197+ * @return Returns the crystal type name of the item
4198+ */
4199+ public final String getCrystalName()
4200+ {
4201+ switch (_crystalType)
4202+ {
4203+ case NONE:
4204+ return "None";
4205+ case D:
4206+ return "D";
4207+ case C:
4208+ return "C";
4209+ case B:
4210+ return "B";
4211+ case A:
4212+ return "A";
4213+ case S:
4214+ return "S";
4215+ case S80:
4216+ return "S80";
4217+ case S84:
4218+ return "S84";
4219+ }
4220+
4221+ return "All";
4222+ }
4223+
4224+ /**
4225+ * @return Returns true if this item is a jewel
4226+ */
4227+ public boolean isJewel()
4228+ {
4229+ return (_bodyPart == L2Item.SLOT_LR_FINGER) || (_bodyPart == L2Item.SLOT_LR_EAR) || (_bodyPart == L2Item.SLOT_NECK);
4230+ }
4231+
4232+ /**
4233+ * @return Returns true if this items is only for pets
4234+ */
4235+ public boolean isForPet()
4236+ {
4237+ return _isForPet;
4238+ }
4239+
4240+ /**
4241+ * It also takes into account that stat enchants
4242+ * @param activeChar
4243+ * @param item
4244+ * @param stat
4245+ * @param order
4246+ * @return Returns the value of a certain function of the item. This is for example to find the value in <set order = "0x08" stat = "MATK" val = "28" /> with order 0x08 and MATK stat
4247+ */
4248+ public double getValueFromStatFunc(L2PcInstance activeChar, L2ItemInstance item, String stat, String order)
4249+ {
4250+ try
4251+ {
4252+ // First we find the constant value of that stat
4253+ double value = 0;
4254+ for (FuncTemplate t : _funcTemplates)
4255+ {
4256+ if (!t.getStat().getValue().equalsIgnoreCase(stat))
4257+ {
4258+ continue;
4259+ }
4260+
4261+ if (t.getOrder() != Integer.decode(order))
4262+ {
4263+ continue;
4264+ }
4265+ }
4266+
4267+ // Then look for the enchant
4268+ for (FuncTemplate t : _funcTemplates)
4269+ {
4270+ if (!t.getStat().getValue().equalsIgnoreCase(stat))
4271+ {
4272+ continue;
4273+ }
4274+
4275+ if (!t.functionClass.getSimpleName().equalsIgnoreCase("FuncEnchant"))
4276+ {
4277+ continue;
4278+ }
4279+
4280+ Env env = new Env();
4281+ env.setCharacter(activeChar);
4282+ env.setTarget(activeChar);
4283+ env.setItem(item);
4284+
4285+ AbstractFunction func = t.getFunc(env, item);
4286+ if (func == null)
4287+ {
4288+ continue;
4289+ }
4290+
4291+ func.calc(env);
4292+ return value + env.getValue();
4293+ }
4294+ }
4295+ catch (NumberFormatException e)
4296+ {
4297+ }
4298+
4299+ return 0;
4300+ }
4301+
4302+ /**
4303 * Sets the base elemental of the item.
4304 * @param element the element to set.
4305 */
4306Index: java/l2r/gameserver/model/actor/instance/L2PcInstance.java
4307===================================================================
4308--- java/l2r/gameserver/model/actor/instance/L2PcInstance.java (revision 940)
4309+++ java/l2r/gameserver/model/actor/instance/L2PcInstance.java (working copy)
4310@@ -277,6 +277,7 @@
4311 import l2r.gameserver.network.serverpackets.ExStorageMaxCount;
4312 import l2r.gameserver.network.serverpackets.ExVoteSystemInfo;
4313 import l2r.gameserver.network.serverpackets.FlyToLocation.FlyType;
4314+import l2r.gameserver.network.serverpackets.FriendPacket;
4315 import l2r.gameserver.network.serverpackets.FriendStatusPacket;
4316 import l2r.gameserver.network.serverpackets.GameGuardQuery;
4317 import l2r.gameserver.network.serverpackets.GetOnVehicle;
4318@@ -9501,6 +9502,44 @@
4319 sendPacket(new ExShowScreenMessage2(text, timeonscreenins * 1000, ScreenMessageAlign.TOP_CENTER, text.length() > 30 ? false : true));
4320 }
4321
4322+ /**
4323+ * @param name
4324+ */
4325+ public void removeFriend(String name)
4326+ {
4327+ SystemMessage sm;
4328+ int id = CharNameTable.getInstance().getIdByName(name);
4329+
4330+ try (Connection con = L2DatabaseFactory.getInstance().getConnection();
4331+ PreparedStatement statement = con.prepareStatement("DELETE FROM character_friends WHERE (charId=? AND friendId=?) OR (charId=? AND friendId=?)"))
4332+ {
4333+ statement.setInt(1, getObjectId());
4334+ statement.setInt(2, id);
4335+ statement.setInt(3, id);
4336+ statement.setInt(4, getObjectId());
4337+ statement.execute();
4338+
4339+ // Player deleted from your friend list
4340+ sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_DELETED_FROM_YOUR_FRIENDS_LIST);
4341+ sm.addString(name);
4342+ sendPacket(sm);
4343+
4344+ getFriendList().remove(Integer.valueOf(id));
4345+ sendPacket(new FriendPacket(false, id));
4346+
4347+ L2PcInstance player = L2World.getInstance().getPlayer(name);
4348+ if (player != null)
4349+ {
4350+ player.getFriendList().remove(Integer.valueOf(getObjectId()));
4351+ player.sendPacket(new FriendPacket(false, getObjectId()));
4352+ }
4353+ }
4354+ catch (Exception e)
4355+ {
4356+ _log.warn("could not del friend objectid: ", e);
4357+ }
4358+ }
4359+
4360 public void enterObserverMode(Location loc)
4361 {
4362 setLastLocation();
4363@@ -13247,6 +13286,26 @@
4364 return _friendList;
4365 }
4366
4367+ public int getFriendsCount()
4368+ {
4369+ return _friendList.size();
4370+ }
4371+
4372+ public int getOnlineFriendsCount()
4373+ {
4374+ int onlineCount = 0;
4375+ for (int id : _friendList)
4376+ {
4377+ L2PcInstance friend = L2World.getInstance().getPlayer(id);
4378+ if ((friend != null) && friend.isOnline())
4379+ {
4380+ onlineCount++;
4381+ }
4382+ }
4383+
4384+ return onlineCount;
4385+ }
4386+
4387 public void restoreFriendList()
4388 {
4389 _friendList.clear();
4390@@ -15014,6 +15073,19 @@
4391 return _nevitSystem;
4392 }
4393
4394+ public void broadcastRelationChanged2()
4395+ {
4396+ if (getSummon() != null)
4397+ {
4398+ sendPacket(new RelationChanged(getSummon(), getRelation(this), this));
4399+ }
4400+
4401+ for (L2PcInstance player : getKnownList().getKnownPlayers().values())
4402+ {
4403+ RelationChanged.sendRelationChanged(this, player);
4404+ }
4405+ }
4406+
4407 private PcAdmin _pcAdmin = null;
4408
4409 public PcAdmin getPcAdmin()
4410Index: java/l2r/features/auctionEngine/templates/AuctionConditions.java
4411===================================================================
4412--- java/l2r/features/auctionEngine/templates/AuctionConditions.java (revision 0)
4413+++ java/l2r/features/auctionEngine/templates/AuctionConditions.java (working copy)
4414@@ -0,0 +1,285 @@
4415+/*
4416+ * This program is free software: you can redistribute it and/or modify it under
4417+ * the terms of the GNU General Public License as published by the Free Software
4418+ * Foundation, either version 3 of the License, or (at your option) any later
4419+ * version.
4420+ *
4421+ * This program is distributed in the hope that it will be useful, but WITHOUT
4422+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
4423+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
4424+ * details.
4425+ *
4426+ * You should have received a copy of the GNU General Public License along with
4427+ * this program. If not, see <http://www.gnu.org/licenses/>.
4428+ */
4429+package l2r.features.auctionEngine.templates;
4430+
4431+import java.util.ArrayList;
4432+import java.util.List;
4433+
4434+import l2r.gameserver.model.holders.SkillHolder;
4435+import l2r.gameserver.model.items.L2EtcItem;
4436+import l2r.gameserver.model.items.L2Weapon;
4437+import l2r.gameserver.model.items.instance.L2ItemInstance;
4438+import l2r.gameserver.model.items.type.ArmorType;
4439+import l2r.gameserver.model.items.type.EtcItemType;
4440+import l2r.gameserver.model.items.type.WeaponType;
4441+
4442+/**
4443+ * List of conditions that can be used to filter what kind of items include each category
4444+ * @author GodFather
4445+ */
4446+public class AuctionConditions
4447+{
4448+ public static abstract class AuctionCondition
4449+ {
4450+ /**
4451+ * @param item
4452+ * @param entrance
4453+ * @return Returns true if the item passes all the checks invoqued by the conditions of that entry
4454+ */
4455+ public abstract boolean checkCondition(L2ItemInstance item, AuctionHouse entrance);
4456+ }
4457+
4458+ public static class AuctionConditionEtcType extends AuctionCondition
4459+ {
4460+ private final List<EtcItemType> _types = new ArrayList<>();
4461+
4462+ public AuctionConditionEtcType(EtcItemType... types)
4463+ {
4464+ for (EtcItemType type : types)
4465+ {
4466+ _types.add(type);
4467+ }
4468+ }
4469+
4470+ @Override
4471+ public boolean checkCondition(L2ItemInstance item, AuctionHouse entrance)
4472+ {
4473+ if (!(item.getItem() instanceof L2EtcItem))
4474+ {
4475+ return false;
4476+ }
4477+
4478+ return _types.contains(item.getItem().getItemType());
4479+ }
4480+ }
4481+
4482+ public static class AuctionConditionWeaponType extends AuctionCondition
4483+ {
4484+ private final boolean _isMagicWeapon;
4485+ private final List<WeaponType> _types = new ArrayList<>();
4486+
4487+ public AuctionConditionWeaponType(boolean isMagicWeapon, WeaponType... types)
4488+ {
4489+ _isMagicWeapon = isMagicWeapon;
4490+ for (WeaponType type : types)
4491+ {
4492+ _types.add(type);
4493+ }
4494+ }
4495+
4496+ @Override
4497+ public boolean checkCondition(L2ItemInstance item, AuctionHouse entrance)
4498+ {
4499+ if (!item.getItem().isWeapon())
4500+ {
4501+ return false;
4502+ }
4503+
4504+ if (_isMagicWeapon != ((L2Weapon) item.getItem()).isMagicWeapon())
4505+ {
4506+ return false;
4507+ }
4508+
4509+ return _types.contains(item.getItem().getItemType());
4510+ }
4511+ }
4512+
4513+ public static class AuctionConditionArmorType extends AuctionCondition
4514+ {
4515+ private final List<ArmorType> _types = new ArrayList<>();
4516+
4517+ public AuctionConditionArmorType(ArmorType... types)
4518+ {
4519+ for (ArmorType type : types)
4520+ {
4521+ _types.add(type);
4522+ }
4523+ }
4524+
4525+ @Override
4526+ public boolean checkCondition(L2ItemInstance item, AuctionHouse entrance)
4527+ {
4528+ if (!item.getItem().isArmorOrShield())
4529+ {
4530+ return false;
4531+ }
4532+
4533+ return _types.contains(item.getItem().getItemType());
4534+ }
4535+ }
4536+
4537+ public static class AuctionConditionSkill extends AuctionCondition
4538+ {
4539+ private final List<Integer> _skills = new ArrayList<>();
4540+
4541+ public AuctionConditionSkill(int... skills)
4542+ {
4543+ for (int skill : skills)
4544+ {
4545+ _skills.add(skill);
4546+ }
4547+ }
4548+
4549+ @Override
4550+ public boolean checkCondition(L2ItemInstance item, AuctionHouse entrance)
4551+ {
4552+ if (!item.getItem().hasSkills())
4553+ {
4554+ return false;
4555+ }
4556+
4557+ for (SkillHolder skill : item.getItem().getSkills())
4558+ {
4559+ if (_skills.contains(skill.getSkillId()))
4560+ {
4561+ return true;
4562+ }
4563+ }
4564+
4565+ return false;
4566+ }
4567+ }
4568+
4569+ public static class AuctionConditionSlot extends AuctionCondition
4570+ {
4571+ private final List<Integer> _slots = new ArrayList<>();
4572+
4573+ public AuctionConditionSlot(int... slots)
4574+ {
4575+ for (int slot : slots)
4576+ {
4577+ _slots.add(slot);
4578+ }
4579+ }
4580+
4581+ @Override
4582+ public boolean checkCondition(L2ItemInstance item, AuctionHouse entrance)
4583+ {
4584+ return _slots.contains(item.getItem().getBodyPart());
4585+ }
4586+ }
4587+
4588+ public static class AuctionConditionIcon extends AuctionCondition
4589+ {
4590+ private final List<String> _icons = new ArrayList<>();
4591+
4592+ public AuctionConditionIcon(String... icons)
4593+ {
4594+ for (String icon : icons)
4595+ {
4596+ _icons.add(icon);
4597+ }
4598+ }
4599+
4600+ @Override
4601+ public boolean checkCondition(L2ItemInstance item, AuctionHouse entrance)
4602+ {
4603+ if (!item.getItem().hasSkills())
4604+ {
4605+ return false;
4606+ }
4607+
4608+ for (String icon : _icons)
4609+ {
4610+ if (item.getItem().getIcon().startsWith(icon))
4611+ {
4612+ return true;
4613+ }
4614+ }
4615+
4616+ return false;
4617+ }
4618+ }
4619+
4620+ public static class AuctionConditionName extends AuctionCondition
4621+ {
4622+ private final List<String> _names = new ArrayList<>();
4623+
4624+ public AuctionConditionName(String... names)
4625+ {
4626+ for (String name : names)
4627+ {
4628+ _names.add(name);
4629+ }
4630+ }
4631+
4632+ @Override
4633+ public boolean checkCondition(L2ItemInstance item, AuctionHouse entrance)
4634+ {
4635+ for (String name : _names)
4636+ {
4637+ if (item.getItem().getName().startsWith(name))
4638+ {
4639+ return true;
4640+ }
4641+ }
4642+
4643+ return false;
4644+ }
4645+ }
4646+
4647+ public static class AuctionConditionHandler extends AuctionCondition
4648+ {
4649+ private final List<String> _handlers = new ArrayList<>();
4650+
4651+ public AuctionConditionHandler(String... handlers)
4652+ {
4653+ for (String handler : handlers)
4654+ {
4655+ _handlers.add(handler);
4656+ }
4657+ }
4658+
4659+ @Override
4660+ public boolean checkCondition(L2ItemInstance item, AuctionHouse entrance)
4661+ {
4662+ if (!(item.getItem() instanceof L2EtcItem))
4663+ {
4664+ return false;
4665+ }
4666+
4667+ if (item.getEtcItem().getHandlerName() == null)
4668+ {
4669+ return false;
4670+ }
4671+
4672+ for (String handler : _handlers)
4673+ {
4674+ if (item.getEtcItem().getHandlerName().equalsIgnoreCase(handler))
4675+ {
4676+ return true;
4677+ }
4678+ }
4679+
4680+ return false;
4681+ }
4682+ }
4683+
4684+ public static class AuctionConditionForPet extends AuctionCondition
4685+ {
4686+ private final boolean _isForPet;
4687+
4688+ public AuctionConditionForPet(boolean isForPet)
4689+ {
4690+ _isForPet = isForPet;
4691+ }
4692+
4693+ @Override
4694+ public boolean checkCondition(L2ItemInstance item, AuctionHouse entrance)
4695+ {
4696+ return _isForPet == item.getItem().isForPet();
4697+ }
4698+ }
4699+}
4700Index: java/l2r/gameserver/communitybbs/SunriseBoards/TopPvpPlayers.java
4701===================================================================
4702--- java/l2r/gameserver/communitybbs/SunriseBoards/TopPvpPlayers.java (revision 173)
4703+++ java/l2r/gameserver/communitybbs/SunriseBoards/TopPvpPlayers.java (working copy)
4704@@ -31,13 +31,12 @@
4705
4706 private void addChar(String name, String cname, int pvp)
4707 {
4708- _list.append("<table width=680 bgcolor=111111 height=16 border=0 cellspacing=0 cellpadding=0>");
4709 _list.append("<tr>");
4710- _list.append("<td FIXWIDTH=40>" + _counter + "</td");
4711- _list.append("<td fixwidth=160>" + name + "</td");
4712- _list.append("<td fixwidth=160>" + cname + "</td>");
4713- _list.append("<td align=center fixwidth=80>" + pvp + "</td>");
4714- _list.append("</tr></table><img src=\"L2UI.Squaregray\" width=\"680\" height=\"1\">");
4715+ _list.append("<td valign=\"top\" align=\"center\">" + _counter + "</td");
4716+ _list.append("<td valign=\"top\" align=\"center\">" + name + "</td");
4717+ _list.append("<td valign=\"top\" align=\"center\">" + cname + "</td>");
4718+ _list.append("<td valign=\"top\" align=\"center\">" + pvp + "</td>");
4719+ _list.append("</tr>");
4720 }
4721
4722 @Override
4723Index: java/l2r/gameserver/communitybbs/Managers/FriendsBBSManager.java
4724===================================================================
4725--- java/l2r/gameserver/communitybbs/Managers/FriendsBBSManager.java (revision 0)
4726+++ java/l2r/gameserver/communitybbs/Managers/FriendsBBSManager.java (working copy)
4727@@ -0,0 +1,359 @@
4728+package l2r.gameserver.communitybbs.Managers;
4729+
4730+import l2r.gameserver.data.sql.CharNameTable;
4731+import l2r.gameserver.model.BlockList;
4732+import l2r.gameserver.model.L2World;
4733+import l2r.gameserver.model.actor.instance.L2PcInstance;
4734+import l2r.gameserver.network.SystemMessageId;
4735+import l2r.gameserver.network.serverpackets.FriendAddRequest;
4736+import l2r.gameserver.network.serverpackets.NpcHtmlMessage;
4737+import l2r.gameserver.network.serverpackets.SystemMessage;
4738+
4739+import gr.sr.utils.Tools;
4740+
4741+public class FriendsBBSManager extends BaseBBSManager
4742+{
4743+ @Override
4744+ public void cbByPass(String command, L2PcInstance activeChar)
4745+ {
4746+ if (command.startsWith("_bbs_friends:invite"))
4747+ {
4748+ String[] cm = command.split(" ");
4749+ try
4750+ {
4751+ if ((cm[1] != null) && (cm[1].length() < 16))
4752+ {
4753+ TryFriendInvite(activeChar, cm[1]);
4754+ }
4755+ }
4756+ catch (ArrayIndexOutOfBoundsException e)
4757+ {
4758+ activeChar.sendMessage("Friend invite box cannot be empty");
4759+ }
4760+ }
4761+ else if (command.startsWith("_bbs_friends:go"))
4762+ {
4763+ String[] cm = command.split(" ");
4764+ if (cm[1].length() < 2)
4765+ {
4766+ pagr(activeChar, Integer.parseInt(cm[1]));
4767+ }
4768+ }
4769+ else if (command.startsWith("_bbs_friends:block"))
4770+ {
4771+ String[] cm = command.split(" ");
4772+
4773+ try
4774+ {
4775+ if (cm[1].length() < 16)
4776+ {
4777+ final int targetId = CharNameTable.getInstance().getIdByName(cm[1]);
4778+
4779+ if (BlockList.isBlocked(activeChar, targetId))
4780+ {
4781+ removeFromBlockList(activeChar, targetId, Integer.parseInt(cm[2]));
4782+ }
4783+ else
4784+ {
4785+ addToBlockList(activeChar, targetId, 1);
4786+ }
4787+ }
4788+ }
4789+ catch (ArrayIndexOutOfBoundsException e)
4790+ {
4791+ activeChar.sendMessage("Block player box cannot be empty");
4792+ }
4793+ }
4794+ else if (command.startsWith("_bbs_friends:remove"))
4795+ {
4796+ String[] cm = command.split(" ");
4797+ try
4798+ {
4799+ if (cm[1].length() < 16)
4800+ {
4801+ removeFriend(activeChar, cm[1], Integer.parseInt(cm[2]));
4802+ }
4803+ }
4804+ catch (Exception e)
4805+ {
4806+
4807+ }
4808+ }
4809+ else
4810+ {
4811+ pagr(activeChar, 1);
4812+ }
4813+ }
4814+
4815+ public void pagr(L2PcInstance pl, int page)
4816+ {
4817+ if (pl == null)
4818+ {
4819+ return;
4820+ }
4821+
4822+ String html = getHtml("data/html/CommunityBoard/friends/friends.htm");
4823+ int friendforvisual = 0;
4824+ int blockforvisual = 0;
4825+ int all = 0;
4826+ boolean pagereached = false;
4827+
4828+ html = html.replaceAll("%fonline%", "" + pl.getOnlineFriendsCount());
4829+ html = html.replaceAll("%fall%", "" + pl.getFriendsCount());
4830+ html = html.replaceAll("%blocked%", "" + pl.getBlockList().getBlockList().size());
4831+
4832+ int totalpages = 0;
4833+
4834+ int maxfpages = (int) Math.round((pl.getFriendList().size() / 12.0) + 1);
4835+ int maxbpages = (int) Math.round((pl.getBlockList().getBlockList().size() / 6.0) + 1);
4836+
4837+ if (maxfpages > maxbpages)
4838+ {
4839+ totalpages = maxfpages;
4840+ }
4841+ else if (maxfpages < maxbpages)
4842+ {
4843+ totalpages = maxbpages;
4844+ }
4845+ else
4846+ {
4847+ totalpages = maxfpages;
4848+ }
4849+
4850+ if (page == 1)
4851+ {
4852+ html = html.replaceAll("%more%", "<button value=\"\" action=\"bypass _bbs_friends:go " + (page + 1) + "\" width=40 height=20 back=\"L2UI_CT1.Inventory_DF_Btn_RotateLeft\" fore=\"L2UI_CT1.Inventory_DF_Btn_RotateLeft\">");
4853+ html = html.replaceAll("%back%", " ");
4854+ }
4855+ else if (page > 1)
4856+ {
4857+ if (totalpages == page)
4858+ {
4859+ html = html.replaceAll("%back%", "<button value=\"\" action=\"bypass _bbs_friends:go " + (page - 1) + "\" width=40 height=20 back=\"L2UI_CT1.Inventory_DF_Btn_RotateRight\" fore=\"L2UI_CT1.Inventory_DF_Btn_RotateRight\">");
4860+ html = html.replaceAll("%more%", " ");
4861+ }
4862+ else
4863+ {
4864+ html = html.replaceAll("%more%", "<button value=\"\" action=\"bypass _bbs_friends:go " + (page + 1) + "\" width=40 height=20 back=\"L2UI_CT1.Inventory_DF_Btn_RotateLeft\" fore=\"L2UI_CT1.Inventory_DF_Btn_RotateLeft\">");
4865+ html = html.replaceAll("%back%", "<button value=\"\" action=\"bypass _bbs_friends:go " + (page - 1) + "\" width=40 height=20 back=\"L2UI_CT1.Inventory_DF_Btn_RotateRight\" fore=\"L2UI_CT1.Inventory_DF_Btn_RotateRight\">");
4866+ }
4867+ }
4868+
4869+ if (page <= maxfpages)
4870+ {
4871+ for (int id : pl.getFriendList())
4872+ {
4873+ String friend = CharNameTable.getInstance().getNameById(id);
4874+
4875+ all++;
4876+ if ((page == 1) && (friendforvisual > 12))
4877+ {
4878+ continue;
4879+ }
4880+ if (!pagereached && (all > (page * 12)))
4881+ {
4882+ continue;
4883+ }
4884+ if (!pagereached && (all <= ((page - 1) * 12)))
4885+ {
4886+ continue;
4887+ }
4888+ friendforvisual++;
4889+
4890+ html = html.replaceAll("%charName" + friendforvisual + "%", friend);
4891+ html = html.replaceAll("%charImage" + friendforvisual + "%", friend);// FIXME f.getImage());
4892+
4893+ if (L2World.getInstance().getPlayer(id) != null)
4894+ {
4895+ html = html.replaceAll("%charLoginDate" + friendforvisual + "%", "Friend is <font color=\"00CC33\">Online</font>");
4896+ }
4897+ else
4898+ {
4899+ Long lastaccess = CharNameTable.getInstance().getLastAccessById(id);
4900+ String date = Tools.convertDateToString(lastaccess);
4901+ html = html.replaceAll("%charLoginDate" + friendforvisual + "%", "Friend was online at <font color=\"5b574c\">" + date + "</font>");
4902+ }
4903+ html = html.replaceAll("%charwidth" + friendforvisual + "%", "100");
4904+ html = html.replaceAll("%btn" + friendforvisual + "%", "<button value=\"\" action=\"bypass _bbs_friends:remove " + friend + " " + page + "\" width=32 height=32 back=\"L2UI_CT1.MiniMap_DF_MinusBtn_Red_Over\" fore=\"L2UI_CT1.MiniMap_DF_MinusBtn_Red\">");
4905+ }
4906+ }
4907+
4908+ if (page <= maxbpages)
4909+ {
4910+ all = 0;
4911+ pagereached = false;
4912+
4913+ for (Integer id : pl.getBlockList().getBlockList())
4914+ {
4915+ String blocked = CharNameTable.getInstance().getNameById(id);
4916+
4917+ all++;
4918+ if ((page == 1) && (blockforvisual > 6))
4919+ {
4920+ continue;
4921+ }
4922+ if (!pagereached && (all > (page * 6)))
4923+ {
4924+ continue;
4925+ }
4926+ if (!pagereached && (all <= ((page - 1) * 6)))
4927+ {
4928+ continue;
4929+ }
4930+ blockforvisual++;
4931+ if (blocked != null)
4932+ {
4933+ html = html.replaceAll("%bcharName" + blockforvisual + "%", blocked);
4934+ }
4935+ else
4936+ {
4937+ html = html.replaceAll("%bcharName" + blockforvisual + "%", "N/A");
4938+ }
4939+
4940+ html = html.replaceAll("%bcharImage" + blockforvisual + "%", "icon.skill4269");
4941+ html = html.replaceAll("%bcharwidth" + blockforvisual + "%", "100");
4942+ html = html.replaceAll("%bchar" + blockforvisual + "%", "Blocked player.");
4943+ if (blocked != null)
4944+ {
4945+ html = html.replaceAll("%bbtn" + blockforvisual + "%", "<button value=\"\" action=\"bypass _bbs_friends:block " + blocked + " " + page + "\" width=32 height=32 back=\"L2UI_CT1.MiniMap_DF_MinusBtn_Red_Over\" fore=\"L2UI_CT1.MiniMap_DF_MinusBtn_Red\">");
4946+ }
4947+ else
4948+ {
4949+ html = html.replaceAll("%bbtn" + blockforvisual + "%", "<button value=\"\" action=\"bypass _bbs_friends:block N/A " + page + "\" width=32 height=32 back=\"L2UI_CT1.MiniMap_DF_MinusBtn_Red_Over\" fore=\"L2UI_CT1.MiniMap_DF_MinusBtn_Red\">");
4950+ }
4951+ }
4952+ }
4953+
4954+ if (friendforvisual < 12)
4955+ {
4956+ for (int d = friendforvisual + 1; d != 13; d++)
4957+ {
4958+ html = html.replaceAll("%charName" + d + "%", " ");
4959+ html = html.replaceAll("%charImage" + d + "%", "L2UI_CH3.multisell_plusicon");
4960+ html = html.replaceAll("%charLoginDate" + d + "%", " ");
4961+ html = html.replaceAll("%charwidth" + d + "%", "121");
4962+ html = html.replaceAll("%btn" + d + "%", " ");
4963+ }
4964+ }
4965+ if (blockforvisual < 6)
4966+ {
4967+ for (int d = blockforvisual + 1; d != 7; d++)
4968+ {
4969+ html = html.replaceAll("%bcharName" + d + "%", " ");
4970+ html = html.replaceAll("%bcharImage" + d + "%", "L2UI_CH3.multisell_plusicon");
4971+ html = html.replaceAll("%bcharwidth" + d + "%", "121");
4972+ html = html.replaceAll("%bchar" + d + "%", " ");
4973+ html = html.replaceAll("%bbtn" + d + "%", " ");
4974+ }
4975+ }
4976+ separateAndSend(html.toString(), pl);
4977+ }
4978+
4979+ public void removeFriend(L2PcInstance pl, String name, int page)
4980+ {
4981+ if (pl == null)
4982+ {
4983+ return;
4984+ }
4985+
4986+ final int targetId = CharNameTable.getInstance().getIdByName(name);
4987+
4988+ if (pl.getFriendList().contains(targetId))
4989+ {
4990+ pl.removeFriend(name);
4991+ pagr(pl, page);
4992+ }
4993+ else
4994+ {
4995+ pl.sendMessageS("Friend not found.", 4);
4996+ }
4997+ }
4998+
4999+ public void addToBlockList(L2PcInstance player, int targetId, int page)
5000+ {
5001+ BlockList.addToBlockList(player, targetId);
5002+ pagr(player, page);
5003+ }
5004+
5005+ public void removeFromBlockList(L2PcInstance activeChar, int targetId, int page)
5006+ {
5007+ BlockList.removeFromBlockList(activeChar, targetId);
5008+ pagr(activeChar, page);
5009+ }
5010+
5011+ public boolean TryFriendInvite(L2PcInstance activeChar, String addFriend)
5012+ {
5013+ if ((activeChar == null) || (addFriend == null) || addFriend.isEmpty())
5014+ {
5015+ return false;
5016+ }
5017+ if (activeChar.isProcessingTransaction())
5018+ {
5019+ activeChar.sendPacket(SystemMessageId.WAITING_FOR_ANOTHER_REPLY);
5020+ return false;
5021+ }
5022+ if (activeChar.getName().equalsIgnoreCase(addFriend))
5023+ {
5024+ activeChar.sendPacket(SystemMessageId.YOU_CANNOT_ADD_YOURSELF_TO_OWN_FRIEND_LIST);
5025+ return false;
5026+ }
5027+ L2PcInstance friendChar = L2World.getInstance().getPlayer(addFriend);
5028+ if (friendChar == null)
5029+ {
5030+ activeChar.sendPacket(SystemMessageId.THE_USER_YOU_REQUESTED_IS_NOT_IN_GAME);
5031+ return false;
5032+ }
5033+ if (friendChar.getBlockList().isInBlockList(activeChar) || friendChar.getMessageRefusal())
5034+ {
5035+ activeChar.sendPacket(SystemMessageId.THE_PERSON_IS_IN_MESSAGE_REFUSAL_MODE);
5036+ return false;
5037+ }
5038+ if (friendChar.isProcessingTransaction())
5039+ {
5040+ activeChar.sendPacket(SystemMessageId.PLEASE_TRY_AGAIN_LATER);
5041+ return false;
5042+ }
5043+ if (activeChar.getFriendList().contains(addFriend.toLowerCase()))
5044+ {
5045+ activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.C1_ALREADY_ON_FRIEND_LIST).addString(friendChar.getName()));
5046+ return false;
5047+ }
5048+
5049+ final L2PcInstance friend = L2World.getInstance().getPlayer(addFriend);
5050+ activeChar.onTransactionRequest(friend);
5051+ SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_REQUESTED_C1_TO_BE_FRIEND);
5052+ sm.addString(addFriend);
5053+ FriendAddRequest ajf = new FriendAddRequest(activeChar.getName());
5054+ friend.sendPacket(ajf);
5055+ activeChar.sendMessageS("Friend invitation has beed sent.", 5);
5056+ return true;
5057+ }
5058+
5059+ public String getHtml(String path)
5060+ {
5061+ NpcHtmlMessage html = new NpcHtmlMessage(0);
5062+
5063+ if (!html.setFile(null, null, path))
5064+ {
5065+ return null;
5066+ }
5067+
5068+ return html.getHtml();
5069+ }
5070+
5071+ @Override
5072+ public void parsewrite(String url, String ar1, String ar2, String ar3, String ar4, String ar5, L2PcInstance activeChar)
5073+ {
5074+
5075+ }
5076+
5077+ public static FriendsBBSManager getInstance()
5078+ {
5079+ return SingletonHolder._instance;
5080+ }
5081+
5082+ private static class SingletonHolder
5083+ {
5084+ protected static final FriendsBBSManager _instance = new FriendsBBSManager();
5085+ }
5086+}
5087\ No newline at end of file
5088Index: java/l2r/gameserver/communitybbs/SunriseBoards/GrandBossList.java
5089===================================================================
5090--- java/l2r/gameserver/communitybbs/SunriseBoards/GrandBossList.java (revision 173)
5091+++ java/l2r/gameserver/communitybbs/SunriseBoards/GrandBossList.java (working copy)
5092@@ -59,14 +59,11 @@
5093
5094 private void addGrandBossToList(int pos, String npcname, boolean rstatus)
5095 {
5096- _list.append("<table width=680 bgcolor=111111 height=16 border=0 cellspacing=0 cellpadding=0>");
5097 _list.append("<tr>");
5098- _list.append("<td FIXWIDTH=30>" + pos + "</td>");
5099- _list.append("<td FIXWIDTH=30>" + npcname + "</td>");
5100- _list.append("<td FIXWIDTH=30 align=center>" + ((rstatus) ? "<font color=99FF00>Alive</font>" : "<font color=CC0000>Dead</font>") + "</td>");
5101+ _list.append("<td valign=\"top\" align=\"center\">" + pos + "</td>");
5102+ _list.append("<td valign=\"top\" align=\"center\">" + npcname + "</td>");
5103+ _list.append("<td valign=\"top\" align=\"center\">" + ((rstatus) ? "<font color=99FF00>Alive</font>" : "<font color=CC0000>Dead</font>") + "</td>");
5104 _list.append("</tr>");
5105- _list.append("</table>");
5106- _list.append("<img src=\"L2UI.Squaregray\" width=\"680\" height=\"1\">");
5107 }
5108
5109 @Override
5110Index: java/l2r/gameserver/communitybbs/Managers/ClanBBSManager.java
5111===================================================================
5112--- java/l2r/gameserver/communitybbs/Managers/ClanBBSManager.java (revision 173)
5113+++ java/l2r/gameserver/communitybbs/Managers/ClanBBSManager.java (working copy)
5114@@ -122,32 +122,30 @@
5115 }
5116 else
5117 {
5118- final StringBuilder html = StringUtil.startAppend(2000, "<html><body><br><br><table border=0 width=610><tr><td width=10></td><td width=600 align=left><a action=\"bypass _bbshome\">HOME</a> > <a action=\"bypass _bbsclan_clanlist\"> CLAN COMMUNITY </a> > <a action=\"bypass _bbsclan_clanhome;", String.valueOf(clanId), "\"> &$802; </a></td></tr></table>");
5119+ final StringBuilder html = StringUtil.startAppend(2000, "<html><body><br><br><br><center><table width=\"742\" cellpadding=\"0\" cellspacing=\"0\" background=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"><tr><td height=10></td></tr><tr><td align=center width=\"700\" valign=\"top\"><table width=\"680\" height=\"60\" cellspacing=\"0\" cellpadding=\"7\"><tr><td width=\"32\" valign\"top\"><img src=\"L2UI_CT1.PVP_DF_TriggerBtn_Over\" width=\"32\" height=\"32\" align=\"top\" /></td><td width=\"545\" valign=\"top\"><table cellspacing=\"0\" cellpadding=\"0\"><tr><td height=\"26\" valign=\"top\"><font color=\"aa9977\">Clan notice</font></td></tr><tr><td>This function allows clan leader to send messages through a pop-up window to clan members at login!</td></tr></table></td><td width=\"128\" valign=\"top\"><table cellspacing=\"0\" cellpadding=\"0\"><tr><td><button value=\"Back\" action=\"bypass _bbsclan_clanhome;", String.valueOf((activeChar.getClan() != null) ? activeChar.getClan().getId() : 0), "\" width=120 height=25 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td></tr></table></td></tr></table><br><br>");
5120 if (activeChar.isClanLeader())
5121 {
5122- StringUtil.append(html, "<br><br><center><table width=610 border=0 cellspacing=0 cellpadding=0><tr><td fixwidth=610><font color=\"AAAAAA\">The Clan Notice function allows the clan leader to send messages through a pop-up window to clan members at login.</font> </td></tr><tr><td height=20></td></tr>");
5123-
5124 if (activeChar.getClan().isNoticeEnabled())
5125 {
5126- StringUtil.append(html, "<tr><td fixwidth=610> Clan Notice Function: on / <a action=\"bypass _bbsclan_clannotice_disable\">off</a>");
5127+ StringUtil.append(html, "<center><table><tr><td height=7></td></tr><tr><td fixwidth=610> Clan Notice Function: on / <a action=\"bypass _bbsclan_clannotice_disable\">off</a>");
5128 }
5129 else
5130 {
5131- StringUtil.append(html, "<tr><td fixwidth=610> Clan Notice Function: <a action=\"bypass _bbsclan_clannotice_enable\">on</a> / off");
5132+ StringUtil.append(html, "<center><table><tr><td height=7></td></tr><tr><td fixwidth=610> Clan Notice Function: <a action=\"bypass _bbsclan_clannotice_enable\">on</a> / off");
5133 }
5134
5135- StringUtil.append(html, "</td></tr></table><img src=\"L2UI.Squaregray\" width=\"610\" height=\"1\"><br> <br><table width=610 border=0 cellspacing=2 cellpadding=0><tr><td>Edit Notice: </td></tr><tr><td height=5></td></tr><tr><td><MultiEdit var =\"Content\" width=610 height=100></td></tr></table><br><table width=610 border=0 cellspacing=0 cellpadding=0><tr><td height=5></td></tr><tr><td align=center FIXWIDTH=65><button value=\"&$140;\" action=\"Write Notice Set _ Content Content Content\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\" ></td><td align=center FIXWIDTH=45></td><td align=center FIXWIDTH=500></td></tr></table></center></body></html>");
5136+ StringUtil.append(html, "</td></tr></table><br><br><table width=610 border=0 cellspacing=2 cellpadding=0><tr><td>Edit Notice: </td></tr><tr><td height=5></td></tr><tr><td><MultiEdit var =\"Content\" width=610 height=100></td></tr></table><br><table width=610 border=0 cellspacing=0 cellpadding=0><tr><td height=5></td></tr><tr><td align=center FIXWIDTH=65><button value=\"Save\" action=\"Write Notice Set _ Content Content Content\" width=65 height=20 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td><td align=center FIXWIDTH=45></td><td align=center FIXWIDTH=500></td></tr></table><br><br><table border=0 cellspacing=0 cellpadding=0><tr><td width=755 height=20></td></tr></table><br><br></td></tr></table><br><table width=640><tr><td align=center>Community Board | <font color=aa9977>L2jSunrise</font> 2013</td></tr></table><br></center></body></html></center></body></html>");
5137 send1001(html.toString(), activeChar);
5138 send1002(activeChar, activeChar.getClan().getNotice(), " ", "0");
5139 }
5140 else
5141 {
5142- StringUtil.append(html, "<img src=\"L2UI.squareblank\" width=\"1\" height=\"10\"><center><table border=0 cellspacing=0 cellpadding=0><tr><td>You are not your clan's leader, and therefore cannot change the clan notice</td></tr></table>");
5143+ StringUtil.append(html, "<img src=\"L2UI.squareblank\" width=\"1\" height=\"10\"><center><table border=0 cellspacing=0 cellpadding=0><tr><td>You are not your clan's leader, and therefore you cannot change the clan notice</td></tr></table>");
5144 if (activeChar.getClan().isNoticeEnabled())
5145 {
5146- StringUtil.append(html, "<table border=0 cellspacing=0 cellpadding=0><tr><td>The current clan notice:</td></tr><tr><td fixwidth=5></td><td FIXWIDTH=600 align=left>" + activeChar.getClan().getNotice() + "</td><td fixqqwidth=5></td></tr></table>");
5147+ StringUtil.append(html, "<br><br><table table border=0 background=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" cellspacing=0 cellpadding=0 width=540><tr><td height=20></td></tr><tr><td align=center><font color=\"aa9977\">The current clan notice:</font></td></tr><tr><td height=28></td></tr><tr><td align=center>" + activeChar.getClan().getNotice() + "</td><td fixqqwidth=5></td></tr><tr><td height=20></td></tr></table>");
5148 }
5149- StringUtil.append(html, "</center></body></html>");
5150+ StringUtil.append(html, "<br><br></td></tr></table> <br><table width=640><tr><td align=center>Community Board | <font color=aa9977>L2jSunrise</font> 2013</td></tr></table><br></center></body></html>");
5151 separateAndSend(html.toString(), activeChar);
5152 }
5153 }
5154@@ -166,7 +164,7 @@
5155 }
5156
5157 // header
5158- final StringBuilder html = StringUtil.startAppend(2000, "<html><body><br><br><center><br1><br1><table border=0 cellspacing=0 cellpadding=0><tr><td FIXWIDTH=15> </td><td width=610 height=30 align=left><a action=\"bypass _bbsclan_clanlist\"> CLAN COMMUNITY </a></td></tr></table><table border=0 cellspacing=0 cellpadding=0 width=610 bgcolor=434343><tr><td height=10></td></tr><tr><td fixWIDTH=5></td><td fixWIDTH=600><a action=\"bypass _bbsclan_clanhome;", String.valueOf((activeChar.getClan() != null) ? activeChar.getClan().getId() : 0), "\">[GO TO MY CLAN]</a> </td><td fixWIDTH=5></td></tr><tr><td height=10></td></tr></table><br><table border=0 cellspacing=0 cellpadding=2 bgcolor=5A5A5A width=610><tr><td FIXWIDTH=5></td><td FIXWIDTH=200 align=center>CLAN NAME</td><td FIXWIDTH=200 align=center>CLAN LEADER</td><td FIXWIDTH=100 align=center>CLAN LEVEL</td><td FIXWIDTH=100 align=center>CLAN MEMBERS</td><td FIXWIDTH=5></td></tr></table><img src=\"L2UI.Squareblank\" width=\"1\" height=\"5\">");
5159+ final StringBuilder html = StringUtil.startAppend(2000, "<html><body><br><br><center><table width=\"720\" background=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"><tr><td height=10></td></tr><tr><td align=center width=\"720\" valign=\"top\"><table width=\"700\" height=\"60\" cellspacing=\"0\" cellpadding=\"7\"><tr><td width=\"32\" valign=\"top\"><img src=\"L2UI_CT1.PVP_DF_TriggerBtn_Over\" width=\"32\" height=\"32\" align=\"top\" /></td><td width=\"545\" valign=\"top\"><table cellspacing=\"0\" cellpadding=\"0\"><tr><td height=\"26\" valign=\"top\"><font color=\"aa9977\">Search clan manager</font></td></tr><tr><td>Here you can find all available clans and usefull information about them. No more searching! </td></tr></table></td><td width=\"128\" valign=\"top\"><table cellspacing=\"0\" cellpadding=\"0\"><tr><td height=\"18\"></td></tr><tr><td><button value=\"My clan\" action=\"bypass _bbsclan_clanhome;", String.valueOf((activeChar.getClan() != null) ? activeChar.getClan().getId() : 0), "\" width=120 height=25 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td></tr></table></td></tr></table><table border=0 cellspacing=0 cellpadding=2 bgcolor=A7A19A width=710><tr><td FIXWIDTH=315></td><td WIDTH=360>Clan Name</td><td FIXWIDTH=70></td><td WIDTH=360>Clan Leader</td><td FIXWIDTH=30></td><td WIDTH=215>Clan Level</td><td FIXWIDTH=1></td><td WIDTH=360>Clan Members</td></tr></table>");
5160
5161 int i = 0;
5162 for (L2Clan cl : ClanTable.getInstance().getClans())
5163@@ -178,11 +176,11 @@
5164
5165 if (i++ >= ((index - 1) * 7))
5166 {
5167- StringUtil.append(html, "<img src=\"L2UI.SquareBlank\" width=\"610\" height=\"3\"><table border=0 cellspacing=0 cellpadding=0 width=610><tr> <td FIXWIDTH=5></td><td FIXWIDTH=200 align=center><a action=\"bypass _bbsclan_clanhome;", String.valueOf(cl.getId()), "\">", cl.getName(), "</a></td><td FIXWIDTH=200 align=center>", cl.getLeaderName(), "</td><td FIXWIDTH=100 align=center>", String.valueOf(cl.getLevel()), "</td><td FIXWIDTH=100 align=center>", String.valueOf(cl.getMembersCount()), "</td><td FIXWIDTH=5></td></tr><tr><td height=5></td></tr></table><img src=\"L2UI.SquareBlank\" width=\"610\" height=\"3\"><img src=\"L2UI.SquareGray\" width=\"610\" height=\"1\">");
5168+ StringUtil.append(html, "<img src=\"L2UI.SquareBlank\" width=\"680\" height=\"3\"><table border=0 cellspacing=0 cellpadding=0 width=610><tr> <td FIXWIDTH=5></td><td FIXWIDTH=200 align=center><a action=\"bypass _bbsclan_clanhome;", String.valueOf(cl.getId()), "\">", cl.getName(), "</a></td><td FIXWIDTH=200 align=center>", cl.getLeaderName(), "</td><td FIXWIDTH=100 align=center>", String.valueOf(cl.getLevel()), "</td><td FIXWIDTH=100 align=center>", String.valueOf(cl.getMembersCount()), "</td><td FIXWIDTH=5></td></tr><tr><td height=5></td></tr></table><img src=\"L2UI.SquareBlank\" width=\"610\" height=\"3\"><img src=\"L2UI.SquareGray\" width=\"610\" height=\"1\">");
5169 }
5170 }
5171
5172- html.append("<img src=\"L2UI.SquareBlank\" width=\"610\" height=\"2\"><table cellpadding=0 cellspacing=2 border=0><tr>");
5173+ html.append("<img src=\"L2UI.SquareBlank\" width=\"680\" height=\"2\"><table cellpadding=0 cellspacing=2 border=0><tr>");
5174
5175 if (index == 1)
5176 {
5177@@ -219,9 +217,9 @@
5178 {
5179 StringUtil.append(html, "<td><button action=\"bypass _bbsclan_clanlist;", String.valueOf(index + 1), "\" back=\"l2ui_ch3.next1_down\" fore=\"l2ui_ch3.next1\" width=16 height=16 ></td>");
5180 }
5181- html.append("</tr></table><table border=0 cellspacing=0 cellpadding=0><tr><td width=610><img src=\"sek.cbui141\" width=\"610\" height=\"1\"></td></tr></table><table border=0><tr><td><combobox width=65 var=keyword list=\"Name;Ruler\"></td><td><edit var = \"Search\" width=130 height=11 length=\"16\"></td>" +
5182+ html.append("</tr></table><table border=0 cellspacing=0 cellpadding=0><tr><td width=610><img src=\"sek.cbui141\" width=\"610\" height=\"1\"></td></tr></table><table border=0><tr><td><combobox width=65 var=keyword list=\"Name; \"></td><td><edit var = \"Search\" width=130 height=11 length=\"16\"></td>" +
5183 // TODO: search (Write in BBS)
5184- "<td><button value=\"&$420;\" action=\"Write 5 -1 0 Search keyword keyword\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\"> </td> </tr></table><br><br></center></body></html>");
5185+ "<td><button value=\"&$420;\" action=\"Write 5 -1 0 Search keyword keyword\" back=\"l2ui_ct1.button.button_df_small_down\" width=70 height=25 fore=\"l2ui_ct1.button.button_df_small\"> </td> </tr></table><br><br></td></tr></table><br><table width=640><tr><td align=center>Community Board | <font color=aa9977>L2jSunrise</font> 2013</td></tr></table><br></center></body></html>");
5186 separateAndSend(html.toString(), activeChar);
5187 }
5188
5189@@ -249,15 +247,7 @@
5190 }
5191 else
5192 {
5193- final String html = StringUtil.concat("<html><body><center><br><br><br1><br1><table border=0 cellspacing=0 cellpadding=0><tr><td FIXWIDTH=15> </td><td width=610 height=30 align=left><a action=\"bypass _bbshome\">HOME</a> > <a action=\"bypass _bbsclan_clanlist\"> CLAN COMMUNITY </a> > <a action=\"bypass _bbsclan_clanhome;", String.valueOf(clanId), "\"> &$802; </a></td></tr></table><table border=0 cellspacing=0 cellpadding=0 width=610 bgcolor=434343><tr><td height=10></td></tr><tr><td fixWIDTH=5></td><td fixwidth=600><a action=\"bypass _bbsclan_clanhome;", String.valueOf(clanId), ";announce\">[CLAN ANNOUNCEMENT]</a> <a action=\"bypass _bbsclan_clanhome;", String.valueOf(clanId), ";cbb\">[CLAN BULLETIN BOARD]</a><a action=\"bypass _bbsclan_clanhome;", String.valueOf(clanId), ";cmail\">[CLAN MAIL]</a> <a action=\"bypass _bbsclan_clannotice_edit;", String.valueOf(clanId), ";cnotice\">[CLAN NOTICE]</a> </td><td fixWIDTH=5></td></tr><tr><td height=10></td></tr></table><table border=0 cellspacing=0 cellpadding=0 width=610><tr><td height=10></td></tr><tr><td fixWIDTH=5></td><td fixwidth=290 valign=top></td><td fixWIDTH=5></td><td fixWIDTH=5 align=center valign=top><img src=\"l2ui.squaregray\" width=2 height=128></td><td fixWIDTH=5></td><td fixwidth=295><table border=0 cellspacing=0 cellpadding=0 width=295><tr><td fixWIDTH=100 align=left>CLAN NAME</td><td fixWIDTH=195 align=left>", cl.getName(), "</td></tr><tr><td height=7></td></tr><tr><td fixWIDTH=100 align=left>CLAN LEVEL</td><td fixWIDTH=195 align=left height=16>", String.valueOf(cl.getLevel()), "</td></tr><tr><td height=7></td></tr><tr><td fixWIDTH=100 align=left>CLAN MEMBERS</td><td fixWIDTH=195 align=left height=16>", String.valueOf(cl.getMembersCount()), "</td></tr><tr><td height=7></td></tr><tr><td fixWIDTH=100 align=left>CLAN LEADER</td><td fixWIDTH=195 align=left height=16>", cl.getLeaderName(), "</td></tr><tr><td height=7></td></tr>" +
5194- // ADMINISTRATOR ??
5195- /*
5196- * html.append("<tr>"); html.append("<td fixWIDTH=100 align=left>ADMINISTRATOR</td>"); html.append("<td fixWIDTH=195 align=left height=16>"+cl.getLeaderName()+"</td>"); html.append("</tr>");
5197- */
5198- "<tr><td height=7></td></tr><tr><td fixWIDTH=100 align=left>ALLIANCE</td><td fixWIDTH=195 align=left height=16>", (cl.getAllyName() != null) ? cl.getAllyName() : "", "</td></tr></table></td><td fixWIDTH=5></td></tr><tr><td height=10></td></tr></table>" +
5199- // TODO: the BB for clan :)
5200- // html.append("<table border=0 cellspacing=0 cellpadding=0 width=610 bgcolor=333333>");
5201- "<img src=\"L2UI.squareblank\" width=\"1\" height=\"5\"><img src=\"L2UI.squaregray\" width=\"610\" height=\"1\"><br></center><br> <br></body></html>");
5202+ final String html = StringUtil.concat("<html><body><br><br><br><center><table width=\"742\" cellpadding=\"0\" cellspacing=\"0\" background=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"><tr><td height=10></td></tr><tr><td align=center width=\"700\" valign=\"top\"><table width=\"680\" height=\"60\" cellspacing=\"0\" cellpadding=\"7\"><tr><td width=\"32\" valign=\"top\"><img src=\"L2UI_CT1.PVP_DF_TriggerBtn_Over\" width=\"32\" height=\"32\" align=\"top\" /></td><td width=\"545\" valign=\"top\"><table cellspacing=\"0\" cellpadding=\"0\"><tr><td height=\"26\" valign=\"top\"><font color=\"aa9977\">Your clan</font></td></tr><tr><td>Here you can find usefull information about your clan. No more searching! </td></tr></table></td><td width=\"128\" valign=\"top\"><table cellspacing=\"0\" cellpadding=\"0\"><tr><td><button value=\"Search for clan\" action=\"bypass _bbsclan_clanlist\" width=120 height=25 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td></tr><tr><td><button value=\"Clan Notice\" action=\"bypass _bbsclan_clannotice_edit;", String.valueOf(clanId), ";cnotice\" width=120 height=25 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td></tr></table></td></tr></table><br><br><table border=0 background=\"L2UI_CH3.refinewnd_back_Pattern\" cellspacing=0 cellpadding=0 width=610><tr><td height=40></td><</tr><tr><td valign=\"top\" align=\"center\"><table border=0 cellspacing=0 cellpadding=0 width=295><tr><tr><td fixWIDTH=100 align=left><font color=\"aa9977\">Clan Name:</font></td><td fixWIDTH=195 align=center>", cl.getName(), "</td></tr><tr><td height=7></td></tr><tr><td fixWIDTH=100 align=left><font color=\"aa9977\">Clan Level:</font></td><td fixWIDTH=195 align=center height=16>", String.valueOf(cl.getLevel()), "</td></tr><tr><td height=7></td></tr><tr><td fixWIDTH=100 align=left><font color=\"aa9977\">Clan Members:</font></td><td fixWIDTH=195 align=center height=16>", String.valueOf(cl.getMembersCount()), "</td></tr><tr><td height=7></td></tr><tr><td fixWIDTH=100 align=left><font color=\"aa9977\">Online Players</font></td><td fixWIDTH=195 align=center height=16>", String.valueOf(cl.getOnlineMembersCount()), "</td></tr><tr><td height=7></td></tr><tr><td fixWIDTH=100 align=left><font color=\"aa9977\">Clan Leader:</font></td><td fixWIDTH=195 align=center height=16>", cl.getLeaderName(), "</td></tr><tr><td height=7></td></tr><tr><td height=7></td></tr><tr><td fixWIDTH=100 align=left><font color=\"aa9977\">Alliance:</font></td><td fixWIDTH=195 align=center height=16>", (cl.getAllyName() != null) ? cl.getAllyName() : "N/A", "</td></tr></tr><tr><td height=7></td></tr><tr><td fixWIDTH=100 align=left><font color=\"aa9977\">Siege kills:</font></td><td fixWIDTH=195 align=center height=16>", String.valueOf(cl.getSiegeKills()), "</td></tr><tr><td height=7></td></tr><tr><td fixWIDTH=100 align=left><font color=\"aa9977\">Siege deaths:</font></td><td fixWIDTH=195 align=center height=16>", String.valueOf(cl.getSiegeDeaths()), "</td></tr><tr><td height=7></td></tr><tr><td fixWIDTH=100 align=left><font color=\"aa9977\">Reputation:</font></td><td fixWIDTH=195 align=center height=16>", String.valueOf(cl.getReputationScore()), "</td></tr><tr><td height=7></td></tr><tr><td fixWIDTH=100 align=left><font color=\"aa9977\">At War:</font></td><td fixWIDTH=195 align=center height=16>", String.valueOf(cl.isAtWar()), "</td></tr></table></td></tr><tr><td height=40></td><</tr></table><br><br><table border=0 cellspacing=0 cellpadding=0><tr><td width=755 height=20></td></tr></table><br><br></td></tr></table><br><table width=640><tr><td align=center>Community Board | <font color=aa9977>L2jSunrise</font> 2013</td></tr></table><br></center></body></html>");
5203 separateAndSend(html, activeChar);
5204 }
5205 }