Advertisement
Guest User

Dobate shop Acis

a guest
Sep 27th, 2016
2,360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.15 KB | None | 0 0
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see .
  14. */
  15. package net.sf.l2j.gameserver.model.actor.instance;
  16.  
  17. import java.sql.Connection;
  18. import java.sql.PreparedStatement;
  19. import java.sql.SQLException;
  20. import java.util.StringTokenizer;
  21. import java.util.logging.Logger;
  22.  
  23. import net.sf.l2j.commons.lang.StringUtil;
  24.  
  25. import net.sf.l2j.Config;
  26. import net.sf.l2j.L2DatabaseFactory;
  27. import net.sf.l2j.gameserver.ai.CtrlIntention;
  28. import net.sf.l2j.gameserver.cache.HtmCache;
  29. import net.sf.l2j.gameserver.DonateAudit;
  30. import net.sf.l2j.gameserver.GameServer;
  31. import net.sf.l2j.gameserver.datatables.CharNameTable;
  32. import net.sf.l2j.gameserver.datatables.SkillTable;
  33. import net.sf.l2j.gameserver.model.L2Augmentation;
  34. import net.sf.l2j.gameserver.model.L2Skill;
  35. import net.sf.l2j.gameserver.model.World;
  36. import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  37. import net.sf.l2j.gameserver.model.base.Sex;
  38. import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
  39. import net.sf.l2j.gameserver.model.item.type.EtcItemType;
  40. import net.sf.l2j.gameserver.model.itemcontainer.Inventory;
  41. import net.sf.l2j.gameserver.network.SystemMessageId;
  42. import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  43. import net.sf.l2j.gameserver.network.serverpackets.EtcStatusUpdate;
  44. import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate;
  45. import net.sf.l2j.gameserver.network.serverpackets.ItemList;
  46. import net.sf.l2j.gameserver.network.serverpackets.LeaveWorld;
  47. import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected;
  48. import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  49. import net.sf.l2j.gameserver.network.serverpackets.PartySmallWindowAll;
  50. import net.sf.l2j.gameserver.network.serverpackets.PartySmallWindowDeleteAll;
  51. import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
  52. import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  53. import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;
  54. import net.sf.l2j.gameserver.util.Util;
  55.  
  56. @SuppressWarnings("unused")
  57. public class L2DonateShopInstance extends L2NpcInstance
  58. {
  59. private static final Logger _log = Logger.getLogger(L2DonateShopInstance.class.getName());
  60.  
  61. public L2DonateShopInstance(int objectId, NpcTemplate template)
  62. {
  63. super(objectId, template);
  64. }
  65.  
  66. // Config Donate Shop
  67. private static int itemid = 1704;
  68. private static int[] clanSkills =
  69. {
  70. 370,
  71. 371,
  72. 372,
  73. 373,
  74. 374,
  75. 375,
  76. 376,
  77. 377,
  78. 378,
  79. 379,
  80. 380,
  81. 381,
  82. 382,
  83. 383,
  84. 384,
  85. 385,
  86. 386,
  87. 387,
  88. 388,
  89. 389,
  90. 390,
  91. 391
  92. };
  93.  
  94. @Override
  95. public void onBypassFeedback(L2PcInstance player, String command)
  96. {
  97. StringTokenizer st = new StringTokenizer(command, " ");
  98. String actualCommand = st.nextToken(); // Get actual command
  99.  
  100. switch (command)
  101. {
  102. case "clan":
  103. clanReward(player, 20);
  104. break;
  105. case "windows":
  106. winds(player, 7);
  107. break;
  108. case "augments":
  109. winds(player, 8);
  110. break;
  111. case "augmentpanel":
  112. winds(player, 13);
  113. break;
  114. case "passive":
  115. winds(player, 14);
  116. break;
  117. case "passive2":
  118. winds(player, 15);
  119. break;
  120. case "page2":
  121. winds(player, 9);
  122. break;
  123. case "page3":
  124. winds(player, 10);
  125. break;
  126. case "page4":
  127. winds(player, 11);
  128. break;
  129. case "page5":
  130. winds(player, 12);
  131. break;
  132. case "chars":
  133. winds(player, 5);
  134. break;
  135. case "noblesse":
  136. noblesse(player, 5);
  137. break;
  138. case "donate":
  139. showEnchantSkillList(player, null, player.getClassId());
  140. break;
  141. case "donatewin":
  142. winds(player, 2);
  143. break;
  144. case "sexwin":
  145. winds(player, 4);
  146. break;
  147. case "noblessewin":
  148. winds(player, 1);
  149. break;
  150. case "clanwin":
  151. winds(player, 3);
  152. break;
  153. case "herowin":
  154. winds(player, 6);
  155. break;
  156. case "sex":
  157. sex(player, 10);
  158. break;
  159. case "sethero":
  160. hero(player, 50, 0);
  161. break;
  162. case "sethero1":
  163. hero(player, 5, 1);
  164. break;
  165. case "sethero7":
  166. hero(player, 25, 30);
  167. break;
  168. case "weapon":
  169. enchantw(player);
  170. break;
  171. case "armor":
  172. enchanta(player);
  173. break;
  174. case "jewel":
  175. enchantj(player);
  176. break;
  177. case "rhand":
  178. Enchant(player, 16, 8, Inventory.PAPERDOLL_RHAND);
  179. break;
  180. case "lhand":
  181. Enchant(player, 16, 8, Inventory.PAPERDOLL_LHAND);
  182. break;
  183. case "rear":
  184. Enchant(player, 16, 3, Inventory.PAPERDOLL_REAR);
  185. break;
  186. case "lear":
  187. Enchant(player, 16, 3, Inventory.PAPERDOLL_LEAR);
  188. break;
  189. case "rf":
  190. Enchant(player, 16, 3, Inventory.PAPERDOLL_RFINGER);
  191. break;
  192. case "lf":
  193. Enchant(player, 16, 3, Inventory.PAPERDOLL_LFINGER);
  194. break;
  195. case "neck":
  196. Enchant(player, 16, 3, Inventory.PAPERDOLL_NECK);
  197. break;
  198. case "head":
  199. Enchant(player, 16, 3, Inventory.PAPERDOLL_HEAD);
  200. break;
  201. case "feet":
  202. Enchant(player, 16, 3, Inventory.PAPERDOLL_FEET);
  203. break;
  204. case "gloves":
  205. Enchant(player, 16, 3, Inventory.PAPERDOLL_GLOVES);
  206. break;
  207. case "chest":
  208. Enchant(player, 16, 3, Inventory.PAPERDOLL_CHEST);
  209. break;
  210. case "legs":
  211. Enchant(player, 16, 3, Inventory.PAPERDOLL_LEGS);
  212. break;
  213. case "tattoo":
  214. Enchant(player, 16, 3, Inventory.PAPERDOLL_UNDER);
  215. break;
  216. }
  217. if (command.startsWith("addaugment"))
  218. {
  219. StringTokenizer sts = new StringTokenizer(command);
  220. sts.nextToken();
  221. try
  222. {
  223. String type = sts.nextToken();
  224. switch (type)
  225. {
  226. case "DuelMight":
  227. augments(player, 10, 1062406807, 3134, 10);
  228. break;
  229. case "Might":
  230. augments(player, 10, 1062079106, 3132, 10);
  231. break;
  232. case "Shield":
  233. augments(player, 10, 968884225, 3135, 10);
  234. break;
  235. case "MagicBarrier":
  236. augments(player, 10, 956760065, 3136, 10);
  237. break;
  238. case "Empower":
  239. augments(player, 10, 1061423766, 3133, 10);
  240. break;
  241. case "BattleRoar":
  242. augments(player, 10, 968228865, 3125, 10);
  243. break;
  244. case "Agility":
  245. augments(player, 10, 1060444351, 3139, 10);
  246. break;
  247. case "Heal":
  248. augments(player, 10, 1061361888, 3123, 10);
  249. break;
  250. case "CelestialShield":
  251. augments(player, 10, 974454785, 3158, 1);
  252. break;
  253. case "Guidance":
  254. augments(player, 10, 1061034178, 3140, 10);
  255. break;
  256. case "Focus":
  257. augments(player, 10, 1067523168, 3141, 10);
  258. break;
  259. case "WildMagic":
  260. augments(player, 10, 1067850844, 3142, 10);
  261. break;
  262. case "ReflectDamage":
  263. augments(player, 10, 1067588698, 3204, 3);
  264. break;
  265. case "Stone":
  266. augments(player, 10, 1060640984, 3169, 10);
  267. break;
  268. case "HealEmpower":
  269. augments(player, 10, 1061230760, 3138, 10);
  270. break;
  271. case "ShadowFlare":
  272. augments(player, 10, 1063520931, 3171, 10);
  273. break;
  274. case "AuraFlare":
  275. augments(player, 10, 1063455338, 3172, 10);
  276. break;
  277. case "Prominence":
  278. augments(player, 10, 1063327898, 3165, 10);
  279. break;
  280. case "HydroBlast":
  281. augments(player, 10, 1063590051, 3167, 10);
  282. break;
  283. case "SolarFlare":
  284. augments(player, 10, 1061158912, 3177, 10);
  285. break;
  286. case "ManaBurn":
  287. augments(player, 10, 956825600, 3154, 10);
  288. break;
  289. case "Refresh":
  290. augments(player, 10, 997392384, 3202, 3);
  291. break;
  292. case "Hurricane":
  293. augments(player, 10, 1064108032, 3168, 10);
  294. break;
  295. case "SpellRefresh":
  296. augments(player, 10, 1068302336, 3200, 3);
  297. break;
  298. case "SkillRefresh":
  299. augments(player, 10, 1068040192, 3199, 3);
  300. break;
  301. case "Stun":
  302. augments(player, 10, 969867264, 3189, 10);
  303. break;
  304. case "Prayer":
  305. augments(player, 10, 991297536, 3126, 10);
  306. break;
  307. case "Cheer":
  308. augments(player, 10, 979828736, 3131, 10);
  309. break;
  310. case "BlessedSoul":
  311. augments(player, 10, 991690752, 3128, 10);
  312. break;
  313. case "BlessedBody":
  314. augments(player, 10, 991625216, 3124, 10);
  315. break;
  316. case "DuelMightp":
  317. augments(player, 10, 1067260101, 3243, 10);
  318. break;
  319. case "Mightp":
  320. augments(player, 10, 1067125363, 3240, 10);
  321. break;
  322. case "Shieldp":
  323. augments(player, 10, 1067194549, 3244, 10);
  324. break;
  325. case "MagicBarrierp":
  326. augments(player, 10, 962068481, 3245, 10);
  327. break;
  328. case "Empowerp":
  329. augments(player, 10, 1066994296, 3241, 10);
  330. break;
  331. case "Agilityp":
  332. augments(player, 10, 965279745, 3247, 10);
  333. break;
  334. case "Guidancep":
  335. augments(player, 10, 1070537767, 3248, 10);
  336. break;
  337. case "Focusp":
  338. augments(player, 10, 1070406728, 3249, 10);
  339. break;
  340. case "WildMagicp":
  341. augments(player, 10, 1070599653, 3250, 10);
  342. break;
  343. case "ReflectDamagep":
  344. augments(player, 10, 1070472227, 3259, 3);
  345. break;
  346. case "HealEmpowerp":
  347. augments(player, 10, 1066866909, 3246, 10);
  348. break;
  349. case "Prayerp":
  350. augments(player, 10, 1066932422, 3238, 10);
  351. break;
  352. }
  353. }
  354. catch (Exception e)
  355. {
  356. player.sendMessage("Usage : Bar>");
  357. }
  358. }
  359. else if (command.startsWith("name"))
  360. {
  361. try
  362. {
  363. String commands[] = command.split(" ");
  364. name(player, 10, commands);
  365. }
  366. catch (StringIndexOutOfBoundsException e)
  367. {
  368. // Case of empty character name
  369. player.sendMessage("Usage: enter box your name");
  370. }
  371. }
  372. }
  373.  
  374. @Override
  375. public void onAction(L2PcInstance player)
  376. {
  377. // Check if the L2PcInstance already target the L2NpcInstance
  378. if (this != player.getTarget())
  379. {
  380. // Set the target of the L2PcInstance player
  381. player.setTarget(this);
  382.  
  383. // Send a Server->Client packet MyTargetSelected to the L2PcInstance player
  384. MyTargetSelected my = new MyTargetSelected(getObjectId(), 0);
  385. player.sendPacket(my);
  386. my = null;
  387.  
  388. // Send a Server->Client packet ValidateLocation to correct the L2NpcInstance position and heading on the client
  389. player.sendPacket(new ValidateLocation(this));
  390. }
  391. else
  392. {
  393. // Calculate the distance between the L2PcInstance and the L2NpcInstance
  394. if (!canInteract(player))
  395. {
  396. // Notify the L2PcInstance AI with AI_INTENTION_INTERACT
  397. player.getAI().setIntention(CtrlIntention.INTERACT, this);
  398. }
  399. else
  400. {
  401. showChatWindow(player);
  402. }
  403. }
  404.  
  405. // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
  406. player.sendPacket(ActionFailed.STATIC_PACKET);
  407. }
  408.  
  409. public void showClanWindow(L2PcInstance activeChar)
  410. {
  411. NpcHtmlMessage nhm = new NpcHtmlMessage(5);
  412. StringBuilder tb = new StringBuilder("");
  413.  
  414. tb.append("");
  415. tb.append("
  416. ");
  417. tb.append("");
  418. tb.append("");
  419. tb.append("");
  420. tb.append("
  421. Hello," + activeChar.getName() + " Here You can Buy with Donate Coin.
  422. ");
  423. tb.append("
  424. ");
  425. tb.append("");
  426. tb.append("");
  427. tb.append("");
  428. tb.append("");
  429. tb.append("");
  430. tb.append("");
  431. tb.append("");
  432. tb.append("");
  433. tb.append("");
  434. tb.append("");
  435. tb.append("");
  436. tb.append("");
  437. tb.append("");
  438. tb.append("");
  439. tb.append("");
  440. tb.append("");
  441. tb.append("");
  442. tb.append("");
  443. tb.append("");
  444. tb.append("");
  445. tb.append("");
  446. tb.append("");
  447. tb.append("");
  448. tb.append("");
  449. tb.append("");
  450. tb.append("");
  451. tb.append("");
  452. tb.append("");
  453. tb.append("
  454.  
  455.  
  456.  
  457.  
  458. ");
  459. tb.append("");
  460. tb.append("
  461. ");
  462. tb.append("
  463. ");
  464. tb.append("");
  465. tb.append("");
  466. tb.append("");
  467. tb.append("");
  468. tb.append("
  469. WebSite: www.la2SERVERNAME.com
  470. ");
  471. tb.append("");
  472.  
  473. nhm.setHtml(tb.toString());
  474. activeChar.sendPacket(nhm);
  475. }
  476.  
  477. public static void augments(L2PcInstance activeChar, int ammount, int attributes, int idaugment, int levelaugment)
  478. {
  479. ItemInstance rhand = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
  480. if (activeChar.getInventory().getInventoryItemCount(itemid, 0) >= ammount)
  481. {
  482. if (rhand == null)
  483. {
  484. activeChar.sendMessage(activeChar.getName() + " have to equip a weapon.");
  485. return;
  486. }
  487. else if (rhand.getItem().getCrystalType() != null)
  488. {
  489. activeChar.sendMessage("You can't augment under " + rhand.getItem().getCrystalType() + " Grade Weapon!");
  490. return;
  491. }
  492. else if (rhand.isHeroItem())
  493. {
  494. activeChar.sendMessage("You Cannot be add Augment On " + rhand.getItemName() + " !");
  495. return;
  496. }
  497.  
  498. if (!rhand.isAugmented())
  499. {
  500. activeChar.sendMessage("Successfully To Add " + SkillTable.getInstance().getInfo(idaugment, levelaugment).getName() + ".");
  501. augmentweapondatabase(activeChar, attributes, idaugment, levelaugment);
  502.  
  503. DonateAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", "Donated " + SkillTable.getInstance().getInfo(idaugment, levelaugment).getName() + " Stuck " + rhand.getItemName() + ".", "Donate Coins:" + ammount);
  504. }
  505. else
  506. {
  507. activeChar.sendMessage("You Have Augment on weapon!");
  508. return;
  509. }
  510.  
  511. if (!activeChar.destroyItemByItemId("Donate Coin", itemid, ammount, activeChar, false))
  512. return;
  513.  
  514. }
  515. else
  516. {
  517. activeChar.sendMessage("You do not have enough Donate Coin.");
  518. }
  519. }
  520.  
  521. public static void augmentweapondatabase(L2PcInstance player, int attributes, int id, int level)
  522. {
  523. ItemInstance item = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
  524. L2Augmentation augmentation = new L2Augmentation(attributes, id, level);
  525. augmentation.applyBonus(player);
  526. item.setAugmentation(augmentation);
  527.  
  528. try (
  529. Connection con = L2DatabaseFactory.getInstance().getConnection())
  530. {
  531. PreparedStatement statement = con.prepareStatement("REPLACE INTO augmentations VALUES(?,?,?,?)");
  532. statement.setInt(1, item.getObjectId());
  533. statement.setInt(2, attributes);
  534. statement.setInt(3, id);
  535. statement.setInt(4, level);
  536. InventoryUpdate iu = new InventoryUpdate();
  537. player.sendPacket(iu);
  538. statement.execute();
  539. statement.close();
  540. }
  541. catch (SQLException e)
  542. {
  543. System.out.println(e);
  544. }
  545. }
  546.  
  547. public static void clanReward(L2PcInstance activeChar, int ammount)
  548. {
  549. if (activeChar.getInventory().getInventoryItemCount(itemid, 0) >= ammount)
  550. {
  551. if (activeChar.isClanLeader() && activeChar.getClan().getLevel() == 8)
  552. {
  553. activeChar.sendMessage("You are the leader and you have clan lvl 8.");
  554. return;
  555. }
  556.  
  557. if (!activeChar.isClanLeader())
  558. {
  559. activeChar.sendMessage("You are not the leader of your Clan.");
  560. return;
  561. }
  562.  
  563. if (activeChar.isClanLeader() && activeChar.getClan().getLevel() < 8)
  564. {
  565. activeChar.getClan().changeLevel(8);
  566. activeChar.getClan().setReputationScore(10000);
  567. activeChar.getSkills();
  568. activeChar.sendPacket(new EtcStatusUpdate(activeChar));
  569. activeChar.getClan().broadcastClanStatus();
  570. activeChar.sendMessage("Your Buy clan level 8 and full clan skills was successful.");
  571. DonateAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", "Donated Clan level 8 and full clan skills", "Donate Coins:" + ammount);
  572. }
  573. if (!activeChar.destroyItemByItemId("Donate Coin", itemid, ammount, activeChar, false))
  574. return;
  575. }
  576. else
  577. {
  578. activeChar.sendMessage("You do not have enough Donate Coin.");
  579. }
  580. }
  581.  
  582. public static void noblesse(L2PcInstance activeChar, int ammount)
  583. {
  584. if (activeChar.getInventory().getInventoryItemCount(itemid, 0) >= ammount)
  585. {
  586. if (activeChar.isNoble())
  587. {
  588. activeChar.sendMessage("You Are Already A Noblesse!.");
  589. return;
  590. }
  591.  
  592. if (!activeChar.isNoble())
  593. {
  594. activeChar.setNoble(true,true);
  595. activeChar.broadcastUserInfo();
  596. activeChar.getInventory().addItem("Tiara", 7694, 1, activeChar, null);
  597. activeChar.sendMessage("You Are Now a Noble,You Are Granted With Noblesse Status , And Noblesse Skills.");
  598. DonateAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", "Donated Noblesse Status", "Donate Coins:" + ammount);
  599. }
  600. if (!activeChar.destroyItemByItemId("Donate Coin", itemid, ammount, activeChar, false))
  601. return;
  602. }
  603. else
  604. {
  605. activeChar.sendMessage("You do not have enough Donate Coin.");
  606. }
  607. }
  608.  
  609. @SuppressWarnings({
  610. "null", "resource"
  611. })
  612. public static void hero(final L2PcInstance activeChar, int ammount,int heroTime )
  613.  
  614. {
  615. if (activeChar.getInventory().getInventoryItemCount(itemid, 0) >= ammount)
  616. {
  617. if(activeChar.isHero())
  618. {
  619. activeChar.sendMessage("You Are Already A Hero!");
  620. return;
  621. }
  622. activeChar.setHero(true);
  623. activeChar.sendMessage("You Are Now a Donate Hero,You Are Granted With Hero Status , Skills ,Aura.");
  624. activeChar.broadcastUserInfo();
  625.  
  626. String days = null;
  627.  
  628. String INSERT_DATA = "REPLACE INTO characters_custom_data (obj_Id, char_name, hero, noble, donator, hero_end_date) VALUES (?,?,?,?,?,?)";
  629.  
  630.  
  631.  
  632. Connection con = null;
  633. try
  634. {
  635. if (activeChar == null)
  636. return;
  637.  
  638. con = L2DatabaseFactory.getInstance().getConnection();
  639. PreparedStatement stmt = con.prepareStatement(INSERT_DATA);
  640.  
  641. stmt.setInt(1, activeChar.getObjectId());
  642. stmt.setString(2, activeChar.getName());
  643. stmt.setInt(3, 1);
  644. stmt.setInt(4, activeChar.isNoble() ? 1 : 0);
  645. stmt.setInt(5, activeChar.isVip() ? 1 : 0);
  646. stmt.setLong(6, heroTime == 0 ? 0 : System.currentTimeMillis() + heroTime);
  647. stmt.execute();
  648. stmt.close();
  649. stmt = null;
  650. }
  651. catch (final Exception e)
  652. {
  653. _log.info("Error: could not update database: ");
  654. e.printStackTrace();
  655. }
  656.  
  657. switch(heroTime)
  658. {
  659. case 0:
  660. days = " 4ever";
  661. break;
  662. case 1:
  663. days = " Days";
  664. break;
  665. case 30:
  666. days = " Days";
  667. break;
  668. }
  669. DonateAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", "Donated Hero for " + heroTime + days + " Status", "Donate Coins:" + ammount);
  670.  
  671. if (!activeChar.destroyItemByItemId("Donate Coin", itemid, ammount, activeChar, false))
  672. return;
  673. }
  674. else
  675. {
  676. activeChar.sendMessage("You do not have enough Donate Coin.");
  677. }
  678. }
  679.  
  680. /*
  681. * public static void donatestatus(L2PcInstance activeChar,int ammount) { if (activeChar.getInventory().getInventoryItemCount(itemid, 0) >= ammount) { if(activeChar.isdonator()) { activeChar.sendMessage("You Are Already A Donate Status!."); return; } if(!activeChar.isdonator()) {
  682. * activeChar.setdonator(true); activeChar.updateNameTitleColor(); try (Connection connection = L2DatabaseFactory.getInstance().getConnection()) { PreparedStatement statement = connection.prepareStatement("SELECT obj_id FROM characters where char_name=?");
  683. * statement.setString(1,activeChar.getName()); ResultSet rset = statement.executeQuery(); int objId = 0; if (rset.next()) { objId = rset.getInt(1); } rset.close(); statement.close(); if (objId == 0) { connection.close(); return; } statement = connection.prepareStatement(
  684. * "UPDATE characters SET donator=1 WHERE obj_id=?"); statement.setInt(1, objId); statement.execute(); statement.close(); connection.close(); } catch (Exception e) { System.out.println("could not set donator stats of char:"+ e); } activeChar.sendMessage("You Are Now a Have Donate Status.");
  685. * activeChar.broadcastUserInfo(); DonateAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]","Donated Donate Status","Donate Coins:"+ammount); } if (!activeChar.destroyItemByItemId("Donate Coin",itemid, ammount, activeChar, false)) return; } else {
  686. * activeChar.sendMessage("You do not have enough Donate Coin."); } }
  687. */
  688.  
  689. public void enchantj(L2PcInstance activeChar)
  690. {
  691. // jewels
  692. ItemInstance rear = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_REAR);
  693. ItemInstance lear = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEAR);
  694. ItemInstance rfinger = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RFINGER);
  695. ItemInstance lfinger = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LFINGER);
  696. ItemInstance neck = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_NECK);
  697.  
  698. NpcHtmlMessage nhm = new NpcHtmlMessage(5);
  699. StringBuilder tb = new StringBuilder("");
  700.  
  701. tb.append("");
  702. tb.append("
  703. Donate Shop
  704. ");
  705. tb.append("
  706. Enchant Jewel's Part +16 Will Cost 3 Donate Coin.
  707. ");
  708. tb.append("
  709. ");
  710. tb.append("");
  711. tb.append("
  712. ");
  713. if (rear != null)
  714. {
  715. tb.append("}
  716. if (lear != null)
  717. {
  718. tb.append("}
  719. if (rfinger != null)
  720. {
  721. tb.append("}
  722. if (lfinger != null)
  723. {
  724. tb.append("}
  725. if (neck != null)
  726. {
  727. tb.append("}
  728. tb.append("
  729. ");
  730. tb.append("
  731. ");
  732. tb.append("");
  733.  
  734. nhm.setHtml(tb.toString());
  735. activeChar.sendPacket(nhm);
  736. }
  737.  
  738. public void enchanta(L2PcInstance activeChar)
  739. {
  740. // armors
  741. ItemInstance head = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_HEAD);
  742. ItemInstance chest = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST);
  743. ItemInstance legs = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS);
  744. ItemInstance feet = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET);
  745. ItemInstance gloves = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES);
  746. ItemInstance tattoo = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_UNDER);
  747. NpcHtmlMessage nhm = new NpcHtmlMessage(5);
  748. StringBuilder tb = new StringBuilder("");
  749.  
  750. tb.append("
  751. ");
  752. tb.append("
  753. Donate Shop
  754. ");
  755. tb.append("
  756. Enchant Armor Part +16 Will Cost 3 Donate Coin.
  757. ");
  758. tb.append("
  759. ");
  760. tb.append("");
  761. tb.append("
  762. ");
  763. if (head != null)
  764. {
  765. tb.append("}
  766. if (chest != null)
  767. {
  768. tb.append("}
  769. if (legs != null)
  770. {
  771. tb.append("}
  772. if (feet != null)
  773. {
  774. tb.append("}
  775. if (gloves != null)
  776. {
  777. tb.append("}
  778. if (tattoo != null)
  779. {
  780. tb.append("}
  781. tb.append("
  782. ");
  783. tb.append("
  784. ");
  785. tb.append("");
  786.  
  787. nhm.setHtml(tb.toString());
  788. activeChar.sendPacket(nhm);
  789. }
  790.  
  791. public void enchantw(L2PcInstance activeChar)
  792. {
  793. ItemInstance rhand = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
  794. ItemInstance lhand = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND);
  795.  
  796. NpcHtmlMessage nhm = new NpcHtmlMessage(5);
  797. StringBuilder tb = new StringBuilder("");
  798.  
  799. tb.append("
  800. ");
  801. tb.append("
  802. Donate Shop
  803. ");
  804. tb.append("
  805. Enchant Weapon +16 Will Cost 8 Donate Coin.
  806. ");
  807. tb.append("
  808. ");
  809. tb.append("");
  810. tb.append("
  811. ");
  812. if (rhand != null)
  813. {
  814. tb.append("}
  815. if (lhand != null && lhand.getItem().getItemType() != EtcItemType.ARROW)
  816. {
  817. tb.append("}
  818.  
  819. tb.append("
  820. ");
  821. tb.append("
  822. ");
  823. tb.append("");
  824.  
  825. nhm.setHtml(tb.toString());
  826. activeChar.sendPacket(nhm);
  827. }
  828.  
  829. public static void sex(L2PcInstance activeChar, int ammount)
  830. {
  831. if (activeChar.getInventory().getInventoryItemCount(itemid, 0) >= ammount)
  832. {
  833. if (activeChar.getClassId().getId() == activeChar.getBaseClass())
  834. {
  835. activeChar.getAppearance().setSex(activeChar.getAppearance().getSex() == Sex.MALE ? Sex.FEMALE : Sex.MALE);
  836. activeChar.broadcastUserInfo();
  837. activeChar.decayMe();
  838. activeChar.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
  839. activeChar.sendMessage("Congratulations! Your Sex has been changed succesfully. You will now be disconnected for Update Sex. Please login again!");
  840. DonateAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", "Donated Change Sex", "Donate Coins:" + ammount);
  841. try
  842. {
  843. Thread.sleep(3000L);
  844. }
  845. catch (Exception e)
  846. {
  847. }
  848. activeChar.deleteMe();
  849. activeChar.sendPacket(LeaveWorld.STATIC_PACKET);
  850.  
  851. if (!activeChar.destroyItemByItemId("Donate Coin", itemid, ammount, activeChar, false))
  852. return;
  853. }
  854. else
  855. {
  856. activeChar.sendMessage("In Order To Get Sex You Need To Be On Main Class");
  857. return;
  858. }
  859. }
  860. else
  861. {
  862. activeChar.sendMessage("You do not have enough Donate Coin.");
  863. }
  864. }
  865.  
  866. private void winds(L2PcInstance player, int count)
  867. {
  868. ItemInstance rhand = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
  869. NpcHtmlMessage html = new NpcHtmlMessage(1);
  870. switch (count)
  871. {
  872. case 1:
  873. String htmContent = HtmCache.getInstance().getHtm("data/html/mods/donate/noblesse.htm");
  874. html.setHtml(htmContent);
  875. html.replace("%objectId%", String.valueOf(this.getObjectId()));
  876. html.replace("%charname%", player.getName());
  877. player.sendPacket(html);
  878. break;
  879. case 2:
  880. String htmContent1 = HtmCache.getInstance().getHtm("data/html/mods/donate/donate.htm");
  881. html.setHtml(htmContent1);
  882. html.replace("%objectId%", String.valueOf(this.getObjectId()));
  883. html.replace("%charname%", player.getName());
  884. player.sendPacket(html);
  885. break;
  886. case 3:
  887. String htmContent2 = HtmCache.getInstance().getHtm("data/html/mods/donate/clan.htm");
  888. html.setHtml(htmContent2);
  889. html.replace("%objectId%", String.valueOf(this.getObjectId()));
  890. html.replace("%charname%", player.getName());
  891. player.sendPacket(html);
  892. break;
  893. case 4:
  894. String htmContent3 = HtmCache.getInstance().getHtm("data/html/mods/donate/sex.htm");
  895. html.setHtml(htmContent3);
  896. html.replace("%objectId%", String.valueOf(this.getObjectId()));
  897. html.replace("%charname%", player.getName());
  898. player.sendPacket(html);
  899. break;
  900. case 5:
  901. String htmContent4 = HtmCache.getInstance().getHtm("data/html/mods/donate/name.htm");
  902. html.setHtml(htmContent4);
  903. html.replace("%objectId%", String.valueOf(this.getObjectId()));
  904. html.replace("%charname%", player.getName());
  905. player.sendPacket(html);
  906. break;
  907. case 6:
  908. String htmContent5 = HtmCache.getInstance().getHtm("data/html/mods/donate/hero.htm");
  909. html.setHtml(htmContent5);
  910. html.replace("%objectId%", String.valueOf(this.getObjectId()));
  911. html.replace("%charname%", player.getName());
  912. player.sendPacket(html);
  913. break;
  914. case 7:
  915. String htmContent6 = HtmCache.getInstance().getHtm("data/html/mods/donate/enchant.htm");
  916. html.setHtml(htmContent6);
  917. html.replace("%objectId%", String.valueOf(this.getObjectId()));
  918. html.replace("%charname%", player.getName());
  919. player.sendPacket(html);
  920. break;
  921. case 8:
  922. String htmContent8 = HtmCache.getInstance().getHtm("data/html/mods/donate/augment/active/page1.htm");
  923. html.setHtml(htmContent8);
  924. html.replace("%objectId%", String.valueOf(this.getObjectId()));
  925. html.replace("%charname%", player.getName());
  926. if (rhand != null && rhand.isAugmented() && rhand.getAugmentation() != null && rhand.getAugmentation().getSkill() != null && rhand.getAugmentation().getSkill().getLevel() >= 1)
  927. {
  928. html.replace("%level%", rhand.getAugmentation().getSkill().getLevel());
  929. }
  930. html.replace("%level%", "None");
  931. player.sendPacket(html);
  932. break;
  933. case 9:
  934. String htmContent9 = HtmCache.getInstance().getHtm("data/html/mods/donate/augment/active/page2.htm");
  935. html.setHtml(htmContent9);
  936. html.replace("%objectId%", String.valueOf(this.getObjectId()));
  937. html.replace("%charname%", player.getName());
  938. if (rhand != null && rhand.isAugmented() && rhand.getAugmentation() != null && rhand.getAugmentation().getSkill() != null && rhand.getAugmentation().getSkill().getLevel() >= 1)
  939. {
  940. html.replace("%level%", rhand.getAugmentation().getSkill().getLevel());
  941. }
  942. html.replace("%level%", "None");
  943. player.sendPacket(html);
  944. break;
  945. case 10:
  946. String htmContent10 = HtmCache.getInstance().getHtm("data/html/mods/donate/augment/active/page3.htm");
  947. html.setHtml(htmContent10);
  948. html.replace("%objectId%", String.valueOf(this.getObjectId()));
  949. html.replace("%charname%", player.getName());
  950. if (rhand != null && rhand.isAugmented() && rhand.getAugmentation() != null && rhand.getAugmentation().getSkill() != null && rhand.getAugmentation().getSkill().getLevel() >= 1)
  951. {
  952. html.replace("%level%", rhand.getAugmentation().getSkill().getLevel());
  953. }
  954. html.replace("%level%", "None");
  955. player.sendPacket(html);
  956. break;
  957. case 11:
  958. String htmContent11 = HtmCache.getInstance().getHtm("data/html/mods/donate/augment/active/page4.htm");
  959. html.setHtml(htmContent11);
  960. html.replace("%objectId%", String.valueOf(this.getObjectId()));
  961. html.replace("%charname%", player.getName());
  962. if (rhand != null && rhand.isAugmented() && rhand.getAugmentation() != null && rhand.getAugmentation().getSkill() != null && rhand.getAugmentation().getSkill().getLevel() >= 1)
  963. {
  964. html.replace("%level%", rhand.getAugmentation().getSkill().getLevel());
  965. }
  966. html.replace("%level%", "None");
  967. player.sendPacket(html);
  968. break;
  969. case 12:
  970. String htmContent12 = HtmCache.getInstance().getHtm("data/html/mods/donate/augment/active/page5.htm");
  971. html.setHtml(htmContent12);
  972. html.replace("%objectId%", String.valueOf(this.getObjectId()));
  973. html.replace("%charname%", player.getName());
  974. if (rhand != null && rhand.isAugmented() && rhand.getAugmentation() != null && rhand.getAugmentation().getSkill() != null && rhand.getAugmentation().getSkill().getLevel() >= 1)
  975. {
  976. html.replace("%level%", rhand.getAugmentation().getSkill().getLevel());
  977. }
  978. html.replace("%level%", "None");
  979. player.sendPacket(html);
  980. break;
  981. case 13:
  982. String htmContent13 = HtmCache.getInstance().getHtm("data/html/mods/donate/augment.htm");
  983. html.setHtml(htmContent13);
  984. html.replace("%objectId%", String.valueOf(this.getObjectId()));
  985. html.replace("%charname%", player.getName());
  986. player.sendPacket(html);
  987. break;
  988. case 14:
  989. String htmContent14 = HtmCache.getInstance().getHtm("data/html/mods/donate/augment/passive/page1.htm");
  990. html.setHtml(htmContent14);
  991. html.replace("%objectId%", String.valueOf(this.getObjectId()));
  992. html.replace("%charname%", player.getName());
  993. if (rhand != null && rhand.isAugmented() && rhand.getAugmentation() != null && rhand.getAugmentation().getSkill() != null && rhand.getAugmentation().getSkill().getLevel() >= 1)
  994. {
  995. html.replace("%level%", rhand.getAugmentation().getSkill().getLevel());
  996. }
  997. html.replace("%level%", "None");
  998. player.sendPacket(html);
  999. break;
  1000. case 15:
  1001. String htmContent15 = HtmCache.getInstance().getHtm("data/html/mods/donate/augment/passive/page2.htm");
  1002. html.setHtml(htmContent15);
  1003. html.replace("%objectId%", String.valueOf(this.getObjectId()));
  1004. html.replace("%charname%", player.getName());
  1005. if (rhand != null && rhand.isAugmented() && rhand.getAugmentation() != null && rhand.getAugmentation().getSkill() != null && rhand.getAugmentation().getSkill().getLevel() >= 1)
  1006. {
  1007. html.replace("%level%", rhand.getAugmentation().getSkill().getLevel());
  1008. }
  1009. html.replace("%level%", "None");
  1010. player.sendPacket(html);
  1011. break;
  1012. }
  1013. }
  1014.  
  1015. private static void name(L2PcInstance activeChar, int ammount, String val[])
  1016. {
  1017. if (activeChar.getInventory().getInventoryItemCount(itemid, 0) >= ammount)
  1018. {
  1019. if (val.length != 2)
  1020. {
  1021. activeChar.sendMessage("Enter a new name or remove the space between the names.");
  1022. return;
  1023. }
  1024. else if (val[1].length() < 1 || val[1].length() > 16)
  1025. {
  1026. activeChar.sendMessage("Maximum number of characters: 16");
  1027. return;
  1028. }
  1029. else if (!StringUtil.isAlphaNumeric(val[1]))
  1030. {
  1031. activeChar.sendMessage("The name must only contain alpha-numeric characters.");
  1032. return;
  1033. }
  1034. else if (CharNameTable.getInstance().getPlayerObjectId(val[1]) > 0)
  1035. {
  1036. activeChar.sendMessage("The name chosen is already in use. Choose another name.");
  1037. return;
  1038. }
  1039.  
  1040. if (activeChar.isInParty())
  1041. {
  1042. activeChar.getParty().broadcastToPartyMembers(activeChar, new PartySmallWindowDeleteAll());
  1043. for (L2PcInstance member : activeChar.getParty().getPartyMembers())
  1044. {
  1045. if (member != activeChar)
  1046. member.sendPacket(new PartySmallWindowAll(member, activeChar.getParty()));
  1047. }
  1048. }
  1049. if (activeChar.getClan() != null)
  1050. activeChar.getClan().broadcastClanStatus();
  1051.  
  1052. World.getInstance().removePlayer(activeChar);
  1053. activeChar.setName(val[1]);
  1054. activeChar.store();
  1055. World.getInstance().addPlayer(activeChar);
  1056. activeChar.sendMessage("Your name has been changed successfully.");
  1057. activeChar.broadcastUserInfo();
  1058.  
  1059. if (!activeChar.destroyItemByItemId("Donate Coin", itemid, ammount, activeChar, false))
  1060. return;
  1061. }
  1062. else
  1063. {
  1064. activeChar.sendMessage("You do not have enough Donate Coin.");
  1065. }
  1066. }
  1067.  
  1068. public static void Enchant(L2PcInstance activeChar, int enchant, int ammount, int type)
  1069. {
  1070. ItemInstance item = activeChar.getInventory().getPaperdollItem(type);
  1071.  
  1072. if (activeChar.getInventory().getInventoryItemCount(itemid, 0) >= ammount)
  1073. {
  1074. if (item == null)
  1075. {
  1076. activeChar.sendMessage("That item doesn't exist in your inventory.");
  1077. return;
  1078. }
  1079. else if (item.getEnchantLevel() == 20)
  1080. {
  1081. activeChar.sendMessage("Your " + item.getItemName() + " is already on maximun enchant!");
  1082. return;
  1083. }
  1084. else if (item.getItem().getCrystalType() != null)
  1085. {
  1086. activeChar.sendMessage("You can't Enchant under " + item.getItem().getCrystalType() + " Grade Weapon!");
  1087. return;
  1088. }
  1089. else if (item.isHeroItem())
  1090. {
  1091. activeChar.sendMessage("You Cannot be Enchant On " + item.getItemName() + " !");
  1092. return;
  1093. }
  1094.  
  1095. if (item.isEquipped())
  1096. {
  1097. item.setEnchantLevel(enchant);
  1098. item.updateDatabase();
  1099. activeChar.sendPacket(new ItemList(activeChar, false));
  1100. activeChar.broadcastUserInfo();
  1101. activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_S2_SUCCESSFULLY_ENCHANTED).addNumber(item.getEnchantLevel()).addItemName(item.getItemId()));
  1102. DonateAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", "Donated: " + item.getItemName() + " +" + item.getEnchantLevel(), "Donate Coins:" + ammount);
  1103. }
  1104. if (!activeChar.destroyItemByItemId("Donate Coin", itemid, ammount, activeChar, false))
  1105. return;
  1106. }
  1107. else
  1108. {
  1109. activeChar.sendMessage("You do not have enough Donate Coin.");
  1110. }
  1111. }
  1112. }
  1113.  
  1114. /*
  1115. * This program is free software: you can redistribute it and/or modify it under
  1116. * the terms of the GNU General Public License as published by the Free Software
  1117. * Foundation, either version 3 of the License, or (at your option) any later
  1118. * version.
  1119. *
  1120. * This program is distributed in the hope that it will be useful, but WITHOUT
  1121. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  1122. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  1123. * details.
  1124. *
  1125. * You should have received a copy of the GNU General Public License along with
  1126. * this program. If not, see .
  1127. */
  1128. package net.sf.l2j.gameserver;
  1129.  
  1130. import java.io.File;
  1131. import java.io.FileWriter;
  1132. import java.io.IOException;
  1133. import java.util.Date;
  1134. import java.util.logging.Level;
  1135. import java.util.logging.Logger;
  1136.  
  1137. import net.sf.l2j.gameserver.util.Util;
  1138.  
  1139. public class DonateAudit
  1140. {
  1141. static
  1142. {
  1143. new File("log/Donates").mkdirs();
  1144. }
  1145.  
  1146. private static final Logger LOGGER = Logger.getLogger(DonateAudit.class.getName());
  1147.  
  1148. public static void auditGMAction(String activeChar, String action, String target, String params)
  1149. {
  1150. final File file = new File("log/Donates/" + activeChar + ".txt");
  1151. if (!file.exists())
  1152. try
  1153. {
  1154. file.createNewFile();
  1155. }
  1156. catch (IOException e)
  1157. {
  1158. }
  1159.  
  1160. try (FileWriter save = new FileWriter(file, true))
  1161. {
  1162. save.write(Util.formatDate(new Date(), "dd/MM/yyyy H:mm:ss") + ">" + activeChar + ">" + action + ">" + target + ">" + params + "\r\n");
  1163. }
  1164. catch (IOException e)
  1165. {
  1166. LOGGER.log(Level.SEVERE, "GMAudit for GM " + activeChar + " could not be saved: ", e);
  1167. }
  1168. }
  1169.  
  1170. public static void auditGMAction(String activeChar, String action, String target)
  1171. {
  1172. auditGMAction(activeChar, action, target, "");
  1173. }
  1174. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement