Addition of player action flood protector.

This commit is contained in:
MobiusDevelopment 2021-11-08 15:52:50 +00:00
parent 1c6d57c355
commit 259fa858f6
214 changed files with 1376 additions and 3796 deletions

View File

@ -121,3 +121,10 @@ FloodProtectorItemAuctionLogFlooding = False
FloodProtectorItemAuctionPunishmentLimit = 0
FloodProtectorItemAuctionPunishmentType = none
FloodProtectorItemAuctionPunishmentTime = 0
# Player Action - Next Target, Attack, etc
FloodProtectorPlayerActionInterval = 3
FloodProtectorPlayerActionLogFlooding = False
FloodProtectorPlayerActionPunishmentLimit = 0
FloodProtectorPlayerActionPunishmentType = none
FloodProtectorPlayerActionPunishmentTime = 0

View File

@ -613,6 +613,7 @@ public class Config
public static FloodProtectorConfig FLOOD_PROTECTOR_SENDMAIL;
public static FloodProtectorConfig FLOOD_PROTECTOR_CHARACTER_SELECT;
public static FloodProtectorConfig FLOOD_PROTECTOR_ITEM_AUCTION;
public static FloodProtectorConfig FLOOD_PROTECTOR_PLAYER_ACTION;
// --------------------------------------------------
// NPC Settings
@ -1359,6 +1360,7 @@ public class Config
FLOOD_PROTECTOR_SENDMAIL = new FloodProtectorConfig("SendMailFloodProtector");
FLOOD_PROTECTOR_CHARACTER_SELECT = new FloodProtectorConfig("CharacterSelectFloodProtector");
FLOOD_PROTECTOR_ITEM_AUCTION = new FloodProtectorConfig("ItemAuctionFloodProtector");
FLOOD_PROTECTOR_PLAYER_ACTION = new FloodProtectorConfig("PlayerActionFloodProtector");
final PropertiesParser serverSettings = new PropertiesParser(SERVER_CONFIG_FILE);
GAMESERVER_HOSTNAME = serverSettings.getString("GameserverHostname", "0.0.0.0");
@ -3678,6 +3680,7 @@ public class Config
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_SENDMAIL, "SendMail", 100);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_CHARACTER_SELECT, "CharacterSelect", 30);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_ITEM_AUCTION, "ItemAuction", 9);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_PLAYER_ACTION, "PlayerAction", 3);
}
/**

View File

@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs
public enum IncomingPackets implements IIncomingPackets<GameClient>
{
LOGOUT(0x00, Logout::new, ConnectionState.AUTHENTICATED, ConnectionState.IN_GAME),
ATTACK(0x01, Attack::new, ConnectionState.IN_GAME),
ATTACK(0x01, AttackRequest::new, ConnectionState.IN_GAME),
REQUEST_START_PLEDGE_WAR(0x03, RequestStartPledgeWar::new, ConnectionState.IN_GAME),
REQUEST_REPLY_START_PLEDGE(0x04, RequestReplyStartPledgeWar::new, ConnectionState.IN_GAME),
REQUEST_STOP_PLEDGE_WAR(0x05, RequestStopPledgeWar::new, ConnectionState.IN_GAME),

View File

@ -54,6 +54,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)

View File

@ -1,139 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.enums.PrivateStoreType;
import org.l2jmobius.gameserver.model.PlayerCondOverride;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.effects.AbstractEffect;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
/**
* TODO: This class is a copy of AttackRequest, we should get proper structure for both.
*/
public class Attack implements IClientIncomingPacket
{
// cddddc
private int _objectId;
@SuppressWarnings("unused")
private int _originX;
@SuppressWarnings("unused")
private int _originY;
@SuppressWarnings("unused")
private int _originZ;
@SuppressWarnings("unused")
private int _attackId;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_objectId = packet.readD();
_originX = packet.readD();
_originY = packet.readD();
_originZ = packet.readD();
_attackId = packet.readC(); // 0 for simple click 1 for shift-click
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
// Avoid Attacks in Boat.
if (player.isPlayable() && player.isInBoat())
{
player.sendPacket(SystemMessageId.THIS_IS_NOT_ALLOWED_WHILE_RIDING_A_FERRY_OR_BOAT);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final BuffInfo info = player.getEffectList().getFirstBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
if (info != null)
{
for (AbstractEffect effect : info.getEffects())
{
if (!effect.checkCondition(-1))
{
player.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REPORTED_AS_AN_ILLEGAL_PROGRAM_USER_SO_YOUR_ACTIONS_HAVE_BEEN_RESTRICTED);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
}
}
// avoid using expensive operations if not needed
final WorldObject target;
if (player.getTargetId() == _objectId)
{
target = player.getTarget();
}
else
{
target = World.getInstance().findObject(_objectId);
}
if (target == null)
{
return;
}
if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Players can't attack objects in the other instances
else if (target.getInstanceWorld() != player.getInstanceWorld())
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Only GMs can directly attack invisible characters
else if (!target.isVisibleFor(player))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
player.onActionRequest();
if (player.getTarget() != target)
{
target.onAction(player);
}
else if ((target.getObjectId() != player.getObjectId()) && (player.getPrivateStoreType() == PrivateStoreType.NONE) && (player.getActiveRequester() == null))
{
target.onForcedAttack(player);
}
else
{
player.sendPacket(ActionFailed.STATIC_PACKET);
}
}
}

View File

@ -56,12 +56,25 @@ public class AttackRequest implements IClientIncomingPacket
@Override
public void run(GameClient client)
{
if (!client.getFloodProtectors().getPlayerAction().tryPerformAction("PlayerAction"))
{
return;
}
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
// Avoid Attacks in Boat.
if (player.isPlayable() && player.isInBoat())
{
player.sendPacket(SystemMessageId.THIS_IS_NOT_ALLOWED_WHILE_RIDING_A_FERRY_OR_BOAT);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final BuffInfo info = player.getEffectList().getFirstBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
if (info != null)
{
@ -92,7 +105,8 @@ public class AttackRequest implements IClientIncomingPacket
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
else if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
@ -110,6 +124,8 @@ public class AttackRequest implements IClientIncomingPacket
return;
}
player.onActionRequest();
if (player.getTarget() != target)
{
target.onAction(player);

View File

@ -87,12 +87,12 @@ public class FloodProtectorAction
*/
public boolean tryPerformAction(String command)
{
final int curTick = GameTimeTaskManager.getInstance().getGameTicks();
if ((_client.getPlayer() != null) && _client.getPlayer().canOverrideCond(PlayerCondOverride.FLOOD_CONDITIONS))
{
return true;
}
final int curTick = GameTimeTaskManager.getInstance().getGameTicks();
if ((curTick < _nextGameTick) || _punishmentInProgress)
{
if (_config.LOG_FLOODING && !_logged && LOGGER.isLoggable(Level.WARNING))

View File

@ -89,6 +89,10 @@ public class FloodProtectors
* Item Auction
*/
private final FloodProtectorAction _itemAuction;
/**
* Player Action
*/
private final FloodProtectorAction _playerAction;
/**
* Creates new instance of FloodProtectors.
@ -113,6 +117,7 @@ public class FloodProtectors
_sendMail = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_SENDMAIL);
_characterSelect = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_CHARACTER_SELECT);
_itemAuction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_ITEM_AUCTION);
_playerAction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_PLAYER_ACTION);
}
/**
@ -257,4 +262,13 @@ public class FloodProtectors
{
return _itemAuction;
}
/**
* Returns {@link #_playerAction}.
* @return {@link #_playerAction}
*/
public FloodProtectorAction getPlayerAction()
{
return _playerAction;
}
}

View File

@ -121,3 +121,10 @@ FloodProtectorItemAuctionLogFlooding = False
FloodProtectorItemAuctionPunishmentLimit = 0
FloodProtectorItemAuctionPunishmentType = none
FloodProtectorItemAuctionPunishmentTime = 0
# Player Action - Next Target, Attack, etc
FloodProtectorPlayerActionInterval = 3
FloodProtectorPlayerActionLogFlooding = False
FloodProtectorPlayerActionPunishmentLimit = 0
FloodProtectorPlayerActionPunishmentType = none
FloodProtectorPlayerActionPunishmentTime = 0

View File

@ -623,6 +623,7 @@ public class Config
public static FloodProtectorConfig FLOOD_PROTECTOR_SENDMAIL;
public static FloodProtectorConfig FLOOD_PROTECTOR_CHARACTER_SELECT;
public static FloodProtectorConfig FLOOD_PROTECTOR_ITEM_AUCTION;
public static FloodProtectorConfig FLOOD_PROTECTOR_PLAYER_ACTION;
// --------------------------------------------------
// NPC Settings
@ -1370,6 +1371,7 @@ public class Config
FLOOD_PROTECTOR_SENDMAIL = new FloodProtectorConfig("SendMailFloodProtector");
FLOOD_PROTECTOR_CHARACTER_SELECT = new FloodProtectorConfig("CharacterSelectFloodProtector");
FLOOD_PROTECTOR_ITEM_AUCTION = new FloodProtectorConfig("ItemAuctionFloodProtector");
FLOOD_PROTECTOR_PLAYER_ACTION = new FloodProtectorConfig("PlayerActionFloodProtector");
final PropertiesParser serverSettings = new PropertiesParser(SERVER_CONFIG_FILE);
GAMESERVER_HOSTNAME = serverSettings.getString("GameserverHostname", "0.0.0.0");
@ -3701,6 +3703,7 @@ public class Config
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_SENDMAIL, "SendMail", 100);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_CHARACTER_SELECT, "CharacterSelect", 30);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_ITEM_AUCTION, "ItemAuction", 9);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_PLAYER_ACTION, "PlayerAction", 3);
}
/**

View File

@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs
public enum IncomingPackets implements IIncomingPackets<GameClient>
{
LOGOUT(0x00, Logout::new, ConnectionState.AUTHENTICATED, ConnectionState.IN_GAME),
ATTACK(0x01, Attack::new, ConnectionState.IN_GAME),
ATTACK(0x01, AttackRequest::new, ConnectionState.IN_GAME),
REQUEST_START_PLEDGE_WAR(0x03, RequestStartPledgeWar::new, ConnectionState.IN_GAME),
REQUEST_REPLY_START_PLEDGE(0x04, RequestReplyStartPledgeWar::new, ConnectionState.IN_GAME),
REQUEST_STOP_PLEDGE_WAR(0x05, RequestStopPledgeWar::new, ConnectionState.IN_GAME),

View File

@ -54,6 +54,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)

View File

@ -1,139 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.enums.PrivateStoreType;
import org.l2jmobius.gameserver.model.PlayerCondOverride;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.effects.AbstractEffect;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
/**
* TODO: This class is a copy of AttackRequest, we should get proper structure for both.
*/
public class Attack implements IClientIncomingPacket
{
// cddddc
private int _objectId;
@SuppressWarnings("unused")
private int _originX;
@SuppressWarnings("unused")
private int _originY;
@SuppressWarnings("unused")
private int _originZ;
@SuppressWarnings("unused")
private int _attackId;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_objectId = packet.readD();
_originX = packet.readD();
_originY = packet.readD();
_originZ = packet.readD();
_attackId = packet.readC(); // 0 for simple click 1 for shift-click
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
// Avoid Attacks in Boat.
if (player.isPlayable() && player.isInBoat())
{
player.sendPacket(SystemMessageId.THIS_IS_NOT_ALLOWED_WHILE_RIDING_A_FERRY_OR_BOAT);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final BuffInfo info = player.getEffectList().getFirstBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
if (info != null)
{
for (AbstractEffect effect : info.getEffects())
{
if (!effect.checkCondition(-1))
{
player.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REPORTED_AS_AN_ILLEGAL_PROGRAM_USER_SO_YOUR_ACTIONS_HAVE_BEEN_RESTRICTED);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
}
}
// avoid using expensive operations if not needed
final WorldObject target;
if (player.getTargetId() == _objectId)
{
target = player.getTarget();
}
else
{
target = World.getInstance().findObject(_objectId);
}
if (target == null)
{
return;
}
if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Players can't attack objects in the other instances
else if (target.getInstanceWorld() != player.getInstanceWorld())
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Only GMs can directly attack invisible characters
else if (!target.isVisibleFor(player))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
player.onActionRequest();
if (player.getTarget() != target)
{
target.onAction(player);
}
else if ((target.getObjectId() != player.getObjectId()) && (player.getPrivateStoreType() == PrivateStoreType.NONE) && (player.getActiveRequester() == null))
{
target.onForcedAttack(player);
}
else
{
player.sendPacket(ActionFailed.STATIC_PACKET);
}
}
}

View File

@ -56,12 +56,25 @@ public class AttackRequest implements IClientIncomingPacket
@Override
public void run(GameClient client)
{
if (!client.getFloodProtectors().getPlayerAction().tryPerformAction("PlayerAction"))
{
return;
}
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
// Avoid Attacks in Boat.
if (player.isPlayable() && player.isInBoat())
{
player.sendPacket(SystemMessageId.THIS_IS_NOT_ALLOWED_WHILE_RIDING_A_FERRY_OR_BOAT);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final BuffInfo info = player.getEffectList().getFirstBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
if (info != null)
{
@ -92,7 +105,8 @@ public class AttackRequest implements IClientIncomingPacket
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
else if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
@ -110,6 +124,8 @@ public class AttackRequest implements IClientIncomingPacket
return;
}
player.onActionRequest();
if (player.getTarget() != target)
{
target.onAction(player);

View File

@ -87,12 +87,12 @@ public class FloodProtectorAction
*/
public boolean tryPerformAction(String command)
{
final int curTick = GameTimeTaskManager.getInstance().getGameTicks();
if ((_client.getPlayer() != null) && _client.getPlayer().canOverrideCond(PlayerCondOverride.FLOOD_CONDITIONS))
{
return true;
}
final int curTick = GameTimeTaskManager.getInstance().getGameTicks();
if ((curTick < _nextGameTick) || _punishmentInProgress)
{
if (_config.LOG_FLOODING && !_logged && LOGGER.isLoggable(Level.WARNING))

View File

@ -89,6 +89,10 @@ public class FloodProtectors
* Item Auction
*/
private final FloodProtectorAction _itemAuction;
/**
* Player Action
*/
private final FloodProtectorAction _playerAction;
/**
* Creates new instance of FloodProtectors.
@ -113,6 +117,7 @@ public class FloodProtectors
_sendMail = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_SENDMAIL);
_characterSelect = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_CHARACTER_SELECT);
_itemAuction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_ITEM_AUCTION);
_playerAction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_PLAYER_ACTION);
}
/**
@ -257,4 +262,13 @@ public class FloodProtectors
{
return _itemAuction;
}
/**
* Returns {@link #_playerAction}.
* @return {@link #_playerAction}
*/
public FloodProtectorAction getPlayerAction()
{
return _playerAction;
}
}

View File

@ -121,3 +121,10 @@ FloodProtectorItemAuctionLogFlooding = False
FloodProtectorItemAuctionPunishmentLimit = 0
FloodProtectorItemAuctionPunishmentType = none
FloodProtectorItemAuctionPunishmentTime = 0
# Player Action - Next Target, Attack, etc
FloodProtectorPlayerActionInterval = 3
FloodProtectorPlayerActionLogFlooding = False
FloodProtectorPlayerActionPunishmentLimit = 0
FloodProtectorPlayerActionPunishmentType = none
FloodProtectorPlayerActionPunishmentTime = 0

View File

@ -623,6 +623,7 @@ public class Config
public static FloodProtectorConfig FLOOD_PROTECTOR_SENDMAIL;
public static FloodProtectorConfig FLOOD_PROTECTOR_CHARACTER_SELECT;
public static FloodProtectorConfig FLOOD_PROTECTOR_ITEM_AUCTION;
public static FloodProtectorConfig FLOOD_PROTECTOR_PLAYER_ACTION;
// --------------------------------------------------
// NPC Settings
@ -1383,6 +1384,7 @@ public class Config
FLOOD_PROTECTOR_SENDMAIL = new FloodProtectorConfig("SendMailFloodProtector");
FLOOD_PROTECTOR_CHARACTER_SELECT = new FloodProtectorConfig("CharacterSelectFloodProtector");
FLOOD_PROTECTOR_ITEM_AUCTION = new FloodProtectorConfig("ItemAuctionFloodProtector");
FLOOD_PROTECTOR_PLAYER_ACTION = new FloodProtectorConfig("PlayerActionFloodProtector");
final PropertiesParser serverSettings = new PropertiesParser(SERVER_CONFIG_FILE);
GAMESERVER_HOSTNAME = serverSettings.getString("GameserverHostname", "0.0.0.0");
@ -3723,6 +3725,7 @@ public class Config
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_SENDMAIL, "SendMail", 100);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_CHARACTER_SELECT, "CharacterSelect", 30);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_ITEM_AUCTION, "ItemAuction", 9);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_PLAYER_ACTION, "PlayerAction", 3);
}
/**

View File

@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs
public enum IncomingPackets implements IIncomingPackets<GameClient>
{
LOGOUT(0x00, Logout::new, ConnectionState.AUTHENTICATED, ConnectionState.IN_GAME),
ATTACK(0x01, Attack::new, ConnectionState.IN_GAME),
ATTACK(0x01, AttackRequest::new, ConnectionState.IN_GAME),
REQUEST_START_PLEDGE_WAR(0x03, RequestStartPledgeWar::new, ConnectionState.IN_GAME),
REQUEST_REPLY_START_PLEDGE(0x04, RequestReplyStartPledgeWar::new, ConnectionState.IN_GAME),
REQUEST_STOP_PLEDGE_WAR(0x05, RequestStopPledgeWar::new, ConnectionState.IN_GAME),

View File

@ -54,6 +54,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)

View File

@ -1,139 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.enums.PrivateStoreType;
import org.l2jmobius.gameserver.model.PlayerCondOverride;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.effects.AbstractEffect;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
/**
* TODO: This class is a copy of AttackRequest, we should get proper structure for both.
*/
public class Attack implements IClientIncomingPacket
{
// cddddc
private int _objectId;
@SuppressWarnings("unused")
private int _originX;
@SuppressWarnings("unused")
private int _originY;
@SuppressWarnings("unused")
private int _originZ;
@SuppressWarnings("unused")
private int _attackId;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_objectId = packet.readD();
_originX = packet.readD();
_originY = packet.readD();
_originZ = packet.readD();
_attackId = packet.readC(); // 0 for simple click 1 for shift-click
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
// Avoid Attacks in Boat.
if (player.isPlayable() && player.isInBoat())
{
player.sendPacket(SystemMessageId.THIS_IS_NOT_ALLOWED_WHILE_RIDING_A_FERRY_OR_BOAT);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final BuffInfo info = player.getEffectList().getFirstBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
if (info != null)
{
for (AbstractEffect effect : info.getEffects())
{
if (!effect.checkCondition(-1))
{
player.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REPORTED_AS_AN_ILLEGAL_PROGRAM_USER_SO_YOUR_ACTIONS_HAVE_BEEN_RESTRICTED);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
}
}
// avoid using expensive operations if not needed
final WorldObject target;
if (player.getTargetId() == _objectId)
{
target = player.getTarget();
}
else
{
target = World.getInstance().findObject(_objectId);
}
if (target == null)
{
return;
}
if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Players can't attack objects in the other instances
else if (target.getInstanceWorld() != player.getInstanceWorld())
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Only GMs can directly attack invisible characters
else if (!target.isVisibleFor(player))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
player.onActionRequest();
if (player.getTarget() != target)
{
target.onAction(player);
}
else if ((target.getObjectId() != player.getObjectId()) && (player.getPrivateStoreType() == PrivateStoreType.NONE) && (player.getActiveRequester() == null))
{
target.onForcedAttack(player);
}
else
{
player.sendPacket(ActionFailed.STATIC_PACKET);
}
}
}

View File

@ -56,12 +56,25 @@ public class AttackRequest implements IClientIncomingPacket
@Override
public void run(GameClient client)
{
if (!client.getFloodProtectors().getPlayerAction().tryPerformAction("PlayerAction"))
{
return;
}
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
// Avoid Attacks in Boat.
if (player.isPlayable() && player.isInBoat())
{
player.sendPacket(SystemMessageId.THIS_IS_NOT_ALLOWED_WHILE_RIDING_A_FERRY_OR_BOAT);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final BuffInfo info = player.getEffectList().getFirstBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
if (info != null)
{
@ -92,7 +105,8 @@ public class AttackRequest implements IClientIncomingPacket
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
else if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
@ -110,6 +124,8 @@ public class AttackRequest implements IClientIncomingPacket
return;
}
player.onActionRequest();
if (player.getTarget() != target)
{
target.onAction(player);

View File

@ -87,12 +87,12 @@ public class FloodProtectorAction
*/
public boolean tryPerformAction(String command)
{
final int curTick = GameTimeTaskManager.getInstance().getGameTicks();
if ((_client.getPlayer() != null) && _client.getPlayer().canOverrideCond(PlayerCondOverride.FLOOD_CONDITIONS))
{
return true;
}
final int curTick = GameTimeTaskManager.getInstance().getGameTicks();
if ((curTick < _nextGameTick) || _punishmentInProgress)
{
if (_config.LOG_FLOODING && !_logged && LOGGER.isLoggable(Level.WARNING))

View File

@ -89,6 +89,10 @@ public class FloodProtectors
* Item Auction
*/
private final FloodProtectorAction _itemAuction;
/**
* Player Action
*/
private final FloodProtectorAction _playerAction;
/**
* Creates new instance of FloodProtectors.
@ -113,6 +117,7 @@ public class FloodProtectors
_sendMail = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_SENDMAIL);
_characterSelect = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_CHARACTER_SELECT);
_itemAuction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_ITEM_AUCTION);
_playerAction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_PLAYER_ACTION);
}
/**
@ -257,4 +262,13 @@ public class FloodProtectors
{
return _itemAuction;
}
/**
* Returns {@link #_playerAction}.
* @return {@link #_playerAction}
*/
public FloodProtectorAction getPlayerAction()
{
return _playerAction;
}
}

View File

@ -121,3 +121,10 @@ FloodProtectorItemAuctionLogFlooding = False
FloodProtectorItemAuctionPunishmentLimit = 0
FloodProtectorItemAuctionPunishmentType = none
FloodProtectorItemAuctionPunishmentTime = 0
# Player Action - Next Target, Attack, etc
FloodProtectorPlayerActionInterval = 3
FloodProtectorPlayerActionLogFlooding = False
FloodProtectorPlayerActionPunishmentLimit = 0
FloodProtectorPlayerActionPunishmentType = none
FloodProtectorPlayerActionPunishmentTime = 0

View File

@ -610,6 +610,7 @@ public class Config
public static FloodProtectorConfig FLOOD_PROTECTOR_SENDMAIL;
public static FloodProtectorConfig FLOOD_PROTECTOR_CHARACTER_SELECT;
public static FloodProtectorConfig FLOOD_PROTECTOR_ITEM_AUCTION;
public static FloodProtectorConfig FLOOD_PROTECTOR_PLAYER_ACTION;
// --------------------------------------------------
// NPC Settings
@ -1370,6 +1371,7 @@ public class Config
FLOOD_PROTECTOR_SENDMAIL = new FloodProtectorConfig("SendMailFloodProtector");
FLOOD_PROTECTOR_CHARACTER_SELECT = new FloodProtectorConfig("CharacterSelectFloodProtector");
FLOOD_PROTECTOR_ITEM_AUCTION = new FloodProtectorConfig("ItemAuctionFloodProtector");
FLOOD_PROTECTOR_PLAYER_ACTION = new FloodProtectorConfig("PlayerActionFloodProtector");
final PropertiesParser serverSettings = new PropertiesParser(SERVER_CONFIG_FILE);
GAMESERVER_HOSTNAME = serverSettings.getString("GameserverHostname", "0.0.0.0");
@ -3698,6 +3700,7 @@ public class Config
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_SENDMAIL, "SendMail", 100);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_CHARACTER_SELECT, "CharacterSelect", 30);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_ITEM_AUCTION, "ItemAuction", 9);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_PLAYER_ACTION, "PlayerAction", 3);
}
/**

View File

@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs
public enum IncomingPackets implements IIncomingPackets<GameClient>
{
LOGOUT(0x00, Logout::new, ConnectionState.AUTHENTICATED, ConnectionState.IN_GAME),
ATTACK(0x01, Attack::new, ConnectionState.IN_GAME),
ATTACK(0x01, AttackRequest::new, ConnectionState.IN_GAME),
REQUEST_START_PLEDGE_WAR(0x03, RequestStartPledgeWar::new, ConnectionState.IN_GAME),
REQUEST_REPLY_START_PLEDGE(0x04, RequestReplyStartPledgeWar::new, ConnectionState.IN_GAME),
REQUEST_STOP_PLEDGE_WAR(0x05, RequestStopPledgeWar::new, ConnectionState.IN_GAME),

View File

@ -54,6 +54,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)

View File

@ -1,139 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.enums.PrivateStoreType;
import org.l2jmobius.gameserver.model.PlayerCondOverride;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.effects.AbstractEffect;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
/**
* TODO: This class is a copy of AttackRequest, we should get proper structure for both.
*/
public class Attack implements IClientIncomingPacket
{
// cddddc
private int _objectId;
@SuppressWarnings("unused")
private int _originX;
@SuppressWarnings("unused")
private int _originY;
@SuppressWarnings("unused")
private int _originZ;
@SuppressWarnings("unused")
private int _attackId;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_objectId = packet.readD();
_originX = packet.readD();
_originY = packet.readD();
_originZ = packet.readD();
_attackId = packet.readC(); // 0 for simple click 1 for shift-click
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
// Avoid Attacks in Boat.
if (player.isPlayable() && player.isInBoat())
{
player.sendPacket(SystemMessageId.THIS_IS_NOT_ALLOWED_WHILE_RIDING_A_FERRY_OR_BOAT);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final BuffInfo info = player.getEffectList().getFirstBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
if (info != null)
{
for (AbstractEffect effect : info.getEffects())
{
if (!effect.checkCondition(-1))
{
player.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REPORTED_AS_AN_ILLEGAL_PROGRAM_USER_SO_YOUR_ACTIONS_HAVE_BEEN_RESTRICTED);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
}
}
// avoid using expensive operations if not needed
final WorldObject target;
if (player.getTargetId() == _objectId)
{
target = player.getTarget();
}
else
{
target = World.getInstance().findObject(_objectId);
}
if (target == null)
{
return;
}
if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Players can't attack objects in the other instances
else if (target.getInstanceWorld() != player.getInstanceWorld())
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Only GMs can directly attack invisible characters
else if (!target.isVisibleFor(player))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
player.onActionRequest();
if (player.getTarget() != target)
{
target.onAction(player);
}
else if ((target.getObjectId() != player.getObjectId()) && (player.getPrivateStoreType() == PrivateStoreType.NONE) && (player.getActiveRequester() == null))
{
target.onForcedAttack(player);
}
else
{
player.sendPacket(ActionFailed.STATIC_PACKET);
}
}
}

View File

@ -56,12 +56,25 @@ public class AttackRequest implements IClientIncomingPacket
@Override
public void run(GameClient client)
{
if (!client.getFloodProtectors().getPlayerAction().tryPerformAction("PlayerAction"))
{
return;
}
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
// Avoid Attacks in Boat.
if (player.isPlayable() && player.isInBoat())
{
player.sendPacket(SystemMessageId.THIS_IS_NOT_ALLOWED_WHILE_RIDING_A_FERRY_OR_BOAT);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final BuffInfo info = player.getEffectList().getFirstBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
if (info != null)
{
@ -92,7 +105,8 @@ public class AttackRequest implements IClientIncomingPacket
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
else if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
@ -110,6 +124,8 @@ public class AttackRequest implements IClientIncomingPacket
return;
}
player.onActionRequest();
if (player.getTarget() != target)
{
target.onAction(player);

View File

@ -87,12 +87,12 @@ public class FloodProtectorAction
*/
public boolean tryPerformAction(String command)
{
final int curTick = GameTimeTaskManager.getInstance().getGameTicks();
if ((_client.getPlayer() != null) && _client.getPlayer().canOverrideCond(PlayerCondOverride.FLOOD_CONDITIONS))
{
return true;
}
final int curTick = GameTimeTaskManager.getInstance().getGameTicks();
if ((curTick < _nextGameTick) || _punishmentInProgress)
{
if (_config.LOG_FLOODING && !_logged && LOGGER.isLoggable(Level.WARNING))

View File

@ -89,6 +89,10 @@ public class FloodProtectors
* Item Auction
*/
private final FloodProtectorAction _itemAuction;
/**
* Player Action
*/
private final FloodProtectorAction _playerAction;
/**
* Creates new instance of FloodProtectors.
@ -113,6 +117,7 @@ public class FloodProtectors
_sendMail = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_SENDMAIL);
_characterSelect = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_CHARACTER_SELECT);
_itemAuction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_ITEM_AUCTION);
_playerAction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_PLAYER_ACTION);
}
/**
@ -257,4 +262,13 @@ public class FloodProtectors
{
return _itemAuction;
}
/**
* Returns {@link #_playerAction}.
* @return {@link #_playerAction}
*/
public FloodProtectorAction getPlayerAction()
{
return _playerAction;
}
}

View File

@ -121,3 +121,10 @@ FloodProtectorItemAuctionLogFlooding = False
FloodProtectorItemAuctionPunishmentLimit = 0
FloodProtectorItemAuctionPunishmentType = none
FloodProtectorItemAuctionPunishmentTime = 0
# Player Action - Next Target, Attack, etc
FloodProtectorPlayerActionInterval = 3
FloodProtectorPlayerActionLogFlooding = False
FloodProtectorPlayerActionPunishmentLimit = 0
FloodProtectorPlayerActionPunishmentType = none
FloodProtectorPlayerActionPunishmentTime = 0

View File

@ -605,6 +605,7 @@ public class Config
public static FloodProtectorConfig FLOOD_PROTECTOR_SENDMAIL;
public static FloodProtectorConfig FLOOD_PROTECTOR_CHARACTER_SELECT;
public static FloodProtectorConfig FLOOD_PROTECTOR_ITEM_AUCTION;
public static FloodProtectorConfig FLOOD_PROTECTOR_PLAYER_ACTION;
// --------------------------------------------------
// NPC Settings
@ -1365,6 +1366,7 @@ public class Config
FLOOD_PROTECTOR_SENDMAIL = new FloodProtectorConfig("SendMailFloodProtector");
FLOOD_PROTECTOR_CHARACTER_SELECT = new FloodProtectorConfig("CharacterSelectFloodProtector");
FLOOD_PROTECTOR_ITEM_AUCTION = new FloodProtectorConfig("ItemAuctionFloodProtector");
FLOOD_PROTECTOR_PLAYER_ACTION = new FloodProtectorConfig("PlayerActionFloodProtector");
final PropertiesParser serverSettings = new PropertiesParser(SERVER_CONFIG_FILE);
GAMESERVER_HOSTNAME = serverSettings.getString("GameserverHostname", "0.0.0.0");
@ -3698,6 +3700,7 @@ public class Config
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_SENDMAIL, "SendMail", 100);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_CHARACTER_SELECT, "CharacterSelect", 30);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_ITEM_AUCTION, "ItemAuction", 9);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_PLAYER_ACTION, "PlayerAction", 3);
}
/**

View File

@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs
public enum IncomingPackets implements IIncomingPackets<GameClient>
{
LOGOUT(0x00, Logout::new, ConnectionState.AUTHENTICATED, ConnectionState.IN_GAME),
ATTACK(0x01, Attack::new, ConnectionState.IN_GAME),
ATTACK(0x01, AttackRequest::new, ConnectionState.IN_GAME),
REQUEST_START_PLEDGE_WAR(0x03, RequestStartPledgeWar::new, ConnectionState.IN_GAME),
REQUEST_REPLY_START_PLEDGE(0x04, RequestReplyStartPledgeWar::new, ConnectionState.IN_GAME),
REQUEST_STOP_PLEDGE_WAR(0x05, RequestStopPledgeWar::new, ConnectionState.IN_GAME),

View File

@ -54,6 +54,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)

View File

@ -1,139 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.enums.PrivateStoreType;
import org.l2jmobius.gameserver.model.PlayerCondOverride;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.effects.AbstractEffect;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
/**
* TODO: This class is a copy of AttackRequest, we should get proper structure for both.
*/
public class Attack implements IClientIncomingPacket
{
// cddddc
private int _objectId;
@SuppressWarnings("unused")
private int _originX;
@SuppressWarnings("unused")
private int _originY;
@SuppressWarnings("unused")
private int _originZ;
@SuppressWarnings("unused")
private int _attackId;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_objectId = packet.readD();
_originX = packet.readD();
_originY = packet.readD();
_originZ = packet.readD();
_attackId = packet.readC(); // 0 for simple click 1 for shift-click
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
// Avoid Attacks in Boat.
if (player.isPlayable() && player.isInBoat())
{
player.sendPacket(SystemMessageId.THIS_IS_NOT_ALLOWED_WHILE_RIDING_A_FERRY_OR_BOAT);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final BuffInfo info = player.getEffectList().getFirstBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
if (info != null)
{
for (AbstractEffect effect : info.getEffects())
{
if (!effect.checkCondition(-1))
{
player.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REPORTED_AS_AN_ILLEGAL_PROGRAM_USER_SO_YOUR_ACTIONS_HAVE_BEEN_RESTRICTED);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
}
}
// avoid using expensive operations if not needed
final WorldObject target;
if (player.getTargetId() == _objectId)
{
target = player.getTarget();
}
else
{
target = World.getInstance().findObject(_objectId);
}
if (target == null)
{
return;
}
if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Players can't attack objects in the other instances
else if (target.getInstanceWorld() != player.getInstanceWorld())
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Only GMs can directly attack invisible characters
else if (!target.isVisibleFor(player))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
player.onActionRequest();
if (player.getTarget() != target)
{
target.onAction(player);
}
else if ((target.getObjectId() != player.getObjectId()) && (player.getPrivateStoreType() == PrivateStoreType.NONE) && (player.getActiveRequester() == null))
{
target.onForcedAttack(player);
}
else
{
player.sendPacket(ActionFailed.STATIC_PACKET);
}
}
}

View File

@ -56,12 +56,25 @@ public class AttackRequest implements IClientIncomingPacket
@Override
public void run(GameClient client)
{
if (!client.getFloodProtectors().getPlayerAction().tryPerformAction("PlayerAction"))
{
return;
}
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
// Avoid Attacks in Boat.
if (player.isPlayable() && player.isInBoat())
{
player.sendPacket(SystemMessageId.THIS_IS_NOT_ALLOWED_WHILE_RIDING_A_FERRY_OR_BOAT);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final BuffInfo info = player.getEffectList().getFirstBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
if (info != null)
{
@ -92,7 +105,8 @@ public class AttackRequest implements IClientIncomingPacket
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
else if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
@ -110,6 +124,8 @@ public class AttackRequest implements IClientIncomingPacket
return;
}
player.onActionRequest();
if (player.getTarget() != target)
{
target.onAction(player);

View File

@ -40,6 +40,11 @@ public class RequestTargetActionMenu implements IClientIncomingPacket
@Override
public void run(GameClient client)
{
if (!client.getFloodProtectors().getPlayerAction().tryPerformAction("PlayerAction"))
{
return;
}
final PlayerInstance player = client.getPlayer();
if ((player == null) || player.isTargetingDisabled())
{

View File

@ -87,12 +87,12 @@ public class FloodProtectorAction
*/
public boolean tryPerformAction(String command)
{
final int curTick = GameTimeTaskManager.getInstance().getGameTicks();
if ((_client.getPlayer() != null) && _client.getPlayer().canOverrideCond(PlayerCondOverride.FLOOD_CONDITIONS))
{
return true;
}
final int curTick = GameTimeTaskManager.getInstance().getGameTicks();
if ((curTick < _nextGameTick) || _punishmentInProgress)
{
if (_config.LOG_FLOODING && !_logged && LOGGER.isLoggable(Level.WARNING))

View File

@ -89,6 +89,10 @@ public class FloodProtectors
* Item Auction
*/
private final FloodProtectorAction _itemAuction;
/**
* Player Action
*/
private final FloodProtectorAction _playerAction;
/**
* Creates new instance of FloodProtectors.
@ -113,6 +117,7 @@ public class FloodProtectors
_sendMail = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_SENDMAIL);
_characterSelect = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_CHARACTER_SELECT);
_itemAuction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_ITEM_AUCTION);
_playerAction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_PLAYER_ACTION);
}
/**
@ -257,4 +262,13 @@ public class FloodProtectors
{
return _itemAuction;
}
/**
* Returns {@link #_playerAction}.
* @return {@link #_playerAction}
*/
public FloodProtectorAction getPlayerAction()
{
return _playerAction;
}
}

View File

@ -121,3 +121,10 @@ FloodProtectorItemAuctionLogFlooding = False
FloodProtectorItemAuctionPunishmentLimit = 0
FloodProtectorItemAuctionPunishmentType = none
FloodProtectorItemAuctionPunishmentTime = 0
# Player Action - Next Target, Attack, etc
FloodProtectorPlayerActionInterval = 3
FloodProtectorPlayerActionLogFlooding = False
FloodProtectorPlayerActionPunishmentLimit = 0
FloodProtectorPlayerActionPunishmentType = none
FloodProtectorPlayerActionPunishmentTime = 0

View File

@ -605,6 +605,7 @@ public class Config
public static FloodProtectorConfig FLOOD_PROTECTOR_SENDMAIL;
public static FloodProtectorConfig FLOOD_PROTECTOR_CHARACTER_SELECT;
public static FloodProtectorConfig FLOOD_PROTECTOR_ITEM_AUCTION;
public static FloodProtectorConfig FLOOD_PROTECTOR_PLAYER_ACTION;
// --------------------------------------------------
// NPC Settings
@ -1372,6 +1373,7 @@ public class Config
FLOOD_PROTECTOR_SENDMAIL = new FloodProtectorConfig("SendMailFloodProtector");
FLOOD_PROTECTOR_CHARACTER_SELECT = new FloodProtectorConfig("CharacterSelectFloodProtector");
FLOOD_PROTECTOR_ITEM_AUCTION = new FloodProtectorConfig("ItemAuctionFloodProtector");
FLOOD_PROTECTOR_PLAYER_ACTION = new FloodProtectorConfig("PlayerActionFloodProtector");
final PropertiesParser serverSettings = new PropertiesParser(SERVER_CONFIG_FILE);
GAMESERVER_HOSTNAME = serverSettings.getString("GameserverHostname", "0.0.0.0");
@ -3710,6 +3712,7 @@ public class Config
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_SENDMAIL, "SendMail", 100);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_CHARACTER_SELECT, "CharacterSelect", 30);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_ITEM_AUCTION, "ItemAuction", 9);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_PLAYER_ACTION, "PlayerAction", 3);
}
/**

View File

@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs
public enum IncomingPackets implements IIncomingPackets<GameClient>
{
LOGOUT(0x00, Logout::new, ConnectionState.AUTHENTICATED, ConnectionState.IN_GAME),
ATTACK(0x01, Attack::new, ConnectionState.IN_GAME),
ATTACK(0x01, AttackRequest::new, ConnectionState.IN_GAME),
REQUEST_START_PLEDGE_WAR(0x03, RequestStartPledgeWar::new, ConnectionState.IN_GAME),
REQUEST_REPLY_START_PLEDGE(0x04, RequestReplyStartPledgeWar::new, ConnectionState.IN_GAME),
REQUEST_STOP_PLEDGE_WAR(0x05, RequestStopPledgeWar::new, ConnectionState.IN_GAME),

View File

@ -54,6 +54,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)

View File

@ -1,139 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.enums.PrivateStoreType;
import org.l2jmobius.gameserver.model.PlayerCondOverride;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.effects.AbstractEffect;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
/**
* TODO: This class is a copy of AttackRequest, we should get proper structure for both.
*/
public class Attack implements IClientIncomingPacket
{
// cddddc
private int _objectId;
@SuppressWarnings("unused")
private int _originX;
@SuppressWarnings("unused")
private int _originY;
@SuppressWarnings("unused")
private int _originZ;
@SuppressWarnings("unused")
private int _attackId;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_objectId = packet.readD();
_originX = packet.readD();
_originY = packet.readD();
_originZ = packet.readD();
_attackId = packet.readC(); // 0 for simple click 1 for shift-click
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
// Avoid Attacks in Boat.
if (player.isPlayable() && player.isInBoat())
{
player.sendPacket(SystemMessageId.THIS_IS_NOT_ALLOWED_WHILE_RIDING_A_FERRY_OR_BOAT);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final BuffInfo info = player.getEffectList().getFirstBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
if (info != null)
{
for (AbstractEffect effect : info.getEffects())
{
if (!effect.checkCondition(-1))
{
player.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REPORTED_AS_AN_ILLEGAL_PROGRAM_USER_SO_YOUR_ACTIONS_HAVE_BEEN_RESTRICTED);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
}
}
// avoid using expensive operations if not needed
final WorldObject target;
if (player.getTargetId() == _objectId)
{
target = player.getTarget();
}
else
{
target = World.getInstance().findObject(_objectId);
}
if (target == null)
{
return;
}
if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Players can't attack objects in the other instances
else if (target.getInstanceWorld() != player.getInstanceWorld())
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Only GMs can directly attack invisible characters
else if (!target.isVisibleFor(player))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
player.onActionRequest();
if (player.getTarget() != target)
{
target.onAction(player);
}
else if ((target.getObjectId() != player.getObjectId()) && (player.getPrivateStoreType() == PrivateStoreType.NONE) && (player.getActiveRequester() == null))
{
target.onForcedAttack(player);
}
else
{
player.sendPacket(ActionFailed.STATIC_PACKET);
}
}
}

View File

@ -56,12 +56,25 @@ public class AttackRequest implements IClientIncomingPacket
@Override
public void run(GameClient client)
{
if (!client.getFloodProtectors().getPlayerAction().tryPerformAction("PlayerAction"))
{
return;
}
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
// Avoid Attacks in Boat.
if (player.isPlayable() && player.isInBoat())
{
player.sendPacket(SystemMessageId.THIS_IS_NOT_ALLOWED_WHILE_RIDING_A_FERRY_OR_BOAT);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final BuffInfo info = player.getEffectList().getFirstBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
if (info != null)
{
@ -92,7 +105,8 @@ public class AttackRequest implements IClientIncomingPacket
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
else if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
@ -110,6 +124,8 @@ public class AttackRequest implements IClientIncomingPacket
return;
}
player.onActionRequest();
if (player.getTarget() != target)
{
target.onAction(player);

View File

@ -40,6 +40,11 @@ public class RequestTargetActionMenu implements IClientIncomingPacket
@Override
public void run(GameClient client)
{
if (!client.getFloodProtectors().getPlayerAction().tryPerformAction("PlayerAction"))
{
return;
}
final PlayerInstance player = client.getPlayer();
if ((player == null) || player.isTargetingDisabled())
{

View File

@ -87,12 +87,12 @@ public class FloodProtectorAction
*/
public boolean tryPerformAction(String command)
{
final int curTick = GameTimeTaskManager.getInstance().getGameTicks();
if ((_client.getPlayer() != null) && _client.getPlayer().canOverrideCond(PlayerCondOverride.FLOOD_CONDITIONS))
{
return true;
}
final int curTick = GameTimeTaskManager.getInstance().getGameTicks();
if ((curTick < _nextGameTick) || _punishmentInProgress)
{
if (_config.LOG_FLOODING && !_logged && LOGGER.isLoggable(Level.WARNING))

View File

@ -89,6 +89,10 @@ public class FloodProtectors
* Item Auction
*/
private final FloodProtectorAction _itemAuction;
/**
* Player Action
*/
private final FloodProtectorAction _playerAction;
/**
* Creates new instance of FloodProtectors.
@ -113,6 +117,7 @@ public class FloodProtectors
_sendMail = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_SENDMAIL);
_characterSelect = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_CHARACTER_SELECT);
_itemAuction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_ITEM_AUCTION);
_playerAction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_PLAYER_ACTION);
}
/**
@ -257,4 +262,13 @@ public class FloodProtectors
{
return _itemAuction;
}
/**
* Returns {@link #_playerAction}.
* @return {@link #_playerAction}
*/
public FloodProtectorAction getPlayerAction()
{
return _playerAction;
}
}

View File

@ -121,3 +121,10 @@ FloodProtectorItemAuctionLogFlooding = False
FloodProtectorItemAuctionPunishmentLimit = 0
FloodProtectorItemAuctionPunishmentType = none
FloodProtectorItemAuctionPunishmentTime = 0
# Player Action - Next Target, Attack, etc
FloodProtectorPlayerActionInterval = 3
FloodProtectorPlayerActionLogFlooding = False
FloodProtectorPlayerActionPunishmentLimit = 0
FloodProtectorPlayerActionPunishmentType = none
FloodProtectorPlayerActionPunishmentTime = 0

View File

@ -606,6 +606,7 @@ public class Config
public static FloodProtectorConfig FLOOD_PROTECTOR_SENDMAIL;
public static FloodProtectorConfig FLOOD_PROTECTOR_CHARACTER_SELECT;
public static FloodProtectorConfig FLOOD_PROTECTOR_ITEM_AUCTION;
public static FloodProtectorConfig FLOOD_PROTECTOR_PLAYER_ACTION;
// --------------------------------------------------
// NPC Settings
@ -1394,6 +1395,7 @@ public class Config
FLOOD_PROTECTOR_SENDMAIL = new FloodProtectorConfig("SendMailFloodProtector");
FLOOD_PROTECTOR_CHARACTER_SELECT = new FloodProtectorConfig("CharacterSelectFloodProtector");
FLOOD_PROTECTOR_ITEM_AUCTION = new FloodProtectorConfig("ItemAuctionFloodProtector");
FLOOD_PROTECTOR_PLAYER_ACTION = new FloodProtectorConfig("PlayerActionFloodProtector");
final PropertiesParser serverSettings = new PropertiesParser(SERVER_CONFIG_FILE);
GAMESERVER_HOSTNAME = serverSettings.getString("GameserverHostname", "0.0.0.0");
@ -3753,6 +3755,7 @@ public class Config
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_SENDMAIL, "SendMail", 100);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_CHARACTER_SELECT, "CharacterSelect", 30);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_ITEM_AUCTION, "ItemAuction", 9);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_PLAYER_ACTION, "PlayerAction", 3);
}
/**

View File

@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs
public enum IncomingPackets implements IIncomingPackets<GameClient>
{
LOGOUT(0x00, Logout::new, ConnectionState.AUTHENTICATED, ConnectionState.IN_GAME),
ATTACK(0x01, Attack::new, ConnectionState.IN_GAME),
ATTACK(0x01, AttackRequest::new, ConnectionState.IN_GAME),
REQUEST_START_PLEDGE_WAR(0x03, RequestStartPledgeWar::new, ConnectionState.IN_GAME),
REQUEST_REPLY_START_PLEDGE(0x04, RequestReplyStartPledgeWar::new, ConnectionState.IN_GAME),
REQUEST_STOP_PLEDGE_WAR(0x05, RequestStopPledgeWar::new, ConnectionState.IN_GAME),

View File

@ -54,6 +54,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)

View File

@ -1,139 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.enums.PrivateStoreType;
import org.l2jmobius.gameserver.model.PlayerCondOverride;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.effects.AbstractEffect;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
/**
* TODO: This class is a copy of AttackRequest, we should get proper structure for both.
*/
public class Attack implements IClientIncomingPacket
{
// cddddc
private int _objectId;
@SuppressWarnings("unused")
private int _originX;
@SuppressWarnings("unused")
private int _originY;
@SuppressWarnings("unused")
private int _originZ;
@SuppressWarnings("unused")
private int _attackId;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_objectId = packet.readD();
_originX = packet.readD();
_originY = packet.readD();
_originZ = packet.readD();
_attackId = packet.readC(); // 0 for simple click 1 for shift-click
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
// Avoid Attacks in Boat.
if (player.isPlayable() && player.isInBoat())
{
player.sendPacket(SystemMessageId.THIS_IS_NOT_ALLOWED_WHILE_RIDING_A_FERRY_OR_BOAT);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final BuffInfo info = player.getEffectList().getFirstBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
if (info != null)
{
for (AbstractEffect effect : info.getEffects())
{
if (!effect.checkCondition(-1))
{
player.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REPORTED_AS_AN_ILLEGAL_PROGRAM_USER_SO_YOUR_ACTIONS_HAVE_BEEN_RESTRICTED);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
}
}
// avoid using expensive operations if not needed
final WorldObject target;
if (player.getTargetId() == _objectId)
{
target = player.getTarget();
}
else
{
target = World.getInstance().findObject(_objectId);
}
if (target == null)
{
return;
}
if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Players can't attack objects in the other instances
else if (target.getInstanceWorld() != player.getInstanceWorld())
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Only GMs can directly attack invisible characters
else if (!target.isVisibleFor(player))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
player.onActionRequest();
if (player.getTarget() != target)
{
target.onAction(player);
}
else if ((target.getObjectId() != player.getObjectId()) && (player.getPrivateStoreType() == PrivateStoreType.NONE) && (player.getActiveRequester() == null))
{
target.onForcedAttack(player);
}
else
{
player.sendPacket(ActionFailed.STATIC_PACKET);
}
}
}

View File

@ -56,12 +56,25 @@ public class AttackRequest implements IClientIncomingPacket
@Override
public void run(GameClient client)
{
if (!client.getFloodProtectors().getPlayerAction().tryPerformAction("PlayerAction"))
{
return;
}
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
// Avoid Attacks in Boat.
if (player.isPlayable() && player.isInBoat())
{
player.sendPacket(SystemMessageId.THIS_IS_NOT_ALLOWED_WHILE_RIDING_A_FERRY_OR_BOAT);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final BuffInfo info = player.getEffectList().getFirstBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
if (info != null)
{
@ -92,7 +105,8 @@ public class AttackRequest implements IClientIncomingPacket
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
else if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
@ -110,6 +124,8 @@ public class AttackRequest implements IClientIncomingPacket
return;
}
player.onActionRequest();
if (player.getTarget() != target)
{
target.onAction(player);

View File

@ -40,6 +40,11 @@ public class RequestTargetActionMenu implements IClientIncomingPacket
@Override
public void run(GameClient client)
{
if (!client.getFloodProtectors().getPlayerAction().tryPerformAction("PlayerAction"))
{
return;
}
final PlayerInstance player = client.getPlayer();
if ((player == null) || player.isTargetingDisabled())
{

View File

@ -87,12 +87,12 @@ public class FloodProtectorAction
*/
public boolean tryPerformAction(String command)
{
final int curTick = GameTimeTaskManager.getInstance().getGameTicks();
if ((_client.getPlayer() != null) && _client.getPlayer().canOverrideCond(PlayerCondOverride.FLOOD_CONDITIONS))
{
return true;
}
final int curTick = GameTimeTaskManager.getInstance().getGameTicks();
if ((curTick < _nextGameTick) || _punishmentInProgress)
{
if (_config.LOG_FLOODING && !_logged && LOGGER.isLoggable(Level.WARNING))

View File

@ -89,6 +89,10 @@ public class FloodProtectors
* Item Auction
*/
private final FloodProtectorAction _itemAuction;
/**
* Player Action
*/
private final FloodProtectorAction _playerAction;
/**
* Creates new instance of FloodProtectors.
@ -113,6 +117,7 @@ public class FloodProtectors
_sendMail = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_SENDMAIL);
_characterSelect = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_CHARACTER_SELECT);
_itemAuction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_ITEM_AUCTION);
_playerAction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_PLAYER_ACTION);
}
/**
@ -257,4 +262,13 @@ public class FloodProtectors
{
return _itemAuction;
}
/**
* Returns {@link #_playerAction}.
* @return {@link #_playerAction}
*/
public FloodProtectorAction getPlayerAction()
{
return _playerAction;
}
}

View File

@ -121,3 +121,10 @@ FloodProtectorItemAuctionLogFlooding = False
FloodProtectorItemAuctionPunishmentLimit = 0
FloodProtectorItemAuctionPunishmentType = none
FloodProtectorItemAuctionPunishmentTime = 0
# Player Action - Next Target, Attack, etc
FloodProtectorPlayerActionInterval = 3
FloodProtectorPlayerActionLogFlooding = False
FloodProtectorPlayerActionPunishmentLimit = 0
FloodProtectorPlayerActionPunishmentType = none
FloodProtectorPlayerActionPunishmentTime = 0

View File

@ -612,6 +612,7 @@ public class Config
public static FloodProtectorConfig FLOOD_PROTECTOR_SENDMAIL;
public static FloodProtectorConfig FLOOD_PROTECTOR_CHARACTER_SELECT;
public static FloodProtectorConfig FLOOD_PROTECTOR_ITEM_AUCTION;
public static FloodProtectorConfig FLOOD_PROTECTOR_PLAYER_ACTION;
// --------------------------------------------------
// NPC Settings
@ -1402,6 +1403,7 @@ public class Config
FLOOD_PROTECTOR_SENDMAIL = new FloodProtectorConfig("SendMailFloodProtector");
FLOOD_PROTECTOR_CHARACTER_SELECT = new FloodProtectorConfig("CharacterSelectFloodProtector");
FLOOD_PROTECTOR_ITEM_AUCTION = new FloodProtectorConfig("ItemAuctionFloodProtector");
FLOOD_PROTECTOR_PLAYER_ACTION = new FloodProtectorConfig("PlayerActionFloodProtector");
final PropertiesParser serverSettings = new PropertiesParser(SERVER_CONFIG_FILE);
GAMESERVER_HOSTNAME = serverSettings.getString("GameserverHostname", "0.0.0.0");
@ -3769,6 +3771,7 @@ public class Config
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_SENDMAIL, "SendMail", 100);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_CHARACTER_SELECT, "CharacterSelect", 30);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_ITEM_AUCTION, "ItemAuction", 9);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_PLAYER_ACTION, "PlayerAction", 3);
}
/**

View File

@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs
public enum IncomingPackets implements IIncomingPackets<GameClient>
{
LOGOUT(0x00, Logout::new, ConnectionState.AUTHENTICATED, ConnectionState.IN_GAME),
ATTACK(0x01, Attack::new, ConnectionState.IN_GAME),
ATTACK(0x01, AttackRequest::new, ConnectionState.IN_GAME),
REQUEST_START_PLEDGE_WAR(0x03, RequestStartPledgeWar::new, ConnectionState.IN_GAME),
REQUEST_REPLY_START_PLEDGE(0x04, RequestReplyStartPledgeWar::new, ConnectionState.IN_GAME),
REQUEST_STOP_PLEDGE_WAR(0x05, RequestStopPledgeWar::new, ConnectionState.IN_GAME),

View File

@ -54,6 +54,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)

View File

@ -1,139 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.enums.PrivateStoreType;
import org.l2jmobius.gameserver.model.PlayerCondOverride;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.effects.AbstractEffect;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
/**
* TODO: This class is a copy of AttackRequest, we should get proper structure for both.
*/
public class Attack implements IClientIncomingPacket
{
// cddddc
private int _objectId;
@SuppressWarnings("unused")
private int _originX;
@SuppressWarnings("unused")
private int _originY;
@SuppressWarnings("unused")
private int _originZ;
@SuppressWarnings("unused")
private int _attackId;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_objectId = packet.readD();
_originX = packet.readD();
_originY = packet.readD();
_originZ = packet.readD();
_attackId = packet.readC(); // 0 for simple click 1 for shift-click
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
// Avoid Attacks in Boat.
if (player.isPlayable() && player.isInBoat())
{
player.sendPacket(SystemMessageId.THIS_IS_NOT_ALLOWED_WHILE_RIDING_A_FERRY_OR_BOAT);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final BuffInfo info = player.getEffectList().getFirstBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
if (info != null)
{
for (AbstractEffect effect : info.getEffects())
{
if (!effect.checkCondition(-1))
{
player.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REPORTED_AS_AN_ILLEGAL_PROGRAM_USER_SO_YOUR_ACTIONS_HAVE_BEEN_RESTRICTED);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
}
}
// avoid using expensive operations if not needed
final WorldObject target;
if (player.getTargetId() == _objectId)
{
target = player.getTarget();
}
else
{
target = World.getInstance().findObject(_objectId);
}
if (target == null)
{
return;
}
if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Players can't attack objects in the other instances
else if (target.getInstanceWorld() != player.getInstanceWorld())
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Only GMs can directly attack invisible characters
else if (!target.isVisibleFor(player))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
player.onActionRequest();
if (player.getTarget() != target)
{
target.onAction(player);
}
else if ((target.getObjectId() != player.getObjectId()) && (player.getPrivateStoreType() == PrivateStoreType.NONE) && (player.getActiveRequester() == null))
{
target.onForcedAttack(player);
}
else
{
player.sendPacket(ActionFailed.STATIC_PACKET);
}
}
}

View File

@ -56,12 +56,25 @@ public class AttackRequest implements IClientIncomingPacket
@Override
public void run(GameClient client)
{
if (!client.getFloodProtectors().getPlayerAction().tryPerformAction("PlayerAction"))
{
return;
}
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
// Avoid Attacks in Boat.
if (player.isPlayable() && player.isInBoat())
{
player.sendPacket(SystemMessageId.THIS_IS_NOT_ALLOWED_WHILE_RIDING_A_FERRY_OR_BOAT);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final BuffInfo info = player.getEffectList().getFirstBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
if (info != null)
{
@ -92,7 +105,8 @@ public class AttackRequest implements IClientIncomingPacket
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
else if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
@ -110,6 +124,8 @@ public class AttackRequest implements IClientIncomingPacket
return;
}
player.onActionRequest();
if (player.getTarget() != target)
{
target.onAction(player);

View File

@ -40,6 +40,11 @@ public class RequestTargetActionMenu implements IClientIncomingPacket
@Override
public void run(GameClient client)
{
if (!client.getFloodProtectors().getPlayerAction().tryPerformAction("PlayerAction"))
{
return;
}
final PlayerInstance player = client.getPlayer();
if ((player == null) || player.isTargetingDisabled())
{

View File

@ -87,12 +87,12 @@ public class FloodProtectorAction
*/
public boolean tryPerformAction(String command)
{
final int curTick = GameTimeTaskManager.getInstance().getGameTicks();
if ((_client.getPlayer() != null) && _client.getPlayer().canOverrideCond(PlayerCondOverride.FLOOD_CONDITIONS))
{
return true;
}
final int curTick = GameTimeTaskManager.getInstance().getGameTicks();
if ((curTick < _nextGameTick) || _punishmentInProgress)
{
if (_config.LOG_FLOODING && !_logged && LOGGER.isLoggable(Level.WARNING))

View File

@ -89,6 +89,10 @@ public class FloodProtectors
* Item Auction
*/
private final FloodProtectorAction _itemAuction;
/**
* Player Action
*/
private final FloodProtectorAction _playerAction;
/**
* Creates new instance of FloodProtectors.
@ -113,6 +117,7 @@ public class FloodProtectors
_sendMail = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_SENDMAIL);
_characterSelect = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_CHARACTER_SELECT);
_itemAuction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_ITEM_AUCTION);
_playerAction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_PLAYER_ACTION);
}
/**
@ -257,4 +262,13 @@ public class FloodProtectors
{
return _itemAuction;
}
/**
* Returns {@link #_playerAction}.
* @return {@link #_playerAction}
*/
public FloodProtectorAction getPlayerAction()
{
return _playerAction;
}
}

View File

@ -121,3 +121,10 @@ FloodProtectorItemAuctionLogFlooding = False
FloodProtectorItemAuctionPunishmentLimit = 0
FloodProtectorItemAuctionPunishmentType = none
FloodProtectorItemAuctionPunishmentTime = 0
# Player Action - Next Target, Attack, etc
FloodProtectorPlayerActionInterval = 3
FloodProtectorPlayerActionLogFlooding = False
FloodProtectorPlayerActionPunishmentLimit = 0
FloodProtectorPlayerActionPunishmentType = none
FloodProtectorPlayerActionPunishmentTime = 0

View File

@ -610,6 +610,7 @@ public class Config
public static FloodProtectorConfig FLOOD_PROTECTOR_SENDMAIL;
public static FloodProtectorConfig FLOOD_PROTECTOR_CHARACTER_SELECT;
public static FloodProtectorConfig FLOOD_PROTECTOR_ITEM_AUCTION;
public static FloodProtectorConfig FLOOD_PROTECTOR_PLAYER_ACTION;
// --------------------------------------------------
// NPC Settings
@ -1400,6 +1401,7 @@ public class Config
FLOOD_PROTECTOR_SENDMAIL = new FloodProtectorConfig("SendMailFloodProtector");
FLOOD_PROTECTOR_CHARACTER_SELECT = new FloodProtectorConfig("CharacterSelectFloodProtector");
FLOOD_PROTECTOR_ITEM_AUCTION = new FloodProtectorConfig("ItemAuctionFloodProtector");
FLOOD_PROTECTOR_PLAYER_ACTION = new FloodProtectorConfig("PlayerActionFloodProtector");
final PropertiesParser serverSettings = new PropertiesParser(SERVER_CONFIG_FILE);
GAMESERVER_HOSTNAME = serverSettings.getString("GameserverHostname", "0.0.0.0");
@ -3765,6 +3767,7 @@ public class Config
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_SENDMAIL, "SendMail", 100);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_CHARACTER_SELECT, "CharacterSelect", 30);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_ITEM_AUCTION, "ItemAuction", 9);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_PLAYER_ACTION, "PlayerAction", 3);
}
/**

View File

@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs
public enum IncomingPackets implements IIncomingPackets<GameClient>
{
LOGOUT(0x00, Logout::new, ConnectionState.AUTHENTICATED, ConnectionState.IN_GAME),
ATTACK(0x01, Attack::new, ConnectionState.IN_GAME),
ATTACK(0x01, AttackRequest::new, ConnectionState.IN_GAME),
REQUEST_START_PLEDGE_WAR(0x03, RequestStartPledgeWar::new, ConnectionState.IN_GAME),
REQUEST_REPLY_START_PLEDGE(0x04, RequestReplyStartPledgeWar::new, ConnectionState.IN_GAME),
REQUEST_STOP_PLEDGE_WAR(0x05, RequestStopPledgeWar::new, ConnectionState.IN_GAME),

View File

@ -54,6 +54,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)

View File

@ -1,139 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.enums.PrivateStoreType;
import org.l2jmobius.gameserver.model.PlayerCondOverride;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.effects.AbstractEffect;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
/**
* TODO: This class is a copy of AttackRequest, we should get proper structure for both.
*/
public class Attack implements IClientIncomingPacket
{
// cddddc
private int _objectId;
@SuppressWarnings("unused")
private int _originX;
@SuppressWarnings("unused")
private int _originY;
@SuppressWarnings("unused")
private int _originZ;
@SuppressWarnings("unused")
private int _attackId;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_objectId = packet.readD();
_originX = packet.readD();
_originY = packet.readD();
_originZ = packet.readD();
_attackId = packet.readC(); // 0 for simple click 1 for shift-click
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
// Avoid Attacks in Boat.
if (player.isPlayable() && player.isInBoat())
{
player.sendPacket(SystemMessageId.THIS_IS_NOT_ALLOWED_WHILE_RIDING_A_FERRY_OR_BOAT);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final BuffInfo info = player.getEffectList().getFirstBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
if (info != null)
{
for (AbstractEffect effect : info.getEffects())
{
if (!effect.checkCondition(-1))
{
player.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REPORTED_AS_AN_ILLEGAL_PROGRAM_USER_SO_YOUR_ACTIONS_HAVE_BEEN_RESTRICTED);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
}
}
// avoid using expensive operations if not needed
final WorldObject target;
if (player.getTargetId() == _objectId)
{
target = player.getTarget();
}
else
{
target = World.getInstance().findObject(_objectId);
}
if (target == null)
{
return;
}
if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Players can't attack objects in the other instances
else if (target.getInstanceWorld() != player.getInstanceWorld())
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Only GMs can directly attack invisible characters
else if (!target.isVisibleFor(player))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
player.onActionRequest();
if (player.getTarget() != target)
{
target.onAction(player);
}
else if ((target.getObjectId() != player.getObjectId()) && (player.getPrivateStoreType() == PrivateStoreType.NONE) && (player.getActiveRequester() == null))
{
target.onForcedAttack(player);
}
else
{
player.sendPacket(ActionFailed.STATIC_PACKET);
}
}
}

View File

@ -56,12 +56,25 @@ public class AttackRequest implements IClientIncomingPacket
@Override
public void run(GameClient client)
{
if (!client.getFloodProtectors().getPlayerAction().tryPerformAction("PlayerAction"))
{
return;
}
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
// Avoid Attacks in Boat.
if (player.isPlayable() && player.isInBoat())
{
player.sendPacket(SystemMessageId.THIS_IS_NOT_ALLOWED_WHILE_RIDING_A_FERRY_OR_BOAT);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final BuffInfo info = player.getEffectList().getFirstBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
if (info != null)
{
@ -92,7 +105,8 @@ public class AttackRequest implements IClientIncomingPacket
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
else if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
@ -110,6 +124,8 @@ public class AttackRequest implements IClientIncomingPacket
return;
}
player.onActionRequest();
if (player.getTarget() != target)
{
target.onAction(player);

View File

@ -40,6 +40,11 @@ public class RequestTargetActionMenu implements IClientIncomingPacket
@Override
public void run(GameClient client)
{
if (!client.getFloodProtectors().getPlayerAction().tryPerformAction("PlayerAction"))
{
return;
}
final PlayerInstance player = client.getPlayer();
if ((player == null) || player.isTargetingDisabled())
{

View File

@ -87,12 +87,12 @@ public class FloodProtectorAction
*/
public boolean tryPerformAction(String command)
{
final int curTick = GameTimeTaskManager.getInstance().getGameTicks();
if ((_client.getPlayer() != null) && _client.getPlayer().canOverrideCond(PlayerCondOverride.FLOOD_CONDITIONS))
{
return true;
}
final int curTick = GameTimeTaskManager.getInstance().getGameTicks();
if ((curTick < _nextGameTick) || _punishmentInProgress)
{
if (_config.LOG_FLOODING && !_logged && LOGGER.isLoggable(Level.WARNING))

View File

@ -89,6 +89,10 @@ public class FloodProtectors
* Item Auction
*/
private final FloodProtectorAction _itemAuction;
/**
* Player Action
*/
private final FloodProtectorAction _playerAction;
/**
* Creates new instance of FloodProtectors.
@ -113,6 +117,7 @@ public class FloodProtectors
_sendMail = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_SENDMAIL);
_characterSelect = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_CHARACTER_SELECT);
_itemAuction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_ITEM_AUCTION);
_playerAction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_PLAYER_ACTION);
}
/**
@ -257,4 +262,13 @@ public class FloodProtectors
{
return _itemAuction;
}
/**
* Returns {@link #_playerAction}.
* @return {@link #_playerAction}
*/
public FloodProtectorAction getPlayerAction()
{
return _playerAction;
}
}

View File

@ -121,3 +121,10 @@ FloodProtectorItemAuctionLogFlooding = False
FloodProtectorItemAuctionPunishmentLimit = 0
FloodProtectorItemAuctionPunishmentType = none
FloodProtectorItemAuctionPunishmentTime = 0
# Player Action - Next Target, Attack, etc
FloodProtectorPlayerActionInterval = 3
FloodProtectorPlayerActionLogFlooding = False
FloodProtectorPlayerActionPunishmentLimit = 0
FloodProtectorPlayerActionPunishmentType = none
FloodProtectorPlayerActionPunishmentTime = 0

View File

@ -610,6 +610,7 @@ public class Config
public static FloodProtectorConfig FLOOD_PROTECTOR_SENDMAIL;
public static FloodProtectorConfig FLOOD_PROTECTOR_CHARACTER_SELECT;
public static FloodProtectorConfig FLOOD_PROTECTOR_ITEM_AUCTION;
public static FloodProtectorConfig FLOOD_PROTECTOR_PLAYER_ACTION;
// --------------------------------------------------
// NPC Settings
@ -1402,6 +1403,7 @@ public class Config
FLOOD_PROTECTOR_SENDMAIL = new FloodProtectorConfig("SendMailFloodProtector");
FLOOD_PROTECTOR_CHARACTER_SELECT = new FloodProtectorConfig("CharacterSelectFloodProtector");
FLOOD_PROTECTOR_ITEM_AUCTION = new FloodProtectorConfig("ItemAuctionFloodProtector");
FLOOD_PROTECTOR_PLAYER_ACTION = new FloodProtectorConfig("PlayerActionFloodProtector");
final PropertiesParser serverSettings = new PropertiesParser(SERVER_CONFIG_FILE);
GAMESERVER_HOSTNAME = serverSettings.getString("GameserverHostname", "0.0.0.0");
@ -3769,6 +3771,7 @@ public class Config
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_SENDMAIL, "SendMail", 100);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_CHARACTER_SELECT, "CharacterSelect", 30);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_ITEM_AUCTION, "ItemAuction", 9);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_PLAYER_ACTION, "PlayerAction", 3);
}
/**

View File

@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs
public enum IncomingPackets implements IIncomingPackets<GameClient>
{
LOGOUT(0x00, Logout::new, ConnectionState.AUTHENTICATED, ConnectionState.IN_GAME),
ATTACK(0x01, Attack::new, ConnectionState.IN_GAME),
ATTACK(0x01, AttackRequest::new, ConnectionState.IN_GAME),
REQUEST_START_PLEDGE_WAR(0x03, RequestStartPledgeWar::new, ConnectionState.IN_GAME),
REQUEST_REPLY_START_PLEDGE(0x04, RequestReplyStartPledgeWar::new, ConnectionState.IN_GAME),
REQUEST_STOP_PLEDGE_WAR(0x05, RequestStopPledgeWar::new, ConnectionState.IN_GAME),

View File

@ -54,6 +54,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)

View File

@ -1,139 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.enums.PrivateStoreType;
import org.l2jmobius.gameserver.model.PlayerCondOverride;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.effects.AbstractEffect;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
/**
* TODO: This class is a copy of AttackRequest, we should get proper structure for both.
*/
public class Attack implements IClientIncomingPacket
{
// cddddc
private int _objectId;
@SuppressWarnings("unused")
private int _originX;
@SuppressWarnings("unused")
private int _originY;
@SuppressWarnings("unused")
private int _originZ;
@SuppressWarnings("unused")
private int _attackId;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_objectId = packet.readD();
_originX = packet.readD();
_originY = packet.readD();
_originZ = packet.readD();
_attackId = packet.readC(); // 0 for simple click 1 for shift-click
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
// Avoid Attacks in Boat.
if (player.isPlayable() && player.isInBoat())
{
player.sendPacket(SystemMessageId.THIS_IS_NOT_ALLOWED_WHILE_RIDING_A_FERRY_OR_BOAT);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final BuffInfo info = player.getEffectList().getFirstBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
if (info != null)
{
for (AbstractEffect effect : info.getEffects())
{
if (!effect.checkCondition(-1))
{
player.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REPORTED_AS_AN_ILLEGAL_PROGRAM_USER_SO_YOUR_ACTIONS_HAVE_BEEN_RESTRICTED);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
}
}
// avoid using expensive operations if not needed
final WorldObject target;
if (player.getTargetId() == _objectId)
{
target = player.getTarget();
}
else
{
target = World.getInstance().findObject(_objectId);
}
if (target == null)
{
return;
}
if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Players can't attack objects in the other instances
else if (target.getInstanceWorld() != player.getInstanceWorld())
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Only GMs can directly attack invisible characters
else if (!target.isVisibleFor(player))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
player.onActionRequest();
if (player.getTarget() != target)
{
target.onAction(player);
}
else if ((target.getObjectId() != player.getObjectId()) && (player.getPrivateStoreType() == PrivateStoreType.NONE) && (player.getActiveRequester() == null))
{
target.onForcedAttack(player);
}
else
{
player.sendPacket(ActionFailed.STATIC_PACKET);
}
}
}

View File

@ -56,12 +56,25 @@ public class AttackRequest implements IClientIncomingPacket
@Override
public void run(GameClient client)
{
if (!client.getFloodProtectors().getPlayerAction().tryPerformAction("PlayerAction"))
{
return;
}
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
// Avoid Attacks in Boat.
if (player.isPlayable() && player.isInBoat())
{
player.sendPacket(SystemMessageId.THIS_IS_NOT_ALLOWED_WHILE_RIDING_A_FERRY_OR_BOAT);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final BuffInfo info = player.getEffectList().getFirstBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
if (info != null)
{
@ -92,7 +105,8 @@ public class AttackRequest implements IClientIncomingPacket
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
else if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
@ -110,6 +124,8 @@ public class AttackRequest implements IClientIncomingPacket
return;
}
player.onActionRequest();
if (player.getTarget() != target)
{
target.onAction(player);

View File

@ -40,6 +40,11 @@ public class RequestTargetActionMenu implements IClientIncomingPacket
@Override
public void run(GameClient client)
{
if (!client.getFloodProtectors().getPlayerAction().tryPerformAction("PlayerAction"))
{
return;
}
final PlayerInstance player = client.getPlayer();
if ((player == null) || player.isTargetingDisabled())
{

View File

@ -87,12 +87,12 @@ public class FloodProtectorAction
*/
public boolean tryPerformAction(String command)
{
final int curTick = GameTimeTaskManager.getInstance().getGameTicks();
if ((_client.getPlayer() != null) && _client.getPlayer().canOverrideCond(PlayerCondOverride.FLOOD_CONDITIONS))
{
return true;
}
final int curTick = GameTimeTaskManager.getInstance().getGameTicks();
if ((curTick < _nextGameTick) || _punishmentInProgress)
{
if (_config.LOG_FLOODING && !_logged && LOGGER.isLoggable(Level.WARNING))

View File

@ -89,6 +89,10 @@ public class FloodProtectors
* Item Auction
*/
private final FloodProtectorAction _itemAuction;
/**
* Player Action
*/
private final FloodProtectorAction _playerAction;
/**
* Creates new instance of FloodProtectors.
@ -113,6 +117,7 @@ public class FloodProtectors
_sendMail = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_SENDMAIL);
_characterSelect = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_CHARACTER_SELECT);
_itemAuction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_ITEM_AUCTION);
_playerAction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_PLAYER_ACTION);
}
/**
@ -257,4 +262,13 @@ public class FloodProtectors
{
return _itemAuction;
}
/**
* Returns {@link #_playerAction}.
* @return {@link #_playerAction}
*/
public FloodProtectorAction getPlayerAction()
{
return _playerAction;
}
}

View File

@ -121,3 +121,10 @@ FloodProtectorItemAuctionLogFlooding = False
FloodProtectorItemAuctionPunishmentLimit = 0
FloodProtectorItemAuctionPunishmentType = none
FloodProtectorItemAuctionPunishmentTime = 0
# Player Action - Next Target, Attack, etc
FloodProtectorPlayerActionInterval = 3
FloodProtectorPlayerActionLogFlooding = False
FloodProtectorPlayerActionPunishmentLimit = 0
FloodProtectorPlayerActionPunishmentType = none
FloodProtectorPlayerActionPunishmentTime = 0

View File

@ -610,6 +610,7 @@ public class Config
public static FloodProtectorConfig FLOOD_PROTECTOR_SENDMAIL;
public static FloodProtectorConfig FLOOD_PROTECTOR_CHARACTER_SELECT;
public static FloodProtectorConfig FLOOD_PROTECTOR_ITEM_AUCTION;
public static FloodProtectorConfig FLOOD_PROTECTOR_PLAYER_ACTION;
// --------------------------------------------------
// NPC Settings
@ -1402,6 +1403,7 @@ public class Config
FLOOD_PROTECTOR_SENDMAIL = new FloodProtectorConfig("SendMailFloodProtector");
FLOOD_PROTECTOR_CHARACTER_SELECT = new FloodProtectorConfig("CharacterSelectFloodProtector");
FLOOD_PROTECTOR_ITEM_AUCTION = new FloodProtectorConfig("ItemAuctionFloodProtector");
FLOOD_PROTECTOR_PLAYER_ACTION = new FloodProtectorConfig("PlayerActionFloodProtector");
final PropertiesParser serverSettings = new PropertiesParser(SERVER_CONFIG_FILE);
GAMESERVER_HOSTNAME = serverSettings.getString("GameserverHostname", "0.0.0.0");
@ -3769,6 +3771,7 @@ public class Config
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_SENDMAIL, "SendMail", 100);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_CHARACTER_SELECT, "CharacterSelect", 30);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_ITEM_AUCTION, "ItemAuction", 9);
loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_PLAYER_ACTION, "PlayerAction", 3);
}
/**

View File

@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs
public enum IncomingPackets implements IIncomingPackets<GameClient>
{
LOGOUT(0x00, Logout::new, ConnectionState.AUTHENTICATED, ConnectionState.IN_GAME),
ATTACK(0x01, Attack::new, ConnectionState.IN_GAME),
ATTACK(0x01, AttackRequest::new, ConnectionState.IN_GAME),
REQUEST_START_PLEDGE_WAR(0x03, RequestStartPledgeWar::new, ConnectionState.IN_GAME),
REQUEST_REPLY_START_PLEDGE(0x04, RequestReplyStartPledgeWar::new, ConnectionState.IN_GAME),
REQUEST_STOP_PLEDGE_WAR(0x05, RequestStopPledgeWar::new, ConnectionState.IN_GAME),

View File

@ -54,6 +54,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)

View File

@ -1,139 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.enums.PrivateStoreType;
import org.l2jmobius.gameserver.model.PlayerCondOverride;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.effects.AbstractEffect;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
/**
* TODO: This class is a copy of AttackRequest, we should get proper structure for both.
*/
public class Attack implements IClientIncomingPacket
{
// cddddc
private int _objectId;
@SuppressWarnings("unused")
private int _originX;
@SuppressWarnings("unused")
private int _originY;
@SuppressWarnings("unused")
private int _originZ;
@SuppressWarnings("unused")
private int _attackId;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_objectId = packet.readD();
_originX = packet.readD();
_originY = packet.readD();
_originZ = packet.readD();
_attackId = packet.readC(); // 0 for simple click 1 for shift-click
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
// Avoid Attacks in Boat.
if (player.isPlayable() && player.isInBoat())
{
player.sendPacket(SystemMessageId.THIS_IS_NOT_ALLOWED_WHILE_RIDING_A_FERRY_OR_BOAT);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final BuffInfo info = player.getEffectList().getFirstBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
if (info != null)
{
for (AbstractEffect effect : info.getEffects())
{
if (!effect.checkCondition(-1))
{
player.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REPORTED_AS_AN_ILLEGAL_PROGRAM_USER_SO_YOUR_ACTIONS_HAVE_BEEN_RESTRICTED);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
}
}
// avoid using expensive operations if not needed
final WorldObject target;
if (player.getTargetId() == _objectId)
{
target = player.getTarget();
}
else
{
target = World.getInstance().findObject(_objectId);
}
if (target == null)
{
return;
}
if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Players can't attack objects in the other instances
else if (target.getInstanceWorld() != player.getInstanceWorld())
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Only GMs can directly attack invisible characters
else if (!target.isVisibleFor(player))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
player.onActionRequest();
if (player.getTarget() != target)
{
target.onAction(player);
}
else if ((target.getObjectId() != player.getObjectId()) && (player.getPrivateStoreType() == PrivateStoreType.NONE) && (player.getActiveRequester() == null))
{
target.onForcedAttack(player);
}
else
{
player.sendPacket(ActionFailed.STATIC_PACKET);
}
}
}

View File

@ -56,12 +56,25 @@ public class AttackRequest implements IClientIncomingPacket
@Override
public void run(GameClient client)
{
if (!client.getFloodProtectors().getPlayerAction().tryPerformAction("PlayerAction"))
{
return;
}
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
// Avoid Attacks in Boat.
if (player.isPlayable() && player.isInBoat())
{
player.sendPacket(SystemMessageId.THIS_IS_NOT_ALLOWED_WHILE_RIDING_A_FERRY_OR_BOAT);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final BuffInfo info = player.getEffectList().getFirstBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
if (info != null)
{
@ -92,7 +105,8 @@ public class AttackRequest implements IClientIncomingPacket
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
else if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
if ((!target.isTargetable() || player.isTargetingDisabled()) && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
@ -110,6 +124,8 @@ public class AttackRequest implements IClientIncomingPacket
return;
}
player.onActionRequest();
if (player.getTarget() != target)
{
target.onAction(player);

View File

@ -40,6 +40,11 @@ public class RequestTargetActionMenu implements IClientIncomingPacket
@Override
public void run(GameClient client)
{
if (!client.getFloodProtectors().getPlayerAction().tryPerformAction("PlayerAction"))
{
return;
}
final PlayerInstance player = client.getPlayer();
if ((player == null) || player.isTargetingDisabled())
{

View File

@ -87,12 +87,12 @@ public class FloodProtectorAction
*/
public boolean tryPerformAction(String command)
{
final int curTick = GameTimeTaskManager.getInstance().getGameTicks();
if ((_client.getPlayer() != null) && _client.getPlayer().canOverrideCond(PlayerCondOverride.FLOOD_CONDITIONS))
{
return true;
}
final int curTick = GameTimeTaskManager.getInstance().getGameTicks();
if ((curTick < _nextGameTick) || _punishmentInProgress)
{
if (_config.LOG_FLOODING && !_logged && LOGGER.isLoggable(Level.WARNING))

View File

@ -89,6 +89,10 @@ public class FloodProtectors
* Item Auction
*/
private final FloodProtectorAction _itemAuction;
/**
* Player Action
*/
private final FloodProtectorAction _playerAction;
/**
* Creates new instance of FloodProtectors.
@ -113,6 +117,7 @@ public class FloodProtectors
_sendMail = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_SENDMAIL);
_characterSelect = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_CHARACTER_SELECT);
_itemAuction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_ITEM_AUCTION);
_playerAction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_PLAYER_ACTION);
}
/**
@ -257,4 +262,13 @@ public class FloodProtectors
{
return _itemAuction;
}
/**
* Returns {@link #_playerAction}.
* @return {@link #_playerAction}
*/
public FloodProtectorAction getPlayerAction()
{
return _playerAction;
}
}

View File

@ -120,13 +120,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
@ -148,16 +141,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

View File

@ -779,13 +779,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;
@ -2217,13 +2216,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);
@ -2236,9 +2234,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");
@ -2912,13 +2910,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)

View File

@ -377,7 +377,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);
@ -15174,16 +15173,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++)

View File

@ -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)

View File

@ -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)

Some files were not shown because too many files have changed in this diff Show More