Guest User

Untitled

a guest
May 6th, 2012
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.08 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2_GameServer_freya
  3. Index: java/com/l2jserver/gameserver/model/ItemBypass.java
  4. ===================================================================
  5. --- java/com/l2jserver/gameserver/model/ItemBypass.java (revision 0)
  6. +++ java/com/l2jserver/gameserver/model/ItemBypass.java (revision 0)
  7. @@ -0,0 +1,652 @@
  8. +package com.l2jserver.gameserver.model;
  9. +
  10. +import java.sql.Connection;
  11. +import java.sql.PreparedStatement;
  12. +import java.sql.ResultSet;
  13. +import java.sql.SQLException;
  14. +import java.util.Map;
  15. +
  16. +import javolution.text.TextBuilder;
  17. +import javolution.util.FastList;
  18. +import javolution.util.FastMap;
  19. +import com.l2jserver.Config;
  20. +import com.l2jserver.L2DatabaseFactory;
  21. +import com.l2jserver.gameserver.TradeController;
  22. +import com.l2jserver.gameserver.datatables.HennaTreeTable;
  23. +import com.l2jserver.gameserver.datatables.ItemTable;
  24. +import com.l2jserver.gameserver.datatables.SkillTable;
  25. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  26. +import com.l2jserver.gameserver.model.entity.TvTEvent;
  27. +import com.l2jserver.gameserver.network.SystemMessageId;
  28. +import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
  29. +import com.l2jserver.gameserver.network.serverpackets.BuyList;
  30. +import com.l2jserver.gameserver.network.serverpackets.ExShowVariationCancelWindow;
  31. +import com.l2jserver.gameserver.network.serverpackets.ExShowVariationMakeWindow;
  32. +import com.l2jserver.gameserver.network.serverpackets.HennaEquipList;
  33. +import com.l2jserver.gameserver.network.serverpackets.HennaRemoveList;
  34. +import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  35. +import com.l2jserver.gameserver.network.serverpackets.SortedWareHouseWithdrawalList;
  36. +import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  37. +import com.l2jserver.gameserver.network.serverpackets.WareHouseDepositList;
  38. +import com.l2jserver.gameserver.network.serverpackets.WareHouseWithdrawalList;
  39. +import com.l2jserver.gameserver.network.serverpackets.SortedWareHouseWithdrawalList.WarehouseListType;
  40. +import com.l2jserver.gameserver.datatables.MultiSell;
  41. +import com.l2jserver.gameserver.model.actor.L2Npc;
  42. +
  43. +
  44. +
  45. +/**
  46. + *
  47. + * @author BiggBoss
  48. + *
  49. + */
  50. +
  51. +public class ItemBypass {
  52. +
  53. + /* Constants */
  54. + private static final String _headHtml = "<html><title>AIO Item</title><body><center><br>";
  55. + private static final String _endHtml = "</center></body></html>";
  56. +
  57. + /* Maps, Lists and Arrays to hold the data */
  58. + protected static Map<String, FastMap<String, Integer[]>> _teleports = new FastMap<String, FastMap<String, Integer[]>>();
  59. + protected static Map<String, FastMap<String, Integer[]>> _buffs = new FastMap<String, FastMap<String, Integer[]>>();
  60. +
  61. + private static int _pagesPerTp;
  62. + private static int _pagesPerBuffs;
  63. + private static final int _coinpertp = Config.AIO_TPCOIN;
  64. + private static final int _coinperbuff = Config.AIO_BUFFCOIN;
  65. + /* Pice for teleport */
  66. + private static final int _tpprice = Config.AIO_PRICE_PERTP;
  67. + /* Price per buff */
  68. + private static final int _buffprice = Config.AIO_PRICE_PERBUFF;
  69. + private static final L2Npc target = null;
  70. +
  71. + /* Enum to diference betwen the diferent packets */
  72. + private enum Packet {
  73. + DYNAMIC,
  74. + FILE,
  75. + PREDEFINED
  76. + }
  77. + private ItemBypass() {
  78. +
  79. + }
  80. +
  81. + /**
  82. + * Send a packet with the html file to show
  83. + * @param player
  84. + * @param tb
  85. + */
  86. + private static void sendPacket(L2PcInstance player, String html, Packet packet) {
  87. + NpcHtmlMessage msg = new NpcHtmlMessage(5);
  88. + if(packet.equals(Packet.FILE))
  89. + msg.setFile(player.getHtmlPrefix(),"/data/html/AIOItem/" + html);
  90. + else if(packet.equals(Packet.DYNAMIC))
  91. + msg.setHtml(html);
  92. + player.sendPacket(msg);
  93. + }
  94. +
  95. + /**
  96. + * Load all necessary data to use and modify the item
  97. + */
  98. + public static void loadData() {
  99. + byte counter = 0;
  100. + System.out.println("----------------------------------------------");
  101. + System.out.println("Loading AIO Item data. Info:");
  102. + System.out.println("----------------------------------------------");
  103. +
  104. + try {
  105. + Connection con = L2DatabaseFactory.getInstance().getConnection();
  106. + PreparedStatement statement = con.prepareStatement("SELECT category FROM aio_teleports");
  107. + ResultSet rset = statement.executeQuery();
  108. +
  109. + while(rset.next()) {
  110. + String tpcategory = rset.getString("category");
  111. +
  112. + Connection con2 = L2DatabaseFactory.getInstance().getConnection();
  113. + PreparedStatement statement2 = con2.prepareStatement("SELECT tpname, x, y, z FROM aio_teleports WHERE category = ?");
  114. + statement2.setString(1, tpcategory);
  115. + ResultSet rset2 = statement2.executeQuery();
  116. + FastMap <String, Integer[]> temptp = new FastMap<String, Integer[]>();
  117. +
  118. + while(rset2.next()) {
  119. + String tpname = rset2.getString("tpname");
  120. + Integer[] coords = new Integer[3];
  121. + coords[0] = rset2.getInt("x");
  122. + coords[1] = rset2.getInt("y");
  123. + coords[2] = rset2.getInt("z");
  124. + temptp.put(tpname, coords);
  125. + }
  126. + con2.close();
  127. + statement2.close();
  128. + rset2.close();
  129. + _teleports.put(tpcategory, temptp);
  130. + }
  131. + con.close();
  132. + statement.close();
  133. + rset.close();
  134. + }
  135. + catch(SQLException e) {
  136. + counter += 1;
  137. + e.printStackTrace();
  138. + }
  139. + int c = 0;
  140. + System.out.println("Loaded " + _teleports.keySet().size() + " teleport categories for the AIO Item");
  141. + for(String st : _teleports.keySet()) {
  142. + c += _teleports.get(st).keySet().size();
  143. + }
  144. + System.out.println("Loaded " + c + " teleport spawnpoints for the AIO Item");
  145. +
  146. + try {
  147. + Connection con3 = L2DatabaseFactory.getInstance().getConnection();
  148. + PreparedStatement statement3 = con3.prepareStatement("SELECT category FROM aio_buffs");
  149. + ResultSet rset3 = statement3.executeQuery();
  150. +
  151. + while(rset3.next()) {
  152. + String bcategory = rset3.getString("category");
  153. +
  154. + Connection con4 = L2DatabaseFactory.getInstance().getConnection();
  155. + PreparedStatement statement4 = con4.prepareStatement("SELECT buff_name, buff_id, buff_lvl FROM aio_buffs WHERE category = ?");
  156. + statement4.setString(1, bcategory);
  157. + ResultSet rset4 = statement4.executeQuery();
  158. + FastMap<String, Integer[]> tempbuff = new FastMap<String, Integer[]>();
  159. +
  160. + while(rset4.next()) {
  161. + String bname = rset4.getString("buff_name");
  162. + Integer[] ar = new Integer[2];
  163. + ar[0] = rset4.getInt("buff_id");
  164. + ar[1] = rset4.getInt("buff_lvl");
  165. + tempbuff.put(bname, ar);
  166. + }
  167. + con4.close();
  168. + statement4.close();
  169. + rset4.close();
  170. + _buffs.put(bcategory, tempbuff);
  171. + }
  172. + con3.close();
  173. + statement3.close();
  174. + rset3.close();
  175. + }
  176. + catch(SQLException e) {
  177. + counter += 2;
  178. + e.printStackTrace();
  179. + }
  180. + int i = 0;
  181. + System.out.println("Loaded " + _buffs.keySet().size() + " buffs categories for the AIO Item");
  182. + for(String st : _buffs.keySet()) {
  183. + i += _buffs.get(st).keySet().size();
  184. + }
  185. + System.out.println("Loaded " + i + " buffs for the AIO Item");
  186. +
  187. + if(counter == 0)
  188. + System.out.println("AIO Item loaded sucesfully!");
  189. + else
  190. + switch(counter) {
  191. + case 1:
  192. + System.out.println("There was a problem loading Teleports. Check what did you enter on aio_teleports.");
  193. + break;
  194. + case 2:
  195. + System.out.println("There was a problem loading Buffs. Check what did you enter on aio_buffs.");
  196. + break;
  197. + default:
  198. + System.out.println("Something was wrong during AIO item load. Check the console.");
  199. + }
  200. + System.out.println("----------------------------------------------");
  201. + }
  202. +
  203. + /**
  204. + * Manages all bypasses for normal players
  205. + * @param player
  206. + * @param command
  207. + */
  208. + public static void onBypassFeedback(L2PcInstance player, String command) {
  209. +
  210. + //No null pointers
  211. + if(player == null) return;
  212. +
  213. + if(player.isInOlympiadMode()) {
  214. + player.sendMessage("Cannot use while in Olympiad");
  215. + return;
  216. + }
  217. + else if(player.getKarma() > 0) {
  218. + player.sendMessage("Cannot use while hava karma");
  219. + return;
  220. + }
  221. + else if(player.isInJail()) {
  222. + player.sendMessage("Cannot use while in Jail");
  223. + return;
  224. + }
  225. + else if(player.isDead()) return;
  226. + else if(TvTEvent.isPlayerParticipant(player.getObjectId())) {
  227. + player.sendMessage("Cannot use while in TvT");
  228. + return;
  229. + }
  230. + else if(player.isInCombat()) {
  231. + player.sendMessage("Cannot use while in combat");
  232. + return;
  233. + }
  234. +
  235. + if(player.getTarget() != player) {
  236. + player.sendMessage("Taget yourself to use the AIO Item");
  237. + return;
  238. + }
  239. +
  240. + long pAdena = player.getAdena();
  241. + String[] subCommand = command.split("_");
  242. + WarehouseListType itemtype = null;
  243. +
  244. + /* Warehouse */
  245. +
  246. + if(command.startsWith("warehouse"))
  247. + showWarehouseWindow(player);
  248. + else if(command.startsWith("nwidraw")) {
  249. + player.sendPacket(ActionFailed.STATIC_PACKET);
  250. + player.setActiveWarehouse(player.getWarehouse());
  251. + if(pAdena == 0 || player.getInventory().getItemByItemId(57) == null) {
  252. + player.sendMessage("You dont have adena to afford the transaction");
  253. + return;
  254. + }
  255. + if(player.getWarehouse().getSize() == 0) {
  256. + player.sendPacket(new SystemMessage(SystemMessageId.NO_ITEM_DEPOSITED_IN_WH));
  257. + return;
  258. + }
  259. + else {
  260. + player.setIsUsingAioWh(true);
  261. + if (itemtype != null)
  262. + player.sendPacket(new SortedWareHouseWithdrawalList(player, WareHouseWithdrawalList.PRIVATE, itemtype, (byte) 0));
  263. + else
  264. + player.sendPacket(new WareHouseWithdrawalList(player, WareHouseWithdrawalList.PRIVATE));
  265. +
  266. + }
  267. + }
  268. + else if(command.startsWith("ndeposit")) {
  269. + player.sendPacket(ActionFailed.STATIC_PACKET);
  270. + player.setActiveWarehouse(player.getWarehouse());
  271. + if(player.getWarehouse().getSize() == player.getWareHouseLimit()) {
  272. + player.sendMessage("The warehouse is full");
  273. + return;
  274. + }
  275. + else {
  276. + player.setIsUsingAioWh(true);
  277. + player.tempInventoryDisable();
  278. + player.sendPacket(new WareHouseDepositList(player, WareHouseDepositList.PRIVATE));
  279. + }
  280. + }
  281. + else if(command.startsWith("clanwidraw")) {
  282. + player.sendPacket(ActionFailed.STATIC_PACKET);
  283. + player.setActiveWarehouse(player.getClan().getWarehouse());
  284. + if(!player.isClanLeader() || player.getClan() == null ) {
  285. + player.sendMessage("You are not the clan leader");
  286. + return;
  287. + }
  288. + else if(player.getClan().getWarehouse().getSize() == 0) {
  289. + player.sendPacket(new SystemMessage(SystemMessageId.NO_ITEM_DEPOSITED_IN_WH));
  290. + return;
  291. + }
  292. + else if ((player.getClanPrivileges() & L2Clan.CP_CL_VIEW_WAREHOUSE) != L2Clan.CP_CL_VIEW_WAREHOUSE) {
  293. + player.sendPacket(new SystemMessage(SystemMessageId.YOU_DO_NOT_HAVE_THE_RIGHT_TO_USE_CLAN_WAREHOUSE));
  294. + return;
  295. + }
  296. + else if(player.getClan().getLevel() == 0) {
  297. + player.sendMessage("Only clan with lvl 1 or avobe can use clan warehouse");
  298. + return;
  299. + }
  300. + else {
  301. + player.setIsUsingAioWh(true);
  302. + player.setActiveWarehouse(player.getClan().getWarehouse());
  303. +
  304. + if (itemtype != null)
  305. + player.sendPacket(new SortedWareHouseWithdrawalList(player, WareHouseWithdrawalList.CLAN, itemtype, (byte) 0));
  306. + else
  307. + player.sendPacket(new WareHouseWithdrawalList(player, WareHouseWithdrawalList.CLAN));
  308. + }
  309. + }
  310. +
  311. + else if(command.startsWith("clandeposit")) {
  312. + player.sendPacket(ActionFailed.STATIC_PACKET);
  313. + player.setActiveWarehouse(player.getClan().getWarehouse());
  314. + if(!player.isClanLeader() || player.getClan() == null ) {
  315. + player.sendMessage("You are not the clan leader");
  316. + return;
  317. + }
  318. + else {
  319. + player.setIsUsingAioWh(true);
  320. + player.setActiveWarehouse(player.getClan().getWarehouse());
  321. + player.tempInventoryDisable();
  322. + player.sendPacket(new WareHouseDepositList(player, WareHouseDepositList.CLAN));
  323. + }
  324. + }
  325. +
  326. + /* Gatekeeper */
  327. +
  328. + else if(command.startsWith("showTeleportWindow")) {
  329. + if(player.getPvpFlag() > 0) {
  330. + player.sendMessage("Cannot teleport while in pvp");
  331. + return;
  332. + }
  333. + else
  334. + showTeleportWindow(player);
  335. + }
  336. + else if(command.startsWith("tpcategory"))
  337. + showTeleportCategoryWindow(player, subCommand[1], 1);
  338. +
  339. + else if(command.startsWith("teleportTo")) {
  340. + if(player.getInventory().getItemByItemId(_coinpertp) == null) {
  341. + player.sendMessage("You dont have the necessary items");
  342. + return;
  343. + }
  344. + else if(player.getInventory().getItemByItemId(_coinpertp).getCount() < _tpprice) {
  345. + player.sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
  346. + return;
  347. + }
  348. +
  349. + int x = Integer.valueOf(subCommand[1]);
  350. + int y = Integer.valueOf(subCommand[2]);
  351. + int z = Integer.valueOf(subCommand[3]);
  352. +
  353. + player.destroyItemByItemId("AIO Teleport", _coinpertp, _tpprice, player, true);
  354. + player.teleToLocation(x, y, z);
  355. + }
  356. +
  357. + // Page navigation
  358. + else if(command.startsWith("Chat")) {
  359. + if(subCommand[1].isEmpty() || subCommand[1] == null) return;
  360. +
  361. + String file = "data/html/AIOItem/"+subCommand[1];
  362. + NpcHtmlMessage msg = new NpcHtmlMessage(5);
  363. + msg.setFile(player.getHtmlPrefix(),file);
  364. + player.sendPacket(msg);
  365. + }
  366. +
  367. + /* GM Shop */
  368. +
  369. + else if(command.startsWith("showShopWindow")) {
  370. + if(player.getPvpFlag() > 0 || pAdena == 0) {
  371. + player.sendMessage("You dont have adena!");
  372. + return;
  373. + }
  374. +
  375. + String buyHtml = "data/html/AIOItem/GMShop.htm";
  376. + NpcHtmlMessage msg = new NpcHtmlMessage(5);
  377. + msg.setFile(player.getHtmlPrefix(),buyHtml);
  378. + player.sendPacket(msg);
  379. + }
  380. + else if(command.startsWith("showBuyWindow")){
  381. + int val = Integer.valueOf(subCommand[1]);
  382. + showBuyWindow(player, val);
  383. + }
  384. +
  385. + else if(command.startsWith("showMultiSellWindow")) {
  386. + int multi = Integer.valueOf(subCommand[1]);
  387. + player.setIsUsingAioMultisell(true);
  388. + MultiSell.getInstance().separateAndSend(multi, player, target , false);
  389. + }
  390. +
  391. + /* Buffer */
  392. +
  393. + else if(command.startsWith("ShowBuffWindow"))
  394. + showBuffsPage(player);
  395. + else if(command.startsWith("showBuffCategory")){
  396. + showBuffsPage(player, subCommand[1], Integer.valueOf(subCommand[2]));
  397. + }
  398. + else if(command.startsWith("buffMe")) {
  399. + if(player.getInventory().getItemByItemId(_coinperbuff).getCount() < _buffprice) {
  400. + player.sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_REQUIRED_ITEMS));
  401. + return;
  402. + }
  403. + else {
  404. + player.destroyItemByItemId("AIO Buffer", _coinperbuff, _buffprice, player, true);
  405. + SkillTable.getInstance().getInfo(_buffs.get(subCommand[1]).get(subCommand[2])[0], _buffs.get(subCommand[1]).get(subCommand[2])[1]).getEffects(player, player);
  406. + showBuffsPage(player, subCommand[1], 1);
  407. + }
  408. + }
  409. +
  410. + /* TvT Manager */
  411. +
  412. + else if(command.startsWith("tvtinfo")) {
  413. + showTvTInfoPage(player);
  414. + }
  415. + else if(command.startsWith("tvtjoin")) {
  416. + if(subCommand[1].equals("reg"))
  417. + TvTEvent.onBypass("tvt_event_participation", player);
  418. + else if(subCommand[1].equals("unreg"))
  419. + TvTEvent.onBypass("tvt_event_remove_participation", player);
  420. + else
  421. + return;
  422. + }
  423. +
  424. + /* Augmentation, Symbol drawer, Gold Bar Trader */
  425. +
  426. + else if(command.startsWith("augment")) {
  427. + player.sendPacket(new ExShowVariationMakeWindow());
  428. + }
  429. + else if(command.startsWith("unAugment")) {
  430. + player.sendPacket(new ExShowVariationCancelWindow());
  431. + }
  432. + else if(command.startsWith("drawSymbol")) {
  433. + L2HennaInstance[] tato = HennaTreeTable.getInstance().getAvailableHenna(player.getClassId());
  434. + player.sendPacket(new HennaEquipList(player, tato));
  435. + }
  436. + else if(command.startsWith("removeSymbol")) {
  437. + boolean hasHennas = false;
  438. +
  439. + for (int i = 1; i <= 3; i++)
  440. + {
  441. + L2HennaInstance henna = player.getHenna(i);
  442. +
  443. + if (henna != null)
  444. + hasHennas = true;
  445. + }
  446. + if (hasHennas)
  447. + player.sendPacket(new HennaRemoveList(player));
  448. + }
  449. + else if(command.startsWith("adenaToBars")) {
  450. + if(pAdena > Config.AIOADENA_PERBAR) {
  451. + player.destroyItemByItemId("Aio Item", 57, Config.AIOADENA_PERBAR, player, true);
  452. + player.addItem("Aio Item", Config.AIO_GBAR, 1, player, true);
  453. + }
  454. + else
  455. + player.sendMessage("Not Enough adena to complete the transaction");
  456. +
  457. + sendPacket(player, "services.htm", Packet.FILE);
  458. + }
  459. + else if(command.startsWith("barsToAdena")) {
  460. + if(player.getInventory().getItemByItemId(Config.AIO_GBAR) != null) {
  461. + if(player.getInventory().getItemByItemId(Config.AIO_GBAR).getCount() >= 1) {
  462. + player.destroyItemByItemId("Aio Item", Config.AIO_GBAR, 1, player, true);
  463. + player.addItem("Aio Item", 57, Config.AIOADENA_PERBAR, player, true);
  464. + }
  465. + }
  466. + else
  467. + player.sendMessage("Not enough " + ItemTable.getInstance().getTemplate(Config.AIO_GBAR).getName());
  468. +
  469. + sendPacket(player, "services.htm", Packet.FILE);
  470. + }
  471. + }
  472. +
  473. + private static Object getCastle() {
  474. + // TODO Auto-generated method stub
  475. + return null;
  476. + }
  477. +
  478. + private static int getNpcId() {
  479. + // TODO Auto-generated method stub
  480. + return 0;
  481. + }
  482. +
  483. + /**
  484. + * TvT Manager
  485. + * @param player
  486. + */
  487. + private static void showTvTInfoPage(L2PcInstance player) {
  488. + TextBuilder tb = new TextBuilder();
  489. + tb.append(_headHtml);
  490. + if(TvTEvent.isParticipating()) {
  491. + tb.append("TvT did not start yet!.<br1>");
  492. + if(!TvTEvent.isPlayerParticipant(player.getObjectId())) {
  493. + tb.append("Do you want to participate? Click <font color=LEVEL>Ok!</font> to<br1>");
  494. + tb.append("join the event!");
  495. + tb.append("<button value=\"Ok!\" action=\"bypass -h Aioitem_tvtjoin_reg\" width=120 height=32 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\">");
  496. + }
  497. + else {
  498. + tb.append("You are alredy participating. Do you<br1>");
  499. + tb.append("want to unregister? Click the below button<br>");
  500. + tb.append("<button value=\"Unregister\" action=\"bypass -h Aioitem_tvtjoin_unreg\" width=120 height=32 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\">");
  501. + }
  502. + }
  503. + else if(TvTEvent.isStarted()) {
  504. + tb.append("TvT alredy started. You can not join<br1>");
  505. + tb.append("join at this momment. But you can see the<br1>");
  506. + tb.append("stats:<br>");
  507. + for(String st : TvTEvent.getTeamNames()) {
  508. + tb.append("<font color=LEVEL>" + st + ":</font><br1>");
  509. + tb.append("- Participants: <font color=\"0000FF\">" + TvTEvent.getTeamsPlayerCounts()[0] +"</font><br1>");
  510. + tb.append("- Kills: <font color=\"0000FF\">" + TvTEvent.getTeamsPoints()[0] +"</font><br1>");
  511. + tb.append("- Deads: <font color=\"0000FF\">" + TvTEvent.getTeamsPoints()[1] +"</font><br>");
  512. + }
  513. + }
  514. + else {
  515. + tb.append("TvT is not avaliable at this moment!<br1>");
  516. + tb.append("Wait till it starts!");
  517. + }
  518. + tb.append(_endHtml);
  519. +
  520. + sendPacket(player, tb.toString(), Packet.DYNAMIC);
  521. + }
  522. +
  523. + /**
  524. + * Buffer
  525. + * @param player
  526. + * @param string
  527. + * @param val
  528. + */
  529. + private static void showBuffsPage(L2PcInstance player, String string, int val) {
  530. +
  531. + FastMap<String, Integer[]> temp = _buffs.get(string);
  532. + FastList<String> buff = new FastList<String>();
  533. + buff.addAll(_buffs.get(string).keySet());
  534. + _pagesPerBuffs = Math.round((buff.size() / 15));
  535. +
  536. + TextBuilder tb = new TextBuilder();
  537. + tb.append(_headHtml);
  538. + tb.append("Choose between the below buffs:<br>");
  539. + tb.append("<table width = 240 height = 32>");
  540. + for(String st : buff.subList((val * 15) - 15, getMaxRange(buff, ((val * 15) * 2) - 15))) {
  541. + tb.append("<tr>");
  542. + if(temp.get(st)[0] < 1000)
  543. + tb.append("<td><img src=\"icon.skill0" + temp.get(st)[0] + "\" width=32 height=32></td>");
  544. + else
  545. + tb.append("<td><img src=\"icon.skill" +temp.get(st)[0] + "\" width=32 height=32></td>");
  546. + tb.append("<td><button value=\"" + st + "\" action=\"bypass -h Aioitem_buffMe_" + string + "_" + st + "\" width=176 height=32 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"></td>");
  547. + if(temp.get(st)[0] < 1000)
  548. + tb.append("<td><img src=\"icon.skill0" + temp.get(st)[0] + "\" width=32 height=32></td>");
  549. + else
  550. + tb.append("<td><img src=\"icon.skill" +temp.get(st)[0] + "\" width=32 height=32></td>");
  551. +
  552. + tb.append("</tr>");
  553. + }
  554. + tb.append("</table>");
  555. + for(int i = 1; i<_pagesPerBuffs; i++) {
  556. + tb.append("<a action=\"bypass -h Aioitem_showBuffCategory_" + string + "_" + i +"\">" + i + "</a>");
  557. + }
  558. + tb.append(_endHtml);
  559. +
  560. + sendPacket(player, tb.toString(), Packet.DYNAMIC);
  561. + }
  562. + private static void showBuffsPage(L2PcInstance player) {
  563. + TextBuilder tb = new TextBuilder();
  564. + tb.append(_headHtml);
  565. + tb.append("Choose between the below categories:<br>");
  566. + for(String st : _buffs.keySet()) {
  567. + tb.append("<button value=\"" + st + "\" action=\"bypass -h Aioitem_showBuffCategory_" + st + "_1\" width=176 height=32 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\">");
  568. + }
  569. + tb.append(_endHtml);
  570. +
  571. + sendPacket(player, tb.toString(), Packet.DYNAMIC);
  572. + }
  573. +
  574. + /**
  575. + * Gatekeeper
  576. + * @param player
  577. + * @param string
  578. + * @param val
  579. + */
  580. + private static void showTeleportCategoryWindow(L2PcInstance player, String string, int val) {
  581. +
  582. + FastMap<String, Integer[]> temp = _teleports.get(string);
  583. + FastList<String> keys = new FastList<String>();
  584. + keys.addAll(_teleports.get(string).keySet());
  585. + _pagesPerTp = Math.round(keys.size() / 15);
  586. +
  587. + TextBuilder tb = new TextBuilder();
  588. + tb.append(_headHtml);
  589. + tb.append("Choose a teleport:<br>");
  590. +
  591. + for(String st : keys.subList((val * 15) - 15, getMaxRange(keys, ((val * 15) * 2) - 15)) ) {
  592. + tb.append("<button value=\"" + st + "\" action=\"bypass -h Aioitem_teleportTo_" +temp.get(st)[0] + "_" +
  593. + temp.get(st)[1] + "_" + temp.get(st)[2] + "\" width=176 height=32 back=\"L2UI_CT1.Button_DF_Down\" " +
  594. + "fore=\"L2UI_ct1.button_df\">");
  595. + }
  596. + for(int i = 1; i<_pagesPerTp; i++) {
  597. + tb.append("<a action=\"bypass -h Aioitem_tpcategory_" + string + "_" + i +"\">" + i + "</a>");
  598. + }
  599. + tb.append(_endHtml);
  600. +
  601. + sendPacket(player, tb.toString(), Packet.DYNAMIC);
  602. + }
  603. +
  604. + private static void showTeleportWindow(L2PcInstance player) {
  605. +
  606. + TextBuilder tb = new TextBuilder();
  607. + tb.append(_headHtml);
  608. + tb.append("Choose one of the below categories:<br>");
  609. +
  610. + for(String st : _teleports.keySet()) {
  611. + tb.append("<button value=\"" + st + "\" action=\"bypass -h Aioitem_tpcategory_" + st + "_1\" width=176 height=32 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\">");
  612. + }
  613. + tb.append(_endHtml);
  614. +
  615. + sendPacket(player, tb.toString(), Packet.DYNAMIC);
  616. + }
  617. +
  618. + /**
  619. + * WareHouse
  620. + * @param player
  621. + */
  622. + private static void showWarehouseWindow(L2PcInstance player) {
  623. +
  624. + TextBuilder tb = new TextBuilder();
  625. + tb.append(_headHtml);
  626. + tb.append("Choose between the avaliable options:<br>");
  627. + tb.append("<button value=\"Withdraw\" action=\"bypass -h Aioitem_nwidraw\" width=176 height=32 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\">");
  628. + tb.append("<button value=\"Deposit\" action=\"bypass -h Aioitem_ndeposit\" width=176 height=32 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\">");
  629. + tb.append("<button value=\"Clan Withdraw\" action=\"bypass -h Aioitem_clanwidraw\" width=176 height=32 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\">");
  630. + tb.append("<button value=\"Clan Deposit\" action=\"bypass -h Aioitem_clandeposit\" width=176 height=32 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\">");
  631. + tb.append(_endHtml);
  632. +
  633. + sendPacket(player, tb.toString(), Packet.DYNAMIC);
  634. + }
  635. +
  636. + /**
  637. + * GMShop
  638. + * @param player
  639. + * @param val
  640. + */
  641. + private static void showBuyWindow(L2PcInstance player, int val) {
  642. + player.tempInventoryDisable();
  643. +
  644. + L2TradeList list = TradeController.getInstance().getBuyList(val);
  645. +
  646. + if (list != null) {
  647. + player.sendPacket(new BuyList(list, player.getAdena(), 0));
  648. + }
  649. + player.sendPacket(ActionFailed.STATIC_PACKET);
  650. + }
  651. +
  652. + //Give the max range each 15 units
  653. + private static int getMaxRange(FastList<String> list, int lastindex) {
  654. + if(list.size() - lastindex > 0)
  655. + return lastindex;
  656. + else
  657. + return list.size();
  658. + }
  659. +}
  660. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment