Просмотр исходного кода

BETA: Using AntiFeedManager for L2Event also.

Nik 14 лет назад
Родитель
Сommit
01f284cbb1

+ 2 - 0
L2J_Server_BETA/java/com/l2jserver/Config.java

@@ -733,6 +733,7 @@ public final class Config
 	public static boolean L2JMOD_DEBUG_VOICE_COMMAND;
 	public static int L2JMOD_DUALBOX_CHECK_MAX_PLAYERS_PER_IP;
 	public static int L2JMOD_DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP;
+	public static int L2JMOD_DUALBOX_CHECK_MAX_L2EVENT_PARTICIPANTS_PER_IP;
 	public static TIntIntHashMap L2JMOD_DUALBOX_CHECK_WHITELIST;
 	
 	//--------------------------------------------------
@@ -2526,6 +2527,7 @@ public final class Config
 
 					L2JMOD_DUALBOX_CHECK_MAX_PLAYERS_PER_IP = Integer.parseInt(L2JModSettings.getProperty("DualboxCheckMaxPlayersPerIP", "0"));
 					L2JMOD_DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP = Integer.parseInt(L2JModSettings.getProperty("DualboxCheckMaxOlympiadParticipantsPerIP", "0"));
+					L2JMOD_DUALBOX_CHECK_MAX_L2EVENT_PARTICIPANTS_PER_IP = Integer.parseInt(L2JModSettings.getProperty("DualboxCheckMaxL2EventParticipantsPerIP", "0"));
 					String[] propertySplit = L2JModSettings.getProperty("DualboxCheckWhitelist", "127.0.0.1,0").split(";");
 					L2JMOD_DUALBOX_CHECK_WHITELIST = new TIntIntHashMap(propertySplit.length);
 					for (String entry : propertySplit)

+ 3 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/AntiFeedManager.java

@@ -31,9 +31,10 @@ public class AntiFeedManager
 	public static final int GAME_ID = 0;
 	public static final int OLYMPIAD_ID = 1;
 	public static final int TVT_ID = 2;
+	public static final int L2EVENT_ID = 3;
 
-	private Map<Integer,Long> _lastDeathTimes;
-	private TIntObjectHashMap<Map<Integer, Connections>> _eventIPs;
+	private final Map<Integer,Long> _lastDeathTimes;
+	private final TIntObjectHashMap<Map<Integer, Connections>> _eventIPs;
 
 	public static final AntiFeedManager getInstance()
 	{

+ 16 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/L2Event.java

@@ -28,9 +28,11 @@ import java.util.logging.Logger;
 import javolution.util.FastList;
 import javolution.util.FastMap;
 
+import com.l2jserver.Config;
 import com.l2jserver.gameserver.cache.HtmCache;
 import com.l2jserver.gameserver.datatables.NpcTable;
 import com.l2jserver.gameserver.datatables.SpawnTable;
+import com.l2jserver.gameserver.instancemanager.AntiFeedManager;
 import com.l2jserver.gameserver.model.L2Spawn;
 import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
@@ -250,7 +252,15 @@ public class L2Event
 			return;
 		}
 		
-		_registeredPlayers.add(player);
+		if (AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.L2EVENT_ID, player, Config.L2JMOD_DUALBOX_CHECK_MAX_L2EVENT_PARTICIPANTS_PER_IP))
+			_registeredPlayers.add(player);
+		else
+		{
+			player.sendMessage("You have reached the maximum allowed participants per IP.");
+			return;
+		}
+		
+		
 	}
 	
 	/**
@@ -344,6 +354,10 @@ public class L2Event
 					break;
 			}
 			
+			// Register the event at AntiFeedManager and clean it for just in case if the event is already registered.
+			AntiFeedManager.getInstance().registerEvent(AntiFeedManager.L2EVENT_ID);
+			AntiFeedManager.getInstance().clear(AntiFeedManager.TVT_ID);
+			
 			// Just in case
 			unspawnEventNpcs();
 			_registeredPlayers.clear();
@@ -486,6 +500,7 @@ public class L2Event
 					}
 					
 					eventState = EventState.OFF;
+					AntiFeedManager.getInstance().clear(AntiFeedManager.TVT_ID);
 					unspawnEventNpcs(); // Just in case
 					//_npcs.clear();
 					_registeredPlayers.clear();

+ 4 - 0
L2J_Server_BETA/java/config/l2jmods.properties

@@ -417,6 +417,10 @@ DualboxCheckMaxPlayersPerIP = 0
 # Default: 0 (unlimited)
 DualboxCheckMaxOlympiadParticipantsPerIP = 0
 
+# Maximum number of players per IP address allowed to participate in events using L2J Event Engine (//event).
+# Default: 0 (unlimited)
+DualboxCheckMaxL2EventParticipantsPerIP = 0
+
 # Whitelist of the addresses for dualbox checks.
 # Format: Address1,Number1;Address2,Number2...
 # Network address can be number (127.0.0.1) or symbolic (localhost) formats.