Advertisement
Reanimation06

L2jMobius H5 SubStuck from l2jmobius c6

Sep 29th, 2023
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.14 KB | Gaming | 0 0
  1. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java
  2. index f984695..acaee2a 100644
  3. --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java
  4. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java
  5. @@ -147,6 +147,7 @@
  6.     private static final String CUSTOM_WAREHOUSE_SORTING_CONFIG_FILE = "./config/Custom/WarehouseSorting.ini";
  7.     private static final String CUSTOM_WEDDING_CONFIG_FILE = "./config/Custom/Wedding.ini";
  8.     private static final String CUSTOM_WALKER_BOT_PROTECTION_CONFIG_FILE = "./config/Custom/WalkerBotProtection.ini";
  9. +   private static final String CUSTOM_SUB_STUCK_CONFIG_FILE = "./config/Custom/SubStuck.ini";
  10.    
  11.     // --------------------------------------------------
  12.     // Variable Definitions
  13. @@ -1237,6 +1238,7 @@
  14.     public static int NOBLESS_MASTER_LEVEL_REQUIREMENT;
  15.     public static boolean NOBLESS_MASTER_REWARD_TIARA;
  16.     public static boolean L2WALKER_PROTECTION;
  17. +   public static boolean KEEP_SUBCLASS_SKILLS;
  18.     public static int DUALBOX_CHECK_MAX_PLAYERS_PER_IP;
  19.     public static int DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP;
  20.     public static int DUALBOX_CHECK_MAX_L2EVENT_PARTICIPANTS_PER_IP;
  21. @@ -3161,6 +3163,10 @@
  22.             // Load WalkerBotProtection config file (if exists)
  23.             final PropertiesParser walkerBotProtectionConfig = new PropertiesParser(CUSTOM_WALKER_BOT_PROTECTION_CONFIG_FILE);
  24.             L2WALKER_PROTECTION = walkerBotProtectionConfig.getBoolean("L2WalkerProtection", false);
  25. +          
  26. +           // Load substuck config file (if exists)
  27. +           final PropertiesParser substuckConfig = new PropertiesParser(CUSTOM_SUB_STUCK_CONFIG_FILE);
  28. +           KEEP_SUBCLASS_SKILLS = substuckConfig.getBoolean("KeepSubClassSkills", false);
  29.         }
  30.         else if (SERVER_MODE == ServerMode.LOGIN)
  31.         {
  32.  
  33. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Player.java
  34. index ec575d7..074d782 100644
  35. --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Player.java
  36. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Player.java
  37. @@ -62,7 +62,6 @@
  38.  import org.l2jmobius.gameserver.data.sql.OfflineTraderTable;
  39.  import org.l2jmobius.gameserver.data.xml.AdminData;
  40.  import org.l2jmobius.gameserver.data.xml.CategoryData;
  41. -import org.l2jmobius.gameserver.data.xml.ClassListData;
  42.  import org.l2jmobius.gameserver.data.xml.EnchantSkillGroupsData;
  43.  import org.l2jmobius.gameserver.data.xml.ExperienceData;
  44.  import org.l2jmobius.gameserver.data.xml.FishData;
  45. @@ -81,7 +80,6 @@
  46.  import org.l2jmobius.gameserver.enums.ClassId;
  47.  import org.l2jmobius.gameserver.enums.FlyType;
  48.  import org.l2jmobius.gameserver.enums.HtmlActionScope;
  49. -import org.l2jmobius.gameserver.enums.IllegalActionPunishmentType;
  50.  import org.l2jmobius.gameserver.enums.InstanceType;
  51.  import org.l2jmobius.gameserver.enums.ItemLocation;
  52.  import org.l2jmobius.gameserver.enums.MountType;
  53. @@ -347,6 +345,7 @@
  54.  {
  55.     // Character Skill SQL String Definitions:
  56.     private static final String RESTORE_SKILLS_FOR_CHAR = "SELECT skill_id,skill_level FROM character_skills WHERE charId=? AND class_index=?";
  57. +   private static final String RESTORE_SKILLS_FOR_CHAR_ALT_SUBCLASS = "SELECT skill_id,skill_level FROM character_skills WHERE charId=? ORDER BY (skill_level+0)";
  58.     private static final String UPDATE_CHARACTER_SKILL_LEVEL = "UPDATE character_skills SET skill_level=? WHERE skill_id=? AND charId=? AND class_index=?";
  59.     private static final String ADD_NEW_SKILLS = "REPLACE INTO character_skills (charId,skill_id,skill_level,class_index) VALUES (?,?,?,?)";
  60.     private static final String DELETE_SKILL_FROM_CHAR = "DELETE FROM character_skills WHERE skill_id=? AND charId=? AND class_index=?";
  61. @@ -7727,46 +7726,67 @@
  62.     /**
  63.      * Retrieve from the database all skills of this Player and add them to _skills.
  64.      */
  65. -   private void restoreSkills()
  66. +   public synchronized void restoreSkills()
  67.     {
  68. -       try (Connection con = DatabaseFactory.getConnection();
  69. -           PreparedStatement ps = con.prepareStatement(RESTORE_SKILLS_FOR_CHAR))
  70. +       try (Connection con = DatabaseFactory.getConnection())
  71.         {
  72. -           // Retrieve all skills of this Player from the database
  73. -           ps.setInt(1, getObjectId());
  74. -           ps.setInt(2, _classIndex);
  75. -           try (ResultSet rs = ps.executeQuery())
  76. +           if (!Config.KEEP_SUBCLASS_SKILLS)
  77.             {
  78. -               while (rs.next())
  79. +               final PreparedStatement statement = con.prepareStatement(RESTORE_SKILLS_FOR_CHAR);
  80. +               statement.setInt(1, getObjectId());
  81. +               statement.setInt(2, getClassIndex());
  82. +               final ResultSet rset = statement.executeQuery();
  83. +              
  84. +               // Go though the recordset of this SQL query
  85. +               while (rset.next())
  86.                 {
  87. -                   final int id = rs.getInt("skill_id");
  88. -                   final int level = rs.getInt("skill_level");
  89. +                   final int id = rset.getInt("skill_id");
  90. +                   final int level = rset.getInt("skill_level");
  91. +                   if (id > 9000)
  92. +                   {
  93. +                       continue; // fake skills for base stats
  94. +                   }
  95.                    
  96.                     // Create a Skill object for each record
  97.                     final Skill skill = SkillData.getInstance().getSkill(id, level);
  98. -                   if (skill == null)
  99. -                   {
  100. -                       LOGGER.warning("Skipped null skill Id: " + id + " Level: " + level + " while restoring player skills for playerObjId: " + getObjectId());
  101. -                       continue;
  102. -                   }
  103.                    
  104.                     // Add the Skill object to the Creature _skills and its Func objects to the calculator set of the Creature
  105. -                   addSkill(skill);
  106. -                  
  107. -                   if (Config.SKILL_CHECK_ENABLE && (!canOverrideCond(PlayerCondOverride.SKILL_CONDITIONS) || Config.SKILL_CHECK_GM) && !SkillTreeData.getInstance().isSkillAllowed(this, skill))
  108. -                   {
  109. -                       Util.handleIllegalPlayerAction(this, "Player " + getName() + " has invalid skill " + skill.getName() + " (" + skill.getId() + "/" + skill.getLevel() + "), class:" + ClassListData.getInstance().getClass(getClassId()).getClassName(), IllegalActionPunishmentType.BROADCAST);
  110. -                       if (Config.SKILL_CHECK_REMOVE)
  111. -                       {
  112. -                           removeSkill(skill);
  113. -                       }
  114. -                   }
  115. +                   super.addSkill(skill);
  116.                 }
  117. +              
  118. +               rset.close();
  119. +               statement.close();
  120. +           }
  121. +           else
  122. +           {
  123. +               final PreparedStatement statement = con.prepareStatement(RESTORE_SKILLS_FOR_CHAR_ALT_SUBCLASS);
  124. +               statement.setInt(1, getObjectId());
  125. +               final ResultSet rset = statement.executeQuery();
  126. +              
  127. +               // Go though the recordset of this SQL query
  128. +               while (rset.next())
  129. +               {
  130. +                   final int id = rset.getInt("skill_id");
  131. +                   final int level = rset.getInt("skill_level");
  132. +                   if (id > 9000)
  133. +                   {
  134. +                       continue; // fake skills for base stats
  135. +                   }
  136. +                  
  137. +                   // Create a Skill object for each record
  138. +                   final Skill skill = SkillData.getInstance().getSkill(id, level);
  139. +                  
  140. +                   // Add the Skill object to the Creature _skills and its Func objects to the calculator set of the Creature
  141. +                   super.addSkill(skill);
  142. +               }
  143. +              
  144. +               rset.close();
  145. +               statement.close();
  146.             }
  147.         }
  148.         catch (Exception e)
  149.         {
  150. -           LOGGER.log(Level.WARNING, "Could not restore character " + this + " skills: " + e.getMessage(), e);
  151. +           LOGGER.warning("Could not restore character skills: " + e);
  152.         }
  153.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement