Addition of player action flood protector.
This commit is contained in:
@@ -127,13 +127,6 @@ FloodProtectorCharacterSelectPunishmentLimit = 0
|
||||
FloodProtectorCharacterSelectPunishmentType = none
|
||||
FloodProtectorCharacterSelectPunishmentTime = 0
|
||||
|
||||
# PacketUnknown - attempts to send unknown packets
|
||||
FloodProtectorUnknownPacketsInterval = 5
|
||||
FloodProtectorUnknownPacketsLogFlooding = False
|
||||
FloodProtectorUnknownPacketsPunishmentLimit = 3
|
||||
FloodProtectorUnknownPacketsPunishmentType = kick
|
||||
FloodProtectorUnknownPacketsPunishmentTime = 0
|
||||
|
||||
# Party Invitation - attempts to invite into party
|
||||
FloodProtectorPartyInvitationInterval = 5
|
||||
FloodProtectorPartyInvitationLogFlooding = False
|
||||
@@ -155,16 +148,16 @@ FloodProtectorMoveActionPunishmentLimit = 0
|
||||
FloodProtectorMoveActionPunishmentType = none
|
||||
FloodProtectorMoveActionPunishmentTime = 0
|
||||
|
||||
# Generic Action
|
||||
FloodProtectorGenericActionInterval = 5
|
||||
FloodProtectorGenericActionLogFlooding = false
|
||||
FloodProtectorGenericActionPunishmentLimit = 0
|
||||
FloodProtectorGenericActionPunishmentType = none
|
||||
FloodProtectorGenericActionPunishmentTime = 0
|
||||
|
||||
# Macro - attempts to Macro system
|
||||
FloodProtectorMacroInterval = 8
|
||||
FloodProtectorMacroLogFlooding = True
|
||||
FloodProtectorMacroPunishmentLimit = 6
|
||||
FloodProtectorMacroPunishmentType = kick
|
||||
FloodProtectorMacroPunishmentTime = 0
|
||||
FloodProtectorMacroPunishmentTime = 0
|
||||
|
||||
# Player Action - Next Target, Attack, etc
|
||||
FloodProtectorPlayerActionInterval = 3
|
||||
FloodProtectorPlayerActionLogFlooding = False
|
||||
FloodProtectorPlayerActionPunishmentLimit = 0
|
||||
FloodProtectorPlayerActionPunishmentType = none
|
||||
FloodProtectorPlayerActionPunishmentTime = 0
|
||||
|
@@ -813,13 +813,12 @@ public class Config
|
||||
public static FloodProtectorConfig FLOOD_PROTECTOR_MANUFACTURE;
|
||||
public static FloodProtectorConfig FLOOD_PROTECTOR_MANOR;
|
||||
public static FloodProtectorConfig FLOOD_PROTECTOR_CHARACTER_SELECT;
|
||||
public static FloodProtectorConfig FLOOD_PROTECTOR_UNKNOWN_PACKETS;
|
||||
public static FloodProtectorConfig FLOOD_PROTECTOR_PARTY_INVITATION;
|
||||
public static FloodProtectorConfig FLOOD_PROTECTOR_SAY_ACTION;
|
||||
public static FloodProtectorConfig FLOOD_PROTECTOR_MOVE_ACTION;
|
||||
public static FloodProtectorConfig FLOOD_PROTECTOR_GENERIC_ACTION;
|
||||
public static FloodProtectorConfig FLOOD_PROTECTOR_MACRO;
|
||||
public static FloodProtectorConfig FLOOD_PROTECTOR_POTION;
|
||||
public static FloodProtectorConfig FLOOD_PROTECTOR_PLAYER_ACTION;
|
||||
|
||||
public static boolean CHECK_SKILLS_ON_ENTER;
|
||||
public static boolean CHECK_NAME_ON_LOGIN;
|
||||
@@ -2276,13 +2275,12 @@ public class Config
|
||||
FLOOD_PROTECTOR_MANUFACTURE = new FloodProtectorConfig("ManufactureFloodProtector");
|
||||
FLOOD_PROTECTOR_MANOR = new FloodProtectorConfig("ManorFloodProtector");
|
||||
FLOOD_PROTECTOR_CHARACTER_SELECT = new FloodProtectorConfig("CharacterSelectFloodProtector");
|
||||
FLOOD_PROTECTOR_UNKNOWN_PACKETS = new FloodProtectorConfig("UnknownPacketsFloodProtector");
|
||||
FLOOD_PROTECTOR_PARTY_INVITATION = new FloodProtectorConfig("PartyInvitationFloodProtector");
|
||||
FLOOD_PROTECTOR_SAY_ACTION = new FloodProtectorConfig("SayActionFloodProtector");
|
||||
FLOOD_PROTECTOR_MOVE_ACTION = new FloodProtectorConfig("MoveActionFloodProtector");
|
||||
FLOOD_PROTECTOR_GENERIC_ACTION = new FloodProtectorConfig("GenericActionFloodProtector", true);
|
||||
FLOOD_PROTECTOR_MACRO = new FloodProtectorConfig("MacroFloodProtector", true);
|
||||
FLOOD_PROTECTOR_POTION = new FloodProtectorConfig("PotionFloodProtector", true);
|
||||
FLOOD_PROTECTOR_MACRO = new FloodProtectorConfig("MacroFloodProtector");
|
||||
FLOOD_PROTECTOR_POTION = new FloodProtectorConfig("PotionFloodProtector");
|
||||
FLOOD_PROTECTOR_PLAYER_ACTION = new FloodProtectorConfig("PlayerActionFloodProtector");
|
||||
|
||||
final PropertiesParser floodProtectConfig = new PropertiesParser(PROTECT_FLOOD_CONFIG_FILE);
|
||||
loadFloodProtectorConfigs(floodProtectConfig);
|
||||
@@ -2295,9 +2293,9 @@ public class Config
|
||||
* @param configString flood protector configuration string that determines for which flood protector configuration should be read
|
||||
* @param defaultInterval default flood protector interval
|
||||
*/
|
||||
private static void loadFloodProtectorConfig(PropertiesParser properties, FloodProtectorConfig config, String configString, float defaultInterval)
|
||||
private static void loadFloodProtectorConfig(PropertiesParser properties, FloodProtectorConfig config, String configString, int defaultInterval)
|
||||
{
|
||||
config.FLOOD_PROTECTION_INTERVAL = properties.getFloat(StringUtil.concat("FloodProtector", configString, "Interval"), defaultInterval);
|
||||
config.FLOOD_PROTECTION_INTERVAL = properties.getInt(StringUtil.concat("FloodProtector", configString, "Interval"), defaultInterval);
|
||||
config.LOG_FLOODING = properties.getBoolean(StringUtil.concat("FloodProtector", configString, "LogFlooding"), false);
|
||||
config.PUNISHMENT_LIMIT = properties.getInt(StringUtil.concat("FloodProtector", configString, "PunishmentLimit"), 0);
|
||||
config.PUNISHMENT_TYPE = properties.getString(StringUtil.concat("FloodProtector", configString, "PunishmentType"), "none");
|
||||
@@ -2889,13 +2887,12 @@ public class Config
|
||||
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_MANUFACTURE, "Manufacture", 3);
|
||||
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_MANOR, "Manor", 30);
|
||||
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_CHARACTER_SELECT, "CharacterSelect", 30);
|
||||
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_UNKNOWN_PACKETS, "UnknownPackets", 5);
|
||||
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_PARTY_INVITATION, "PartyInvitation", 30);
|
||||
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_SAY_ACTION, "SayAction", 100);
|
||||
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_MOVE_ACTION, "MoveAction", 30);
|
||||
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_GENERIC_ACTION, "GenericAction", 5);
|
||||
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_MACRO, "Macro", 10);
|
||||
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_POTION, "Potion", 4);
|
||||
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_PLAYER_ACTION, "PlayerAction", 3);
|
||||
}
|
||||
|
||||
public static void load(ServerMode serverMode)
|
||||
|
@@ -390,7 +390,6 @@ public class PlayerInstance extends Playable
|
||||
private boolean _dietMode = false; // ignore weight penalty
|
||||
private boolean _exchangeRefusal = false; // Exchange refusal
|
||||
private Party _party;
|
||||
private long _lastAttackPacket = 0;
|
||||
private PlayerInstance _activeRequester;
|
||||
private long _requestExpireTime = 0;
|
||||
private final Request _request = new Request(this);
|
||||
@@ -15538,16 +15537,6 @@ public class PlayerInstance extends Playable
|
||||
return this;
|
||||
}
|
||||
|
||||
public long getLastAttackPacket()
|
||||
{
|
||||
return _lastAttackPacket;
|
||||
}
|
||||
|
||||
public void setLastAttackPacket()
|
||||
{
|
||||
_lastAttackPacket = Chronos.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void checkItemRestriction()
|
||||
{
|
||||
for (int i = 0; i < Inventory.PAPERDOLL_TOTALSLOTS; i++)
|
||||
|
@@ -50,6 +50,11 @@ public class Action implements IClientIncomingPacket
|
||||
@Override
|
||||
public void run(GameClient client)
|
||||
{
|
||||
if (!client.getFloodProtectors().getPlayerAction().tryPerformAction("PlayerAction"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the current PlayerInstance of the player
|
||||
final PlayerInstance player = client.getPlayer();
|
||||
if (player == null)
|
||||
|
@@ -17,7 +17,6 @@
|
||||
package org.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.commons.util.Chronos;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
@@ -25,13 +24,16 @@ import org.l2jmobius.gameserver.model.actor.instance.SummonInstance;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class AttackRequest implements IClientIncomingPacket
|
||||
{
|
||||
private int _objectId;
|
||||
@SuppressWarnings("unused")
|
||||
private int _originX;
|
||||
@SuppressWarnings("unused")
|
||||
private int _originY;
|
||||
@SuppressWarnings("unused")
|
||||
private int _originZ;
|
||||
@SuppressWarnings("unused")
|
||||
private int _attackId;
|
||||
|
||||
@Override
|
||||
@@ -41,26 +43,24 @@ public class AttackRequest implements IClientIncomingPacket
|
||||
_originX = packet.readD();
|
||||
_originY = packet.readD();
|
||||
_originZ = packet.readD();
|
||||
_attackId = packet.readC(); // 0 for simple click - 1 for shift-click
|
||||
_attackId = packet.readC(); // 0 for simple click 1 for shift-click
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(GameClient client)
|
||||
{
|
||||
if (!client.getFloodProtectors().getPlayerAction().tryPerformAction("PlayerAction"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final PlayerInstance player = client.getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((Chronos.currentTimeMillis() - player.getLastAttackPacket()) < 500)
|
||||
{
|
||||
player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
player.setLastAttackPacket();
|
||||
|
||||
// avoid using expensive operations if not needed
|
||||
final WorldObject target;
|
||||
if (player.getTargetId() == _objectId)
|
||||
|
@@ -16,13 +16,11 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.util.StringUtil;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance.PunishLevel;
|
||||
import org.l2jmobius.gameserver.network.ConnectionState;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
@@ -41,15 +39,15 @@ public class FloodProtectorAction
|
||||
/**
|
||||
* Client for this instance of flood protector.
|
||||
*/
|
||||
private final GameClient client;
|
||||
private final GameClient _client;
|
||||
/**
|
||||
* Configuration of this instance of flood protector.
|
||||
*/
|
||||
private final FloodProtectorConfig config;
|
||||
private final FloodProtectorConfig _config;
|
||||
/**
|
||||
* Next game tick when new request is allowed.
|
||||
*/
|
||||
private volatile float _nextGameTick = GameTimeTaskManager.getGameTicks();
|
||||
private volatile int _nextGameTick = GameTimeTaskManager.getGameTicks();
|
||||
/**
|
||||
* Request counter.
|
||||
*/
|
||||
@@ -62,25 +60,19 @@ public class FloodProtectorAction
|
||||
* Flag determining whether punishment application is in progress so that we do not apply punisment multiple times (flooding).
|
||||
*/
|
||||
private volatile boolean _punishmentInProgress;
|
||||
/**
|
||||
* Count from when the floodProtector start to block next action.
|
||||
*/
|
||||
private final int _untilBlock = 4;
|
||||
|
||||
/**
|
||||
* Creates new instance of FloodProtectorAction.
|
||||
* @param client for which flood protection is being created
|
||||
* @param client the game client for which flood protection is being created
|
||||
* @param config flood protector configuration
|
||||
*/
|
||||
public FloodProtectorAction(GameClient client, FloodProtectorConfig config)
|
||||
{
|
||||
super();
|
||||
this.client = client;
|
||||
this.config = config;
|
||||
_client = client;
|
||||
_config = config;
|
||||
}
|
||||
|
||||
private final Map<String, AtomicInteger> received_commands_actions = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Checks whether the request is flood protected or not.
|
||||
* @param command command issued or short command description
|
||||
@@ -88,135 +80,51 @@ public class FloodProtectorAction
|
||||
*/
|
||||
public boolean tryPerformAction(String command)
|
||||
{
|
||||
// Ignore flood protector for GM char
|
||||
if ((client != null) && (client.getPlayer() != null) && client.getPlayer().isGM())
|
||||
if ((_client.getPlayer() != null) && _client.getPlayer().isGM())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!config.ALTERNATIVE_METHOD)
|
||||
{
|
||||
final int curTick = GameTimeTaskManager.getGameTicks();
|
||||
if ((curTick < _nextGameTick) || _punishmentInProgress)
|
||||
{
|
||||
if (config.LOG_FLOODING && !_logged)
|
||||
{
|
||||
LOGGER.warning(" called command " + command + " ~ " + ((config.FLOOD_PROTECTION_INTERVAL - (_nextGameTick - curTick)) * GameTimeTaskManager.MILLIS_IN_TICK) + " ms after previous command");
|
||||
_logged = true;
|
||||
}
|
||||
|
||||
_count.incrementAndGet();
|
||||
|
||||
if (!_punishmentInProgress && (config.PUNISHMENT_LIMIT > 0) && (_count.get() >= config.PUNISHMENT_LIMIT) && (config.PUNISHMENT_TYPE != null))
|
||||
{
|
||||
_punishmentInProgress = true;
|
||||
if ("kick".equals(config.PUNISHMENT_TYPE))
|
||||
{
|
||||
kickPlayer();
|
||||
}
|
||||
else if ("ban".equals(config.PUNISHMENT_TYPE))
|
||||
{
|
||||
banAccount();
|
||||
}
|
||||
else if ("jail".equals(config.PUNISHMENT_TYPE))
|
||||
{
|
||||
jailChar();
|
||||
}
|
||||
else if ("banchat".equals(config.PUNISHMENT_TYPE))
|
||||
{
|
||||
banChat();
|
||||
}
|
||||
|
||||
_punishmentInProgress = false;
|
||||
}
|
||||
|
||||
// Avoid macro issue
|
||||
if ((config.FLOOD_PROTECTOR_TYPE.equals("UseItemFloodProtector")) || (config.FLOOD_PROTECTOR_TYPE.equals("ServerBypassFloodProtector")))
|
||||
{
|
||||
// _untilBlock value is 4
|
||||
if (_count.get() > _untilBlock)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((_count.get() > 0) && config.LOG_FLOODING)
|
||||
{
|
||||
LOGGER(" issued ", String.valueOf(_count), " extra requests within ~", String.valueOf(config.FLOOD_PROTECTION_INTERVAL * GameTimeTaskManager.MILLIS_IN_TICK), " ms");
|
||||
}
|
||||
|
||||
_nextGameTick = curTick + config.FLOOD_PROTECTION_INTERVAL;
|
||||
_logged = false;
|
||||
_count.set(0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
final int curTick = GameTimeTaskManager.getGameTicks();
|
||||
if ((curTick < _nextGameTick) || _punishmentInProgress)
|
||||
{
|
||||
if (config.LOG_FLOODING && !_logged)
|
||||
if (_config.LOG_FLOODING && !_logged && LOGGER.isLoggable(Level.WARNING))
|
||||
{
|
||||
LOGGER.warning(" called command " + command + " ~ " + ((config.FLOOD_PROTECTION_INTERVAL - (_nextGameTick - curTick)) * GameTimeTaskManager.MILLIS_IN_TICK) + " ms after previous command");
|
||||
log(" called command ", command, " ~", String.valueOf((_config.FLOOD_PROTECTION_INTERVAL - (_nextGameTick - curTick)) * GameTimeTaskManager.MILLIS_IN_TICK), " ms after previous command");
|
||||
_logged = true;
|
||||
}
|
||||
|
||||
AtomicInteger commandCount = received_commands_actions.get(command);
|
||||
if (commandCount == null)
|
||||
{
|
||||
commandCount = new AtomicInteger(0);
|
||||
}
|
||||
_count.incrementAndGet();
|
||||
|
||||
final int count = commandCount.incrementAndGet();
|
||||
received_commands_actions.put(command, commandCount);
|
||||
|
||||
if (!_punishmentInProgress && (config.PUNISHMENT_LIMIT > 0) && (count >= config.PUNISHMENT_LIMIT) && (config.PUNISHMENT_TYPE != null))
|
||||
if (!_punishmentInProgress && (_config.PUNISHMENT_LIMIT > 0) && (_count.get() >= _config.PUNISHMENT_LIMIT) && (_config.PUNISHMENT_TYPE != null))
|
||||
{
|
||||
_punishmentInProgress = true;
|
||||
if ("kick".equals(config.PUNISHMENT_TYPE))
|
||||
if ("kick".equals(_config.PUNISHMENT_TYPE))
|
||||
{
|
||||
kickPlayer();
|
||||
}
|
||||
else if ("ban".equals(config.PUNISHMENT_TYPE))
|
||||
else if ("ban".equals(_config.PUNISHMENT_TYPE))
|
||||
{
|
||||
banAccount();
|
||||
}
|
||||
else if ("jail".equals(config.PUNISHMENT_TYPE))
|
||||
else if ("jail".equals(_config.PUNISHMENT_TYPE))
|
||||
{
|
||||
jailChar();
|
||||
}
|
||||
|
||||
_punishmentInProgress = false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
AtomicInteger commandCount = received_commands_actions.get(command);
|
||||
if (commandCount == null)
|
||||
if ((_count.get() > 0) && _config.LOG_FLOODING && LOGGER.isLoggable(Level.WARNING))
|
||||
{
|
||||
commandCount = new AtomicInteger(0);
|
||||
received_commands_actions.put(command, commandCount);
|
||||
log(" issued ", String.valueOf(_count), " extra requests within ~", String.valueOf(_config.FLOOD_PROTECTION_INTERVAL * GameTimeTaskManager.MILLIS_IN_TICK), " ms");
|
||||
}
|
||||
|
||||
if (commandCount.get() > 0)
|
||||
{
|
||||
if (config.LOG_FLOODING)
|
||||
{
|
||||
LOGGER.warning(" issued " + commandCount + " extra requests within ~ " + (config.FLOOD_PROTECTION_INTERVAL * GameTimeTaskManager.MILLIS_IN_TICK) + " ms");
|
||||
}
|
||||
}
|
||||
|
||||
_nextGameTick = curTick + config.FLOOD_PROTECTION_INTERVAL;
|
||||
_nextGameTick = curTick + _config.FLOOD_PROTECTION_INTERVAL;
|
||||
_logged = false;
|
||||
commandCount.set(0);
|
||||
received_commands_actions.put(command, commandCount);
|
||||
|
||||
_count.set(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -225,40 +133,18 @@ public class FloodProtectorAction
|
||||
*/
|
||||
private void kickPlayer()
|
||||
{
|
||||
if (client.getPlayer() != null)
|
||||
if (_client.getPlayer() != null)
|
||||
{
|
||||
client.getPlayer().logout();
|
||||
_client.getPlayer().logout();
|
||||
}
|
||||
else
|
||||
{
|
||||
client.closeNow();
|
||||
_client.closeNow();
|
||||
}
|
||||
|
||||
LOGGER("Client " + client + " kicked for flooding");
|
||||
}
|
||||
|
||||
/**
|
||||
* Kick player from game (close network connection).
|
||||
*/
|
||||
private void banChat()
|
||||
{
|
||||
if (client.getPlayer() != null)
|
||||
if (LOGGER.isLoggable(Level.WARNING))
|
||||
{
|
||||
final PlayerInstance player = client.getPlayer();
|
||||
long newChatBanTime = 60000; // 1 minute
|
||||
if (player.getPunishLevel() == PunishLevel.CHAT)
|
||||
{
|
||||
if (player.getPunishTimer() <= (60000 * 3)) // if less then 3 minutes (MAX CHAT BAN TIME), add 1 minute
|
||||
{
|
||||
newChatBanTime += player.getPunishTimer();
|
||||
}
|
||||
else
|
||||
{
|
||||
newChatBanTime = player.getPunishTimer();
|
||||
}
|
||||
}
|
||||
|
||||
player.setPunishLevel(PunishLevel.CHAT, newChatBanTime);
|
||||
log("kicked for flooding");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,16 +153,14 @@ public class FloodProtectorAction
|
||||
*/
|
||||
private void banAccount()
|
||||
{
|
||||
if (client.getPlayer() != null)
|
||||
if (_client.getPlayer() != null)
|
||||
{
|
||||
client.getPlayer().setPunishLevel(PunishLevel.ACC, config.PUNISHMENT_TIME);
|
||||
|
||||
LOGGER(client.getPlayer().getName() + " banned for flooding");
|
||||
client.getPlayer().logout();
|
||||
_client.getPlayer().setPunishLevel(PunishLevel.ACC, _config.PUNISHMENT_TIME);
|
||||
_client.getPlayer().logout();
|
||||
}
|
||||
else
|
||||
if (LOGGER.isLoggable(Level.WARNING))
|
||||
{
|
||||
LOGGER(" unable to ban account: no active player");
|
||||
log(" banned for flooding ", _config.PUNISHMENT_TIME <= 0 ? "forever" : "for " + (_config.PUNISHMENT_TIME / 60000) + " mins");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,27 +169,30 @@ public class FloodProtectorAction
|
||||
*/
|
||||
private void jailChar()
|
||||
{
|
||||
if (client.getPlayer() != null)
|
||||
if (_client.getPlayer() == null)
|
||||
{
|
||||
client.getPlayer().setPunishLevel(PunishLevel.JAIL, config.PUNISHMENT_TIME);
|
||||
|
||||
LOGGER.warning(client.getPlayer().getName() + " jailed for flooding");
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
_client.getPlayer().setPunishLevel(PunishLevel.JAIL, _config.PUNISHMENT_TIME);
|
||||
|
||||
if (LOGGER.isLoggable(Level.WARNING))
|
||||
{
|
||||
LOGGER(" unable to jail: no active player");
|
||||
log(" jailed for flooding ", _config.PUNISHMENT_TIME <= 0 ? "forever" : "for " + (_config.PUNISHMENT_TIME / 60000) + " mins");
|
||||
}
|
||||
}
|
||||
|
||||
private void LOGGER(String... lines)
|
||||
private void log(String... lines)
|
||||
{
|
||||
final StringBuilder output = StringUtil.startAppend(100, config.FLOOD_PROTECTOR_TYPE, ": ");
|
||||
final StringBuilder output = new StringBuilder(100);
|
||||
output.append(_config.FLOOD_PROTECTOR_TYPE);
|
||||
output.append(": ");
|
||||
String address = null;
|
||||
try
|
||||
{
|
||||
if (!client.isDetached())
|
||||
if (!_client.isDetached())
|
||||
{
|
||||
address = client.getConnectionAddress().getHostAddress();
|
||||
address = _client.getConnectionAddress().getHostAddress();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -313,24 +200,27 @@ public class FloodProtectorAction
|
||||
// Ignore.
|
||||
}
|
||||
|
||||
final ConnectionState state = (ConnectionState) client.getConnectionState();
|
||||
final ConnectionState state = (ConnectionState) _client.getConnectionState();
|
||||
switch (state)
|
||||
{
|
||||
case ENTERING:
|
||||
case IN_GAME:
|
||||
{
|
||||
if (client.getPlayer() != null)
|
||||
if (_client.getPlayer() != null)
|
||||
{
|
||||
StringUtil.append(output, client.getPlayer().getName());
|
||||
StringUtil.append(output, "(", String.valueOf(client.getPlayer().getObjectId()), ") ");
|
||||
output.append(_client.getPlayer().getName());
|
||||
output.append("(");
|
||||
output.append(_client.getPlayer().getObjectId());
|
||||
output.append(") ");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AUTHENTICATED:
|
||||
{
|
||||
if (client.getAccountName() != null)
|
||||
if (_client.getAccountName() != null)
|
||||
{
|
||||
StringUtil.append(output, client.getAccountName(), " ");
|
||||
output.append(_client.getAccountName());
|
||||
output.append(" ");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -338,7 +228,7 @@ public class FloodProtectorAction
|
||||
{
|
||||
if (address != null)
|
||||
{
|
||||
StringUtil.append(output, address);
|
||||
output.append(address);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -348,7 +238,8 @@ public class FloodProtectorAction
|
||||
}
|
||||
}
|
||||
|
||||
StringUtil.append(output, lines);
|
||||
Arrays.stream(lines).forEach(output::append);
|
||||
|
||||
LOGGER.warning(output.toString());
|
||||
}
|
||||
}
|
@@ -29,7 +29,7 @@ public class FloodProtectorConfig
|
||||
/**
|
||||
* Flood protection interval in game ticks.
|
||||
*/
|
||||
public float FLOOD_PROTECTION_INTERVAL;
|
||||
public int FLOOD_PROTECTION_INTERVAL;
|
||||
/**
|
||||
* Whether flooding should be logged.
|
||||
*/
|
||||
@@ -45,12 +45,7 @@ public class FloodProtectorConfig
|
||||
/**
|
||||
* For how long should the char/account be punished.
|
||||
*/
|
||||
public int PUNISHMENT_TIME;
|
||||
|
||||
/**
|
||||
* Alternative flood protection method: check if in given FLOOD_PROTECTION_INTERVAL more then PUNISHMENT_LIMIT actions are performed: if this condition has been verified apply PUNISHMENT_TYPE for PUNISHMENT_TIME minutes
|
||||
*/
|
||||
public boolean ALTERNATIVE_METHOD;
|
||||
public long PUNISHMENT_TIME;
|
||||
|
||||
/**
|
||||
* Creates new instance of FloodProtectorConfig.
|
||||
@@ -60,18 +55,5 @@ public class FloodProtectorConfig
|
||||
{
|
||||
super();
|
||||
FLOOD_PROTECTOR_TYPE = floodProtectorType;
|
||||
ALTERNATIVE_METHOD = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new instance of FloodProtectorConfig.
|
||||
* @param floodProtectorType {@link #FLOOD_PROTECTOR_TYPE}
|
||||
* @param altFunc
|
||||
*/
|
||||
public FloodProtectorConfig(String floodProtectorType, boolean altFunc)
|
||||
{
|
||||
super();
|
||||
FLOOD_PROTECTOR_TYPE = floodProtectorType;
|
||||
ALTERNATIVE_METHOD = altFunc;
|
||||
}
|
||||
}
|
||||
|
@@ -89,10 +89,6 @@ public class FloodProtectors
|
||||
* Character Select protector
|
||||
*/
|
||||
private final FloodProtectorAction _characterSelect;
|
||||
/**
|
||||
* Unknown Packets protector
|
||||
*/
|
||||
private final FloodProtectorAction _unknownPackets;
|
||||
/**
|
||||
* Party Invitation flood protector.
|
||||
*/
|
||||
@@ -105,10 +101,6 @@ public class FloodProtectors
|
||||
* Move Action protector
|
||||
*/
|
||||
private final FloodProtectorAction _moveAction;
|
||||
/**
|
||||
* Generic Action protector
|
||||
*/
|
||||
private final FloodProtectorAction _genericAction;
|
||||
/**
|
||||
* Macro protector
|
||||
*/
|
||||
@@ -117,10 +109,14 @@ public class FloodProtectors
|
||||
* Potion protector
|
||||
*/
|
||||
private final FloodProtectorAction _potion;
|
||||
/**
|
||||
* Player Action
|
||||
*/
|
||||
private final FloodProtectorAction _playerAction;
|
||||
|
||||
/**
|
||||
* Creates new instance of FloodProtectors.
|
||||
* @param client for which the collection of flood protectors is being created.
|
||||
* @param client game client for which the collection of flood protectors is being created.
|
||||
*/
|
||||
public FloodProtectors(GameClient client)
|
||||
{
|
||||
@@ -141,13 +137,12 @@ public class FloodProtectors
|
||||
_manufacture = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_MANUFACTURE);
|
||||
_manor = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_MANOR);
|
||||
_characterSelect = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_CHARACTER_SELECT);
|
||||
_unknownPackets = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_UNKNOWN_PACKETS);
|
||||
_partyInvitation = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_PARTY_INVITATION);
|
||||
_sayAction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_SAY_ACTION);
|
||||
_moveAction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_MOVE_ACTION);
|
||||
_genericAction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_GENERIC_ACTION);
|
||||
_macro = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_MACRO);
|
||||
_potion = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_POTION);
|
||||
_playerAction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_PLAYER_ACTION);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -290,15 +285,6 @@ public class FloodProtectors
|
||||
return _characterSelect;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@link #_unknownPackets}.
|
||||
* @return {@link #_unknownPackets}
|
||||
*/
|
||||
public FloodProtectorAction getUnknownPackets()
|
||||
{
|
||||
return _unknownPackets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@link #_partyInvitation}.
|
||||
* @return {@link #_partyInvitation}
|
||||
@@ -326,15 +312,6 @@ public class FloodProtectors
|
||||
return _moveAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@link #_genericAction}.
|
||||
* @return {@link #_genericAction}
|
||||
*/
|
||||
public FloodProtectorAction getGenericAction()
|
||||
{
|
||||
return _genericAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@link #_macro}.
|
||||
* @return {@link #_macro}
|
||||
@@ -352,4 +329,13 @@ public class FloodProtectors
|
||||
{
|
||||
return _potion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@link #_playerAction}.
|
||||
* @return {@link #_playerAction}
|
||||
*/
|
||||
public FloodProtectorAction getPlayerAction()
|
||||
{
|
||||
return _playerAction;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user