Advertisement
LIONN

LeaveBurster for L2jFrozen

Jul 24th, 2013
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 13.66 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2jFrozen_GameServer
  3. Index: head-src/com/l2jfrozen/Config.java
  4. ===================================================================
  5. --- head-src/com/l2jfrozen/Config.java  (revision 1004)
  6. +++ head-src/com/l2jfrozen/Config.java  (working copy)
  7. @@ -3418,6 +3418,9 @@
  8.     public static int ALLOWED_BOXES;
  9.     public static boolean ALLOW_DUALBOX_OLY;
  10.     public static boolean ALLOW_DUALBOX_EVENT;
  11. +  
  12. +   public static int LEAVEBURSTER_TIME_KICK;
  13. +
  14.     //============================================================
  15.     public static void loadPOtherConfig()
  16.     {
  17. @@ -3453,6 +3456,8 @@
  18.             BOT_PROTECTOR_FIRST_CHECK = Integer.parseInt(POtherSetting.getProperty("BotProtectFirstCheck", "15"));
  19.             BOT_PROTECTOR_NEXT_CHECK = Integer.parseInt(POtherSetting.getProperty("BotProtectNextCheck", "60"));
  20.             BOT_PROTECTOR_WAIT_ANSVER = Integer.parseInt(POtherSetting.getProperty("BotProtectAnsver", "180"));
  21. +          
  22. +           LEAVEBURSTER_TIME_KICK = Integer.parseInt(POtherSetting.getProperty("LeaveBursterTimeKick", "10"));
  23.         }
  24.         catch(Exception e)
  25.         {
  26. Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestRestartPoint.java
  27. ===================================================================
  28. --- head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestRestartPoint.java    (revision 1004)
  29. +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestRestartPoint.java    (working copy)
  30. @@ -230,6 +230,8 @@
  31.         if (activeChar == null)
  32.             return;
  33.        
  34. +       activeChar.setLastActionMillis(System.currentTimeMillis());
  35. +      
  36.         if (activeChar.isFakeDeath())
  37.         {
  38.             activeChar.stopFakeDeath(null);
  39. Index: head-src/com/l2jfrozen/gameserver/model/entity/LeaveBuster.java
  40. ===================================================================
  41. --- head-src/com/l2jfrozen/gameserver/model/entity/LeaveBuster.java (revision 0)
  42. +++ head-src/com/l2jfrozen/gameserver/model/entity/LeaveBuster.java (working copy)
  43. @@ -0,0 +1,66 @@
  44. +/* This program is free software; you can redistribute it and/or modify
  45. + * it under the terms of the GNU General Public License as published by
  46. + * the Free Software Foundation; either version 2, or (at your option)
  47. + * any later version.
  48. + *
  49. + * This program is distributed in the hope that it will be useful,
  50. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  51. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  52. + * GNU General Public License for more details.
  53. + *
  54. + * You should have received a copy of the GNU General Public License
  55. + * along with this program; if not, write to the Free Software
  56. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  57. + * 02111-1307, USA.
  58. + *
  59. + * http://www.gnu.org/copyleft/gpl.html
  60. + */
  61. +package com.l2jfrozen.gameserver.model.entity;
  62. +
  63. +import java.util.concurrent.ScheduledFuture;
  64. +import java.util.logging.Logger;
  65. +
  66. +import javolution.util.FastMap;
  67. +
  68. +import com.l2jfrozen.Config;
  69. +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  70. +
  71. +/**
  72. + * @author Anarchy
  73. + */
  74. +public class LeaveBuster implements Runnable
  75. +{
  76. +   public static FastMap<L2PcInstance, ScheduledFuture<?>> _players = new FastMap<L2PcInstance, ScheduledFuture<?>>();
  77. +  
  78. +   private static final Logger _log = Logger.getLogger(LeaveBuster.class.getName());
  79. +  
  80. +   private L2PcInstance _p = null;
  81. +  
  82. +   public LeaveBuster(L2PcInstance p)
  83. +   {
  84. +       _p = p;
  85. +   }
  86. +  
  87. +   @Override
  88. +   public void run()
  89. +   {
  90. +       if (_p == null || _p.isOnline() == 0)
  91. +       {
  92. +           if (_p != null)
  93. +           {
  94. +               _players.get(_p).cancel(true);
  95. +               _players.remove(_p);
  96. +           }
  97. +          
  98. +           return;
  99. +       }
  100. +      
  101. +       if ((System.currentTimeMillis() - _p.getLastActionMillis()) / 1000 / 60 >= Config.LEAVEBURSTER_TIME_KICK)
  102. +       {
  103. +           _log.info("Leave Buster: " + _p.getName() + " was kicked out of game.");
  104. +           _players.get(_p).cancel(true);
  105. +           _players.remove(_p);
  106. +           _p.logout();
  107. +       }
  108. +   }
  109. +}
  110. Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/Say2.java
  111. ===================================================================
  112. --- head-src/com/l2jfrozen/gameserver/network/clientpackets/Say2.java   (revision 1004)
  113. +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/Say2.java   (working copy)
  114. @@ -170,6 +170,8 @@
  115.             _type = PETITION_GM;
  116.         }
  117.  
  118. +       activeChar.setLastActionMillis(System.currentTimeMillis());
  119. +      
  120.         if(_text.length() > Config.MAX_CHAT_LENGTH)
  121.         {
  122.             if(Config.DEBUG)
  123. Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestRestart.java
  124. ===================================================================
  125. --- head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestRestart.java (revision 1004)
  126. +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestRestart.java (working copy)
  127. @@ -27,6 +27,7 @@
  128.  import com.l2jfrozen.gameserver.model.Inventory;
  129.  import com.l2jfrozen.gameserver.model.L2Party;
  130.  import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  131. +import com.l2jfrozen.gameserver.model.entity.LeaveBuster;
  132.  import com.l2jfrozen.gameserver.model.entity.olympiad.Olympiad;
  133.  import com.l2jfrozen.gameserver.model.entity.sevensigns.SevenSignsFestival;
  134.  import com.l2jfrozen.gameserver.network.L2GameClient;
  135. @@ -60,6 +61,8 @@
  136.             return;
  137.         }
  138.  
  139. +        player.setLastActionMillis(System.currentTimeMillis());
  140. +
  141.         // Check if player is enchanting
  142.         if(player.getActiveEnchantItem() != null)
  143.         {
  144. @@ -165,6 +168,9 @@
  145.         {
  146.             player.removeSkill(SkillTable.getInstance().getInfo(4289, 1));
  147.         }
  148. +        
  149. +        LeaveBuster._players.get(player).cancel(true);
  150. +        LeaveBuster._players.remove(player);
  151.        
  152.         if(player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND)!=null
  153.                 && player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).isAugmented()){
  154. Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/TradeRequest.java
  155. ===================================================================
  156. --- head-src/com/l2jfrozen/gameserver/network/clientpackets/TradeRequest.java   (revision 1004)
  157. +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/TradeRequest.java   (working copy)
  158. @@ -49,7 +49,9 @@
  159.         if (player == null)
  160.             return;
  161.        
  162. -       if (!player.getAccessLevel().allowTransaction())
  163. +        player.setLastActionMillis(System.currentTimeMillis());
  164. +
  165. +        if (!player.getAccessLevel().allowTransaction())
  166.         {
  167.             player.sendMessage("Transactions are disable for your Access Level");
  168.             player.sendPacket(ActionFailed.STATIC_PACKET);
  169. Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/MoveBackwardToLocation.java
  170. ===================================================================
  171. --- head-src/com/l2jfrozen/gameserver/network/clientpackets/MoveBackwardToLocation.java (revision 1004)
  172. +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/MoveBackwardToLocation.java (working copy)
  173. @@ -76,6 +76,8 @@
  174.         if (activeChar == null)
  175.             return;
  176.        
  177. +       activeChar.setLastActionMillis(System.currentTimeMillis());
  178. +      
  179.         // Move flood protection
  180.         if (!getClient().getFloodProtectors().getMoveAction().tryPerformAction("MoveBackwardToLocation"))
  181.         {
  182. Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/Logout.java
  183. ===================================================================
  184. --- head-src/com/l2jfrozen/gameserver/network/clientpackets/Logout.java (revision 1004)
  185. +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/Logout.java (working copy)
  186. @@ -22,6 +22,7 @@
  187.  import com.l2jfrozen.gameserver.model.L2Character;
  188.  import com.l2jfrozen.gameserver.model.L2Party;
  189.  import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  190. +import com.l2jfrozen.gameserver.model.entity.LeaveBuster;
  191.  import com.l2jfrozen.gameserver.model.entity.olympiad.Olympiad;
  192.  import com.l2jfrozen.gameserver.model.entity.sevensigns.SevenSignsFestival;
  193.  import com.l2jfrozen.gameserver.network.SystemMessageId;
  194. @@ -47,6 +48,8 @@
  195.         if (player == null)
  196.             return;
  197.        
  198. +       player.setLastActionMillis(System.currentTimeMillis());
  199. +      
  200.         if (player.isInFunEvent() && !player.isGM())
  201.         {
  202.             player.sendMessage("You cannot Logout while in registered in an Event.");
  203. @@ -118,6 +121,9 @@
  204.         if (player.isFlying())
  205.             player.removeSkill(SkillTable.getInstance().getInfo(4289, 1));
  206.        
  207. +       LeaveBuster._players.get(player).cancel(true);
  208. +        LeaveBuster._players.remove(player);
  209. +      
  210.         if (Config.OFFLINE_LOGOUT && player.isSitting())
  211.         {
  212.             if ((player.isInStoreMode() && Config.OFFLINE_TRADE_ENABLE) || (player.isInCraftMode() && Config.OFFLINE_CRAFT_ENABLE))
  213. Index: config/protected/other.properties
  214. ===================================================================
  215. --- config/protected/other.properties   (revision 1004)
  216. +++ config/protected/other.properties   (working copy)
  217. @@ -60,4 +60,7 @@
  218.  # The time interval, which will take place from the previous question until the next (minutes).
  219.  BotProtectNextCheck = 60
  220.  # Amount of time allowed for giving the answer (seconds).
  221. -BotProtectAnsver = 200
  222. \ No newline at end of file
  223. +BotProtectAnsver = 200
  224. +
  225. +# Time to kick afkers. Default = 0 (Disabled)
  226. +LeaveBursterTimeKick = 10
  227. \ No newline at end of file
  228. Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/UseItem.java
  229. ===================================================================
  230. --- head-src/com/l2jfrozen/gameserver/network/clientpackets/UseItem.java    (revision 1004)
  231. +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/UseItem.java    (working copy)
  232. @@ -64,6 +64,8 @@
  233.         if (activeChar == null)
  234.             return;
  235.        
  236. +       activeChar.setLastActionMillis(System.currentTimeMillis());
  237. +      
  238.         L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);
  239.        
  240.         if (item == null)
  241. Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java
  242. ===================================================================
  243. --- head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java (revision 1004)
  244. +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java (working copy)
  245. @@ -56,6 +56,7 @@
  246.  import com.l2jfrozen.gameserver.model.entity.Announcements;
  247.  import com.l2jfrozen.gameserver.model.entity.ClanHall;
  248.  import com.l2jfrozen.gameserver.model.entity.Hero;
  249. +import com.l2jfrozen.gameserver.model.entity.LeaveBuster;
  250.  import com.l2jfrozen.gameserver.model.entity.Wedding;
  251.  import com.l2jfrozen.gameserver.model.entity.event.CTF;
  252.  import com.l2jfrozen.gameserver.model.entity.event.DM;
  253. @@ -133,6 +134,9 @@
  254.         // Set lock at login
  255.         activeChar.setLocked(true);
  256.  
  257. +       activeChar.setLastActionMillis(System.currentTimeMillis());
  258. +       LeaveBuster._players.put(activeChar, ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new LeaveBuster(activeChar), 5000, 5000));
  259. +
  260.         // Register in flood protector
  261.         //FloodProtector.getInstance().registerNewPlayer(activeChar.getObjectId());
  262.  
  263. Index: head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java
  264. ===================================================================
  265. --- head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java    (revision 1004)
  266. +++ head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java    (working copy)
  267. @@ -455,6 +455,8 @@
  268.     /** The active_boxes_characters. */
  269.     public List<String> active_boxes_characters = new ArrayList<String>();
  270.    
  271. +   private long _lastAction = 0;
  272. +  
  273.     /** 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=?,good=?,evil=?,gve_kills=? WHERE obj_id=?. */
  274.     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=?,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=?,pc_point=?,name_color=?,title_color=?,aio=?,aio_end=? WHERE obj_id=?";
  275.  
  276. @@ -19299,6 +19301,16 @@
  277.         }
  278.         */
  279.     }
  280. +
  281. +   public long getLastActionMillis()
  282. +   {
  283. +       return _lastAction;
  284. +   }
  285. +  
  286. +   public void setLastActionMillis(long val)
  287. +   {
  288. +       _lastAction = val;
  289. +   }
  290.        
  291.         /**
  292.          * Aio System Start.
  293. @@ -20376,5 +20388,4 @@
  294.  
  295.          _currentPetSkill = new SkillDat(currentSkill, ctrlPressed, shiftPressed);
  296.      }
  297. -    
  298.  }
  299. \ No newline at end of file
  300. Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestSocialAction.java
  301. ===================================================================
  302. --- head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestSocialAction.java    (revision 1004)
  303. +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestSocialAction.java    (working copy)
  304. @@ -45,6 +45,8 @@
  305.         L2PcInstance activeChar = getClient().getActiveChar();
  306.         if(activeChar == null)
  307.             return;
  308. +      
  309. +       activeChar.setLastActionMillis(System.currentTimeMillis());
  310.  
  311.         // You cannot do anything else while fishing
  312.         if(activeChar.isFishing())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement