JVBarbosa

[Hellas]HeroSystemCore

Jun 18th, 2016
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 21.20 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2JHellasC
  3. Index: java/com/l2jhellas/gameserver/model/actor/instance/L2PcInstance.java
  4. ===================================================================
  5. --- java/com/l2jhellas/gameserver/model/actor/instance/L2PcInstance.java    (revision 515)
  6. +++ java/com/l2jhellas/gameserver/model/actor/instance/L2PcInstance.java    (working copy)
  7. @@ -269,8 +269,8 @@
  8.     private static final String DELETE_SKILL_SAVE = "DELETE FROM character_skills_save WHERE char_obj_id=? AND class_index=?";
  9.    
  10.     // Character Character
  11. -   private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?, maxHp=?, curHp=?, maxCp=?, curCp=?, maxMp=?, curMp=?, str=?, con=?, dex=?, _int=?, men=?, wit=?, face=?, hairStyle=?, hairColor=?, heading=?, x=?, y=?, z=?, exp=?, expBeforeDeath=?, sp=?, karma=?, pvpkills=?, pkkills=?, rec_have=?, rec_left=?, clanid=?, maxload=?, race=?, classid=?, deletetime=?, title=?, accesslevel=?, online=?, isin7sdungeon=?, clan_privs=?, wantspeace=?, base_class=?, onlinetime=?, in_jail=?, jail_timer=?, newbie=?, nobless=?, power_grade=?, subpledge=?, last_recom_date=?, lvl_joined_academy=?, apprentice=?, sponsor=?, varka_ketra_ally=?, clan_join_expiry_time=?, clan_create_expiry_time=?, char_name=?, death_penalty_level=?, chat_filter_count=?,hitman_target=?, event_points=? WHERE obj_id=?";
  12. -   private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, acc, crit, evasion, mAtk, mDef, mSpd, pAtk, pDef, pSpd, runSpd, walkSpd, str, con, dex, _int, men, wit, face, hairStyle, hairColor, sex, heading, x, y, z, movement_multiplier, attack_speed_multiplier, colRad, colHeight, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, maxload, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, in_jail, jail_timer, newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally, clan_join_expiry_time, clan_create_expiry_time, death_penalty_level, hero, donator, chatban_timer, chatban_reason, chat_filter_count,hitman_target, email, emailcode, hasSubEmail, answer, secCode, emailchangecode, hasSubSec, lastVoteHopzone, lastVoteTopzone, hasVotedHop, hasVotedTop, monthVotes, totalVotes, tries, event_points FROM characters WHERE obj_Id=?";
  13. +   private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?, maxHp=?, curHp=?, maxCp=?, curCp=?, maxMp=?, curMp=?, str=?, con=?, dex=?, _int=?, men=?, wit=?, face=?, hairStyle=?, hairColor=?, heading=?, x=?, y=?, z=?, exp=?, expBeforeDeath=?, sp=?, karma=?, pvpkills=?, pkkills=?, rec_have=?, rec_left=?, clanid=?, maxload=?, race=?, classid=?, deletetime=?, title=?, accesslevel=?, online=?, isin7sdungeon=?, clan_privs=?, wantspeace=?, base_class=?, onlinetime=?, in_jail=?, jail_timer=?, newbie=?, nobless=?, power_grade=?, subpledge=?, last_recom_date=?, lvl_joined_academy=?, apprentice=?, sponsor=?, varka_ketra_ally=?, clan_join_expiry_time=?, clan_create_expiry_time=?, char_name=?, death_penalty_level=?, chat_filter_count=?,hitman_target=?, event_points=?, hero_custom=?, hero_custom_end=? WHERE obj_id=?";
  14. +   private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, acc, crit, evasion, mAtk, mDef, mSpd, pAtk, pDef, pSpd, runSpd, walkSpd, str, con, dex, _int, men, wit, face, hairStyle, hairColor, sex, heading, x, y, z, movement_multiplier, attack_speed_multiplier, colRad, colHeight, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, maxload, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, in_jail, jail_timer, newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally, clan_join_expiry_time, clan_create_expiry_time, death_penalty_level, hero, donator, chatban_timer, chatban_reason, chat_filter_count,hitman_target, email, emailcode, hasSubEmail, answer, secCode, emailchangecode, hasSubSec, lastVoteHopzone, lastVoteTopzone, hasVotedHop, hasVotedTop, monthVotes, totalVotes, tries, event_points, hero_custom, hero_custom_end FROM characters WHERE obj_Id=?";
  15.     private static final String RESTORE_CHAR_SUBCLASSES = "SELECT class_id,exp,sp,level,class_index FROM character_subclasses WHERE char_obj_id=? ORDER BY class_index ASC";
  16.     private static final String INSERT_CHARACTER = "INSERT INTO characters (account_name,obj_Id,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp,acc,crit,evasion,mAtk,mDef,mSpd,pAtk,pDef,pSpd,runSpd,walkSpd,str,con,dex,_int,men,wit,face,hairStyle,hairColor,sex,movement_multiplier,attack_speed_multiplier,colRad,colHeight,exp,sp,karma,pvpkills,pkkills,clanid,maxload,race,classid,deletetime,cancraft,title,accesslevel,online,isin7sdungeon,clan_privs,wantspeace,base_class,newbie,nobless,power_grade,last_recom_date) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  17.  
  18. @@ -627,6 +627,14 @@
  19.    
  20.     private boolean _noble = false;
  21.     private boolean _hero = false;
  22. +    
  23. +   // Hero Custom System
  24. +   private boolean _isHeroCustom = false;
  25. +   private long _hero_custom_endTime = 0;
  26.        
  27.     /** Account Manager */
  28.     private String _email = null;
  29. @@ -7372,6 +7380,14 @@
  30.                     player.setAllianceWithVarkaKetra(rset.getInt("varka_ketra_ally"));
  31.                    
  32.                     player.setDeathPenaltyBuffLevel(rset.getInt("death_penalty_level"));
  33. +                    
  34. +                   // Hero Custom
  35. +                   player.setHeroCustom(rset.getInt("hero_custom") == 1 ? true : false);
  36. +                   player.setHeroCustomEndTime(rset.getLong("hero_custom_end"));
  37.                    
  38.                     player.setChatFilterCount(rset.getInt("chat_filter_count"));
  39.                     player.setHitmanTarget(rset.getInt("hitman_target"));
  40. @@ -7752,7 +7768,11 @@
  41.             statement.setInt(57, getChatFilterCount());
  42.             statement.setInt(58, getHitmanTarget());
  43.             statement.setInt(59, getEventPoints());
  44. -           statement.setInt(60, getObjectId());
  45. +           statement.setInt(60, isHeroCustom() ? 1 : 0);
  46. +           statement.setLong(61, getHeroCustomEndTime());
  47. +           statement.setInt(62, getObjectId());
  48.            
  49.             statement.execute();
  50.             statement.close();
  51. @@ -12620,6 +12640,79 @@
  52.         }
  53.     }
  54.    
  55. +    public boolean isHeroCustom()
  56. +    {
  57. +            return _isHeroCustom;
  58. +    }
  59. +    
  60. +    public void setHeroCustom(boolean val)
  61. +    {
  62. +            _isHeroCustom = val;
  63. +    }
  64. +    
  65. +    public long getHeroCustomEndTime()
  66. +    {
  67. +            return _hero_custom_endTime;
  68. +    }
  69. +    
  70. +    public void setHeroCustomEndTime(long val)
  71. +    {
  72. +            _hero_custom_endTime = val;
  73. +    }
  74. +  
  75. +    public void setEndTime(String process, int val)
  76. +    {
  77. +            Calendar calendar = Calendar.getInstance();
  78. +            calendar.add(Calendar.DAY_OF_MONTH, val);
  79. +            long end_day = calendar.getTimeInMillis();
  80. +            
  81. +            if(process.equals("hero_custom"))
  82. +               _hero_custom_endTime = end_day;
  83. +    }
  84. +  
  85.     public int getPowerGrade()
  86.     {
  87.         return _powerGrade;
  88. Index: java/com/l2jhellas/Config.java
  89. ===================================================================
  90. --- java/com/l2jhellas/Config.java  (revision 515)
  91. +++ java/com/l2jhellas/Config.java  (working copy)
  92. @@ -81,12 +82,16 @@
  93.     private static final String EVENT_RAID_CONFIG_FILE = "./config/Events/Raid.ini";
  94.     private static final String EVENT_WEDDING_CONFIG_FILE = "./config/Events/Wedding.ini";
  95.     // Mods Folder
  96. +   private static final String MOD_OTHERS_CONFIG_FILE = "./config/Mods/Others.ini";
  97.     private static final String MOD_CHAMPIONS_CONFIG_FILE = "./config/Mods/Champions.ini";
  98.     private static final String MOD_L2JHellas_CONFIG_FILE = "./config/Mods/L2JHellas.ini";
  99.     private static final String MOD_RANK_CONFIG_FILE = "./config/Mods/Rank PvP System.ini";
  100. @@ -347,6 +352,31 @@
  101.     public static boolean CHAMPION_ENABLE;
  102.  
  103.     /**
  104. +    * Others Mods Config File
  105. +    */
  106. +   // Hero Custom System
  107. +   public static boolean ENABLE_HERO_CUSTOM_SYSTEM;
  108. +
  109. +   /**
  110.      * PvP Config File
  111.      */
  112.     public static boolean REMOVE_BUFFS_ON_DIE;
  113. @@ -1592,6 +1622,68 @@
  114.             CHAMPION_SPCL_LVL_DIFF = Integer.parseInt(ChampionSettings.getProperty("ChampionSpecialItemLevelDiff", "0"));
  115.  
  116.             /**
  117. +            * Others Mods
  118. +            */
  119. +           /** Hero Custom System */
  120. +           ENABLE_HERO_CUSTOM_SYSTEM = Boolean.parseBoolean(OthersSettings.getProperty("EnableHeroCustomSystem", "True"));
  121. +           /**
  122.              * PvP
  123.              */
  124.             Properties PvPSettings = new Properties();
  125. Index: java/com/l2jhellas/gameserver/network/clientpackets/EnterWorld.java
  126. ===================================================================
  127. --- java/com/l2jhellas/gameserver/network/clientpackets/EnterWorld.java (revision 515)
  128. +++ java/com/l2jhellas/gameserver/network/clientpackets/EnterWorld.java (working copy)
  129. @@ -12,8 +12,13 @@
  130.   */
  131.  package com.l2jhellas.gameserver.network.clientpackets;
  132.  
  133. +import java.util.Calendar;
  134. +import java.util.Date;
  135. +
  136. +import com.l2jhellas.Config;
  137.  import com.l2jhellas.gameserver.TaskPriority;
  138.  import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  139. +import com.l2jhellas.gameserver.network.serverpackets.CreatureSay;
  140.  
  141.  /**
  142.   * Enter World Packet Handler
  143. @@ -46,7 +51,72 @@
  144.             return;
  145.         }  
  146.         activeChar.checks();   
  147. +      
  148. +       // Hero System
  149. +       if(activeChar.isHeroCustom()) {
  150. +           onEnterHeroCustom(activeChar);
  151. +       }
  152. +      
  153.     }
  154. +    
  155. +   private static void onEnterHeroCustom(L2PcInstance activeChar)
  156. +   {
  157. +       long now = Calendar.getInstance().getTimeInMillis();
  158. +       long endDay = activeChar.getHeroCustomEndTime();
  159. +       if(now > endDay)
  160. +       {
  161. +           activeChar.setHero(false);
  162. +           activeChar.setHeroCustomEndTime(0);
  163. +           activeChar.sendPacket(new CreatureSay(0,Say2.HERO_VOICE,"System","Your Hero period ends."));
  164. +       }
  165. +       else
  166. +       {
  167. +       if (activeChar.isHero())
  168. +       {
  169. +           activeChar.sendMessage("You Are Already A Hero!.");
  170. +       }
  171. +       else
  172. +       {
  173. +           Date dt = new Date(endDay);
  174. +           activeChar.setHero(true);
  175. +           activeChar.sendMessage("Your Hero period ends at: " + dt);
  176. +       }
  177. +           activeChar = null;
  178. +       }
  179. +    }
  180.  
  181.     @Override
  182.     public String getType()
  183. Index: java/com/l2jhellas/gameserver/handler/admincommandhandlers/AdminHeroCustom.java
  184. ===================================================================
  185. --- java/com/l2jhellas/gameserver/handler/admincommandhandlers/AdminHeroCustom.java (revision 0)
  186. +++ java/com/l2jhellas/gameserver/handler/admincommandhandlers/AdminHeroCustom.java (working copy)
  187. @@ -0,0 +1,213 @@
  188. +/*
  189. + * This program is free software; you can redistribute it and/or modify
  190. + * it under the terms of the GNU General Public License as published by
  191. + * the Free Software Foundation; either version 2, or (at your option)
  192. + * any later version.
  193. + *
  194. + * This program is distributed in the hope that it will be useful,
  195. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  196. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  197. + * GNU General Public License for more details.
  198. + *
  199. + * You should have received a copy of the GNU General Public License
  200. + * along with this program; if not, write to the Free Software
  201. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  202. + * 02111-1307, USA.
  203. + *
  204. + * http://www.gnu.org/copyleft/gpl.html
  205. + */
  206. +package com.l2jhellas.gameserver.handler.admincommandhandlers;
  207. +
  208. +import java.sql.Connection;
  209. +import java.sql.PreparedStatement;
  210. +import java.util.StringTokenizer;
  211. +import java.util.logging.Level;
  212. +import java.util.logging.Logger;
  213. +
  214. +import com.l2jhellas.gameserver.datatables.xml.AdminData;
  215. +import com.l2jhellas.gameserver.handler.IAdminCommandHandler;
  216. +import com.l2jhellas.gameserver.model.L2Object;
  217. +import com.l2jhellas.gameserver.model.L2World;
  218. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  219. +import com.l2jhellas.gameserver.network.clientpackets.Say2;
  220. +import com.l2jhellas.gameserver.network.serverpackets.CreatureSay;
  221. +import com.l2jhellas.util.database.L2DatabaseFactory;
  222. +
  223. +/**
  224. + * Give / remove hero_custom status to player
  225. + * Changes name color and title color if enabled
  226. + *
  227. + * Uses:
  228. + * sethero_custom [<player_name>] [<time_duration in days>]
  229. + *
  230. + * If <player_name> is not specified, the current target player is used.
  231. + *
  232. + * @author Danilo Nascimento
  233. + *
  234. + */
  235. +public class AdminHeroCustom implements IAdminCommandHandler
  236. +{
  237. +       private static String[] _adminCommands = { "admin_sethero_custom", "admin_removehero_custom" };
  238. +       private final static Logger _log = Logger.getLogger(AdminHeroCustom.class.getName());
  239. +
  240. +       @Override
  241. +       public boolean useAdminCommand(String command, L2PcInstance activeChar)
  242. +       {
  243. +               if (command.startsWith("admin_sethero_custom"))
  244. +               {
  245. +                       StringTokenizer str = new StringTokenizer(command);
  246. +                      
  247. +                       L2Object target = activeChar.getTarget();
  248. +                       L2PcInstance player = null;
  249. +                      
  250. +                       if (target != null && target instanceof L2PcInstance)
  251. +                               player = (L2PcInstance)target;
  252. +                       else
  253. +                               player = activeChar;
  254. +
  255. +                       try
  256. +                       {
  257. +                               str.nextToken();
  258. +                               String time = str.nextToken();
  259. +                               if (str.hasMoreTokens())
  260. +                               {
  261. +                                       String playername = time;
  262. +                                       time = str.nextToken();
  263. +                                       player = L2World.getInstance().getPlayer(playername);
  264. +                                       doHeroCustom(activeChar, player, playername, time);
  265. +                               }
  266. +                               else
  267. +                               {
  268. +                                       String playername = player.getName();
  269. +                                       doHeroCustom(activeChar, player, playername, time);
  270. +                               }
  271. +                       }
  272. +                       catch(Exception e)
  273. +                       {
  274. +                               activeChar.sendMessage("Usage: //sethero_custom <char_name> [time](in days)");
  275. +                       }
  276. +
  277. +                       player.broadcastUserInfo();
  278. +                      
  279. +                       if(player.isHeroCustom())
  280. +                               return true;
  281. +               }
  282. +               else if(command.startsWith("admin_removehero_custom"))
  283. +               {
  284. +                       StringTokenizer str = new StringTokenizer(command);
  285. +                      
  286. +                       L2Object target = activeChar.getTarget();
  287. +                       L2PcInstance player = null;
  288. +                      
  289. +                       if (target instanceof L2PcInstance)
  290. +                               player = (L2PcInstance)target;
  291. +                       else
  292. +                               player = activeChar;
  293. +
  294. +                       try
  295. +                       {
  296. +                               str.nextToken();
  297. +                              
  298. +                               if (str.hasMoreTokens())
  299. +                               {
  300. +                                       String playername = str.nextToken();
  301. +                                       player = L2World.getInstance().getPlayer(playername);
  302. +                                       removeHeroCustom(activeChar, player, playername);
  303. +                               }
  304. +                               else
  305. +                               {
  306. +                                       String playername = player.getName();
  307. +                                       removeHeroCustom(activeChar, player, playername);
  308. +                               }
  309. +                       }
  310. +                       catch(Exception e)
  311. +                       {
  312. +                               activeChar.sendMessage("Usage: //removehero_custom <char_name>");
  313. +                       }
  314. +                      
  315. +                       player.broadcastUserInfo();
  316. +                      
  317. +                       if(player.isHeroCustom())
  318. +                               return false;
  319. +               }
  320. +               return false;
  321. +       }
  322. +
  323. +       public void doHeroCustom(L2PcInstance activeChar, L2PcInstance _player, String _playername, String _time)
  324. +       {
  325. +               int days = Integer.parseInt(_time);
  326. +              
  327. +               if (_player == null)
  328. +               {
  329. +                       activeChar.sendMessage("Character not found.");
  330. +                       return;
  331. +               }
  332. +               if (_player.isHeroCustom())
  333. +               {
  334. +                       activeChar.sendMessage("Player " + _playername + " is already an Hero.");
  335. +                       return;
  336. +               }
  337. +
  338. +               if(days > 0)
  339. +               {
  340. +                       _player.setHeroCustom(true);
  341. +                       _player.setHero(true);
  342. +                       _player.setEndTime("hero_custom", days);
  343. +                       _player.sendPacket(new CreatureSay(0,Say2.HERO_VOICE,"System","Dear player, you are now an Hero, congratulations."));
  344. +                      
  345. +                       try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  346. +                       {
  347. +                               PreparedStatement statement = con.prepareStatement("UPDATE characters SET hero_custom=1, hero_custom_end=? WHERE obj_id=?");
  348. +                               statement.setLong(1, _player.getHeroCustomEndTime());
  349. +                               statement.setInt(2, _player.getObjectId());
  350. +                               statement.execute();
  351. +                               statement.close();
  352. +                              
  353. +                               _player.broadcastUserInfo();
  354. +                               _player.sendSkillList();
  355. +                              
  356. +                               AdminData.getInstance().broadcastMessageToGMs("GM "+ activeChar.getName()+ " set an Hero status for player "+ _playername + " for " + _time + " day(s)");
  357. +                       }
  358. +                       catch (Exception e)
  359. +                       {
  360. +                               _log.log(Level.WARNING,"Something went wrong, check log folder for details", e);
  361. +                       }
  362. +               }
  363. +       }
  364. +
  365. +       public void removeHeroCustom(L2PcInstance activeChar, L2PcInstance _player, String _playername)
  366. +       {
  367. +               if (!_player.isHeroCustom())
  368. +               {
  369. +                       activeChar.sendMessage("Player " + _playername + " is not an Hero.");
  370. +                       return;
  371. +               }
  372. +              
  373. +               _player.setHeroCustom(false);
  374. +               _player.setHero(false);
  375. +               _player.setHeroCustomEndTime(0);
  376. +
  377. +               try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  378. +               {
  379. +                       PreparedStatement statement = con.prepareStatement("UPDATE characters SET hero_custom=0, hero_custom_end=0 WHERE obj_id=?");
  380. +                       statement.setInt(1, _player.getObjectId());
  381. +                       statement.execute();
  382. +                       statement.close();
  383. +                      
  384. +                       _player.broadcastUserInfo();
  385. +                       _player.sendSkillList();
  386. +                      
  387. +                       AdminData.getInstance().broadcastMessageToGMs("GM "+activeChar.getName()+" removed Hero status of player "+ _playername);
  388. +               }
  389. +               catch (Exception e)
  390. +               {
  391. +                       _log.log(Level.WARNING,"Something went wrong, check log folder for details", e);
  392. +               }
  393. +       }
  394. +
  395. +       @Override
  396. +       public String[] getAdminCommandList()
  397. +       {
  398. +               return _adminCommands;
  399. +       }
  400. +}
  401. \ No newline at end of file
  402. Index: config/Mods/Others.ini
  403. ===================================================================
  404. --- config/Mods/Others.ini  (revision 0)
  405. +++ config/Mods/Others.ini  (working copy)
  406. @@ -0,0 +1,53 @@
  407. +#=============================================================
  408. +#                      Hero System
  409. +#=============================================================
  410. +EnableHeroCustomSystem = True
  411. \ No newline at end of file
  412. Index: java/com/l2jhellas/gameserver/handler/AdminCommandHandler.java
  413. ===================================================================
  414. --- java/com/l2jhellas/gameserver/handler/AdminCommandHandler.java  (revision 515)
  415. +++ java/com/l2jhellas/gameserver/handler/AdminCommandHandler.java  (working copy)
  416. @@ -17,6 +17,9 @@
  417.  import java.util.HashMap;
  418.  import java.util.Map;
  419.  
  420. +import com.l2jhellas.gameserver.handler.admincommandhandlers.AdminHeroCustom;
  421. +
  422.  public class AdminCommandHandler implements IHandler<IAdminCommandHandler, String>
  423.  {
  424.     private final Map<String, IAdminCommandHandler> _datatable;
  425. @@ -24,6 +27,8 @@
  426.     protected AdminCommandHandler()
  427.     {
  428.         _datatable = new HashMap<>();
  429. +       registerHandler(new AdminHeroCustom());
  430.     }
  431.    
  432.     @Override
Advertisement
Add Comment
Please, Sign In to add comment