Advertisement
Guest User

Donate Menu

a guest
Sep 5th, 2012
766
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 23.42 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2J_Server_BETA
  3. Index: dist/game/config/L2JMods.properties
  4. ===================================================================
  5. --- dist/game/config/L2JMods.properties (revision 5588)
  6. +++ dist/game/config/L2JMods.properties (working copy)
  7. @@ -461,4 +461,40 @@
  8.  # ---------------------------------------------------------------------------
  9.  # Enables .changepassword voiced command which allows the players to change their account's password ingame.
  10. # Default: False
  11. -AllowChangePassword = False
  12. \ No newline at end of file
  13. +AllowChangePassword = False
  14. +
  15. +# ---------------------------------------------------------------------------
  16. +# Donate Window
  17. +# ---------------------------------------------------------------------------
  18. +# Item id that will be used to buy services in Donate Window
  19. +DonateItemId = 57
  20. +# Price of Hp/Mp/Cp Fully heal
  21. +DonateHeal = 500
  22. +# Price of Removing all debuffs
  23. +DonateRemoveDebuff = 200
  24. +# Price of Blessed Soe during combat
  25. +DonateBsoe = 200
  26. +# Price of removing all skill reuses
  27. +DonateRemoveReuse = 300
  28. +# Price of removing karma
  29. +DonateRemoveKarma = 300
  30. +# Price of self ressurection
  31. +DonateSelfRes = 500
  32. +# Price of removing Clan Penaltys
  33. +DonateRemovePenaltys = 100
  34. +# Price of consumables(shots(500), arrows(500), potions(50), spirit ore(300), soul ore(200))
  35. +DonateConsumables = 20
  36. +# Price of adding attribute +5 to a weapon
  37. +DonateAttribute = 200
  38. +# Price of adding 5 olympiad points
  39. +DonateOlyPointsAdd = 500
  40. +# Price of adding 50kk adena
  41. +DonateAdena = 100
  42. +# Price of getting Cursed Weapon(only if its not taken)
  43. +DonateCursedWeapon = 300
  44. +# Price of enchanting Weapon +1
  45. +DonateEnchantWeapon = 800
  46. +# Price of enchanting Armor(always weakest is enchanted)
  47. +DonateEnchantArmor = 500
  48. +# Price of enchanting Jewely(always weakest is enchanted)
  49. +DonateEnchantJewely = 400
  50. \ No newline at end of file
  51. Index: java/com/l2jserver/Config.java
  52. ===================================================================
  53. --- java/com/l2jserver/Config.java  (revision 5588)
  54. +++ java/com/l2jserver/Config.java  (working copy)
  55. @@ -763,6 +763,22 @@
  56.     public static int L2JMOD_DUALBOX_CHECK_MAX_L2EVENT_PARTICIPANTS_PER_IP;
  57.     public static Map<Integer, Integer> L2JMOD_DUALBOX_CHECK_WHITELIST;
  58.     public static boolean L2JMOD_ALLOW_CHANGE_PASSWORD;
  59. +   public static int DONATE_ITEM_ID;
  60. +   public static int DONATE_HEAL;
  61. +   public static int DONATE_REMOVE_DEBUFF;
  62. +   public static int DONATE_BSOE;
  63. +   public static int DONATE_REMOVE_REUSE;
  64. +   public static int DONATE_REMOVE_KARMA;
  65. +   public static int DONATE_SELF_RES;
  66. +   public static int DONATE_REMOVE_CLAN_PENALTYS;
  67. +   public static int DONATE_CONSUMABLES;
  68. +   public static int DONATE_ATTRIBUTE;
  69. +   public static int DONATE_OLYMPIAD_POINT;
  70. +   public static int DONATE_ADENA;
  71. +   public static int DONATE_CURSED_WEAPON;
  72. +   public static int DONATE_ENCHANT_WEAPON;
  73. +   public static int DONATE_ENCHANT_ARMOR;
  74. +   public static int DONATE_ENCHANT_JEWELY;
  75.    
  76.     // --------------------------------------------------
  77.     // NPC Settings
  78. @@ -2673,6 +2689,24 @@
  79.             }
  80.             L2JMOD_ALLOW_CHANGE_PASSWORD = Boolean.parseBoolean(L2JModSettings.getProperty("AllowChangePassword", "False"));
  81.            
  82. +           DONATE_ITEM_ID = Integer.parseInt(L2JModSettings.getProperty("DonateItemId", "57"));
  83. +           DONATE_HEAL = Integer.parseInt(L2JModSettings.getProperty("DonateHeal", "500"));
  84. +           DONATE_REMOVE_DEBUFF = Integer.parseInt(L2JModSettings.getProperty("DonateRemoveDebuff", "200"));
  85. +           DONATE_BSOE = Integer.parseInt(L2JModSettings.getProperty("DonateBsoe", "200"));
  86. +           DONATE_REMOVE_REUSE = Integer.parseInt(L2JModSettings.getProperty("DonateRemoveReuse", "300"));
  87. +           DONATE_REMOVE_KARMA = Integer.parseInt(L2JModSettings.getProperty("DonateRemoveKarma", "300"));
  88. +           DONATE_SELF_RES = Integer.parseInt(L2JModSettings.getProperty("DonateSelfRes", "500"));
  89. +           DONATE_REMOVE_CLAN_PENALTYS = Integer.parseInt(L2JModSettings.getProperty("DonateRemovePenaltys", "100"));
  90. +           DONATE_CONSUMABLES = Integer.parseInt(L2JModSettings.getProperty("DonateConsumables", "20"));
  91. +           DONATE_ATTRIBUTE = Integer.parseInt(L2JModSettings.getProperty("DonateAttribute", "200"));
  92. +           DONATE_OLYMPIAD_POINT = Integer.parseInt(L2JModSettings.getProperty("DonateOlyPointsAdd", "500"));
  93. +           DONATE_ADENA = Integer.parseInt(L2JModSettings.getProperty("DonateAdena", "100"));
  94. +           DONATE_CURSED_WEAPON = Integer.parseInt(L2JModSettings.getProperty("DonateCursedWeapon", "300"));
  95. +           DONATE_ENCHANT_WEAPON = Integer.parseInt(L2JModSettings.getProperty("DonateEnchantWeapon", "800"));
  96. +           DONATE_ENCHANT_ARMOR = Integer.parseInt(L2JModSettings.getProperty("DonateEnchantArmor", "500"));
  97. +           DONATE_ENCHANT_JEWELY = Integer.parseInt(L2JModSettings.getProperty("DonateEnchantJewely", "400"));
  98. +          
  99. +          
  100.             // Load PvP L2Properties file (if exists)
  101.             final File pvp = new File(PVP_CONFIG_FILE);
  102.             L2Properties PVPSettings = new L2Properties();
  103. Index: java/com/l2jserver/gameserver/network/clientpackets/RequestBypassToServer.java
  104. ===================================================================
  105. --- java/com/l2jserver/gameserver/network/clientpackets/RequestBypassToServer.java  (revision 5588)
  106. +++ java/com/l2jserver/gameserver/network/clientpackets/RequestBypassToServer.java  (working copy)
  107. @@ -26,6 +26,7 @@
  108. import com.l2jserver.gameserver.datatables.AdminTable;
  109. import com.l2jserver.gameserver.handler.AdminCommandHandler;
  110. import com.l2jserver.gameserver.handler.BypassHandler;
  111. +import com.l2jserver.gameserver.handler.Donate;
  112. import com.l2jserver.gameserver.handler.IAdminCommandHandler;
  113. import com.l2jserver.gameserver.handler.IBypassHandler;
  114. import com.l2jserver.gameserver.model.L2CharPosition;
  115. @@ -306,6 +307,10 @@
  116.                     handler.useBypass("arenachange " + (arenaId - 1), activeChar, null);
  117.                 }
  118.             }
  119. +           else if(_command.startsWith("_donate"))
  120. +           {
  121. +               Donate.onBypass(activeChar, _command.substring(8));
  122. +           }
  123.             else
  124.             {
  125.                 final IBypassHandler handler = BypassHandler.getInstance().getHandler(_command);
  126. Index: java/com/l2jserver/gameserver/model/olympiad/Olympiad.java
  127. ===================================================================
  128. --- java/com/l2jserver/gameserver/model/olympiad/Olympiad.java  (revision 5588)
  129. +++ java/com/l2jserver/gameserver/model/olympiad/Olympiad.java  (working copy)
  130. @@ -446,7 +446,7 @@
  131.         return _nobles.size();
  132.     }
  133.    
  134. -   protected static StatsSet getNobleStats(int playerId)
  135. +   public static StatsSet getNobleStats(int playerId)
  136.     {
  137.         return _nobles.get(playerId);
  138.     }
  139. Index: java/com/l2jserver/gameserver/handler/Donate.java
  140. ===================================================================
  141. --- java/com/l2jserver/gameserver/handler/Donate.java   (revision 0)
  142. +++ java/com/l2jserver/gameserver/handler/Donate.java   (working copy)
  143. @@ -0,0 +1,396 @@
  144. +/*
  145. + * This program is free software: you can redistribute it and/or modify it under
  146. + * the terms of the GNU General Public License as published by the Free Software
  147. + * Foundation, either version 3 of the License, or (at your option) any later
  148. + * version.
  149. + *
  150. + * This program is distributed in the hope that it will be useful, but WITHOUT
  151. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  152. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  153. + * details.
  154. + *
  155. + * You should have received a copy of the GNU General Public License along with
  156. + * this program. If not, see <http://www.gnu.org/licenses/>.
  157. + */
  158. +package com.l2jserver.gameserver.handler;
  159. +
  160. +import com.l2jserver.Config;
  161. +import com.l2jserver.gameserver.datatables.ItemTable;
  162. +import com.l2jserver.gameserver.datatables.SkillTable;
  163. +import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
  164. +import com.l2jserver.gameserver.model.CursedWeapon;
  165. +import com.l2jserver.gameserver.model.actor.L2Character;
  166. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  167. +import com.l2jserver.gameserver.model.effects.L2Effect;
  168. +import com.l2jserver.gameserver.model.itemcontainer.Inventory;
  169. +import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  170. +import com.l2jserver.gameserver.model.olympiad.Olympiad;
  171. +import com.l2jserver.gameserver.model.skills.L2Skill;
  172. +import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
  173. +import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  174. +import com.l2jserver.gameserver.network.serverpackets.SkillCoolTime;
  175. +
  176. +/**
  177. + * @author Vampir
  178. + */
  179. +public class Donate implements IVoicedCommandHandler
  180. +{
  181. +   private static final String[] VOICED_COMMANDS =
  182. +   {
  183. +       "donate"
  184. +   };
  185. +  
  186. +   //{button name, button command, icon}
  187. +   private static final String[][] combatButtons = {
  188. +       {"Full Heal", "hp", "icon.skill5934"},
  189. +       {"Cure Debuff", "dbuff", "icon.skill0430"},
  190. +       {"Bsoe", "bsoe", "icon.skill0430"},
  191. +       {"Reuse Skills", "clearReuse", "icon.skill0430"},
  192. +       {"Remove Karma", "clearKarma", "icon.skill0430"},
  193. +       {"Ress Myself", "resMe", "icon.skill0430"},
  194. +       };
  195. +  
  196. +   //{button name, button command, icon}
  197. +   private static final String[][] townButtons = {
  198. +       {"Remove Clan Penaltys", "deleteClanPenaltys", "icon.skill0430"},
  199. +       {"Add Consumables", "addConsumables", "icon.skill0430"},
  200. +       {"Add Wpn Attribute", "addAttribute", "icon.skill0430"},
  201. +       {"Add 5 Oly points", "addOlyPoints", "icon.skill0430"},
  202. +       {"Add 50kk adena", "addAdena", "icon.skill0430"},
  203. +       {"Get Cursed Weapon", "addCursedWeapon", "icon.skill0430"},
  204. +       {"Enchant Weapon", "enchantWeapon", "icon.skill0430"},
  205. +       {"Enchant Armor", "enchantArmor", "icon.skill0430"},
  206. +       {"Enchant Jewely", "enchantJewely", "icon.skill0430"},
  207. +   };
  208. +  
  209. +   @Override
  210. +   public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
  211. +   {
  212. +       if (command.equals(VOICED_COMMANDS[0]))//donate
  213. +       {
  214. +           setToShowPage(activeChar);
  215. +          
  216. +           return true;
  217. +       }
  218. +       return false;
  219. +   }
  220. +  
  221. +   public static void onBypass(L2PcInstance activeChar, String command)
  222. +   {
  223. +       String donateItemName = ItemTable.getInstance().getTemplate(Config.DONATE_ITEM_ID).getName();
  224. +       if(command.equals("changePage"))
  225. +       {
  226. +           String[][] buttons;
  227. +           if(activeChar.isInsideZone(L2Character.ZONE_PEACE))
  228. +               buttons = combatButtons;
  229. +           else
  230. +               buttons = townButtons;
  231. +           showPage(activeChar, buttons);
  232. +       }
  233. +       else if(command.equals("hp"))
  234. +       {
  235. +           if(activeChar.getInventory().destroyItemByItemId("Donate", Config.DONATE_ITEM_ID, Config.DONATE_HEAL, activeChar, true) != null)
  236. +           {
  237. +               activeChar.setCurrentHpMp(activeChar.getMaxHp(), activeChar.getMaxMp());
  238. +               activeChar.setCurrentCp(activeChar.getMaxCp());
  239. +               activeChar.sendMessage("Your Hp, Cp and Mp has been restored for "+Config.DONATE_HEAL+" "+donateItemName+"!");
  240. +           }
  241. +           else
  242. +               activeChar.sendMessage("You need "+Config.DONATE_HEAL+" "+donateItemName+" to restore your health!");
  243. +       }
  244. +       else if(command.equals("dbuff"))
  245. +       {
  246. +           L2Effect[] effects = activeChar.getAllEffects();
  247. +           if (effects == null || effects.length == 0)
  248. +               return;
  249. +           if(activeChar.getInventory().destroyItemByItemId("Donate", Config.DONATE_ITEM_ID, Config.DONATE_REMOVE_DEBUFF, activeChar, true) != null)
  250. +           {
  251. +               for (L2Effect e : effects)
  252. +                   if (e.getSkill().isDebuff())
  253. +                       e.exit();
  254. +               activeChar.sendMessage("Your debuffs has been removed for "+Config.DONATE_REMOVE_DEBUFF+" "+donateItemName+"!");
  255. +           }
  256. +           else
  257. +               activeChar.sendMessage("You need "+Config.DONATE_REMOVE_DEBUFF+" "+donateItemName+" to remove your debuffs!");
  258. +       }
  259. +       else if(command.equals("bsoe"))
  260. +       {
  261. +           if(activeChar.getInventory().destroyItemByItemId("Donate", Config.DONATE_ITEM_ID, Config.DONATE_BSOE, activeChar, true) != null)
  262. +           {
  263. +               L2Skill GM_escape = SkillTable.getInstance().getInfo(2100, 1);
  264. +               activeChar.doCast(GM_escape);
  265. +               activeChar.sendMessage("You have escaped from the battle for "+Config.DONATE_BSOE+" "+donateItemName+"!");
  266. +           }
  267. +           else
  268. +               activeChar.sendMessage("You need "+Config.DONATE_BSOE+" "+donateItemName+" to escape from the battle!");
  269. +       }
  270. +       else if(command.equals("clearReuse"))
  271. +       {
  272. +           if(activeChar.getInventory().destroyItemByItemId("Donate", Config.DONATE_ITEM_ID, Config.DONATE_REMOVE_REUSE, activeChar, true) != null)
  273. +           {
  274. +               activeChar.getSkillReuseTimeStamps().clear();
  275. +               activeChar.getDisabledSkills().clear();
  276. +               activeChar.sendPacket(new SkillCoolTime(activeChar));
  277. +               activeChar.sendMessage("You have removed skills reuse for "+Config.DONATE_REMOVE_REUSE+" "+donateItemName+"!");
  278. +           }
  279. +           else
  280. +               activeChar.sendMessage("You need "+Config.DONATE_REMOVE_REUSE+" "+donateItemName+" to remove skills reuses!");
  281. +       }
  282. +       else if(command.equals("clearKarma"))
  283. +       {
  284. +           if(activeChar.getInventory().destroyItemByItemId("Donate", Config.DONATE_ITEM_ID, Config.DONATE_REMOVE_KARMA, activeChar, true) != null)
  285. +           {
  286. +               activeChar.setKarma(0);
  287. +               activeChar.sendMessage("You have cleared your karma for "+Config.DONATE_REMOVE_KARMA+" "+donateItemName+"!");
  288. +           }
  289. +           else
  290. +               activeChar.sendMessage("You need "+Config.DONATE_REMOVE_KARMA+" "+donateItemName+" to clear your karma!");
  291. +       }
  292. +       else if(command.equals("resMe"))
  293. +       {
  294. +           if(activeChar.isDead())
  295. +           {
  296. +               if(activeChar.getInventory().destroyItemByItemId("Donate", Config.DONATE_ITEM_ID, Config.DONATE_SELF_RES, activeChar, true) != null)
  297. +               {
  298. +                   activeChar.restoreExp(100.0);
  299. +                   activeChar.doRevive();
  300. +                   activeChar.sendMessage("You have been ressurected for "+Config.DONATE_SELF_RES+" "+donateItemName+"!");
  301. +               }
  302. +               else
  303. +                   activeChar.sendMessage("You need "+Config.DONATE_SELF_RES+" "+donateItemName+" to ressurect yourself!");
  304. +           }
  305. +       }
  306. +       else if(command.equals("deleteClanPenaltys"))
  307. +       {
  308. +           if(activeChar.getInventory().destroyItemByItemId("Donate", Config.DONATE_ITEM_ID, Config.DONATE_REMOVE_CLAN_PENALTYS, activeChar, true) != null)
  309. +           {
  310. +               activeChar.setClanCreateExpiryTime(0);
  311. +               activeChar.setClanJoinExpiryTime(0);
  312. +               activeChar.sendMessage("You have removed Clan Penaltys for "+Config.DONATE_REMOVE_CLAN_PENALTYS+" "+donateItemName+"!");
  313. +           }
  314. +           else
  315. +               activeChar.sendMessage("You need "+Config.DONATE_REMOVE_CLAN_PENALTYS+" "+donateItemName+" to remove Clan Penaltys!");
  316. +       }
  317. +       else if(command.equals("addConsumables"))
  318. +       {
  319. +           if(activeChar.getInventory().destroyItemByItemId("Donate", Config.DONATE_ITEM_ID, Config.DONATE_CONSUMABLES, activeChar, true) != null)
  320. +           {
  321. +               activeChar.addItem("Donate", 1345, 500, activeChar, false);//Shining Arrow
  322. +               activeChar.addItem("Donate", 1467, 500, activeChar, false);//SoulShot S
  323. +               activeChar.addItem("Donate", 3952, 500, activeChar, false);//Blessed SpiritShot S
  324. +               activeChar.addItem("Donate", 3031, 300, activeChar, false);//Spirit Ore
  325. +               activeChar.addItem("Donate", 1785, 300, activeChar, false);//Soul Ore
  326. +               activeChar.addItem("Donate", 1061, 50, activeChar, false);//Greater Healing Potion
  327. +               activeChar.addItem("Donate", 5592, 50, activeChar, false);//Greater CP Potion
  328. +               activeChar.sendMessage("You have earned few consumables for "+Config.DONATE_CONSUMABLES+" "+donateItemName+"!");
  329. +           }
  330. +           else
  331. +           {
  332. +               activeChar.sendMessage("You need "+Config.DONATE_CONSUMABLES+" "+donateItemName+" to get Consumables!");
  333. +           }
  334. +       }
  335. +       else if(command.equals("addAttribute"))
  336. +       {
  337. +           L2ItemInstance weapon = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
  338. +           if(weapon != null && weapon.getAttackElementPower() != 0)
  339. +           {
  340. +               if(activeChar.getInventory().destroyItemByItemId("Donate", Config.DONATE_ITEM_ID, Config.DONATE_ATTRIBUTE, activeChar, true) != null)
  341. +               {
  342. +                   activeChar.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_RHAND);
  343. +                   weapon.setElementAttr(weapon.getAttackElementType(), weapon.getAttackElementPower()+5);
  344. +                   activeChar.getInventory().equipItem(weapon);
  345. +                  
  346. +                   InventoryUpdate iu = new InventoryUpdate();
  347. +                   iu.addModifiedItem(weapon);
  348. +                   activeChar.sendPacket(iu);
  349. +                   activeChar.sendMessage("You have increased Attribute of weapon for "+Config.DONATE_ATTRIBUTE+" "+donateItemName+"!");
  350. +               }
  351. +               else
  352. +               {
  353. +                   activeChar.sendMessage("You need "+Config.DONATE_ATTRIBUTE+" "+donateItemName+" to increase Attribute!");
  354. +               }
  355. +           }
  356. +           else
  357. +               activeChar.sendMessage("You need to have weapon that already have attribute on it first!");
  358. +       }
  359. +       else if(command.equals("addOlyPoints"))
  360. +       {
  361. +           if(activeChar.isNoble())
  362. +           {
  363. +               if(activeChar.getInventory().destroyItemByItemId("Donate", Config.DONATE_ITEM_ID, Config.DONATE_OLYMPIAD_POINT, activeChar, true) != null)
  364. +               {
  365. +                   int currentPoints = Olympiad.getNobleStats(activeChar.getObjectId()).getInteger("olympiad_points");
  366. +                   currentPoints += 5;
  367. +                   Olympiad.getNobleStats(activeChar.getObjectId()).set("olympiad_points", currentPoints);
  368. +                   activeChar.sendMessage("You have earned 5 olympiad points for "+Config.DONATE_OLYMPIAD_POINT+" "+donateItemName+"!");
  369. +               }
  370. +               else
  371. +                   activeChar.sendMessage("You need "+Config.DONATE_OLYMPIAD_POINT+" "+donateItemName+" to get Olympiad points!");
  372. +           }
  373. +       }
  374. +       else if(command.equals("addAdena"))
  375. +       {
  376. +           if(activeChar.getInventory().destroyItemByItemId("Donate", Config.DONATE_ITEM_ID, Config.DONATE_ADENA, activeChar, true) != null)
  377. +           {
  378. +               activeChar.addAdena("Donate", 50000000, activeChar, false);
  379. +               activeChar.sendMessage("You have earned 50kk adena for "+Config.DONATE_ADENA+" "+donateItemName+"!");
  380. +           }
  381. +           else
  382. +               activeChar.sendMessage("You need "+Config.DONATE_ADENA+" "+donateItemName+" to get 50kk adena!");
  383. +       }
  384. +       else if(command.equals("addCursedWeapon"))
  385. +       {
  386. +           for(CursedWeapon cw : CursedWeaponsManager.getInstance().getCursedWeapons())
  387. +               if (!cw.isActive())
  388. +               {
  389. +                   if(activeChar.getInventory().destroyItemByItemId("Donate", Config.DONATE_ITEM_ID, Config.DONATE_CURSED_WEAPON, activeChar, true) != null)
  390. +                   {
  391. +                       activeChar.addItem("Donate", cw.getItemId(), 1, activeChar, true);
  392. +                       cw.setEndTime(System.currentTimeMillis() + cw.getDuration() * 60000L);
  393. +                       cw.reActivate();
  394. +                       activeChar.sendMessage("You have earned Cursed Weapon for "+Config.DONATE_CURSED_WEAPON+" "+donateItemName+"!");
  395. +                       setToShowPage(activeChar);
  396. +                       return;
  397. +                   }
  398. +               }
  399. +           activeChar.sendMessage("You need "+Config.DONATE_CURSED_WEAPON+" "+donateItemName+" to get Cursed Weapon and at least one of them cannot be used!");
  400. +       }
  401. +       else if(command.equals("enchantWeapon"))
  402. +       {
  403. +           L2ItemInstance weapon = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
  404. +           if(weapon != null)
  405. +           {
  406. +               if(activeChar.getInventory().destroyItemByItemId("Donate", Config.DONATE_ITEM_ID, Config.DONATE_ENCHANT_WEAPON, activeChar, true) != null)
  407. +               {
  408. +                   activeChar.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_RHAND);
  409. +                   weapon.setEnchantLevel(weapon.getEnchantLevel()+1);
  410. +                   activeChar.getInventory().equipItem(weapon);
  411. +                  
  412. +                   InventoryUpdate iu = new InventoryUpdate();
  413. +                   iu.addModifiedItem(weapon);
  414. +                   activeChar.sendPacket(iu);
  415. +                   activeChar.sendMessage("Your Weapon has been enchanted for "+Config.DONATE_ENCHANT_WEAPON+" "+donateItemName+"!");
  416. +               }
  417. +               else
  418. +                   activeChar.sendMessage("You need "+Config.DONATE_ENCHANT_WEAPON+" "+donateItemName+" to enchant your weapon!");
  419. +           }
  420. +       }
  421. +       else if(command.equals("enchantArmor"))
  422. +       {
  423. +           int[] armorParts = {Inventory.PAPERDOLL_HEAD, Inventory.PAPERDOLL_CHEST, Inventory.PAPERDOLL_LEGS, Inventory.PAPERDOLL_GLOVES, Inventory.PAPERDOLL_FEET};
  424. +           L2ItemInstance weakestArmor = null;
  425. +           int weakestEnchantLevel = 100;
  426. +           for(int part : armorParts)
  427. +           {
  428. +               L2ItemInstance armor = activeChar.getInventory().getPaperdollItem(part);
  429. +               if(armor != null && armor.getEnchantLevel()<weakestEnchantLevel)
  430. +               {
  431. +                   weakestEnchantLevel = armor.getEnchantLevel();
  432. +                   weakestArmor = armor;
  433. +               }
  434. +           }
  435. +           if(weakestArmor != null)
  436. +           {
  437. +               if(activeChar.getInventory().destroyItemByItemId("Donate", Config.DONATE_ITEM_ID, Config.DONATE_ENCHANT_ARMOR, activeChar, true) != null)
  438. +               {
  439. +                   weakestArmor.setEnchantLevel(weakestArmor.getEnchantLevel()+1);
  440. +                   InventoryUpdate iu = new InventoryUpdate();
  441. +                   iu.addModifiedItem(weakestArmor);
  442. +                   activeChar.sendPacket(iu);
  443. +                   activeChar.sendMessage("Your armor part has been enchanted for "+Config.DONATE_ENCHANT_ARMOR+" "+donateItemName+"!");
  444. +               }
  445. +               else
  446. +                   activeChar.sendMessage("You need "+Config.DONATE_ENCHANT_ARMOR+" "+donateItemName+" to enchant your armor part!");
  447. +           }
  448. +       }
  449. +       else if(command.equals("enchantJewely"))
  450. +       {
  451. +           int[] jewelyParts = {Inventory.PAPERDOLL_LFINGER, Inventory.PAPERDOLL_RFINGER, Inventory.PAPERDOLL_LEAR, Inventory.PAPERDOLL_REAR, Inventory.PAPERDOLL_NECK};
  452. +           L2ItemInstance weakestJewely = null;
  453. +           int weakestEnchantLevel = 100;
  454. +           for(int part : jewelyParts)
  455. +           {
  456. +               L2ItemInstance jewely = activeChar.getInventory().getPaperdollItem(part);
  457. +               if(jewely != null && jewely.getEnchantLevel()<weakestEnchantLevel)
  458. +               {
  459. +                   weakestEnchantLevel = jewely.getEnchantLevel();
  460. +                   weakestJewely = jewely;
  461. +               }
  462. +           }
  463. +           if(weakestJewely != null)
  464. +           {
  465. +               if(activeChar.getInventory().destroyItemByItemId("Donate", Config.DONATE_ITEM_ID, Config.DONATE_ENCHANT_JEWELY, activeChar, true) != null)
  466. +               {
  467. +                   weakestJewely.setEnchantLevel(weakestJewely.getEnchantLevel()+1);
  468. +                   InventoryUpdate iu = new InventoryUpdate();
  469. +                   iu.addModifiedItem(weakestJewely);
  470. +                   activeChar.sendPacket(iu);
  471. +                   activeChar.sendMessage("Your jewely has been enchanted for "+Config.DONATE_ENCHANT_JEWELY+" "+donateItemName+"!");
  472. +               }
  473. +               else
  474. +                   activeChar.sendMessage("You need "+Config.DONATE_ENCHANT_JEWELY+" "+donateItemName+" to enchant your jewely!");
  475. +           }
  476. +       }
  477. +       setToShowPage(activeChar);
  478. +   }
  479. +  
  480. +   private static void showPage(L2PcInstance activeChar, String[][] buttons)
  481. +   {
  482. +       String text = "<html><head><title>Donate Page</title></head><body>";
  483. +       text += "";
  484. +       text += "<center>";
  485. +       text += "<table width=230>";
  486. +       int buttonIndex = 0;
  487. +       for(int i = 0;i<Math.ceil(buttons.length/(double)2);i++)
  488. +       {
  489. +           text += "<tr>";
  490. +           for(int x = 0;x<2;x++)
  491. +           {
  492. +               if(buttonIndex < buttons.length)
  493. +                   text += "<td align=center><img src=\""+buttons[buttonIndex][2]+"\" width=32 height=32></td>";
  494. +               else
  495. +                   text += "<td></td>";
  496. +               buttonIndex++;
  497. +           }
  498. +           buttonIndex -= 2;
  499. +           text += "</tr>";
  500. +           text += "<tr><td></td></tr>";
  501. +           text += "<tr>";
  502. +          
  503. +           for(int x = 0;x<2;x++)
  504. +           {
  505. +               if(buttonIndex < buttons.length)
  506. +                   text += "<td align=center><button value=\""+buttons[buttonIndex][0]+"\" action=\"bypass -h _donate "+buttons[buttonIndex][1]+"\" width=130 height=26 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>";
  507. +               else
  508. +                   text += "<td></td>";
  509. +               buttonIndex++;
  510. +           }
  511. +           text += "</tr>";
  512. +           text += "<tr><td></td></tr>";
  513. +       }
  514. +      
  515. +       text += "<tr><td></td><td align=center><button value=\"Next Page\" action=\"bypass -h _donate cPage\" width=85 height=26 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td></td></tr>";
  516. +       text += "</body></html>";
  517. +      
  518. +       NpcHtmlMessage msg = new NpcHtmlMessage(activeChar.getObjectId());
  519. +       msg.setHtml(text);
  520. +       activeChar.sendPacket(msg);
  521. +   }
  522. +  
  523. +   public static void setToShowPage(L2PcInstance activeChar)
  524. +   {
  525. +       String[][] buttons;
  526. +       if(activeChar.isInsideZone(L2Character.ZONE_PEACE))
  527. +           buttons = townButtons;
  528. +       else
  529. +           buttons = combatButtons;
  530. +      
  531. +       showPage(activeChar, buttons);
  532. +   }
  533. +  
  534. +   @Override
  535. +   public String[] getVoicedCommandList()
  536. +   {
  537. +       return VOICED_COMMANDS;
  538. +   }
  539. +}
  540. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement