Advertisement
Guest User

L2DonateShopInstance

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