Advertisement
Guest User

VIP

a guest
Jul 1st, 2013
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.53 KB | None | 0 0
  1. Index: java/net/l2jalpha/gameserver/network/clientpackets/EnterWorld.java
  2. ===================================================================
  3. --- java/net/l2jalpha/gameserver/network/clientpackets/EnterWorld.java (revision 31)
  4. +++ java/net/l2jalpha/gameserver/network/clientpackets/EnterWorld.java (working copy)
  5. @@ -27,6 +27,7 @@
  6. import net.l2jalpha.gameserver.Announcements;
  7. import net.l2jalpha.gameserver.GmListTable;
  8. import net.l2jalpha.gameserver.TaskPriority;
  9. +import net.l2jalpha.gameserver.ThreadPoolManager;
  10. import net.l2jalpha.gameserver.cache.HtmCache;
  11. import net.l2jalpha.gameserver.communitybbs.Manager.RegionBBSManager;
  12. import net.l2jalpha.gameserver.datatables.sql.AdminCommandAccessRights;
  13. @@ -46,6 +47,7 @@
  14. import net.l2jalpha.gameserver.model.entity.ClanHall;
  15. import net.l2jalpha.gameserver.model.entity.Hero;
  16. import net.l2jalpha.gameserver.model.entity.Siege;
  17. +import net.l2jalpha.gameserver.model.entity.VipRemoval;
  18. import net.l2jalpha.gameserver.model.olympiad.Olympiad;
  19. import net.l2jalpha.gameserver.model.quest.Quest;
  20. import net.l2jalpha.gameserver.network.SystemMessageId;
  21. @@ -281,6 +283,19 @@
  22.  
  23. RegionBBSManager.getInstance().changeCommunityBoard();
  24.  
  25. + if (activeChar.isVip())
  26. + {
  27. + if ((activeChar.getVipSetTime()+(activeChar.getVipHours()*1000*60*60)) < System.currentTimeMillis())
  28. + {
  29. + activeChar.setVip(false);
  30. + activeChar.setVipHours(0);
  31. + activeChar.setVipSetTime(0);
  32. + }
  33. + else
  34. + {
  35. + ThreadPoolManager.getInstance().scheduleGeneral(new VipRemoval(activeChar.getName()), System.currentTimeMillis() - (activeChar.getVipSetTime()+(activeChar.getVipHours()*1000*60*60)));
  36. + }
  37. + }
  38. }
  39.  
  40. /**
  41. Index: java/net/l2jalpha/gameserver/model/entity/VipRemoval.java
  42. ===================================================================
  43. --- java/net/l2jalpha/gameserver/model/entity/VipRemoval.java (revision 0)
  44. +++ java/net/l2jalpha/gameserver/model/entity/VipRemoval.java (working copy)
  45. @@ -0,0 +1,48 @@
  46. +/* This program is free software; you can redistribute it and/or modify
  47. + * it under the terms of the GNU General Public License as published by
  48. + * the Free Software Foundation; either version 2, or (at your option)
  49. + * any later version.
  50. + *
  51. + * This program is distributed in the hope that it will be useful,
  52. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  53. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  54. + * GNU General Public License for more details.
  55. + *
  56. + * You should have received a copy of the GNU General Public License
  57. + * along with this program; if not, write to the Free Software
  58. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  59. + * 02111-1307, USA.
  60. + *
  61. + * http://www.gnu.org/copyleft/gpl.html
  62. + */
  63. +package net.l2jalpha.gameserver.model.entity;
  64. +
  65. +import net.l2jalpha.gameserver.model.L2World;
  66. +import net.l2jalpha.gameserver.model.actor.instance.L2PcInstance;
  67. +
  68. +/**
  69. + *
  70. + * @author Anarchy
  71. + */
  72. +public class VipRemoval implements Runnable
  73. +{
  74. + private String _p = null;
  75. +
  76. + public VipRemoval(String p)
  77. + {
  78. + _p = p;
  79. + }
  80. +
  81. + @Override
  82. + public void run()
  83. + {
  84. + L2PcInstance player = L2World.getInstance().getPlayer(_p);
  85. +
  86. + if (player != null)
  87. + {
  88. + player.setVip(false);
  89. + player.setVipSetTime(0);
  90. + player.setVipHours(0);
  91. + }
  92. + }
  93. +}
  94. Index: java/net/l2jalpha/gameserver/model/actor/instance/L2TeleporterInstance.java
  95. ===================================================================
  96. --- java/net/l2jalpha/gameserver/model/actor/instance/L2TeleporterInstance.java (revision 31)
  97. +++ java/net/l2jalpha/gameserver/model/actor/instance/L2TeleporterInstance.java (working copy)
  98. @@ -37,7 +37,7 @@
  99. * @version $Revision: 1.3.2.2.2.5 $ $Date: 2005/03/27 15:29:32 $
  100. *
  101. */
  102. -public final class L2TeleporterInstance extends L2NpcInstance
  103. +public class L2TeleporterInstance extends L2NpcInstance
  104. {
  105.  
  106. private static final int COND_ALL_FALSE = 0;
  107. Index: java/net/l2jalpha/gameserver/model/actor/instance/L2PcInstance.java
  108. ===================================================================
  109. --- java/net/l2jalpha/gameserver/model/actor/instance/L2PcInstance.java (revision 31)
  110. +++ java/net/l2jalpha/gameserver/model/actor/instance/L2PcInstance.java (working copy)
  111. @@ -196,6 +196,40 @@
  112. */
  113. public final class L2PcInstance extends L2Playable
  114. {
  115. + private boolean _vip = false;
  116. + private long _vip_settime = 0;
  117. + private int _vip_hours = 0;
  118. +
  119. + public int getVipHours()
  120. + {
  121. + return _vip_hours;
  122. + }
  123. +
  124. + public void setVipHours(int val)
  125. + {
  126. + _vip_hours = val;
  127. + }
  128. +
  129. + public long getVipSetTime()
  130. + {
  131. + return _vip_settime;
  132. + }
  133. +
  134. + public void setVipSetTime(long val)
  135. + {
  136. + _vip_settime = val;
  137. + }
  138. +
  139. + public boolean isVip()
  140. + {
  141. + return _vip;
  142. + }
  143. +
  144. + public void setVip(boolean val)
  145. + {
  146. + _vip = val;
  147. + }
  148. +
  149. private static final String RESTORE_SKILLS_FOR_CHAR = "SELECT skill_id,skill_level FROM character_skills WHERE char_obj_id=? AND class_index=?";
  150. private static final String ADD_NEW_SKILL = "INSERT INTO character_skills (char_obj_id,skill_id,skill_level,skill_name,class_index) VALUES (?,?,?,?,?)";
  151. private static final String UPDATE_CHARACTER_SKILL_LEVEL = "UPDATE character_skills SET skill_level=? WHERE skill_id=? AND char_obj_id=? AND class_index=?";
  152. @@ -207,8 +241,8 @@
  153. private static final String DELETE_SKILL_SAVE = "DELETE FROM character_skills_save WHERE char_obj_id=? AND class_index=?";
  154.  
  155. 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,movement_multiplier,attack_speed_multiplier,colRad,colHeight,exp,sp,karma,pvpkills,pkkills,clanid,maxload,race,classid,deletetime,cancraft,title,accesslevel,online,clan_privs,wantspeace,base_class,newbie,nobless,power_grade,last_recom_date) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  156. - private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,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=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_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=? WHERE obj_id=?";
  157. - 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, 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, punish_level, punish_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 FROM characters WHERE obj_id=?";
  158. + private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,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=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_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=?,vip=?,vip_settime=?,vip_hours=? WHERE obj_id=?";
  159. + 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, 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, punish_level, punish_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,vip,vip_settime,vip_hours FROM characters WHERE obj_id=?";
  160.  
  161. 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";
  162. private static final String ADD_CHAR_SUBCLASS = "INSERT INTO character_subclasses (char_obj_id,class_id,exp,sp,level,class_index) VALUES (?,?,?,?,?,?)";
  163. @@ -5369,6 +5403,10 @@
  164. player.setOnlineTime(rset.getLong("onlinetime"));
  165. player.setNewbie(rset.getInt("newbie")==1);
  166. player.setNoble(rset.getInt("nobless")==1);
  167. +
  168. + player.setVip(rset.getInt("vip")==1);
  169. + player.setVipSetTime(rset.getLong("vip_settime"));
  170. + player.setVipHours(rset.getInt("vip_hours"));
  171.  
  172. player.setClanJoinExpiryTime(rset.getLong("clan_join_expiry_time"));
  173. if (player.getClanJoinExpiryTime() < System.currentTimeMillis())
  174. @@ -5818,7 +5856,10 @@
  175. statement.setLong(47, getClanCreateExpiryTime());
  176. statement.setString(48, getName());
  177. statement.setLong(49, getDeathPenaltyBuffLevel());
  178. - statement.setInt(50, getObjectId());
  179. + statement.setInt(50, isVip() ? 1 : 0);
  180. + statement.setLong(51, getVipSetTime());
  181. + statement.setInt(52, getVipHours());
  182. + statement.setInt(53, getObjectId());
  183.  
  184. statement.execute();
  185. statement.close();
  186. Index: java/net/l2jalpha/gameserver/model/actor/instance/L2VipTeleporterInstance.java
  187. ===================================================================
  188. --- java/net/l2jalpha/gameserver/model/actor/instance/L2VipTeleporterInstance.java (revision 0)
  189. +++ java/net/l2jalpha/gameserver/model/actor/instance/L2VipTeleporterInstance.java (working copy)
  190. @@ -0,0 +1,64 @@
  191. +/* This program is free software; you can redistribute it and/or modify
  192. + * it under the terms of the GNU General Public License as published by
  193. + * the Free Software Foundation; either version 2, or (at your option)
  194. + * any later version.
  195. + *
  196. + * This program is distributed in the hope that it will be useful,
  197. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  198. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  199. + * GNU General Public License for more details.
  200. + *
  201. + * You should have received a copy of the GNU General Public License
  202. + * along with this program; if not, write to the Free Software
  203. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  204. + * 02111-1307, USA.
  205. + *
  206. + * http://www.gnu.org/copyleft/gpl.html
  207. + */
  208. +package net.l2jalpha.gameserver.model.actor.instance;
  209. +
  210. +import java.util.StringTokenizer;
  211. +
  212. +import net.l2jalpha.gameserver.datatables.json.TeleportLocationTable;
  213. +import net.l2jalpha.gameserver.model.L2TeleportLocation;
  214. +import net.l2jalpha.gameserver.templates.L2NpcTemplate;
  215. +
  216. +/**
  217. + *
  218. + * @author Anarchy
  219. + */
  220. +public class L2VipTeleporterInstance extends L2TeleporterInstance
  221. +{
  222. + public L2VipTeleporterInstance(int objectId, L2NpcTemplate template)
  223. + {
  224. + super(objectId, template);
  225. + }
  226. +
  227. + @Override
  228. + public void onBypassFeedback(L2PcInstance player, String command)
  229. + {
  230. + if (command.startsWith("vipgoto"))
  231. + {
  232. + String cmd = command.substring(8);
  233. + StringTokenizer st = new StringTokenizer(cmd);
  234. +
  235. + if (st.countTokens() != 1)
  236. + {
  237. + return;
  238. + }
  239. +
  240. + int id = Integer.parseInt(st.nextToken());
  241. +
  242. + L2TeleportLocation loc = TeleportLocationTable.getInstance().getTemplate(id);
  243. +
  244. + if (loc == null)
  245. + {
  246. + return;
  247. + }
  248. +
  249. + player.teleToLocation(loc.getLocX(), loc.getLocY(), loc.getLocZ(), true);
  250. + }
  251. +
  252. + super.onBypassFeedback(player, command);
  253. + }
  254. +}
  255. #P l2jalpha_datapack_mxc
  256. Index: sql/characters.sql
  257. ===================================================================
  258. --- sql/characters.sql (revision 31)
  259. +++ sql/characters.sql (working copy)
  260. @@ -61,6 +61,9 @@
  261. clan_join_expiry_time DECIMAL(20,0) NOT NULL DEFAULT 0,
  262. clan_create_expiry_time DECIMAL(20,0) NOT NULL DEFAULT 0,
  263. death_penalty_level int(2) NOT NULL DEFAULT 0,
  264. + vip decimal(1,0) NOT NULL DEFAULT 0,
  265. + vip_settime BIGINT DEFAULT 0,
  266. + vip_hours INT DEFAULT 0,
  267. PRIMARY KEY (obj_Id),
  268. KEY `clanid` (`clanid`)
  269. ) ;
  270. Index: data/scripts/handlers/admincommandhandlers/AdminVip.java
  271. ===================================================================
  272. --- data/scripts/handlers/admincommandhandlers/AdminVip.java (revision 0)
  273. +++ data/scripts/handlers/admincommandhandlers/AdminVip.java (working copy)
  274. @@ -0,0 +1,86 @@
  275. +/*
  276. + * This program is free software; you can redistribute it and/or modify
  277. + * it under the terms of the GNU General Public License as published by
  278. + * the Free Software Foundation; either version 2, or (at your option)
  279. + * any later version.
  280. + *
  281. + * This program is distributed in the hope that it will be useful,
  282. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  283. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  284. + * GNU General Public License for more details.
  285. + *
  286. + * You should have received a copy of the GNU General Public License
  287. + * along with this program; if not, write to the Free Software
  288. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  289. + * 02111-1307, USA.
  290. + *
  291. + * http://www.gnu.org/copyleft/gpl.html
  292. + */
  293. +package handlers.admincommandhandlers;
  294. +
  295. +import java.util.StringTokenizer;
  296. +
  297. +import net.l2jalpha.gameserver.ThreadPoolManager;
  298. +import net.l2jalpha.gameserver.handler.IAdminCommandHandler;
  299. +import net.l2jalpha.gameserver.model.L2Object;
  300. +import net.l2jalpha.gameserver.model.actor.instance.L2PcInstance;
  301. +import net.l2jalpha.gameserver.model.entity.VipRemoval;
  302. +
  303. +public class AdminVip implements IAdminCommandHandler
  304. +{
  305. + private static final String[] ADMIN_COMMANDS = { "admin_setvip" };
  306. +
  307. + @Override
  308. + public boolean useAdminCommand(String command, L2PcInstance activeChar)
  309. + {
  310. + if (command.startsWith("admin_setvip"))
  311. + {
  312. + String cmd = command.substring(13);
  313. + StringTokenizer st = new StringTokenizer(cmd);
  314. +
  315. + if (st.countTokens() != 1)
  316. + {
  317. + activeChar.sendMessage("Usage: //setvip hours");
  318. + return false;
  319. + }
  320. +
  321. + int hours = Integer.parseInt(st.nextToken());
  322. +
  323. + if (hours <= 0)
  324. + {
  325. + activeChar.sendMessage("Wrong value for hours; you can't enter number below or equal to 0.");
  326. + return false;
  327. + }
  328. +
  329. + L2Object target = activeChar.getTarget();
  330. +
  331. + if (target == null)
  332. + {
  333. + activeChar.sendMessage("Wrong target.");
  334. + return false;
  335. + }
  336. +
  337. + if (!(target instanceof L2PcInstance))
  338. + {
  339. + activeChar.sendMessage("Wrong target.");
  340. + return false;
  341. + }
  342. +
  343. + L2PcInstance trg = (L2PcInstance)target;
  344. +
  345. + trg.setVip(true);
  346. + trg.setVipSetTime(System.currentTimeMillis());
  347. + trg.setVipHours(hours);
  348. +
  349. + ThreadPoolManager.getInstance().scheduleGeneral(new VipRemoval(trg.getName()), hours*1000*60*60);
  350. + }
  351. +
  352. + return true;
  353. + }
  354. +
  355. + @Override
  356. + public String[] getAdminCommandList()
  357. + {
  358. + return ADMIN_COMMANDS;
  359. + }
  360. +}
  361. Index: data/scripts/handlers/MasterHandler.java
  362. ===================================================================
  363. --- data/scripts/handlers/MasterHandler.java (revision 31)
  364. +++ data/scripts/handlers/MasterHandler.java (working copy)
  365. @@ -63,6 +63,7 @@
  366. import handlers.admincommandhandlers.AdminTarget;
  367. import handlers.admincommandhandlers.AdminTeleport;
  368. import handlers.admincommandhandlers.AdminUnblockIp;
  369. +import handlers.admincommandhandlers.AdminVip;
  370. import handlers.admincommandhandlers.AdminZone;
  371. import handlers.chathandlers.ChatAll;
  372. import handlers.chathandlers.ChatAlliance;
  373. @@ -254,6 +255,7 @@
  374. {
  375. AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminReloadQuizQuestions());
  376. }
  377. + AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminVip());
  378. _log.config("Loaded " + AdminCommandHandler.getInstance().size() + " admin command handlers.");
  379. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement