Advertisement
Guest User

Custom Hero

a guest
Oct 7th, 2013
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.78 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P aCis_gameserver
  3. Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  4. ===================================================================
  5. --- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java    (revision 15)
  6. +++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java    (working copy)
  7. @@ -14,6 +14,8 @@
  8.   */
  9.  package net.sf.l2j.gameserver.network.clientpackets;
  10.  
  11. +import java.util.Calendar;
  12. +
  13.  import net.sf.l2j.Config;
  14.  import net.sf.l2j.gameserver.Announcements;
  15.  import net.sf.l2j.gameserver.GameTimeController;
  16. @@ -233,6 +235,14 @@
  17.             sendPacket(html);
  18.         }
  19.        
  20. +       if (activeChar.getCustomHeroTime() == 0 || activeChar.getCustomHeroTime() > Calendar.getInstance().getTimeInMillis())
  21. +           activeChar.setHero(true);
  22. +       else
  23. +       {
  24. +           activeChar.setCustomHeroTime(-1);
  25. +           activeChar.setHero(false);
  26. +       }
  27. +      
  28.         PetitionManager.getInstance().checkPetitionMessages(activeChar);
  29.        
  30.         // no broadcast needed since the player will already spawn dead to others
  31. Index: java/devlin/custom/CustomHeroItem.java
  32. ===================================================================
  33. --- java/devlin/custom/CustomHeroItem.java  (revision 0)
  34. +++ java/devlin/custom/CustomHeroItem.java  (working copy)
  35. @@ -0,0 +1,45 @@
  36. +/*
  37. + * This program is free software: you can redistribute it and/or modify it under
  38. + * the terms of the GNU General Public License as published by the Free Software
  39. + * Foundation, either version 3 of the License, or (at your option) any later
  40. + * version.
  41. + *
  42. + * This program is distributed in the hope that it will be useful, but WITHOUT
  43. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  44. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  45. + * details.
  46. + *
  47. + * You should have received a copy of the GNU General Public License along with
  48. + * this program. If not, see <http://www.gnu.org/licenses/>.
  49. + */
  50. +package devlin.custom;
  51. +
  52. +import java.util.Calendar;
  53. +
  54. +import net.sf.l2j.gameserver.handler.IItemHandler;
  55. +import net.sf.l2j.gameserver.model.L2ItemInstance;
  56. +import net.sf.l2j.gameserver.model.actor.L2Playable;
  57. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  58. +
  59. +/**
  60. + * @author Devlin
  61. + *
  62. + */
  63. +public class CustomHeroItem implements IItemHandler
  64. +{
  65. +   @Override
  66. +   public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
  67. +   {
  68. +       if (!(playable instanceof L2PcInstance))
  69. +           return;
  70. +       L2PcInstance player = (L2PcInstance) playable;
  71. +      
  72. +       // 86400000 = 1 Day.
  73. +       long heroTime = Calendar.getInstance().getTimeInMillis() + 86400000;
  74. +      
  75. +       player.setCustomHeroTime(heroTime);
  76. +       player.setHero(true);
  77. +       player.broadcastUserInfo();
  78. +       player.sendMessage("You have been blessed with the status of Hero.");
  79. +   }
  80. +}
  81. \ No newline at end of file
  82. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
  83. ===================================================================
  84. --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (revision 18)
  85. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (working copy)
  86. @@ -262,6 +262,18 @@
  87.         _offlineShopStart = time;
  88.     }
  89.    
  90. +   private long customHeroTime = -1;
  91. +  
  92. +   public long getCustomHeroTime()
  93. +   {
  94. +       return customHeroTime;
  95. +   }
  96. +  
  97. +   public void setCustomHeroTime(long time)
  98. +   {
  99. +       customHeroTime = time;
  100. +   }
  101. +  
  102.     // Character Skill SQL String Definitions:
  103.     private static final String RESTORE_SKILLS_FOR_CHAR = "SELECT skill_id,skill_level FROM character_skills WHERE char_obj_id=? AND class_index=?";
  104.     private static final String ADD_NEW_SKILL = "INSERT INTO character_skills (char_obj_id,skill_id,skill_level,class_index) VALUES (?,?,?,?)";
  105. @@ -276,8 +288,8 @@
  106.    
  107.     // Character SQL String Definitions:
  108.     private static final String INSERT_CHARACTER = "INSERT INTO characters (account_name,obj_Id,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp,face,hairStyle,hairColor,sex,exp,sp,karma,pvpkills,pkkills,clanid,race,classid,deletetime,cancraft,title,accesslevel,online,isin7sdungeon,clan_privs,wantspeace,base_class,nobless,power_grade,last_recom_date) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  109. -   private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,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=? WHERE obj_id=?";
  110. -   private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, punish_level, punish_timer, 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 FROM characters WHERE obj_id=?";
  111. +   private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,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=?,custom_hero_time=? WHERE obj_id=?";
  112. +   private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, punish_level, punish_timer, 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,custom_hero_time FROM characters WHERE obj_id=?";
  113.    
  114.     // Character Subclass SQL String Definitions:
  115.     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";
  116. @@ -5614,6 +5626,7 @@
  117.                 player.setPkKills(rset.getInt("pkkills"));
  118.                 player.setOnlineTime(rset.getLong("onlinetime"));
  119.                 player.setNoble(rset.getInt("nobless") == 1, false);
  120. +               player.setCustomHeroTime(rset.getLong("custom_hero_time"));
  121.                
  122.                 player.setClanJoinExpiryTime(rset.getLong("clan_join_expiry_time"));
  123.                 if (player.getClanJoinExpiryTime() < System.currentTimeMillis())
  124. @@ -6054,7 +6067,8 @@
  125.             statement.setLong(47, getClanCreateExpiryTime());
  126.             statement.setString(48, getName());
  127.             statement.setLong(49, getDeathPenaltyBuffLevel());
  128. -           statement.setInt(50, getObjectId());
  129. +           statement.setLong(50, getCustomHeroTime());
  130. +           statement.setInt(51, getObjectId());
  131.            
  132.             statement.execute();
  133.             statement.close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement