Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.54 KB | None | 0 0
  1. 1. Register the admin handler.
  2. 2. L2PcInstance
  3. @@
  4. 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=?,banchat_time=?,newbie=?,nobless=?,hero=?,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=?";
  5. add after death_penalty_level=? ,vip_time=?
  6. 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, banchat_time, newbie, nobless, hero, 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=?";
  7. add after death_penalty_level ,vip_time
  8.  
  9. @@
  10. private boolean createDb()
  11. {
  12. java.sql.Connection con = null;
  13. try
  14. {
  15. con = L2DatabaseFactory.getInstance().getConnection();
  16. PreparedStatement statement;
  17. statement = con.prepareStatement(
  18. "INSERT INTO characters " +
  19. "(account_name,obj_Id,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp," +
  20. "acc,crit,evasion,mAtk,mDef,mSpd,pAtk,pDef,pSpd,runSpd,walkSpd," +
  21. "str,con,dex,_int,men,wit,face,hairStyle,hairColor,sex," +
  22. "movement_multiplier,attack_speed_multiplier,colRad,colHeight," +
  23. "exp,sp,karma,pvpkills,pkkills,clanid,maxload,race,classid,deletetime," +
  24. "cancraft,title,accesslevel,online,isin7sdungeon,clan_privs,wantspeace," +
  25. - "base_class,newbie,nobless,power_grade,last_recom_date) " +
  26. + "base_class,newbie,nobless,power_grade,last_recom_date,vip_time) " +
  27. - "values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
  28. + "values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
  29.  
  30. statement.setLong(57, System.currentTimeMillis());
  31. + statement.setLong(58, getVipTimer());
  32.  
  33. @@
  34.  
  35. + player.setVipTimer(rset.getLong("vip_time"));
  36. CursedWeaponsManager.getInstance().checkPlayer(player);
  37. player.setAllianceWithVarkaKetra(rset.getInt("varka_ketra_ally"));
  38. player.setDeathPenaltyBuffLevel(rset.getInt("death_penalty_level"));
  39. player.setXYZInvisible(rset.getInt("x"), rset.getInt("y"), rset.getInt("z"));
  40.  
  41. and add to the end of class
  42.  
  43. private long _vipTimer = 0L;
  44. private ScheduledFuture _vipTask = null;
  45. private boolean _vip = false;
  46. private ScheduledFuture _removeVipTask = null;
  47.  
  48. public void setVip(boolean state, int delayInMinutes)
  49. {
  50. _vip = state;
  51. _vipTimer = 0L;
  52. stopVipTask(false);
  53. if(_vip && delayInMinutes > 0)
  54. {
  55. _vipTimer = (long)delayInMinutes * 60000L;
  56. _vipTask = ThreadPoolManager.getInstance().scheduleGeneral(new VipTask(this), _vipTimer);
  57. sendMessage("Your character is VIP for "+(delayInMinutes)+" minutes.");
  58. sendPacket(new EtcStatusUpdate(this));
  59. }
  60. storeCharBase();
  61. }
  62.  
  63. public long getVipTimer()
  64. {
  65. if(_vip)
  66. {
  67. long delay = _vipTask.getDelay(TimeUnit.MILLISECONDS);
  68. if(delay >= 0L)
  69. _vipTimer = delay;
  70. }
  71. return _vipTimer;
  72. }
  73.  
  74. public boolean isVip()
  75. {
  76. return _vip;
  77. }
  78.  
  79. public void setVip(boolean state)
  80. {
  81. _vip = state;
  82. }
  83.  
  84. public void setRemoveVipTask(ScheduledFuture task)
  85. {
  86. _removeVipTask = task;
  87. }
  88.  
  89. public ScheduledFuture getRemoveVipTask()
  90. {
  91. return _removeVipTask;
  92. }
  93.  
  94. public void setVipTimer(long time)
  95. {
  96. _vipTimer = time;
  97. }
  98.  
  99. public void updateVipState()
  100. {
  101. if(_vipTimer > 0L)
  102. {
  103. _vip = true;
  104. _vipTask = ThreadPoolManager.getInstance().scheduleGeneral(new VipTask(this), _vipTimer);
  105. sendMessage("You are still vip for "+Math.round(_vipTimer / 60000L)+" minutes.");
  106. sendPacket(new EtcStatusUpdate(this));
  107. }
  108. }
  109. public void stopVipTask(boolean save)
  110. {
  111. if(_vipTask != null)
  112. {
  113. if(save)
  114. {
  115. long delay = _vipTask.getDelay(TimeUnit.MILLISECONDS);
  116. if(delay < 0L)
  117. delay = 0L;
  118. setVipTimer(delay);
  119. }
  120. _vipTask.cancel(false);
  121. _vip = false;
  122. _removeVipTask = null;
  123. sendPacket(new EtcStatusUpdate(this));
  124. }
  125. }
  126. private class VipTask implements Runnable
  127. {
  128. L2PcInstance _player;
  129. protected long _startedAt;
  130.  
  131. protected VipTask(L2PcInstance player)
  132. {
  133. _player = player;
  134. _startedAt = System.currentTimeMillis();
  135. }
  136.  
  137. public void run()
  138. {
  139. _player.setVip(false, 0);
  140. }
  141. }
  142.  
  143. 3. EnterWorld
  144.  
  145. if (Config.GM_STARTUP_AUTO_LIST && AdminCommandAccessRights.getInstance().hasAccess("admin_gmliston", activeChar.getAccessLevel()))
  146. GmListTable.getInstance().addGm(activeChar, false);
  147. else GmListTable.getInstance().addGm(activeChar, true);
  148. }
  149. + activeChar.updateVipState();
  150.  
  151. 4. SQL, Character
  152. after `death_penalty_level`
  153. `banchat_time` int(10) NOT NULL,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement