JVBarbosa

[Hellas]AioSystemCore

Jun 10th, 2016
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 27.30 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=?, aio=?, aio_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, aio, aio_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,10 @@
  19.    
  20.     private boolean _noble = false;
  21.     private boolean _hero = false;
  22. +    
  23. +   /** AIO System */
  24. +   private boolean _isAio = false;
  25. +   private long _aio_endTime = 0;
  26.        
  27.     /** Account Manager */
  28.     private String _email = null;
  29. @@ -7372,6 +7376,9 @@
  30.                     player.setAllianceWithVarkaKetra(rset.getInt("varka_ketra_ally"));
  31.                    
  32.                     player.setDeathPenaltyBuffLevel(rset.getInt("death_penalty_level"));
  33. +                    
  34. +                   player.setAio(rset.getInt("aio") == 1 ? true : false);
  35. +                   player.setAioEndTime(rset.getLong("aio_end"));
  36.                    
  37.                     player.setChatFilterCount(rset.getInt("chat_filter_count"));
  38.                     player.setHitmanTarget(rset.getInt("hitman_target"));
  39. @@ -7752,7 +7759,9 @@
  40.             statement.setInt(57, getChatFilterCount());
  41.             statement.setInt(58, getHitmanTarget());
  42.             statement.setInt(59, getEventPoints());
  43. -           statement.setInt(60, getObjectId());
  44. +           statement.setInt(60, isAio() ? 1 : 0);
  45. +           statement.setLong(61, getAioEndTime());
  46. +           statement.setInt(62, getObjectId());
  47.            
  48.             statement.execute();
  49.             statement.close();
  50. @@ -8075,7 +8084,7 @@
  51.      */
  52.     public void checkAllowedSkills()
  53.     {
  54. -       if (isGM())
  55. +       if (isGM() || isAio())
  56.             return;
  57.        
  58.         Collection<L2SkillLearn> skillTree = SkillTreeData.getInstance().getAllowedSkills(getClassId());
  59. @@ -12620,6 +12629,56 @@
  60.         }
  61.     }
  62.    
  63. +    public boolean isAio()
  64. +    {
  65. +            return _isAio;
  66. +    }
  67. +  
  68. +    public void setAio(boolean val)
  69. +    {
  70. +            _isAio = val;
  71. +    }
  72. +  
  73. +    public long getAioEndTime()
  74. +    {
  75. +            return _aio_endTime;
  76. +    }
  77. +  
  78. +    public void setAioEndTime(long val)
  79. +    {
  80. +            _aio_endTime = val;
  81. +    }
  82. +  
  83. +    public void rewardAioSkills()
  84. +    {
  85. +            L2Skill skill;
  86. +            for(Integer skillid : Config.AIO_SKILLS.keySet())
  87. +            {
  88. +                    int skilllvl = Config.AIO_SKILLS.get(skillid);
  89. +                    skill = SkillTable.getInstance().getInfo(skillid,skilllvl);
  90. +                    if(skill != null)
  91. +                    {
  92. +                            addSkill(skill, true);
  93. +                    }
  94. +            }
  95. +    }
  96. +  
  97. +    public void lostAioSkills()
  98. +    {
  99. +            for (L2Skill skill : this.getAllSkills())
  100. +                    this.removeSkill(skill);
  101. +    }
  102. +  
  103. +    public void setEndTime(String process, int val)
  104. +    {
  105. +            Calendar calendar = Calendar.getInstance();
  106. +            calendar.add(Calendar.DAY_OF_MONTH, val);
  107. +            long end_day = calendar.getTimeInMillis();
  108. +          
  109. +            if(process.equals("aio"))
  110. +                    _aio_endTime = end_day;
  111. +    }
  112. +  
  113.     public int getPowerGrade()
  114.     {
  115.         return _powerGrade;
  116. Index: java/com/l2jhellas/Config.java
  117. ===================================================================
  118. --- java/com/l2jhellas/Config.java  (revision 515)
  119. +++ java/com/l2jhellas/Config.java  (working copy)
  120. @@ -81,6 +81,7 @@
  121.     private static final String EVENT_RAID_CONFIG_FILE = "./config/Events/Raid.ini";
  122.     private static final String EVENT_WEDDING_CONFIG_FILE = "./config/Events/Wedding.ini";
  123.     // Mods Folder
  124. +   private static final String AIO_SYSTEM_CONFIG_FILE = "./config/Mods/AioSystem.ini";
  125.     private static final String MOD_CHAMPIONS_CONFIG_FILE = "./config/Mods/Champions.ini";
  126.     private static final String MOD_L2JHellas_CONFIG_FILE = "./config/Mods/L2JHellas.ini";
  127.     private static final String MOD_RANK_CONFIG_FILE = "./config/Mods/Rank PvP System.ini";
  128. @@ -347,6 +348,18 @@
  129.     public static boolean CHAMPION_ENABLE;
  130.  
  131.     /**
  132. +    * Aio System Config File
  133. +    */
  134. +   public static boolean ENABLE_AIO_SYSTEM;
  135. +   public static Map<Integer, Integer> AIO_SKILLS;
  136. +   public static boolean ALLOW_AIO_NCOLOR;
  137. +   public static int AIO_NCOLOR;
  138. +   public static boolean ALLOW_AIO_TCOLOR;
  139. +   public static int AIO_TCOLOR;
  140. +   public static boolean ALLOW_AIO_ITEM;
  141. +   public static int AIO_ITEMID;
  142. +
  143. +   /**
  144.      * PvP Config File
  145.      */
  146.     public static boolean REMOVE_BUFFS_ON_DIE;
  147. @@ -1592,6 +1605,54 @@
  148.             CHAMPION_SPCL_LVL_DIFF = Integer.parseInt(ChampionSettings.getProperty("ChampionSpecialItemLevelDiff", "0"));
  149.  
  150.             /**
  151. +            * Aio System
  152. +            */
  153. +           Properties AioSystemSettings = new Properties();
  154. +           try (InputStream is = new FileInputStream(new File(AIO_SYSTEM_CONFIG_FILE)))
  155. +           {
  156. +               AioSystemSettings.load(is);
  157. +           }
  158. +           catch (Exception e)
  159. +           {
  160. +               _log.severe(Config.class.getName() + ": Error while loading " + AIO_SYSTEM_CONFIG_FILE + " settings!");
  161. +           }
  162. +            ENABLE_AIO_SYSTEM = Boolean.parseBoolean(AioSystemSettings.getProperty("EnableAioSystem", "True"));
  163. +            ALLOW_AIO_NCOLOR = Boolean.parseBoolean(AioSystemSettings.getProperty("AllowAioNameColor", "True"));
  164. +            AIO_NCOLOR = Integer.decode("0x" + AioSystemSettings.getProperty("AioNameColor", "88AA88"));
  165. +            ALLOW_AIO_TCOLOR = Boolean.parseBoolean(AioSystemSettings.getProperty("AllowAioTitleColor", "True"));
  166. +            AIO_TCOLOR = Integer.decode("0x" + AioSystemSettings.getProperty("AioTitleColor", "88AA88"));
  167. +            AIO_ITEMID = Integer.parseInt(AioSystemSettings.getProperty("ItemIdAio", "9945"));
  168. +            ALLOW_AIO_ITEM = Boolean.parseBoolean(AioSystemSettings.getProperty("AllowAIOItem", "False"));
  169. +          
  170. +            if(ENABLE_AIO_SYSTEM) //create map if system is enabled
  171. +            {
  172. +                    String[] AioSkillsSplit = AioSystemSettings.getProperty("AioSkills", "").split(";");
  173. +                    AIO_SKILLS = new HashMap<>(AioSkillsSplit.length);
  174. +                    for (String skill : AioSkillsSplit)
  175. +                    {
  176. +                            String[] skillSplit = skill.split(",");
  177. +                            if (skillSplit.length != 2)
  178. +                            {
  179. +                                    System.out.println("[AIO System]: invalid config property in triunfo.properties -> AioSkills \"" + skill + "\"");
  180. +                            }
  181. +                            else
  182. +                            {
  183. +                                    try
  184. +                                    {
  185. +                                            AIO_SKILLS.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
  186. +                                    }
  187. +                                    catch (NumberFormatException nfe)
  188. +                                    {
  189. +                                            if (!skill.equals(""))
  190. +                                            {
  191. +                                                    System.out.println("[AIO System]: invalid config property in players.props -> AioSkills \"" + skillSplit[0] + "\"" + skillSplit[1]);
  192. +                                            }
  193. +                                    }
  194. +                            }
  195. +                    }
  196. +            }
  197. +
  198. +           /**
  199.              * PvP
  200.              */
  201.             Properties PvPSettings = new Properties();
  202. Index: java/com/l2jhellas/gameserver/network/clientpackets/EnterWorld.java
  203. ===================================================================
  204. --- java/com/l2jhellas/gameserver/network/clientpackets/EnterWorld.java (revision 515)
  205. +++ java/com/l2jhellas/gameserver/network/clientpackets/EnterWorld.java (working copy)
  206. @@ -12,8 +12,13 @@
  207.   */
  208.  package com.l2jhellas.gameserver.network.clientpackets;
  209.  
  210. +import java.util.Calendar;
  211. +import java.util.Date;
  212. +
  213. +import com.l2jhellas.Config;
  214.  import com.l2jhellas.gameserver.TaskPriority;
  215.  import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  216. +import com.l2jhellas.gameserver.network.serverpackets.CreatureSay;
  217.  
  218.  /**
  219.   * Enter World Packet Handler
  220. @@ -46,7 +51,41 @@
  221.             return;
  222.         }  
  223.         activeChar.checks();   
  224. +      
  225. +       // Aio System
  226. +       if(activeChar.isAio()) {
  227. +           onEnterAio(activeChar);
  228. +       }
  229. +              
  230. +       if(Config.ALLOW_AIO_NCOLOR && activeChar.isAio()) {
  231. +           activeChar.getAppearance().setNameColor(Config.AIO_NCOLOR);
  232. +       }
  233. +                              
  234. +       if(Config.ALLOW_AIO_TCOLOR && activeChar.isAio()) {
  235. +           activeChar.getAppearance().setTitleColor(Config.AIO_TCOLOR);
  236. +       }
  237. +      
  238.     }
  239. +    
  240. +   private static void onEnterAio(L2PcInstance activeChar) {
  241. +       long now = Calendar.getInstance().getTimeInMillis();
  242. +       long endDay = activeChar.getAioEndTime();
  243. +       if(now > endDay) {
  244. +         activeChar.setAio(false);
  245. +         activeChar.setAioEndTime(0);
  246. +         activeChar.lostAioSkills();
  247. +         if(Config.ALLOW_AIO_ITEM) {
  248. +                 activeChar.getInventory().destroyItemByItemId("", Config.AIO_ITEMID, 1, activeChar, null);
  249. +                 activeChar.getWarehouse().destroyItemByItemId("", Config.AIO_ITEMID, 1, activeChar, null);
  250. +         }
  251. +           activeChar.sendPacket(new CreatureSay(0,Say2.HERO_VOICE,"System","Your AIO period ends."));
  252. +       } else {
  253. +         Date dt = new Date(endDay);
  254. +         if(activeChar.isAio()) {
  255. +                 activeChar.sendMessage("Your AIO period ends at: " + dt);
  256. +         }
  257. +       }
  258. +   }
  259.  
  260.     @Override
  261.     public String getType()
  262. Index: java/com/l2jhellas/gameserver/handler/AdminCommandHandler.java
  263. ===================================================================
  264. --- java/com/l2jhellas/gameserver/handler/AdminCommandHandler.java  (revision 515)
  265. +++ java/com/l2jhellas/gameserver/handler/AdminCommandHandler.java  (working copy)
  266. @@ -17,6 +17,8 @@
  267.  import java.util.HashMap;
  268.  import java.util.Map;
  269.  
  270. +import com.l2jhellas.gameserver.handler.admincommandhandlers.AdminAio;
  271. +
  272.  public class AdminCommandHandler implements IHandler<IAdminCommandHandler, String>
  273.  {
  274.     private final Map<String, IAdminCommandHandler> _datatable;
  275. @@ -24,6 +26,7 @@
  276.     protected AdminCommandHandler()
  277.     {
  278.         _datatable = new HashMap<>();
  279. +       registerHandler(new AdminAio());
  280.     }
  281.    
  282.     @Override
  283. Index: config/Mods/AioSystem.ini
  284. ===================================================================
  285. --- config/Mods/AioSystem.ini   (revision 0)
  286. +++ config/Mods/AioSystem.ini   (working copy)
  287. @@ -0,0 +1,31 @@
  288. +#=============================================================
  289. +#                        AIO System
  290. +#=============================================================
  291. +EnableAioSystem = True
  292. +
  293. +# Enable / Disable Name Color
  294. +AllowAioNameColor = True
  295. +AioNameColor = FF0000
  296. +
  297. +# Enable / Disable Title Color
  298. +AllowAioTitleColor = True
  299. +AioTitleColor = FF0000
  300. +
  301. +# List of Aio Skills
  302. +# Format : skillid,skilllvl;skillid2,skilllvl2;
  303. +AioSkills = 1353,1;1329,9;4702,8;1304,3;1043,1;1259,4;4551,4;4552,4;4553,4;4554,4;1374,1;1353,3;1252,3;1085,3;1410,1;1251,2;1261,2;1305,5;1306,6;1364,1;1365,1;1415,1;1416,1;1414,1;1393,3;1392,3;1087,3;1354,1;1062,2;1005,3;1243,6;1045,6;1048,6;\
  304. +1311,6;168,3;213,8;1007,3;1309,3;1552,3;1006,3;1229,15;1308,3;1253,3;1284,3;\
  305. +1009,3;1310,4;1363,1;1362,1;1397,3;1292,6;1078,6;307,1;276,1;309,1;274,1;275,1;\
  306. +272,1;277,1;273,1;311,1;366,1;365,1;310,1;271,1;1242,3;1257,3;1353,3;1391,3;\
  307. +1352,1;229,7;228,3;1077,3;1218,33;1059,3;1219,33;1388,3;1389,3;1240,3;\
  308. +1086,2;1032,3;1073,2;1036,2;1035,4;1068,3;1003,3;1282,2;1356,1;1355,1;1357,33;\
  309. +1044,3;1182,3;1191,3;1033,3;1189,3;1259,4;1306,6;234,23;1040,3;364,1;264,1;306,1;\
  310. +269,1;270,1;265,1;363,1;349,1;308,1;305,1;304,1;267,1;266,1;268,1;1390,3;1303,2;\
  311. +1204,2;1268,4;1413,1;4699,8;4700,8;4703,8;\
  312. +
  313. +# Custom item for AIO
  314. +AllowAIOItem = True
  315. +
  316. +# ID of the item that will be given to AIO
  317. +# Default: Keshanberk*Keshanberk
  318. +ItemIdAio = 5233
  319. \ No newline at end of file
  320. Index: java/com/l2jhellas/gameserver/handler/admincommandhandlers/AdminAio.java
  321. ===================================================================
  322. --- java/com/l2jhellas/gameserver/handler/admincommandhandlers/AdminAio.java    (revision 0)
  323. +++ java/com/l2jhellas/gameserver/handler/admincommandhandlers/AdminAio.java    (working copy)
  324. @@ -0,0 +1,236 @@
  325. +/*
  326. + * This program is free software; you can redistribute it and/or modify
  327. + * it under the terms of the GNU General Public License as published by
  328. + * the Free Software Foundation; either version 2, or (at your option)
  329. + * any later version.
  330. + *
  331. + * This program is distributed in the hope that it will be useful,
  332. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  333. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  334. + * GNU General Public License for more details.
  335. + *
  336. + * You should have received a copy of the GNU General Public License
  337. + * along with this program; if not, write to the Free Software
  338. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  339. + * 02111-1307, USA.
  340. + *
  341. + * http://www.gnu.org/copyleft/gpl.html
  342. + */
  343. +package com.l2jhellas.gameserver.handler.admincommandhandlers;
  344. +
  345. +import java.sql.Connection;
  346. +import java.sql.PreparedStatement;
  347. +import java.util.StringTokenizer;
  348. +import java.util.logging.Level;
  349. +import java.util.logging.Logger;
  350. +
  351. +import com.l2jhellas.Config;
  352. +import com.l2jhellas.util.database.L2DatabaseFactory;
  353. +import com.l2jhellas.gameserver.datatables.xml.AdminData;
  354. +import com.l2jhellas.gameserver.handler.IAdminCommandHandler;
  355. +import com.l2jhellas.gameserver.model.L2Object;
  356. +import com.l2jhellas.gameserver.model.L2World;
  357. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  358. +import com.l2jhellas.gameserver.network.clientpackets.Say2;
  359. +import com.l2jhellas.gameserver.network.serverpackets.CreatureSay;
  360. +
  361. +/**
  362. + * Give / remove aio status to player
  363. + * Changes name color and title color if enabled
  364. + *
  365. + * Uses:
  366. + * setaio [<player_name>] [<time_duration in days>]
  367. + *
  368. + * If <player_name> is not specified, the current target player is used.
  369. + *
  370. + * @author Danilo Nascimento
  371. + *
  372. + */
  373. +public class AdminAio implements IAdminCommandHandler
  374. +{
  375. +       private static String[] _adminCommands = { "admin_setaio", "admin_removeaio" };
  376. +       private final static Logger _log = Logger.getLogger(AdminAio.class.getName());
  377. +
  378. +       @Override
  379. +       public boolean useAdminCommand(String command, L2PcInstance activeChar)
  380. +       {
  381. +               if (command.startsWith("admin_setaio"))
  382. +               {
  383. +                       StringTokenizer str = new StringTokenizer(command);
  384. +                      
  385. +                       L2Object target = activeChar.getTarget();
  386. +                       L2PcInstance player = null;
  387. +                      
  388. +                       if (target != null && target instanceof L2PcInstance)
  389. +                               player = (L2PcInstance)target;
  390. +                       else
  391. +                               player = activeChar;
  392. +
  393. +                       try
  394. +                       {
  395. +                               str.nextToken();
  396. +                               String time = str.nextToken();
  397. +                               if (str.hasMoreTokens())
  398. +                               {
  399. +                                       String playername = time;
  400. +                                       time = str.nextToken();
  401. +                                       player = L2World.getInstance().getPlayer(playername);
  402. +                                       doAio(activeChar, player, playername, time);
  403. +                               }
  404. +                               else
  405. +                               {
  406. +                                       String playername = player.getName();
  407. +                                       doAio(activeChar, player, playername, time);
  408. +                               }
  409. +                       }
  410. +                       catch(Exception e)
  411. +                       {
  412. +                               activeChar.sendMessage("Usage: //setaio <char_name> [time](in days)");
  413. +                       }
  414. +
  415. +                       player.broadcastUserInfo();
  416. +                      
  417. +                       if(player.isAio())
  418. +                               return true;
  419. +               }
  420. +               else if(command.startsWith("admin_removeaio"))
  421. +               {
  422. +                       StringTokenizer str = new StringTokenizer(command);
  423. +                      
  424. +                       L2Object target = activeChar.getTarget();
  425. +                       L2PcInstance player = null;
  426. +                      
  427. +                       if (target instanceof L2PcInstance)
  428. +                               player = (L2PcInstance)target;
  429. +                       else
  430. +                               player = activeChar;
  431. +
  432. +                       try
  433. +                       {
  434. +                               str.nextToken();
  435. +                              
  436. +                               if (str.hasMoreTokens())
  437. +                               {
  438. +                                       String playername = str.nextToken();
  439. +                                       player = L2World.getInstance().getPlayer(playername);
  440. +                                       removeAio(activeChar, player, playername);
  441. +                               }
  442. +                               else
  443. +                               {
  444. +                                       String playername = player.getName();
  445. +                                       removeAio(activeChar, player, playername);
  446. +                               }
  447. +                       }
  448. +                       catch(Exception e)
  449. +                       {
  450. +                               activeChar.sendMessage("Usage: //removeaio <char_name>");
  451. +                       }
  452. +                      
  453. +                       player.broadcastUserInfo();
  454. +                      
  455. +                       if(player.isAio())
  456. +                               return false;
  457. +               }
  458. +               return false;
  459. +       }
  460. +
  461. +       public void doAio(L2PcInstance activeChar, L2PcInstance _player, String _playername, String _time)
  462. +       {
  463. +               int days = Integer.parseInt(_time);
  464. +              
  465. +               if (_player == null)
  466. +               {
  467. +                       activeChar.sendMessage("Character not found.");
  468. +                       return;
  469. +               }
  470. +               if (_player.isAio())
  471. +               {
  472. +                       activeChar.sendMessage("Player " + _playername + " is already an AIO.");
  473. +                       return;
  474. +               }
  475. +
  476. +               if(days > 0)
  477. +               {
  478. +                       _player.lostAioSkills();
  479. +                       _player.setAio(true);
  480. +                       _player.setEndTime("aio", days);
  481. +                       _player.sendPacket(new CreatureSay(0,Say2.HERO_VOICE,"System","Dear player, you are now an AIO, congratulations."));
  482. +                      
  483. +                       try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  484. +                       {
  485. +                               PreparedStatement statement = con.prepareStatement("UPDATE characters SET aio=1, aio_end=? WHERE obj_id=?");
  486. +                               statement.setLong(1, _player.getAioEndTime());
  487. +                               statement.setInt(2, _player.getObjectId());
  488. +                               statement.execute();
  489. +                               statement.close();
  490. +
  491. +                               if(Config.ALLOW_AIO_NCOLOR)
  492. +                                       _player.getAppearance().setNameColor(Config.AIO_NCOLOR);
  493. +
  494. +                               if(Config.ALLOW_AIO_TCOLOR)
  495. +                                       _player.getAppearance().setTitleColor(Config.AIO_TCOLOR);
  496. +
  497. +                               _player.rewardAioSkills();
  498. +                              
  499. +                               if(Config.ALLOW_AIO_ITEM)
  500. +                               {
  501. +                                       _player.getInventory().addItem("", Config.AIO_ITEMID, 1, _player, null);
  502. +                                       _player.getInventory().equipItem(_player.getInventory().getItemByItemId(Config.AIO_ITEMID));
  503. +                                      
  504. +                               }
  505. +                               _player.broadcastUserInfo();
  506. +                               _player.sendSkillList();
  507. +                              
  508. +                               AdminData.getInstance().broadcastMessageToGMs("GM "+ activeChar.getName()+ " set an AIO status for player "+ _playername + " for " + _time + " day(s)");
  509. +                       }
  510. +                       catch (Exception e)
  511. +                       {
  512. +                               _log.log(Level.WARNING,"Something went wrong, check log folder for details", e);
  513. +                       }
  514. +               }
  515. +       }
  516. +
  517. +       public void removeAio(L2PcInstance activeChar, L2PcInstance _player, String _playername)
  518. +       {
  519. +               if (!_player.isAio())
  520. +               {
  521. +                       activeChar.sendMessage("Player " + _playername + " is not an AIO.");
  522. +                       return;
  523. +               }
  524. +              
  525. +               _player.setAio(false);
  526. +               _player.setAioEndTime(0);
  527. +
  528. +               try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  529. +               {
  530. +                       PreparedStatement statement = con.prepareStatement("UPDATE characters SET Aio=0, Aio_end=0 WHERE obj_id=?");
  531. +                       statement.setInt(1, _player.getObjectId());
  532. +                       statement.execute();
  533. +                       statement.close();
  534. +
  535. +                       _player.lostAioSkills();
  536. +                      
  537. +                       if(Config.ALLOW_AIO_ITEM)
  538. +                       {
  539. +                               _player.getInventory().destroyItemByItemId("", Config.AIO_ITEMID, 1, _player, null);
  540. +                               _player.getWarehouse().destroyItemByItemId("", Config.AIO_ITEMID, 1, _player, null);
  541. +                       }
  542. +                       _player.getAppearance().setNameColor(0xFFFF77);
  543. +                       _player.getAppearance().setTitleColor(0xFFFF77);
  544. +                       _player.broadcastUserInfo();
  545. +                       _player.sendSkillList();
  546. +                      
  547. +                       AdminData.getInstance().broadcastMessageToGMs("GM "+activeChar.getName()+" removed Aio status of player "+ _playername);
  548. +               }
  549. +               catch (Exception e)
  550. +               {
  551. +                       _log.log(Level.WARNING,"Something went wrong, check log folder for details", e);
  552. +               }
  553. +       }
  554. +
  555. +       @Override
  556. +       public String[] getAdminCommandList()
  557. +       {
  558. +               return _adminCommands;
  559. +       }
  560. +}
Advertisement
Add Comment
Please, Sign In to add comment