Advertisement
Guest User

TheEnd

a guest
Sep 11th, 2009
3,691
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 26.72 KB | None | 0 0
  1. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
  2. ===================================================================
  3. --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (revision 3427)
  4. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (working copy)
  5.  -2724,7 +2730,7 @@
  6.      * Give all available skills to the player.<br><br>
  7.      *
  8.      */
  9. -   private void giveAvailableSkills()
  10. +   public void giveAvailableSkills()
  11.     {
  12.         int unLearnable = 0;
  13.         int skillCounter = 0;
  14.  
  15. Index: java/config/l2jmods.properties
  16. ===================================================================
  17. --- java/config/l2jmods.properties  (revision 3427)
  18. +++ java/config/l2jmods.properties  (working copy)
  19.  -248,4 +248,47 @@
  20.  # This option will enable core support for:
  21.  # Mana Drug (item ID 726), using skill ID 9007.
  22.  # Mana Potion (item ID 728), using skill ID 9008.
  23. -EnableManaPotionSupport = False
  24. \ No newline at end of file
  25. +EnableManaPotionSupport = False
  26. +
  27.  
  28. +RebirthAllow = True
  29. +RebirthMin = 80
  30. +
  31. +# Items required per rebirth level #
  32. +RebirthItem1Needed = 57
  33. +RebirthItem1Amount = 1000
  34. +RebirthItem2Needed = 57
  35. +RebirthItem2Amount = 2000
  36. +RebirthItem3Needed = 57
  37. +RebirthItem3Amount = 3000
  38. +
  39. +# Bonus skills and levels for Mages or Fighters #
  40. +REBIRTH_MAGE_SKILL1_ID = 1062
  41. +REBIRTH_MAGE_SKILL1_LEVEL = 2
  42. +REBIRTH_MAGE_SKILL2_ID = 1085
  43. +REBIRTH_MAGE_SKILL2_LEVEL = 3
  44. +REBIRTH_MAGE_SKILL3_ID = 1059
  45. +REBIRTH_MAGE_SKILL3_LEVEL = 3
  46. +REBIRTH_FIGHTER_SKILL1_ID = 1045
  47. +REBIRTH_FIGHTER_SKILL1_LEVEL = 6
  48. +REBIRTH_FIGHTER_SKILL2_ID = 1048
  49. +REBIRTH_FIGHTER_SKILL2_LEVEL = 6
  50. +REBIRTH_FIGHTER_SKILL3_ID = 1086
  51. +REBIRTH_FIGHTER_SKILL3_LEVEL = 2
  52. +
  53. Index: java/net/sf/l2j/gameserver/handler/WorldHandler.java
  54. ===================================================================
  55. --- java/net/sf/l2j/gameserver/handler/WorldHandler.java    (revision 0)
  56. +++ java/net/sf/l2j/gameserver/handler/WorldHandler.java    (revision 0)
  57.  -0,0 +1,38 @@
  58. +package net.sf.l2j.gameserver.handler;
  59. +
  60. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  61. +
  62. +import net.sf.l2j.gameserver.model.entity.RebirthManager;
  63. +
  64. +/**
  65. + *This will simply manage any custom 'Enter World callers' needed.<br>
  66. + *Rather then having to add them to the core's. (yuck!)
  67. + *
  68. + * @author  JStar
  69. + */
  70. +public class WorldHandler{
  71. +  
  72. +   private static WorldHandler _instance = null;
  73. +  
  74. +   private WorldHandler(){
  75. +       //Do Nothing ^_-
  76. +   }
  77. +  
  78. +   /** Receives the non-static instance of the RebirthManager.*/
  79. +   public static WorldHandler getInstance(){
  80. +       if(_instance == null){
  81. +           _instance = new WorldHandler();
  82. +       }
  83. +       return _instance;
  84. +   }
  85. +  
  86. +   /** Requests entry into the world - manages appropriately. */
  87. +   public void enterWorld(L2PcInstance player){
  88. +       RebirthManager.getInstance().grantRebirthSkills(player);
  89. +   }
  90. +  
  91. +   /** Requests removal from the world - manages appropriately. */
  92. +   public void exitWorld(L2PcInstance player){
  93. +   }
  94. +  
  95. +}
  96. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java
  97. ===================================================================
  98. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java (revision 3427)
  99. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java (working copy)
  100.  -18,6 +18,7 @@
  101.  import java.util.logging.Level;
  102.  import java.util.logging.Logger;
  103.  
  104. +import net.sf.l2j.gameserver.handler.BypassHandler;
  105.  import net.sf.l2j.Config;
  106.  import net.sf.l2j.gameserver.ai.CtrlIntention;
  107.  import net.sf.l2j.gameserver.communitybbs.CommunityBoard;
  108.  -200,6 +218,10 @@
  109.                 else
  110.                     player.processQuestEvent(p.substring(0, idx), p.substring(idx).trim());
  111.             }
  112. +                       else if(_command.startsWith("custom_")){
  113. +                           L2PcInstance player = getClient().getActiveChar();
  114. +                           BypassHandler.getInstance().handleBypass(player, _command);
  115. +                       }
  116.             else if (_command.startsWith("OlympiadArenaChange"))
  117.             {
  118.                     Olympiad.bypassChangeArena(_command, activeChar);
  119. Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  120. ===================================================================
  121. --- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java    (revision 3427)
  122. +++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java    (working copy)
  123.  -81,6 +83,7 @@
  124.  import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  125.  import net.sf.l2j.gameserver.network.serverpackets.UserInfo;
  126.  import net.sf.l2j.gameserver.util.StringUtil;
  127. +import net.sf.l2j.gameserver.handler.WorldHandler;
  128.  
  129.  /**
  130.   * Enter World Packet Handler<p>
  131.  -252,6 +257,9 @@
  132.             showClanNotice = activeChar.getClan().isNoticeEnabled();
  133.         }
  134.  
  135. +      
  136. +      
  137. +           GmListTable.getInstance().addGm(activeChar, true);
  138.         // Updating Seal of Strife Buff/Debuff
  139.         if (SevenSigns.getInstance().isSealValidationPeriod() && SevenSigns.getInstance().getSealOwner(SevenSigns.SEAL_STRIFE) != SevenSigns.CABAL_NULL)
  140.         {
  141.  -412,6 +425,7 @@
  142.         if (activeChar.getClanJoinExpiryTime() > System.currentTimeMillis())
  143.             activeChar.sendPacket(new SystemMessage(SystemMessageId.CLAN_MEMBERSHIP_TERMINATED));
  144.  
  145. +
  146.         // remove combat flag before teleporting
  147.         if (activeChar.getInventory().getItemByItemId(9819) != null)
  148.         {
  149.  -438,6 +452,9 @@
  150.         RegionBBSManager.getInstance().changeCommunityBoard();
  151.  
  152.         TvTEvent.onLogin(activeChar);
  153. +       WorldHandler.getInstance().enterWorld(activeChar);
  154.     }
  155.  
  156.     /**
  157. Index: java/net/sf/l2j/gameserver/handler/BypassHandler.java
  158. ===================================================================
  159. --- java/net/sf/l2j/gameserver/handler/BypassHandler.java   (revision 0)
  160. +++ java/net/sf/l2j/gameserver/handler/BypassHandler.java   (revision 0)
  161.  -0,0 +1,29 @@
  162. +package net.sf.l2j.gameserver.handler;
  163. +
  164. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  165. +
  166. +import net.sf.l2j.gameserver.model.entity.RebirthManager;
  167. +
  168. +
  169. +public class BypassHandler{
  170. +   private static BypassHandler _instance = null;
  171. +  
  172. +   private BypassHandler(){
  173. +       //Do Nothing ^_-
  174. +   }
  175. +  
  176. +   /** Receives the non-static instance of the RebirthManager.*/
  177. +   public static BypassHandler getInstance(){
  178. +       if(_instance == null){
  179. +           _instance = new BypassHandler();
  180. +       }
  181. +       return _instance;
  182. +   }
  183. +  
  184. +   /** Handles player's Bypass request to the Custom Content. */
  185. +   public void handleBypass(L2PcInstance player, String command){
  186. +       if(command.startsWith("custom_rebirth")){//Rebirth Manager and Engine Caller
  187. +           RebirthManager.getInstance().handleCommand(player, command);
  188. +       }
  189. +   }
  190. +}
  191. Index: java/net/sf/l2j/gameserver/model/entity/RebirthManager.java
  192. ===================================================================
  193. --- java/net/sf/l2j/gameserver/model/entity/RebirthManager.java (revision 0)
  194. +++ java/net/sf/l2j/gameserver/model/entity/RebirthManager.java (revision 0)
  195.  -0,0 +1,361 @@
  196. +/*
  197. + * This program is free software: you can redistribute it and/or modify it under
  198. + * the terms of the GNU General Public License as published by the Free Software
  199. + * Foundation, either version 3 of the License, or (at your option) any later
  200. + * version.
  201. + *
  202. + * This program is distributed in the hope that it will be useful, but WITHOUT
  203. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  204. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  205. + * details.
  206. + *
  207. + * You should have received a copy of the GNU General Public License along with
  208. + * this program. If not, see <http://www.gnu.org/licenses/>.
  209. + */
  210. +package net.sf.l2j.gameserver.model.entity;
  211. +
  212. +import java.sql.PreparedStatement;
  213. +import java.sql.ResultSet;
  214. +import java.util.HashMap;
  215. +import javolution.text.TextBuilder;
  216. +
  217. +import net.sf.l2j.Config;
  218. +import net.sf.l2j.L2DatabaseFactory;
  219. +import net.sf.l2j.gameserver.datatables.SkillTable;
  220. +import net.sf.l2j.gameserver.datatables.ItemTable;
  221. +import net.sf.l2j.gameserver.cache.HtmCache;
  222. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  223. +import net.sf.l2j.gameserver.model.base.Experience;
  224. +import net.sf.l2j.gameserver.model.L2ItemInstance;
  225. +import net.sf.l2j.gameserver.model.L2Skill;
  226. +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  227. +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
  228. +import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
  229. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  230. +import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
  231. +
  232. +
  233. + /**
  234. + *
  235. + * @author  TheEnd
  236. + *
  237. + *
  238. + **/
  239. +public class RebirthManager
  240. +{
  241. +   private static RebirthManager _instance = null;
  242. +  
  243. +   /** Basically, this will act as a cache so it doesnt have to read DB information on relog. */
  244. +   private HashMap<Integer,Integer> _playersRebirthInfo = new HashMap<Integer,Integer>();
  245. +  
  246. +   /** Creates a new NON-STATIC instance */
  247. +   private RebirthManager(){
  248. +       //Do Nothing ^_-
  249. +   }
  250. +  
  251. +   /** Receives the non-static instance of the RebirthManager.*/
  252. +   public static RebirthManager getInstance(){
  253. +       if(_instance == null){
  254. +           _instance = new RebirthManager();
  255. +       }
  256. +       return _instance;
  257. +   }
  258. +  
  259. +   /** This is what it called from the Bypass Handler. (I think that's all thats needed here).*/
  260. +   public void handleCommand(L2PcInstance player,String command){
  261. +       if(command.startsWith("custom_rebirth_requestrebirth")){
  262. +           displayRebirthWindow(player);
  263. +       }
  264. +       else if(command.startsWith("custom_rebirth_confirmrequest")){
  265. +           requestRebirth(player);
  266. +       }
  267. +   }
  268. +  
  269. +   /** Display's an HTML window with the Rebirth Options */
  270. +   public void displayRebirthWindow(L2PcInstance player){
  271. +       try{
  272. +           int currBirth = getRebirthLevel(player); //Returns the player's current birth level
  273. +           if(currBirth >= 3){//Don't send html if player is already at max rebirth count.
  274. +               player.sendMessage("You are currently at your maximum rebirth count!");
  275. +               return;
  276. +           }
  277. +           boolean isMage = player.getBaseTemplate().classId.isMage(); //Returns true if BASE CLASS is a mage.
  278. +           L2Skill skill = getRebirthSkill((currBirth + 1), isMage);//Returns the skill based on next Birth and if isMage.
  279. +          
  280. +           String icon = ""+skill.getId();//Returns the skill's id.
  281. +           if(icon.length() < 4){
  282. +               icon = "0"+icon;
  283. +           }
  284. +          
  285. +           String playerName = "<font color=FF9900>"+player.getName()+"</font>";//return the player's name.
  286. +          
  287. +           TextBuilder text = new TextBuilder();
  288. +           text.append("<html>");
  289. +           text.append("<body>");
  290. +           text.append("<center>");
  291. +           text.append("<title>- Rebirth Request Menu -</title>");
  292. +           text.append("<img src=\"L2UI_CH3.herotower_deco\" width=256 height=32>");
  293. +           text.append("<br>");
  294. +           text.append("<table border=1 cellspacing=1 cellpadding=1 height=37><tr><td valign=top>");
  295. +           text.append("<img src=\"icon.skill3123\" width=32 height=32>");//Cool rebirth icon 'logo' :P
  296. +           text.append("</td></tr></table>");
  297. +           text.append("<br>");
  298. +           text.append("<table width=240 bgcolor=555555 border=1 cellpadding=1 cellspacing=0><tr>");
  299. +           text.append("<td height=40 width=35><img src=\"icon.skill"+icon+"\" width=32 height=32 align=left></td>");
  300. +           text.append("<td height=40 width=140><center><font color=\"FFFFCC\">Bonus Skill Recieved</font><br1><font color=\"FF9900\">"+skill.getName()+"</font></td>");
  301. +           text.append("<td height=40 width=100><center><font color=\"66CC66\">Skill Lvl</font><br1><font color=\"FFFF99\">"+skill.getLevel()+"</font></center></td>");
  302. +           text.append("</tr></table>");
  303. +           text.append("<br>");
  304. +           text.append("<img src=\"L2UI.SquareWhite\" width=\"280\" height=\"1\"><br1>");
  305. +           text.append("<table bgcolor=555555 width=270 height=80><tr><td valign=center align=center>- [ <font color=\"66CC66\">Rebirth Information</font> ] -<br1>");
  306. +           text.append("<table bgcolor=555555 width=250 height=150><tr><td valign=top align=center><center>");
  307. +           text.append("So, "+playerName+", you wish to be <font color=Level>Reborn</font>? ");
  308. +           text.append("Being <font color=Level>Reborn</font> has it's advantages, and it's disadvantages you know. ");
  309. +           text.append("When you are <font color=Level>Reborn</font> you are granted a new bonus skill (listed above), ");
  310. +           text.append("but your character is reset to level 1 and returned to his starting class. So ");
  311. +           text.append("<font color=LEVEL>choose wisely</font> "+playerName+".<br1>");
  312. +           text.append("</center></td></tr></table>");
  313. +           text.append("</td></tr></table>");
  314. +           text.append("<img src=\"L2UI.SquareWhite\" width=\"280\" height=\"1\"><br>");
  315. +           text.append("<center><button value=\" Request Rebirth \" action=\"bypass -h custom_rebirth_confirmrequest\" width=250 height=36 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  316. +           text.append("</center>");
  317. +           text.append("</body>");
  318. +           text.append("</html>");
  319. +          
  320. +           NpcHtmlMessage html = new NpcHtmlMessage(1);
  321. +           html.setHtml(text.toString());
  322. +           player.sendPacket(html);
  323. +       }
  324. +       catch(Exception e){
  325. +           e.printStackTrace();
  326. +       }
  327. +   }
  328. +  
  329. +   /** Checks to see if the player is eligible for a Rebirth, if so it grants it and stores information */
  330. +   public void requestRebirth(L2PcInstance player){
  331. +       if(!Config.REBIRTH_ALLOW_REBIRTH){ //See if the Rebirth Engine is currently allowed.
  332. +           player.sendMessage("The 'Rebirth Engine' is disabled!");
  333. +           return;
  334. +       }
  335. +      
  336. +       else if(player.getLevel() < Config.REBIRTH_MIN_LEVEL){ //Check the player's level.
  337. +           player.sendMessage("You do not meet the level requirement for a Rebirth!");
  338. +           return;
  339. +       }
  340. +      
  341. +       else if(player.isSubClassActive()){
  342. +           player.sendMessage("Please switch to your Main Class before attempting a Rebirth.");
  343. +           return;
  344. +       }
  345. +           else if(player.isAlikeDead()){
  346. +               return;
  347. +           }
  348. +           else if(player.isAttackingNow()){
  349. +               return;
  350. +           }
  351. +           else if(player.isCastingNow()){
  352. +               return;
  353. +           }
  354. +           else if(player.isInDuel()){
  355. +               return;
  356. +           }
  357. +      
  358. +
  359. +       int currBirth = getRebirthLevel(player);
  360. +       int itemNeeded = 0;
  361. +       int itemAmount = 0;
  362. +      
  363. +       if(currBirth >= 3){
  364. +           player.sendMessage("You are currently at your maximum rebirth count!");
  365. +           return;
  366. +       }
  367. +
  368. +       switch(currBirth){//Get the requirements
  369. +           case 0: itemNeeded = Config.REBIRTH_ITEM1_NEEDED; itemAmount = Config.REBIRTH_ITEM1_AMOUNT; break;
  370. +           case 1: itemNeeded = Config.REBIRTH_ITEM2_NEEDED; itemAmount = Config.REBIRTH_ITEM2_AMOUNT; break;
  371. +           case 2: itemNeeded = Config.REBIRTH_ITEM3_NEEDED; itemAmount = Config.REBIRTH_ITEM3_AMOUNT; break;
  372. +       }
  373. +      
  374. +       if(itemNeeded != 0){//Their is an item required
  375. +           if(!playerIsEligible(player, itemNeeded, itemAmount)){//Checks to see if player has required items, and takes them if so.
  376. +               return;
  377. +           }
  378. +       }
  379. +      
  380. +       boolean firstBirth = currBirth == 0;//Check and see if its the player's first Rebirth calling.
  381. +       grantRebirth(player,(currBirth + 1), firstBirth); //Player meets requirements and starts Rebirth Process.
  382. +   }
  383. +  
  384. +   /** Physically rewards player and resets status to nothing. */
  385. +   public void grantRebirth(L2PcInstance player, int newBirthCount, boolean firstBirth){
  386. +       try{
  387. +
  388. +           player.removeExpAndSp(player.getExp() - Experience.LEVEL[1], 0);//Set player to level 1.
  389. +           player.setClassId(player.getBaseClass());//Resets character to first class.
  390. +           for (L2Skill skill : player.getAllSkills()){//Remove the player's current skills.
  391. +               player.removeSkill(skill);
  392. +           }
  393. +           player.giveAvailableSkills();//Give players their eligible skills.
  394. +           player.store(); //Updates the player's information in the Character Database.
  395. +          
  396. +           if(firstBirth) storePlayerBirth(player);
  397. +           else updatePlayerBirth(player,newBirthCount);
  398. +
  399. +           grantRebirthSkills(player);//Give the player his new Skills.
  400. +           displayCongrats(player);//Displays a congratulation message to the player.
  401. +       }
  402. +       catch(Exception e){
  403. +           e.printStackTrace();
  404. +       }
  405. +   }
  406. +  
  407. +   /** Special effects when the player levels. */
  408. +   public void displayCongrats(L2PcInstance player){
  409. +       player.broadcastPacket(new SocialAction(player.getObjectId(), 3));//Victory Social Action.
  410. +       MagicSkillUse  MSU = new MagicSkillUse(player, player, 2024, 1, 1, 0);//Fireworks Display
  411. +       player.broadcastPacket(MSU);
  412. +       ExShowScreenMessage screen = new ExShowScreenMessage("Congratulations "+player.getName()+"! You have been Reborn!", 15000);
  413. +       player.sendPacket(screen);
  414. +   }
  415. +  
  416. +   /** Check and verify the player DOES have the item required for a request. Also, remove the item if he has.*/
  417. +   public boolean playerIsEligible(L2PcInstance player, int itemId, int itemAmount){
  418. +       String itemName = ItemTable.getInstance().getTemplate(itemId).getName();
  419. +       L2ItemInstance itemNeeded = player.getInventory().getItemByItemId(itemId);
  420. +      
  421. +       if(itemNeeded == null || itemNeeded.getCount() < itemAmount){
  422. +           player.sendMessage("You need atleast "+itemAmount+"  [ "+itemName+" ] to request a Rebirth!");
  423. +           return false;
  424. +       }
  425. +      
  426. +       //Player has the required items, so we're going to take them!
  427. +       player.getInventory().destroyItem("Rebirth Engine", itemNeeded, itemAmount, player, null);
  428. +       player.sendMessage("Removed "+itemAmount+" "+itemName+" from your inventory!");
  429. +       return true;
  430. +   }
  431. +  
  432. +   /** Gives the available Bonus Skills to the player. */
  433. +   public void grantRebirthSkills(L2PcInstance player){
  434. +       int rebirthLevel = getRebirthLevel(player); //returns the current Rebirth Level
  435. +       boolean isMage = player.getBaseTemplate().classId.isMage(); //Returns true if BASE CLASS is a mage.
  436. +      
  437. +       //Simply return since no bonus skills are granted.
  438. +       if(rebirthLevel == 0) return;
  439. +      
  440. +       //Load the bonus skills unto the player.
  441. +       CreatureSay rebirthText = null;
  442. +       for(int i = 0; i < rebirthLevel; i++){
  443. +           L2Skill bonusSkill = getRebirthSkill((i + 1), isMage);
  444. +           player.addSkill(bonusSkill, false);
  445. +          
  446. +           //If you'd rather make it simple, simply comment this out and replace with a simple player.sendmessage();
  447. +           rebirthText = new CreatureSay(0, 18, "Rebirth Manager ", " Granted you [ "+bonusSkill.getName()+" ] level [ "+bonusSkill.getLevel()+" ]!");
  448. +           player.sendPacket(rebirthText);
  449. +       }
  450. +   }
  451. +  
  452. +   /** Return the player's current Rebirth Level */
  453. +   public int getRebirthLevel(L2PcInstance player){
  454. +       int playerId = player.getObjectId();
  455. +       if(_playersRebirthInfo.get(playerId) == null) {
  456. +           loadRebirthInfo(player);
  457. +       }
  458. +       return _playersRebirthInfo.get(playerId);
  459. +   }
  460. +  
  461. +   /** Return the L2Skill the player is going to be rewarded. */
  462. +   public L2Skill getRebirthSkill(int rebirthLevel,boolean mage){
  463. +       L2Skill skill = null;
  464. +       if(mage){ //Player is a Mage.
  465. +           switch(rebirthLevel){
  466. +               case 1:skill = SkillTable.getInstance().getInfo(Config.REBIRTH_MAGE_SKILL1_ID, Config.REBIRTH_MAGE_SKILL1_LEVEL) ; break;
  467. +               case 2:skill = SkillTable.getInstance().getInfo(Config.REBIRTH_MAGE_SKILL2_ID, Config.REBIRTH_MAGE_SKILL2_LEVEL) ; break;
  468. +               case 3:skill = SkillTable.getInstance().getInfo(Config.REBIRTH_MAGE_SKILL3_ID, Config.REBIRTH_MAGE_SKILL3_LEVEL) ; break;
  469. +           }
  470. +       }
  471. +       else{ //Player is a Fighter.
  472. +           switch(rebirthLevel){
  473. +               case 1:skill = SkillTable.getInstance().getInfo(Config.REBIRTH_FIGHTER_SKILL1_ID, Config.REBIRTH_FIGHTER_SKILL1_LEVEL) ; break;
  474. +               case 2:skill = SkillTable.getInstance().getInfo(Config.REBIRTH_FIGHTER_SKILL2_ID, Config.REBIRTH_FIGHTER_SKILL2_LEVEL) ; break;
  475. +               case 3:skill = SkillTable.getInstance().getInfo(Config.REBIRTH_FIGHTER_SKILL3_ID, Config.REBIRTH_FIGHTER_SKILL3_LEVEL) ; break;
  476. +           }
  477. +       }
  478. +       return skill;
  479. +   }
  480. +  
  481. +   /** Database caller to retrieve player's current Rebirth Level */
  482. +   public void loadRebirthInfo(L2PcInstance player){
  483. +       int playerId = player.getObjectId();
  484. +       int rebirthCount = 0;
  485. +      
  486. +       java.sql.Connection con = null;
  487. +        try {
  488. +           ResultSet rset;
  489. +            con = L2DatabaseFactory.getInstance().getConnection();
  490. +            PreparedStatement statement = con.prepareStatement
  491. +            ("SELECT * FROM `rebirth_manager` WHERE playerId = ?");
  492. +            statement.setInt(1, playerId);
  493. +            rset = statement.executeQuery();
  494. +            
  495. +            while (rset.next()){
  496. +               rebirthCount = rset.getInt("rebirthCount");
  497. +            }
  498. +
  499. +            rset.close();
  500. +            statement.close();
  501. +              
  502. +        } catch(Exception e) {
  503. +            e.printStackTrace();
  504. +        }
  505. +        finally {
  506. +            try{con.close();}
  507. +            catch (Exception e){}
  508. +        }
  509. +        _playersRebirthInfo.put(playerId, rebirthCount);
  510. +   }
  511. +  
  512. +   /** Stores the player's information in the DB. */
  513. +   public void storePlayerBirth(L2PcInstance player){
  514. +       java.sql.Connection con = null;
  515. +        try {
  516. +            con = L2DatabaseFactory.getInstance().getConnection();
  517. +            PreparedStatement statement = con.prepareStatement
  518. +            ("INSERT INTO `rebirth_manager` (playerId,rebirthCount) VALUES (?,1)");
  519. +            statement.setInt(1, player.getObjectId());
  520. +            statement.execute();
  521. +            
  522. +            _playersRebirthInfo.put(player.getObjectId(), 1);
  523. +              
  524. +        } catch(Exception e) {
  525. +            e.printStackTrace();
  526. +        }
  527. +        finally {
  528. +            try{con.close();}
  529. +            catch (Exception e){}
  530. +        }
  531. +   }
  532. +  
  533. +   /** Updates the player's information in the DB. */
  534. +   public void updatePlayerBirth(L2PcInstance player,int newRebirthCount){
  535. +       java.sql.Connection con = null;
  536. +        try {
  537. +           int playerId = player.getObjectId();
  538. +          
  539. +            con = L2DatabaseFactory.getInstance().getConnection();
  540. +            PreparedStatement statement = con.prepareStatement
  541. +            ("UPDATE `rebirth_manager` SET rebirthCount = ? WHERE playerId = ?");
  542. +            statement.setInt(1, newRebirthCount);
  543. +            statement.setInt(2, playerId);
  544. +            statement.execute();
  545. +            
  546. +            _playersRebirthInfo.put(playerId, newRebirthCount);
  547. +              
  548. +        } catch(Exception e) {
  549. +            e.printStackTrace();
  550. +        }
  551. +        finally {
  552. +            try{con.close();}
  553. +            catch (Exception e){}
  554. +        }
  555. +   }
  556. +}
  557. Index: java/net/sf/l2j/Config.java
  558. ===================================================================
  559. --- java/net/sf/l2j/Config.java (revision 3427)
  560. +++ java/net/sf/l2j/Config.java (working copy)
  561.  -594,7 +594,38 @@
  562.     public static boolean OFFLINE_SET_NAME_COLOR;
  563.     public static int OFFLINE_NAME_COLOR;
  564.     public static boolean L2JMOD_ENABLE_MANA_POTIONS_SUPPORT;
  565. -
  566. +   public static boolean REBIRTH_ALLOW_REBIRTH;
  567. +   public static int REBIRTH_MIN_LEVEL;
  568. +      
  569. +           /* Items required per rebirth level */
  570. +   public static int REBIRTH_ITEM1_NEEDED;
  571. +   public static int REBIRTH_ITEM1_AMOUNT;
  572. +   public static int REBIRTH_ITEM2_NEEDED;
  573. +   public static int REBIRTH_ITEM2_AMOUNT;
  574. +   public static int REBIRTH_ITEM3_NEEDED;
  575. +   public static int REBIRTH_ITEM3_AMOUNT;
  576. +          
  577. +           /* Bonus skills and levels for Mages or Fighters */
  578. +   public static int REBIRTH_MAGE_SKILL1_ID;
  579. +   public static int REBIRTH_MAGE_SKILL1_LEVEL;
  580. +   public static int REBIRTH_MAGE_SKILL2_ID;
  581. +   public static int REBIRTH_MAGE_SKILL2_LEVEL;
  582. +   public static int REBIRTH_MAGE_SKILL3_ID;
  583. +   public static int REBIRTH_MAGE_SKILL3_LEVEL;
  584. +   public static int REBIRTH_FIGHTER_SKILL1_ID;
  585. +   public static int REBIRTH_FIGHTER_SKILL1_LEVEL;
  586. +   public static int REBIRTH_FIGHTER_SKILL2_ID;
  587. +   public static int REBIRTH_FIGHTER_SKILL2_LEVEL;
  588. +   public static int REBIRTH_FIGHTER_SKILL3_ID;
  589. +   public static int REBIRTH_FIGHTER_SKILL3_LEVEL;
  590.  
  591.     //--------------------------------------------------
  592.     // NPC Settings
  593.  -1953,13 +1993,36 @@
  594.                     BANKING_SYSTEM_ENABLED = Boolean.parseBoolean(L2JModSettings.getProperty("BankingEnabled", "false"));
  595.                     BANKING_SYSTEM_GOLDBARS = Integer.parseInt(L2JModSettings.getProperty("BankingGoldbarCount", "1"));
  596.                     BANKING_SYSTEM_ADENA = Integer.parseInt(L2JModSettings.getProperty("BankingAdenaCount", "500000000"));
  597.                     OFFLINE_TRADE_ENABLE = Boolean.parseBoolean(L2JModSettings.getProperty("OfflineTradeEnable", "false"));
  598.                     OFFLINE_CRAFT_ENABLE = Boolean.parseBoolean(L2JModSettings.getProperty("OfflineCraftEnable", "false"));
  599.                     OFFLINE_SET_NAME_COLOR = Boolean.parseBoolean(L2JModSettings.getProperty("OfflineSetNameColor", "false"));
  600. -                   OFFLINE_NAME_COLOR = Integer.decode("0x" + L2JModSettings.getProperty("OfflineNameColor", "808080"));
  601. +                   OFFLINE_NAME_COLOR = Integer.decode("0x" + L2JModSettings.getProperty("OfflineNameColor", "808080"));              
  602.  
  603.                     L2JMOD_ENABLE_MANA_POTIONS_SUPPORT = Boolean.parseBoolean(L2JModSettings.getProperty("EnableManaPotionSupport", "false"));
  604. +                               REBIRTH_ALLOW_REBIRTH          = Boolean.parseBoolean(L2JModSettings.getProperty("RebirthAllow", "False"));
  605. +                               REBIRTH_MIN_LEVEL              = Integer.parseInt(L2JModSettings.getProperty("RebirthMin","80"));
  606. +                              
  607. +                               REBIRTH_ITEM1_NEEDED           = Integer.parseInt(L2JModSettings.getProperty("RebirthItem1Needed","0"));
  608. +                               REBIRTH_ITEM1_AMOUNT           = Integer.parseInt(L2JModSettings.getProperty("RebirthItem1Amount","0"));
  609. +                               REBIRTH_ITEM2_NEEDED           = Integer.parseInt(L2JModSettings.getProperty("RebirthItem2Needed","0"));
  610. +                               REBIRTH_ITEM2_AMOUNT           = Integer.parseInt(L2JModSettings.getProperty("RebirthItem2Amount","0"));
  611. +                               REBIRTH_ITEM3_NEEDED           = Integer.parseInt(L2JModSettings.getProperty("RebirthItem3Needed","0"));
  612. +                               REBIRTH_ITEM3_AMOUNT           = Integer.parseInt(L2JModSettings.getProperty("RebirthItem3Amount","0"));
  613. +                              
  614. +                               REBIRTH_MAGE_SKILL1_ID         = Integer.parseInt(L2JModSettings.getProperty("REBIRTH_MAGE_SKILL1_ID","0"));
  615. +                               REBIRTH_MAGE_SKILL1_LEVEL      = Integer.parseInt(L2JModSettings.getProperty("REBIRTH_MAGE_SKILL1_LEVEL","0"));
  616. +                               REBIRTH_MAGE_SKILL2_ID         = Integer.parseInt(L2JModSettings.getProperty("REBIRTH_MAGE_SKILL2_ID","0"));
  617. +                               REBIRTH_MAGE_SKILL2_LEVEL      = Integer.parseInt(L2JModSettings.getProperty("REBIRTH_MAGE_SKILL2_LEVEL","0"));
  618. +                               REBIRTH_MAGE_SKILL3_ID         = Integer.parseInt(L2JModSettings.getProperty("REBIRTH_MAGE_SKILL3_ID","0"));
  619. +                               REBIRTH_MAGE_SKILL3_LEVEL      = Integer.parseInt(L2JModSettings.getProperty("REBIRTH_MAGE_SKILL3_LEVEL","0"));
  620. +                               REBIRTH_FIGHTER_SKILL1_ID      = Integer.parseInt(L2JModSettings.getProperty("REBIRTH_FIGHTER_SKILL1_ID","0"));
  621. +                               REBIRTH_FIGHTER_SKILL1_LEVEL   = Integer.parseInt(L2JModSettings.getProperty("REBIRTH_FIGHTER_SKILL1_LEVEL","0"));
  622. +                               REBIRTH_FIGHTER_SKILL2_ID      = Integer.parseInt(L2JModSettings.getProperty("REBIRTH_FIGHTER_SKILL2_ID","0"));
  623. +                               REBIRTH_FIGHTER_SKILL2_LEVEL   = Integer.parseInt(L2JModSettings.getProperty("REBIRTH_FIGHTER_SKILL2_LEVEL","0"));
  624. +                               REBIRTH_FIGHTER_SKILL3_ID      = Integer.parseInt(L2JModSettings.getProperty("REBIRTH_FIGHTER_SKILL3_ID","0"));
  625. +                               REBIRTH_FIGHTER_SKILL3_LEVEL   = Integer.parseInt(L2JModSettings.getProperty("REBIRTH_FIGHTER_SKILL3_LEVEL","0"));
  626.                 }
  627.                 catch (Exception e)
  628.                 {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement