JVBarbosa

[Hellas]VipSystemCore

Jun 11th, 2016
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 23.24 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2JHellasC
  3. Index: java/com/l2jhellas/gameserver/model/actor/L2Attackable.java
  4. ===================================================================
  5. --- java/com/l2jhellas/gameserver/model/actor/L2Attackable.java (revision 516)
  6. +++ java/com/l2jhellas/gameserver/model/actor/L2Attackable.java (working copy)
  7. @@ -982,6 +982,10 @@
  8.                                     exp += calculateOverhitExp(exp);
  9.                                     exp_premium += calculateOverhitExp(exp_premium);
  10.                                 }
  11. +                               if (player.isVip() && Config.ALLOW_VIP_XPSP){
  12. +                                   exp *= Config.VIP_XP;
  13. +                                   sp *= Config.VIP_SP;
  14. +                               }
  15.                             }
  16.                            
  17.                             // Distribute the Exp and SP between the L2PcInstance and its L2Summon
  18. Index: java/com/l2jhellas/gameserver/model/actor/instance/L2PcInstance.java
  19. ===================================================================
  20. --- java/com/l2jhellas/gameserver/model/actor/instance/L2PcInstance.java    (revision 516)
  21. +++ java/com/l2jhellas/gameserver/model/actor/instance/L2PcInstance.java    (working copy)
  22. @@ -269,8 +269,8 @@
  23.     private static final String DELETE_SKILL_SAVE = "DELETE FROM character_skills_save WHERE char_obj_id=? AND class_index=?";
  24.    
  25.     // Character Character
  26. -   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=?";
  27. -   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=?";
  28. +   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=?, vip=?, vip_end=? WHERE obj_id=?";
  29. +   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, vip, vip_end FROM characters WHERE obj_Id=?";
  30.     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";
  31.     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 (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  32.  
  33. @@ -627,6 +627,10 @@
  34.    
  35.     private boolean _noble = false;
  36.     private boolean _hero = false;
  37. +  
  38. +   /** VIP System */
  39. +   private boolean _isVip = false;
  40. +   private long _vip_endTime = 0;
  41.        
  42.     /** Account Manager */
  43.     private String _email = null;
  44. @@ -7373,6 +7377,9 @@
  45.                    
  46.                     player.setDeathPenaltyBuffLevel(rset.getInt("death_penalty_level"));
  47.                    
  48. +                   player.setVip(rset.getInt("vip") == 1 ? true : false);
  49. +                   player.setVipEndTime(rset.getLong("vip_end"));
  50. +                  
  51.                     player.setChatFilterCount(rset.getInt("chat_filter_count"));
  52.                     player.setHitmanTarget(rset.getInt("hitman_target"));
  53.                     player._email = rset.getString("email");
  54. @@ -7752,7 +7759,9 @@
  55.             statement.setInt(57, getChatFilterCount());
  56.             statement.setInt(58, getHitmanTarget());
  57.             statement.setInt(59, getEventPoints());
  58. -           statement.setInt(60, getObjectId());
  59. +           statement.setInt(60, isVip() ? 1 : 0);
  60. +           statement.setLong(61, getVipEndTime());
  61. +           statement.setInt(62, getObjectId());
  62.            
  63.             statement.execute();
  64.             statement.close();
  65. @@ -12620,6 +12629,36 @@
  66.         }
  67.     }
  68.    
  69. +    public boolean isVip()
  70. +    {
  71. +            return _isVip;
  72. +    }
  73. +  
  74. +    public void setVip(boolean val)
  75. +    {
  76. +            _isVip = val;
  77. +    }
  78. +  
  79. +    public long getVipEndTime()
  80. +    {
  81. +            return _vip_endTime;
  82. +    }
  83. +  
  84. +    public void setVipEndTime(long val)
  85. +    {
  86. +            _vip_endTime = val;
  87. +    }
  88. +  
  89. +    public void setEndTime(String process, int val)
  90. +    {
  91. +            Calendar calendar = Calendar.getInstance();
  92. +            calendar.add(Calendar.DAY_OF_MONTH, val);
  93. +            long end_day = calendar.getTimeInMillis();
  94. +          
  95. +            if(process.equals("vip"))
  96. +                    _vip_endTime = end_day;
  97. +    }
  98. +  
  99.     public int getPowerGrade()
  100.     {
  101.         return _powerGrade;
  102. Index: java/com/l2jhellas/gameserver/network/clientpackets/EnterWorld.java
  103. ===================================================================
  104. --- java/com/l2jhellas/gameserver/network/clientpackets/EnterWorld.java (revision 516)
  105. +++ java/com/l2jhellas/gameserver/network/clientpackets/EnterWorld.java (working copy)
  106. @@ -12,8 +12,13 @@
  107.   */
  108.  package com.l2jhellas.gameserver.network.clientpackets;
  109.  
  110. +import java.util.Calendar;
  111. +import java.util.Date;
  112. +
  113. +import com.l2jhellas.Config;
  114.  import com.l2jhellas.gameserver.TaskPriority;
  115.  import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  116. +import com.l2jhellas.gameserver.network.serverpackets.CreatureSay;
  117.  
  118.  /**
  119.   * Enter World Packet Handler
  120. @@ -46,6 +51,20 @@
  121.             return;
  122.         }  
  123.         activeChar.checks();   
  124. +      
  125. +       if(Config.ALLOW_VIP_NCOLOR && activeChar.isVip()) {
  126. +           activeChar.getAppearance().setNameColor(Config.VIP_NCOLOR);
  127. +       }
  128. +      
  129. +       if(Config.ALLOW_VIP_TCOLOR && activeChar.isVip()) {
  130. +           activeChar.getAppearance().setTitleColor(Config.VIP_TCOLOR);
  131. +       }
  132. +
  133. +       if(activeChar.isVip()) {
  134. +           onEnterVip(activeChar);
  135. +           activeChar.updateNameTitleColor();
  136. +       }
  137. +
  138.     }
  139.  
  140.     @Override
  141. @@ -53,4 +72,19 @@
  142.     {
  143.         return _C__03_ENTERWORLD;
  144.     }
  145. +  
  146. +   private static void onEnterVip(L2PcInstance activeChar) {
  147. +       long now = Calendar.getInstance().getTimeInMillis();
  148. +       long endDay = activeChar.getVipEndTime();
  149. +       if(now > endDay) {
  150. +           activeChar.setVip(false);
  151. +           activeChar.setVipEndTime(0);
  152. +       activeChar.sendPacket(new CreatureSay(0,Say2.HERO_VOICE,"System","Your VIP period ends."));
  153. +       } else {
  154. +           Date dt = new Date(endDay);
  155. +           if(activeChar.isVip()) {
  156. +               activeChar.sendMessage("Your VIP period ends at: " + dt);
  157. +           }
  158. +       }
  159. +   }
  160.  }
  161. \ No newline at end of file
  162. Index: config/Mods/Vip System.ini
  163. ===================================================================
  164. --- config/Mods/Vip System.ini  (revision 0)
  165. +++ config/Mods/Vip System.ini  (working copy)
  166. @@ -0,0 +1,16 @@
  167. +# ---------------------------------------
  168. +# Vip System
  169. +# ---------------------------------------
  170. +# Enable / Disable Name Color
  171. +AllowVipNameColor = True
  172. +VipNameColor = 0088FF
  173. +
  174. +# Enable / Disable Title Color
  175. +AllowVipTitleColor = True
  176. +VipTitleColor = 0088FF
  177. +
  178. +# if True Player Vip gain Xp*VipMulXp and Sp*VipMulSp
  179. +# Note only works if player not in party
  180. +AllowVipMulXpSp = True
  181. +VipMulXp = 2
  182. +VipMulSp = 2
  183. \ No newline at end of file
  184. Index: java/com/l2jhellas/Config.java
  185. ===================================================================
  186. --- java/com/l2jhellas/Config.java  (revision 516)
  187. +++ java/com/l2jhellas/Config.java  (working copy)
  188. @@ -87,6 +87,7 @@
  189.     private static final String MOD_AUTOMATION_CONFIG_FILE = "./config/Mods/Automatation.ini";
  190.     private static final String MOD_SMART_CB_CONFIG_FILE = "./config/Mods/Smart Community Board.ini";
  191.     private static final String MOD_CUSTOM_NPC_CONFIG_FILE = "./config/Mods/Custom Npcs.ini";
  192. +   private static final String MOD_VIP_SYSTEM_CONFIG_FILE = "./config/Mods/VipSystem.ini";
  193.     // Olympiad Folder
  194.     private static final String OLYMPIAD_FILE = "./config/Olympiad/OlySettings.ini";
  195.     // Others
  196. @@ -703,6 +704,16 @@
  197.     public static boolean RAID_INFO_SHOW_TIME;
  198.  
  199.  
  200. +   /**
  201. +    * NPC Config File
  202. +    */
  203. +   public static boolean ALLOW_VIP_NCOLOR;
  204. +   public static int VIP_NCOLOR;
  205. +   public static boolean ALLOW_VIP_TCOLOR;
  206. +   public static int VIP_TCOLOR;
  207. +   public static boolean ALLOW_VIP_XPSP;
  208. +   public static int VIP_XP;
  209. +   public static int VIP_SP;
  210.    
  211.     /** new Olympiad */
  212.     public static int ALT_OLY_START_TIME;
  213. @@ -2422,8 +2433,28 @@
  214.                 BOSS_RESPAWN_INFO[info] = Integer.parseInt(notenchantable[info]);
  215.             Arrays.sort(BOSS_RESPAWN_INFO);
  216.             RAID_INFO_SHOW_TIME = Boolean.parseBoolean(CustomNpcSettings.getProperty("InfoShowTime", "False"));
  217. -
  218. +          
  219.             /**
  220. +            * Custom Npc
  221. +            */
  222. +           Properties VipSystemSettings = new Properties();
  223. +           try (InputStream is = new FileInputStream(new File(MOD_VIP_SYSTEM_CONFIG_FILE)))
  224. +           {
  225. +               CustomNpcSettings.load(is);
  226. +           }
  227. +           catch (Exception e)
  228. +           {
  229. +               _log.severe(Config.class.getName() + ": Error while loading " + MOD_VIP_SYSTEM_CONFIG_FILE + " settings!");
  230. +           }
  231. +           ALLOW_VIP_NCOLOR = Boolean.parseBoolean(VipSystemSettings.getProperty("AllowVipNameColor", "True"));
  232. +           VIP_NCOLOR = Integer.decode("0x" + VipSystemSettings.getProperty("VipNameColor", "0088FF"));
  233. +           ALLOW_VIP_TCOLOR = Boolean.parseBoolean(VipSystemSettings.getProperty("AllowVipTitleColor", "True"));
  234. +           VIP_TCOLOR = Integer.decode("0x" + VipSystemSettings.getProperty("VipTitleColor", "0088FF"));
  235. +           ALLOW_VIP_XPSP = Boolean.parseBoolean(VipSystemSettings.getProperty("AllowVipMulXpSp", "True"));
  236. +           VIP_XP = Integer.parseInt(VipSystemSettings.getProperty("VipMulXp", "2"));
  237. +           VIP_SP = Integer.parseInt(VipSystemSettings.getProperty("VipMulSp", "2"));
  238. +          
  239. +           /**
  240.              * Olympiad
  241.              */
  242.             Properties OlySettings = new Properties();
  243. Index: java/com/l2jhellas/gameserver/handler/admincommandhandlers/AdminVip.java
  244. ===================================================================
  245. --- java/com/l2jhellas/gameserver/handler/admincommandhandlers/AdminVip.java    (revision 0)
  246. +++ java/com/l2jhellas/gameserver/handler/admincommandhandlers/AdminVip.java    (working copy)
  247. @@ -0,0 +1,218 @@
  248. +/*
  249. + * This program is free software; you can redistribute it and/or modify
  250. + * it under the terms of the GNU General Public License as published by
  251. + * the Free Software Foundation; either version 2, or (at your option)
  252. + * any later version.
  253. + *
  254. + * This program is distributed in the hope that it will be useful,
  255. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  256. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  257. + * GNU General Public License for more details.
  258. + *
  259. + * You should have received a copy of the GNU General Public License
  260. + * along with this program; if not, write to the Free Software
  261. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  262. + * 02111-1307, USA.
  263. + *
  264. + * http://www.gnu.org/copyleft/gpl.html
  265. + */
  266. +package com.l2jhellas.gameserver.handler.admincommandhandlers;
  267. +
  268. +import java.sql.Connection;
  269. +import java.sql.PreparedStatement;
  270. +import java.util.StringTokenizer;
  271. +import java.util.logging.Level;
  272. +import java.util.logging.Logger;
  273. +
  274. +import com.l2jhellas.Config;
  275. +import com.l2jhellas.util.database.L2DatabaseFactory;
  276. +import com.l2jhellas.gameserver.datatables.xml.AdminData;
  277. +import com.l2jhellas.gameserver.handler.IAdminCommandHandler;
  278. +import com.l2jhellas.gameserver.model.L2Object;
  279. +import com.l2jhellas.gameserver.model.L2World;
  280. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  281. +import com.l2jhellas.gameserver.network.clientpackets.Say2;
  282. +import com.l2jhellas.gameserver.network.serverpackets.CreatureSay;
  283. +import com.l2jhellas.gameserver.network.serverpackets.EtcStatusUpdate;
  284. +
  285. +/**
  286. + * Give / remove vip status to player
  287. + * Changes name color and title color if enabled
  288. + *
  289. + * Uses:
  290. + * setvip [<player_name>] [<time_duration in days>]
  291. + *
  292. + * If <player_name> is not specified, the current target player is used.
  293. + *
  294. + * @author Danilo Nascimento
  295. + *
  296. + */
  297. +public class AdminVip implements IAdminCommandHandler
  298. +{
  299. +       private static String[] _adminCommands = { "admin_setvip", "admin_removevip" };
  300. +       private final static Logger _log = Logger.getLogger(AdminVip.class.getName());
  301. +
  302. +       @Override
  303. +       public boolean useAdminCommand(String command, L2PcInstance activeChar)
  304. +       {
  305. +               if (command.startsWith("admin_setvip"))
  306. +               {
  307. +                       StringTokenizer str = new StringTokenizer(command);
  308. +                      
  309. +                       L2Object target = activeChar.getTarget();
  310. +                       L2PcInstance player = null;
  311. +                      
  312. +                       if (target != null && target instanceof L2PcInstance)
  313. +                               player = (L2PcInstance)target;
  314. +                       else
  315. +                               player = activeChar;
  316. +
  317. +                       try
  318. +                       {
  319. +                               str.nextToken();
  320. +                               String time = str.nextToken();
  321. +                               if (str.hasMoreTokens())
  322. +                               {
  323. +                                       String playername = time;
  324. +                                       time = str.nextToken();
  325. +                                       player = L2World.getInstance().getPlayer(playername);
  326. +                                       doVip(activeChar, player, playername, time);
  327. +                               }
  328. +                               else
  329. +                               {
  330. +                                       String playername = player.getName();
  331. +                                       doVip(activeChar, player, playername, time);
  332. +                               }
  333. +                       }
  334. +                       catch(Exception e)
  335. +                       {
  336. +                               activeChar.sendMessage("Usage: //setvip <char_name> [time](in days)");
  337. +                       }
  338. +
  339. +                       player.broadcastUserInfo();
  340. +                      
  341. +                       if(player.isVip())
  342. +                               return true;
  343. +               }
  344. +               else if(command.startsWith("admin_removevip"))
  345. +               {
  346. +                       StringTokenizer str = new StringTokenizer(command);
  347. +                      
  348. +                       L2Object target = activeChar.getTarget();
  349. +                       L2PcInstance player = null;
  350. +                      
  351. +                       if (target instanceof L2PcInstance)
  352. +                               player = (L2PcInstance)target;
  353. +                       else
  354. +                               player = activeChar;
  355. +
  356. +                       try
  357. +                       {
  358. +                               str.nextToken();
  359. +                              
  360. +                               if (str.hasMoreTokens())
  361. +                               {
  362. +                                       String playername = str.nextToken();
  363. +                                       player = L2World.getInstance().getPlayer(playername);
  364. +                                       removeVip(activeChar, player, playername);
  365. +                               }
  366. +                               else
  367. +                               {
  368. +                                       String playername = player.getName();
  369. +                                       removeVip(activeChar, player, playername);
  370. +                               }
  371. +                       }
  372. +                       catch(Exception e)
  373. +                       {
  374. +                               activeChar.sendMessage("Usage: //removevip <char_name>");
  375. +                       }
  376. +                      
  377. +                       player.broadcastUserInfo();
  378. +                      
  379. +                       if(player.isVip())
  380. +                               return false;
  381. +               }
  382. +               return false;
  383. +       }
  384. +
  385. +       public void doVip(L2PcInstance activeChar, L2PcInstance _player, String _playername, String _time)
  386. +       {
  387. +               int days = Integer.parseInt(_time);
  388. +              
  389. +               if (_player == null)
  390. +               {
  391. +                       activeChar.sendMessage("Character not found.");
  392. +                       return;
  393. +               }
  394. +               if (_player.isVip())
  395. +               {
  396. +                       activeChar.sendMessage("Player " + _playername + " is already an VIP.");
  397. +                       return;
  398. +               }
  399. +
  400. +               if(days > 0)
  401. +               {
  402. +                       _player.setVip(true);
  403. +                       _player.setEndTime("vip", days);
  404. +                       _player.sendPacket(new CreatureSay(0,Say2.HERO_VOICE,"System","Dear player, you are now an VIP, congratulations."));
  405. +                      
  406. +                       try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  407. +                       {
  408. +                               PreparedStatement statement = con.prepareStatement("UPDATE characters SET vip=1, vip_end=? WHERE obj_id=?");
  409. +                               statement.setLong(1, _player.getVipEndTime());
  410. +                               statement.setInt(2, _player.getObjectId());
  411. +                               statement.execute();
  412. +                               statement.close();
  413. +
  414. +                               if(Config.ALLOW_VIP_NCOLOR && activeChar.isVip())
  415. +                                  _player.getAppearance().setNameColor(Config.VIP_NCOLOR);
  416. +                               if(Config.ALLOW_VIP_TCOLOR && activeChar.isVip())
  417. +                                  _player.getAppearance().setTitleColor(Config.VIP_TCOLOR);
  418. +                                
  419. +                               _player.broadcastUserInfo();
  420. +                               _player.sendPacket(new EtcStatusUpdate(_player));
  421. +                               AdminData.getInstance().broadcastMessageToGMs("GM "+ activeChar.getName()+ " set an VIP status for player "+ _playername + " for " + _time + " day(s)");
  422. +                       }
  423. +                       catch (Exception e)
  424. +                       {
  425. +                               _log.log(Level.WARNING,"Something went wrong, check log folder for details", e);
  426. +                       }
  427. +               }
  428. +       }
  429. +
  430. +       public void removeVip(L2PcInstance activeChar, L2PcInstance _player, String _playername)
  431. +       {
  432. +               if (!_player.isVip())
  433. +               {
  434. +                       activeChar.sendMessage("Player " + _playername + " is not an VIP.");
  435. +                       return;
  436. +               }
  437. +              
  438. +               _player.setVip(false);
  439. +               _player.setVipEndTime(0);
  440. +
  441. +               try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  442. +               {
  443. +                       PreparedStatement statement = con.prepareStatement("UPDATE characters SET Vip=0, Vip_end=0 WHERE obj_id=?");
  444. +                       statement.setInt(1, _player.getObjectId());
  445. +                       statement.execute();
  446. +                       statement.close();
  447. +
  448. +                      _player.getAppearance().setNameColor(0xFFFF77);
  449. +                       _player.getAppearance().setTitleColor(0xFFFF77);
  450. +                       _player.broadcastUserInfo();
  451. +                       _player.sendSkillList();
  452. +                       AdminData.getInstance().broadcastMessageToGMs("GM "+activeChar.getName()+" removed Vip status of player "+ _playername);
  453. +               }
  454. +               catch (Exception e)
  455. +               {
  456. +                       _log.log(Level.WARNING,"Something went wrong, check log folder for details", e);
  457. +               }
  458. +       }
  459. +
  460. +       @Override
  461. +       public String[] getAdminCommandList()
  462. +       {
  463. +               return _adminCommands;
  464. +       }
  465. +}
  466. \ No newline at end of file
  467. Index: java/com/l2jhellas/gameserver/handler/AdminCommandHandler.java
  468. ===================================================================
  469. --- java/com/l2jhellas/gameserver/handler/AdminCommandHandler.java  (revision 516)
  470. +++ java/com/l2jhellas/gameserver/handler/AdminCommandHandler.java  (working copy)
  471. @@ -17,6 +17,8 @@
  472.  import java.util.HashMap;
  473.  import java.util.Map;
  474.  
  475. +import com.l2jhellas.gameserver.handler.admincommandhandlers.AdminVip;
  476. +
  477.  public class AdminCommandHandler implements IHandler<IAdminCommandHandler, String>
  478.  {
  479.     private final Map<String, IAdminCommandHandler> _datatable;
  480. @@ -24,6 +26,7 @@
  481.     protected AdminCommandHandler()
  482.     {
  483.         _datatable = new HashMap<>();
  484. +       registerHandler(new AdminVip());
  485.     }
  486.    
  487.     @Override
Advertisement
Add Comment
Please, Sign In to add comment