Selaa lähdekoodia

Add 'kick' action to floodprotector for simple kicking player from game.

_DS_ 16 vuotta sitten
vanhempi
sitoutus
f2a451808d

+ 1 - 1
L2_GameServer/java/config/floodprotector.properties

@@ -21,7 +21,7 @@ FloodProtectorUseItemLogFlooding = False
 # specified number then specified punishment is applied
 # (0 - disables punishment feature)
 FloodProtectorUseItemPunishmentLimit = 0
-# PunishmentType - type of the punishment ('none', 'ban', 'jail')
+# PunishmentType - type of the punishment ('none', 'kick', 'ban', 'jail')
 # valid only if PunishmentLimit is greater than zero
 FloodProtectorUseItemPunishmentType = none
 # PunishmentTime - for how many minutes should be the player/account punished,

+ 19 - 2
L2_GameServer/java/net/sf/l2j/gameserver/util/FloodProtectorAction.java

@@ -99,7 +99,11 @@ public final class FloodProtectorAction
 			{
 				_punishmentInProgress = true;
 				
-				if ("ban".equals(_config.PUNISHMENT_TYPE))
+				if ("kick".equals(_config.PUNISHMENT_TYPE))
+				{
+					kickPlayer();
+				}
+				else if ("ban".equals(_config.PUNISHMENT_TYPE))
 				{
 					banAccount();
 				}
@@ -129,7 +133,20 @@ public final class FloodProtectorAction
 		
 		return true;
 	}
-	
+
+	/**
+	 * Kick player from game (close network connection).
+	 */
+	private void kickPlayer()
+	{
+		_player.closeNetConnection();
+
+		if (_log.isLoggable(Level.WARNING))
+		{
+			_log.warning(StringUtil.concat(_config.FLOOD_PROTECTOR_TYPE, ": Account [", _player.getAccountName(), "] kicked for flooding [char ", _player.getName(), "]"));
+		}
+	}
+
 	/**
 	 * Bans char account and logs out the char.
 	 */

+ 1 - 1
L2_GameServer/java/net/sf/l2j/gameserver/util/FloodProtectorConfig.java

@@ -37,7 +37,7 @@ public final class FloodProtectorConfig
 	 */
 	public int PUNISHMENT_LIMIT;
 	/**
-	 * Punishment type. Either 'none', 'ban' or 'jail'.
+	 * Punishment type. Either 'none', 'kick', 'ban' or 'jail'.
 	 */
 	public String PUNISHMENT_TYPE;
 	/**