Noticias:

No tienes permiso para ver los enlaces. Para poder verlos Registrate o Conectate.

Menú Principal

Anti AFK (By LeaveBuster)

Iniciado por Swarlog, Jun 25, 2025, 09:00 PM

Tema anterior - Siguiente tema

Swarlog

### Eclipse Workspace Patch 1.0
#P L2jFrozen_GameServer
Index: head-src/com/l2jfrozen/Config.java
===================================================================
--- head-src/com/l2jfrozen/Config.java	(revision 1004)
+++ head-src/com/l2jfrozen/Config.java	(working copy)
@@ -3418,6 +3418,9 @@
 	public static int ALLOWED_BOXES;
 	public static boolean ALLOW_DUALBOX_OLY;
 	public static boolean ALLOW_DUALBOX_EVENT;
+	
+	public static int LEAVEBURSTER_TIME_KICK;
+
 	//============================================================
 	public static void loadPOtherConfig()
 	{
@@ -3453,6 +3456,8 @@
 			BOT_PROTECTOR_FIRST_CHECK = Integer.parseInt(POtherSetting.getProperty("BotProtectFirstCheck", "15"));
 			BOT_PROTECTOR_NEXT_CHECK = Integer.parseInt(POtherSetting.getProperty("BotProtectNextCheck", "60"));
 			BOT_PROTECTOR_WAIT_ANSVER = Integer.parseInt(POtherSetting.getProperty("BotProtectAnsver", "180"));
+			
+			LEAVEBURSTER_TIME_KICK = Integer.parseInt(POtherSetting.getProperty("LeaveBursterTimeKick", "10"));
 		}
 		catch(Exception e)
 		{
Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestRestartPoint.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestRestartPoint.java	(revision 1004)
+++ head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestRestartPoint.java	(working copy)
@@ -230,6 +230,8 @@
 		if (activeChar == null)
 			return;
 		
+		activeChar.setLastActionMillis(System.currentTimeMillis());
+		
 		if (activeChar.isFakeDeath())
 		{
 			activeChar.stopFakeDeath(null);
Index: head-src/com/l2jfrozen/gameserver/model/entity/LeaveBuster.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/model/entity/LeaveBuster.java	(revision 0)
+++ head-src/com/l2jfrozen/gameserver/model/entity/LeaveBuster.java	(working copy)
@@ -0,0 +1,66 @@
+/* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package com.l2jfrozen.gameserver.model.entity;
+
+import java.util.concurrent.ScheduledFuture;
+import java.util.logging.Logger;
+
+import javolution.util.FastMap;
+
+import com.l2jfrozen.Config;
+import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ * @author Anarchy
+ */
+public class LeaveBuster implements Runnable
+{
+	public static FastMap<L2PcInstance, ScheduledFuture<?>> _players = new FastMap<L2PcInstance, ScheduledFuture<?>>();
+	
+	private static final Logger _log = Logger.getLogger(LeaveBuster.class.getName());
+	
+	private L2PcInstance _p = null;
+	
+	public LeaveBuster(L2PcInstance p)
+	{
+		_p = p;
+	}
+	
+	@Override
+	public void run()
+	{
+		if (_p == null || _p.isOnline() == 0)
+		{
+			if (_p != null)
+			{
+				_players.get(_p).cancel(true);
+				_players.remove(_p);
+			}
+			
+			return;
+		}
+		
+		if ((System.currentTimeMillis() - _p.getLastActionMillis()) / 1000 / 60 >= Config.LEAVEBURSTER_TIME_KICK)
+		{
+			_log.info("Leave Buster: " + _p.getName() + " was kicked out of game.");
+			_players.get(_p).cancel(true);
+			_players.remove(_p);
+			_p.logout();
+		}
+	}
+}
Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/Say2.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/network/clientpackets/Say2.java	(revision 1004)
+++ head-src/com/l2jfrozen/gameserver/network/clientpackets/Say2.java	(working copy)
@@ -170,6 +170,8 @@
 			_type = PETITION_GM;
 		}
 
+		activeChar.setLastActionMillis(System.currentTimeMillis());
+		
 		if(_text.length() > Config.MAX_CHAT_LENGTH)
 		{
 			if(Config.DEBUG)
Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestRestart.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestRestart.java	(revision 1004)
+++ head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestRestart.java	(working copy)
@@ -27,6 +27,7 @@
 import com.l2jfrozen.gameserver.model.Inventory;
 import com.l2jfrozen.gameserver.model.L2Party;
 import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jfrozen.gameserver.model.entity.LeaveBuster;
 import com.l2jfrozen.gameserver.model.entity.olympiad.Olympiad;
 import com.l2jfrozen.gameserver.model.entity.sevensigns.SevenSignsFestival;
 import com.l2jfrozen.gameserver.network.L2GameClient;
@@ -60,6 +61,8 @@
 			return;
 		}
 
+        player.setLastActionMillis(System.currentTimeMillis());
+
 		// Check if player is enchanting
 		if(player.getActiveEnchantItem() != null)
 		{
@@ -165,6 +168,9 @@
 		{
 			player.removeSkill(SkillTable.getInstance().getInfo(4289, 1));
 		}
+        
+        LeaveBuster._players.get(player).cancel(true);
+        LeaveBuster._players.remove(player);
 		
 		if(player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND)!=null
 				&& player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).isAugmented()){
Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/TradeRequest.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/network/clientpackets/TradeRequest.java	(revision 1004)
+++ head-src/com/l2jfrozen/gameserver/network/clientpackets/TradeRequest.java	(working copy)
@@ -49,7 +49,9 @@
 		if (player == null)
 			return;
 		
-		if (!player.getAccessLevel().allowTransaction())
+        player.setLastActionMillis(System.currentTimeMillis());
+
+        if (!player.getAccessLevel().allowTransaction())
 		{
 			player.sendMessage("Transactions are disable for your Access Level");
 			player.sendPacket(ActionFailed.STATIC_PACKET);
Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/MoveBackwardToLocation.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/network/clientpackets/MoveBackwardToLocation.java	(revision 1004)
+++ head-src/com/l2jfrozen/gameserver/network/clientpackets/MoveBackwardToLocation.java	(working copy)
@@ -76,6 +76,8 @@
 		if (activeChar == null)
 			return;
 		
+		activeChar.setLastActionMillis(System.currentTimeMillis());
+		
 		// Move flood protection
 		if (!getClient().getFloodProtectors().getMoveAction().tryPerformAction("MoveBackwardToLocation"))
 		{
Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/Logout.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/network/clientpackets/Logout.java	(revision 1004)
+++ head-src/com/l2jfrozen/gameserver/network/clientpackets/Logout.java	(working copy)
@@ -22,6 +22,7 @@
 import com.l2jfrozen.gameserver.model.L2Character;
 import com.l2jfrozen.gameserver.model.L2Party;
 import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jfrozen.gameserver.model.entity.LeaveBuster;
 import com.l2jfrozen.gameserver.model.entity.olympiad.Olympiad;
 import com.l2jfrozen.gameserver.model.entity.sevensigns.SevenSignsFestival;
 import com.l2jfrozen.gameserver.network.SystemMessageId;
@@ -47,6 +48,8 @@
 		if (player == null)
 			return;
 		
+		player.setLastActionMillis(System.currentTimeMillis());
+		
 		if (player.isInFunEvent() && !player.isGM())
 		{
 			player.sendMessage("You cannot Logout while in registered in an Event.");
@@ -118,6 +121,9 @@
 		if (player.isFlying())
 			player.removeSkill(SkillTable.getInstance().getInfo(4289, 1));
 		
+		LeaveBuster._players.get(player).cancel(true);
+        LeaveBuster._players.remove(player);
+		
 		if (Config.OFFLINE_LOGOUT && player.isSitting())
 		{
 			if ((player.isInStoreMode() && Config.OFFLINE_TRADE_ENABLE) || (player.isInCraftMode() && Config.OFFLINE_CRAFT_ENABLE))
Index: config/protected/other.properties
===================================================================
--- config/protected/other.properties	(revision 1004)
+++ config/protected/other.properties	(working copy)
@@ -60,4 +60,7 @@
 # The time interval, which will take place from the previous question until the next (minutes).
 BotProtectNextCheck = 60
 # Amount of time allowed for giving the answer (seconds).
-BotProtectAnsver = 200
\ No newline at end of file
+BotProtectAnsver = 200
+
+# Time to kick afkers. Default = 0 (Disabled)
+LeaveBursterTimeKick = 10
\ No newline at end of file
Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/UseItem.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/network/clientpackets/UseItem.java	(revision 1004)
+++ head-src/com/l2jfrozen/gameserver/network/clientpackets/UseItem.java	(working copy)
@@ -64,6 +64,8 @@
 		if (activeChar == null)
 			return;
 		
+		activeChar.setLastActionMillis(System.currentTimeMillis());
+		
 		L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);
 		
 		if (item == null)
Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java	(revision 1004)
+++ head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java	(working copy)
@@ -56,6 +56,7 @@
 import com.l2jfrozen.gameserver.model.entity.Announcements;
 import com.l2jfrozen.gameserver.model.entity.ClanHall;
 import com.l2jfrozen.gameserver.model.entity.Hero;
+import com.l2jfrozen.gameserver.model.entity.LeaveBuster;
 import com.l2jfrozen.gameserver.model.entity.Wedding;
 import com.l2jfrozen.gameserver.model.entity.event.CTF;
 import com.l2jfrozen.gameserver.model.entity.event.DM;
@@ -133,6 +134,9 @@
 		// Set lock at login
 		activeChar.setLocked(true);
 
+		activeChar.setLastActionMillis(System.currentTimeMillis());
+		LeaveBuster._players.put(activeChar, ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new LeaveBuster(activeChar), 5000, 5000));
+
 		// Register in flood protector
 		//FloodProtector.getInstance().registerNewPlayer(activeChar.getObjectId());
 
Index: head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java	(revision 1004)
+++ head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -455,6 +455,8 @@
 	/** The active_boxes_characters. */
 	public List<String> active_boxes_characters = new ArrayList<String>();
 	
+	private long _lastAction = 0;
+	
 	/** 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=?. */
 	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=?";
 
@@ -19299,6 +19301,16 @@
 		}
 		*/
 	}
+
+	public long getLastActionMillis()
+	{
+		return _lastAction;
+	}
+	
+	public void setLastActionMillis(long val)
+	{
+		_lastAction = val;
+	}
 	   
    	/**
    	 * Aio System Start.
@@ -20376,5 +20388,4 @@
 
         _currentPetSkill = new SkillDat(currentSkill, ctrlPressed, shiftPressed);
     }
-    
 }
\ No newline at end of file
Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestSocialAction.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestSocialAction.java	(revision 1004)
+++ head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestSocialAction.java	(working copy)
@@ -45,6 +45,8 @@
 		L2PcInstance activeChar = getClient().getActiveChar();
 		if(activeChar == null)
 			return;
+		
+		activeChar.setLastActionMillis(System.currentTimeMillis());
 
 		// You cannot do anything else while fishing
 		if(activeChar.isFishing())

Créditos: Anarchy