Advertisement
Guest User

stucksub

a guest
Mar 22nd, 2017
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.57 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2jNetwork_gameserver
  3. Index: config/server.properties
  4. ===================================================================
  5. --- config/server.properties    (revision 5)
  6. +++ config/server.properties    (working copy)
  7. @@ -302,4 +302,7 @@
  8.  ShowServerNews = False
  9.  
  10.  # Disable tutorial on new player game entrance. Default: False.
  11. -DisableTutorial = False
  12. \ No newline at end of file
  13. +DisableTutorial = False
  14. +
  15. +# If true, players will keep all subclass skills.
  16. +StuckSubs = True
  17. \ No newline at end of file
  18. Index: java/net/sf/l2j/Config.java
  19. ===================================================================
  20. --- java/net/sf/l2j/Config.java (revision 5)
  21. +++ java/net/sf/l2j/Config.java (working copy)
  22. @@ -641,6 +641,7 @@
  23.     public static boolean SERVER_NEWS;
  24.     public static int ZONE_TOWN;
  25.     public static boolean DISABLE_TUTORIAL;
  26. +   public static boolean STUCK_SUBS;
  27.    
  28.     // --------------------------------------------------
  29.     // Those "hidden" settings haven't configs to avoid admins to fuck their server
  30. @@ -1224,6 +1225,7 @@
  31.             ZONE_TOWN = server.getProperty("ZoneTown", 0);
  32.             SERVER_NEWS = server.getProperty("ShowServerNews", false);
  33.             DISABLE_TUTORIAL = server.getProperty("DisableTutorial", false);
  34. +           STUCK_SUBS = server.getProperty("StuckSubs", true);
  35.         }
  36.         else if (Server.serverMode == Server.MODE_LOGINSERVER)
  37.         {
  38. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
  39. ===================================================================
  40. --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (revision 5)
  41. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (working copy)
  42. @@ -303,6 +303,7 @@
  43.     }
  44.    
  45.     private static final String RESTORE_SKILLS_FOR_CHAR = "SELECT skill_id,skill_level FROM character_skills WHERE char_obj_id=? AND class_index=?";
  46. +   private static final String STUCK_SUBS = "SELECT skill_id,skill_level FROM character_skills WHERE char_obj_id=? ORDER BY (skill_level+0)";
  47.     private static final String ADD_NEW_SKILL = "INSERT INTO character_skills (char_obj_id,skill_id,skill_level,class_index) VALUES (?,?,?,?)";
  48.     private static final String UPDATE_CHARACTER_SKILL_LEVEL = "UPDATE character_skills SET skill_level=? WHERE skill_id=? AND char_obj_id=? AND class_index=?";
  49.     private static final String DELETE_SKILL_FROM_CHAR = "DELETE FROM character_skills WHERE skill_id=? AND char_obj_id=? AND class_index=?";
  50. @@ -4084,7 +4085,7 @@
  51.         for (L2Character character : getKnownList().getKnownType(L2Character.class))
  52.             if (character.getFusionSkill() != null && character.getFusionSkill().getTarget() == this)
  53.                 character.abortCast();
  54. -      
  55. +          
  56.         if (isInParty() && getParty().isInDimensionalRift())
  57.             getParty().getDimensionalRift().getDeadMemberList().add(this);
  58.        
  59. @@ -5740,6 +5741,10 @@
  60.         // Retrieve from the database all skills of this L2PcInstance and add them to _skills.
  61.         restoreSkills();
  62.        
  63. +       // If config true, character can keep all sub skills.
  64. +       if (Config.STUCK_SUBS)
  65. +           restoreSubSkills();
  66. +      
  67.         // Retrieve from the database all macroses of this L2PcInstance and add them to _macroses.
  68.         _macroses.restore();
  69.        
  70. @@ -6222,6 +6227,40 @@
  71.         }
  72.     }
  73.    
  74. +   private void restoreSubSkills()
  75. +   {
  76. +       try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  77. +       {
  78. +           PreparedStatement statement = con.prepareStatement(STUCK_SUBS);
  79. +           statement.setInt(1, getObjectId());
  80. +           ResultSet rset = statement.executeQuery();
  81. +          
  82. +           // Go though the recordset of this SQL query
  83. +           while (rset.next())
  84. +           {
  85. +               int id = rset.getInt("skill_id");
  86. +               int level = rset.getInt("skill_level");
  87. +              
  88. +               if (id > 9000)
  89. +                   continue; // fake skills for base stats
  90. +                  
  91. +               // Create a L2Skill object for each record
  92. +               L2Skill skill = SkillTable.getInstance().getInfo(id, level);
  93. +              
  94. +               // Add the L2Skill object to the L2Character _skills and its Func objects to the calculator set of the L2Character
  95. +               super.addSkill(skill);
  96. +           }
  97. +          
  98. +           rset.close();
  99. +           statement.close();
  100. +       }
  101. +       catch (Exception e)
  102. +       {
  103. +           _log.warning("Could not restore character skills: " + e);
  104. +       }
  105. +      
  106. +   }
  107. +  
  108.     /**
  109.      * Retrieve from the database all skills of this L2PcInstance and add them to _skills.
  110.      */
  111. @@ -6229,6 +6268,9 @@
  112.     {
  113.         try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  114.         {
  115. +           if (Config.STUCK_SUBS)
  116. +               return;
  117. +          
  118.             PreparedStatement statement = con.prepareStatement(RESTORE_SKILLS_FOR_CHAR);
  119.             statement.setInt(1, getObjectId());
  120.             statement.setInt(2, getClassIndex());
  121. @@ -6890,7 +6932,7 @@
  122.        
  123.         switch (sklTargetType)
  124.         {
  125. -       // Target the player if skill type is AURA, PARTY, CLAN or SELF
  126. +           // Target the player if skill type is AURA, PARTY, CLAN or SELF
  127.             case TARGET_AURA:
  128.             case TARGET_FRONT_AURA:
  129.             case TARGET_BEHIND_AURA:
  130. @@ -8150,7 +8192,7 @@
  131.         else
  132.             for (L2Skill s : SkillTable.getNobleSkills())
  133.                 super.removeSkill(s); // Just Remove skills without deleting from Sql
  134. -          
  135. +              
  136.         _noble = val;
  137.        
  138.         sendSkillList();
  139. @@ -8496,7 +8538,7 @@
  140.             for (L2Character character : getKnownList().getKnownType(L2Character.class))
  141.                 if (character.getFusionSkill() != null && character.getFusionSkill().getTarget() == this)
  142.                     character.abortCast();
  143. -          
  144. +              
  145.             store();
  146.             _reuseTimeStamps.clear();
  147.            
  148. @@ -8541,6 +8583,9 @@
  149.                 restoreRecipeBook();
  150.            
  151.             restoreSkills();
  152. +           // If config true, character can keep all sub skills.
  153. +           if (Config.STUCK_SUBS)
  154. +               restoreSubSkills();
  155.             rewardSkills();
  156.             regiveTemporarySkills();
  157.            
  158. @@ -9113,7 +9158,7 @@
  159.             for (L2Character character : getKnownList().getKnownType(L2Character.class))
  160.                 if (character.getFusionSkill() != null && character.getFusionSkill().getTarget() == this)
  161.                     character.abortCast();
  162. -          
  163. +              
  164.             // Stop signets & toggles effects.
  165.             for (L2Effect effect : getAllEffects())
  166.             {
  167. @@ -9170,7 +9215,7 @@
  168.             // If the L2PcInstance is a GM, remove it from the GM List
  169.             if (isGM())
  170.                 GmListTable.getInstance().deleteGm(this);
  171. -          
  172. +              
  173.             // Check if the L2PcInstance is in observer mode to set its position to its position
  174.             // before entering in observer mode
  175.             if (inObserverMode())
  176. @@ -9285,13 +9330,13 @@
  177.             case 7809: // yellow for beginners
  178.             case 8486: // prize-winning for beginners
  179.                 return 0;
  180. -              
  181. +          
  182.             case 8485: // prize-winning luminous
  183.             case 8506: // green luminous
  184.             case 8509: // purple luminous
  185.             case 8512: // yellow luminous
  186.                 return 2;
  187. -              
  188. +          
  189.             default:
  190.                 return 1;
  191.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement