From 259fa858f600e8afa1b4b4d3a5214abb78202127 Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Mon, 8 Nov 2021 15:52:50 +0000 Subject: [PATCH] Addition of player action flood protector. --- .../dist/game/config/FloodProtector.ini | 7 + .../java/org/l2jmobius/Config.java | 3 + .../gameserver/network/IncomingPackets.java | 2 +- .../network/clientpackets/Action.java | 5 + .../network/clientpackets/Attack.java | 139 ----------- .../network/clientpackets/AttackRequest.java | 18 +- .../gameserver/util/FloodProtectorAction.java | 2 +- .../gameserver/util/FloodProtectors.java | 14 ++ .../dist/game/config/FloodProtector.ini | 7 + .../java/org/l2jmobius/Config.java | 3 + .../gameserver/network/IncomingPackets.java | 2 +- .../network/clientpackets/Action.java | 5 + .../network/clientpackets/Attack.java | 139 ----------- .../network/clientpackets/AttackRequest.java | 18 +- .../gameserver/util/FloodProtectorAction.java | 2 +- .../gameserver/util/FloodProtectors.java | 14 ++ .../dist/game/config/FloodProtector.ini | 7 + .../java/org/l2jmobius/Config.java | 3 + .../gameserver/network/IncomingPackets.java | 2 +- .../network/clientpackets/Action.java | 5 + .../network/clientpackets/Attack.java | 139 ----------- .../network/clientpackets/AttackRequest.java | 18 +- .../gameserver/util/FloodProtectorAction.java | 2 +- .../gameserver/util/FloodProtectors.java | 14 ++ .../dist/game/config/FloodProtector.ini | 7 + .../java/org/l2jmobius/Config.java | 3 + .../gameserver/network/IncomingPackets.java | 2 +- .../network/clientpackets/Action.java | 5 + .../network/clientpackets/Attack.java | 139 ----------- .../network/clientpackets/AttackRequest.java | 18 +- .../gameserver/util/FloodProtectorAction.java | 2 +- .../gameserver/util/FloodProtectors.java | 14 ++ .../dist/game/config/FloodProtector.ini | 7 + .../java/org/l2jmobius/Config.java | 3 + .../gameserver/network/IncomingPackets.java | 2 +- .../network/clientpackets/Action.java | 5 + .../network/clientpackets/Attack.java | 139 ----------- .../network/clientpackets/AttackRequest.java | 18 +- .../RequestTargetActionMenu.java | 5 + .../gameserver/util/FloodProtectorAction.java | 2 +- .../gameserver/util/FloodProtectors.java | 14 ++ .../dist/game/config/FloodProtector.ini | 7 + .../java/org/l2jmobius/Config.java | 3 + .../gameserver/network/IncomingPackets.java | 2 +- .../network/clientpackets/Action.java | 5 + .../network/clientpackets/Attack.java | 139 ----------- .../network/clientpackets/AttackRequest.java | 18 +- .../RequestTargetActionMenu.java | 5 + .../gameserver/util/FloodProtectorAction.java | 2 +- .../gameserver/util/FloodProtectors.java | 14 ++ .../dist/game/config/FloodProtector.ini | 7 + .../java/org/l2jmobius/Config.java | 3 + .../gameserver/network/IncomingPackets.java | 2 +- .../network/clientpackets/Action.java | 5 + .../network/clientpackets/Attack.java | 139 ----------- .../network/clientpackets/AttackRequest.java | 18 +- .../RequestTargetActionMenu.java | 5 + .../gameserver/util/FloodProtectorAction.java | 2 +- .../gameserver/util/FloodProtectors.java | 14 ++ .../dist/game/config/FloodProtector.ini | 7 + .../java/org/l2jmobius/Config.java | 3 + .../gameserver/network/IncomingPackets.java | 2 +- .../network/clientpackets/Action.java | 5 + .../network/clientpackets/Attack.java | 139 ----------- .../network/clientpackets/AttackRequest.java | 18 +- .../RequestTargetActionMenu.java | 5 + .../gameserver/util/FloodProtectorAction.java | 2 +- .../gameserver/util/FloodProtectors.java | 14 ++ .../dist/game/config/FloodProtector.ini | 7 + .../java/org/l2jmobius/Config.java | 3 + .../gameserver/network/IncomingPackets.java | 2 +- .../network/clientpackets/Action.java | 5 + .../network/clientpackets/Attack.java | 139 ----------- .../network/clientpackets/AttackRequest.java | 18 +- .../RequestTargetActionMenu.java | 5 + .../gameserver/util/FloodProtectorAction.java | 2 +- .../gameserver/util/FloodProtectors.java | 14 ++ .../dist/game/config/FloodProtector.ini | 7 + .../java/org/l2jmobius/Config.java | 3 + .../gameserver/network/IncomingPackets.java | 2 +- .../network/clientpackets/Action.java | 5 + .../network/clientpackets/Attack.java | 139 ----------- .../network/clientpackets/AttackRequest.java | 18 +- .../RequestTargetActionMenu.java | 5 + .../gameserver/util/FloodProtectorAction.java | 2 +- .../gameserver/util/FloodProtectors.java | 14 ++ .../dist/game/config/FloodProtector.ini | 7 + .../java/org/l2jmobius/Config.java | 3 + .../gameserver/network/IncomingPackets.java | 2 +- .../network/clientpackets/Action.java | 5 + .../network/clientpackets/Attack.java | 139 ----------- .../network/clientpackets/AttackRequest.java | 18 +- .../RequestTargetActionMenu.java | 5 + .../gameserver/util/FloodProtectorAction.java | 2 +- .../gameserver/util/FloodProtectors.java | 14 ++ .../game/config/protected/FloodProtector.ini | 23 +- .../java/org/l2jmobius/Config.java | 17 +- .../model/actor/instance/PlayerInstance.java | 11 - .../network/clientpackets/Action.java | 5 + .../network/clientpackets/AttackRequest.java | 20 +- .../gameserver/util/FloodProtectorAction.java | 219 +++++------------- .../gameserver/util/FloodProtectorConfig.java | 22 +- .../gameserver/util/FloodProtectors.java | 44 ++-- .../game/config/protected/FloodProtector.ini | 23 +- .../java/org/l2jmobius/Config.java | 17 +- .../model/actor/instance/PlayerInstance.java | 11 - .../network/clientpackets/Action.java | 5 + .../network/clientpackets/AttackRequest.java | 20 +- .../gameserver/util/FloodProtectorAction.java | 219 +++++------------- .../gameserver/util/FloodProtectorConfig.java | 22 +- .../gameserver/util/FloodProtectors.java | 44 ++-- .../dist/game/config/FloodProtector.ini | 7 + .../java/org/l2jmobius/Config.java | 3 + .../gameserver/network/IncomingPackets.java | 2 +- .../network/clientpackets/Action.java | 5 + .../network/clientpackets/Attack.java | 145 ------------ .../network/clientpackets/AttackRequest.java | 17 +- .../gameserver/util/FloodProtectorAction.java | 2 +- .../gameserver/util/FloodProtectors.java | 14 ++ .../dist/game/config/FloodProtector.ini | 7 + .../java/org/l2jmobius/Config.java | 3 + .../gameserver/network/IncomingPackets.java | 2 +- .../network/clientpackets/Action.java | 5 + .../network/clientpackets/Attack.java | 145 ------------ .../network/clientpackets/AttackRequest.java | 17 +- .../gameserver/util/FloodProtectorAction.java | 2 +- .../gameserver/util/FloodProtectors.java | 14 ++ .../dist/game/config/FloodProtector.ini | 7 + .../java/org/l2jmobius/Config.java | 3 + .../gameserver/network/IncomingPackets.java | 2 +- .../network/clientpackets/Action.java | 5 + .../network/clientpackets/Attack.java | 139 ----------- .../network/clientpackets/AttackRequest.java | 18 +- .../gameserver/util/FloodProtectorAction.java | 2 +- .../gameserver/util/FloodProtectors.java | 14 ++ .../dist/game/config/FloodProtector.ini | 7 + .../java/org/l2jmobius/Config.java | 3 + .../gameserver/network/IncomingPackets.java | 2 +- .../network/clientpackets/Action.java | 5 + .../network/clientpackets/Attack.java | 139 ----------- .../network/clientpackets/AttackRequest.java | 18 +- .../gameserver/util/FloodProtectorAction.java | 2 +- .../gameserver/util/FloodProtectors.java | 14 ++ .../dist/game/config/FloodProtector.ini | 7 + .../java/org/l2jmobius/Config.java | 3 + .../gameserver/network/IncomingPackets.java | 2 +- .../network/clientpackets/Action.java | 5 + .../network/clientpackets/Attack.java | 139 ----------- .../network/clientpackets/AttackRequest.java | 18 +- .../RequestTargetActionMenu.java | 5 + .../gameserver/util/FloodProtectorAction.java | 2 +- .../gameserver/util/FloodProtectors.java | 14 ++ .../dist/game/config/FloodProtector.ini | 7 + .../java/org/l2jmobius/Config.java | 3 + .../gameserver/network/IncomingPackets.java | 2 +- .../network/clientpackets/Action.java | 5 + .../network/clientpackets/Attack.java | 139 ----------- .../network/clientpackets/AttackRequest.java | 18 +- .../RequestTargetActionMenu.java | 5 + .../gameserver/util/FloodProtectorAction.java | 2 +- .../gameserver/util/FloodProtectors.java | 14 ++ .../dist/game/config/FloodProtector.ini | 7 + .../java/org/l2jmobius/Config.java | 3 + .../gameserver/network/IncomingPackets.java | 2 +- .../network/clientpackets/Action.java | 5 + .../network/clientpackets/Attack.java | 139 ----------- .../network/clientpackets/AttackRequest.java | 18 +- .../RequestTargetActionMenu.java | 5 + .../gameserver/util/FloodProtectorAction.java | 2 +- .../gameserver/util/FloodProtectors.java | 14 ++ .../dist/game/config/FloodProtector.ini | 7 + .../java/org/l2jmobius/Config.java | 3 + .../gameserver/network/IncomingPackets.java | 2 +- .../network/clientpackets/Action.java | 5 + .../network/clientpackets/Attack.java | 139 ----------- .../network/clientpackets/AttackRequest.java | 18 +- .../RequestTargetActionMenu.java | 5 + .../gameserver/util/FloodProtectorAction.java | 2 +- .../gameserver/util/FloodProtectors.java | 14 ++ .../dist/game/config/FloodProtector.ini | 7 + .../java/org/l2jmobius/Config.java | 3 + .../gameserver/network/IncomingPackets.java | 2 +- .../network/clientpackets/Action.java | 5 + .../network/clientpackets/Attack.java | 139 ----------- .../network/clientpackets/AttackRequest.java | 18 +- .../gameserver/util/FloodProtectorAction.java | 2 +- .../gameserver/util/FloodProtectors.java | 14 ++ .../dist/game/config/FloodProtector.ini | 7 + .../java/org/l2jmobius/Config.java | 3 + .../gameserver/network/IncomingPackets.java | 2 +- .../network/clientpackets/Action.java | 5 + .../network/clientpackets/Attack.java | 139 ----------- .../network/clientpackets/AttackRequest.java | 18 +- .../RequestTargetActionMenu.java | 5 + .../gameserver/util/FloodProtectorAction.java | 2 +- .../gameserver/util/FloodProtectors.java | 14 ++ .../dist/game/config/FloodProtector.ini | 7 + .../java/org/l2jmobius/Config.java | 3 + .../gameserver/network/IncomingPackets.java | 2 +- .../network/clientpackets/Action.java | 5 + .../network/clientpackets/Attack.java | 139 ----------- .../network/clientpackets/AttackRequest.java | 18 +- .../RequestTargetActionMenu.java | 5 + .../gameserver/util/FloodProtectorAction.java | 2 +- .../gameserver/util/FloodProtectors.java | 14 ++ .../dist/game/config/FloodProtector.ini | 7 + .../java/org/l2jmobius/Config.java | 3 + .../gameserver/network/IncomingPackets.java | 2 +- .../network/clientpackets/Action.java | 5 + .../network/clientpackets/Attack.java | 139 ----------- .../network/clientpackets/AttackRequest.java | 18 +- .../RequestTargetActionMenu.java | 5 + .../gameserver/util/FloodProtectorAction.java | 2 +- .../gameserver/util/FloodProtectors.java | 14 ++ 214 files changed, 1376 insertions(+), 3796 deletions(-) delete mode 100644 L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java delete mode 100644 L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java delete mode 100644 L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java delete mode 100644 L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java delete mode 100644 L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java delete mode 100644 L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java delete mode 100644 L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java delete mode 100644 L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java delete mode 100644 L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java delete mode 100644 L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java delete mode 100644 L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java delete mode 100644 L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java delete mode 100644 L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java delete mode 100644 L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java delete mode 100644 L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java delete mode 100644 L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java delete mode 100644 L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java delete mode 100644 L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java delete mode 100644 L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java delete mode 100644 L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java delete mode 100644 L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java delete mode 100644 L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java delete mode 100644 L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java diff --git a/L2J_Mobius_01.0_Ertheia/dist/game/config/FloodProtector.ini b/L2J_Mobius_01.0_Ertheia/dist/game/config/FloodProtector.ini index 28c86264fb..10bccf42b1 100644 --- a/L2J_Mobius_01.0_Ertheia/dist/game/config/FloodProtector.ini +++ b/L2J_Mobius_01.0_Ertheia/dist/game/config/FloodProtector.ini @@ -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 diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/Config.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/Config.java index 5d948b2661..7fb4bd6827 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/Config.java @@ -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); } /** diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/IncomingPackets.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/IncomingPackets.java index 49e3115b1d..28dd9bf81e 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/IncomingPackets.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/IncomingPackets.java @@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs public enum IncomingPackets implements IIncomingPackets { 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), diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/Action.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/Action.java index 05cb3e912d..a2d1007bc0 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/Action.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/Action.java @@ -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) diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java deleted file mode 100644 index 6b00f49373..0000000000 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java +++ /dev/null @@ -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 . - */ -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); - } - } -} diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java index 1b107de541..71af0d06d2 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java @@ -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); diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java index 993a5ede11..5e7783107d 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java @@ -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)) diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/util/FloodProtectors.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/util/FloodProtectors.java index b9cdcc6362..b9570c8687 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/util/FloodProtectors.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/util/FloodProtectors.java @@ -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; + } } diff --git a/L2J_Mobius_02.5_Underground/dist/game/config/FloodProtector.ini b/L2J_Mobius_02.5_Underground/dist/game/config/FloodProtector.ini index 28c86264fb..10bccf42b1 100644 --- a/L2J_Mobius_02.5_Underground/dist/game/config/FloodProtector.ini +++ b/L2J_Mobius_02.5_Underground/dist/game/config/FloodProtector.ini @@ -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 diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/Config.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/Config.java index 243c1c291e..dd94821fac 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/Config.java @@ -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); } /** diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/IncomingPackets.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/IncomingPackets.java index b06d18ab9b..c46983e2aa 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/IncomingPackets.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/IncomingPackets.java @@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs public enum IncomingPackets implements IIncomingPackets { 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), diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/Action.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/Action.java index 05cb3e912d..a2d1007bc0 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/Action.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/Action.java @@ -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) diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java deleted file mode 100644 index 6b00f49373..0000000000 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java +++ /dev/null @@ -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 . - */ -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); - } - } -} diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java index 1b107de541..71af0d06d2 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java @@ -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); diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java index 993a5ede11..5e7783107d 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java @@ -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)) diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/util/FloodProtectors.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/util/FloodProtectors.java index b9cdcc6362..b9570c8687 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/util/FloodProtectors.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/util/FloodProtectors.java @@ -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; + } } diff --git a/L2J_Mobius_03.0_Helios/dist/game/config/FloodProtector.ini b/L2J_Mobius_03.0_Helios/dist/game/config/FloodProtector.ini index 28c86264fb..10bccf42b1 100644 --- a/L2J_Mobius_03.0_Helios/dist/game/config/FloodProtector.ini +++ b/L2J_Mobius_03.0_Helios/dist/game/config/FloodProtector.ini @@ -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 diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/Config.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/Config.java index 36b08fdd3f..7647cb07f3 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/Config.java @@ -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); } /** diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/IncomingPackets.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/IncomingPackets.java index b06d18ab9b..c46983e2aa 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/IncomingPackets.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/IncomingPackets.java @@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs public enum IncomingPackets implements IIncomingPackets { 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), diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/Action.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/Action.java index 05cb3e912d..a2d1007bc0 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/Action.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/Action.java @@ -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) diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java deleted file mode 100644 index 6b00f49373..0000000000 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java +++ /dev/null @@ -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 . - */ -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); - } - } -} diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java index 1b107de541..71af0d06d2 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java @@ -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); diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java index 993a5ede11..5e7783107d 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java @@ -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)) diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/util/FloodProtectors.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/util/FloodProtectors.java index b9cdcc6362..b9570c8687 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/util/FloodProtectors.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/util/FloodProtectors.java @@ -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; + } } diff --git a/L2J_Mobius_04.0_GrandCrusade/dist/game/config/FloodProtector.ini b/L2J_Mobius_04.0_GrandCrusade/dist/game/config/FloodProtector.ini index 28c86264fb..10bccf42b1 100644 --- a/L2J_Mobius_04.0_GrandCrusade/dist/game/config/FloodProtector.ini +++ b/L2J_Mobius_04.0_GrandCrusade/dist/game/config/FloodProtector.ini @@ -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 diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/Config.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/Config.java index 59f58509af..076529c92b 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/Config.java @@ -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); } /** diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/IncomingPackets.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/IncomingPackets.java index b06d18ab9b..c46983e2aa 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/IncomingPackets.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/IncomingPackets.java @@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs public enum IncomingPackets implements IIncomingPackets { 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), diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/Action.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/Action.java index 05cb3e912d..a2d1007bc0 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/Action.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/Action.java @@ -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) diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java deleted file mode 100644 index 6b00f49373..0000000000 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java +++ /dev/null @@ -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 . - */ -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); - } - } -} diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java index 1b107de541..71af0d06d2 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java @@ -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); diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java index 993a5ede11..5e7783107d 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java @@ -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)) diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/util/FloodProtectors.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/util/FloodProtectors.java index b9cdcc6362..b9570c8687 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/util/FloodProtectors.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/util/FloodProtectors.java @@ -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; + } } diff --git a/L2J_Mobius_05.0_Salvation/dist/game/config/FloodProtector.ini b/L2J_Mobius_05.0_Salvation/dist/game/config/FloodProtector.ini index 28c86264fb..10bccf42b1 100644 --- a/L2J_Mobius_05.0_Salvation/dist/game/config/FloodProtector.ini +++ b/L2J_Mobius_05.0_Salvation/dist/game/config/FloodProtector.ini @@ -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 diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/Config.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/Config.java index aba2f9b7a5..eba998ab30 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/Config.java @@ -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); } /** diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/IncomingPackets.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/IncomingPackets.java index b06d18ab9b..c46983e2aa 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/IncomingPackets.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/IncomingPackets.java @@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs public enum IncomingPackets implements IIncomingPackets { 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), diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/Action.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/Action.java index 05cb3e912d..a2d1007bc0 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/Action.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/Action.java @@ -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) diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java deleted file mode 100644 index 6b00f49373..0000000000 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java +++ /dev/null @@ -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 . - */ -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); - } - } -} diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java index 1b107de541..71af0d06d2 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java @@ -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); diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java index 19cbdbfede..780eb34419 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java @@ -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()) { diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java index 993a5ede11..5e7783107d 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java @@ -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)) diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/util/FloodProtectors.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/util/FloodProtectors.java index b9cdcc6362..b9570c8687 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/util/FloodProtectors.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/util/FloodProtectors.java @@ -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; + } } diff --git a/L2J_Mobius_05.5_EtinasFate/dist/game/config/FloodProtector.ini b/L2J_Mobius_05.5_EtinasFate/dist/game/config/FloodProtector.ini index 28c86264fb..10bccf42b1 100644 --- a/L2J_Mobius_05.5_EtinasFate/dist/game/config/FloodProtector.ini +++ b/L2J_Mobius_05.5_EtinasFate/dist/game/config/FloodProtector.ini @@ -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 diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/Config.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/Config.java index 7208e70096..e24a2b61b1 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/Config.java @@ -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); } /** diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/IncomingPackets.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/IncomingPackets.java index b06d18ab9b..c46983e2aa 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/IncomingPackets.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/IncomingPackets.java @@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs public enum IncomingPackets implements IIncomingPackets { 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), diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/Action.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/Action.java index 05cb3e912d..a2d1007bc0 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/Action.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/Action.java @@ -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) diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java deleted file mode 100644 index 6b00f49373..0000000000 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java +++ /dev/null @@ -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 . - */ -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); - } - } -} diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java index 1b107de541..71af0d06d2 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java @@ -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); diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java index 19cbdbfede..780eb34419 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java @@ -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()) { diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java index 993a5ede11..5e7783107d 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java @@ -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)) diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/util/FloodProtectors.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/util/FloodProtectors.java index b9cdcc6362..b9570c8687 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/util/FloodProtectors.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/util/FloodProtectors.java @@ -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; + } } diff --git a/L2J_Mobius_06.0_Fafurion/dist/game/config/FloodProtector.ini b/L2J_Mobius_06.0_Fafurion/dist/game/config/FloodProtector.ini index 28c86264fb..10bccf42b1 100644 --- a/L2J_Mobius_06.0_Fafurion/dist/game/config/FloodProtector.ini +++ b/L2J_Mobius_06.0_Fafurion/dist/game/config/FloodProtector.ini @@ -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 diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/Config.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/Config.java index 2bab3ac7af..3c957f1337 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/Config.java @@ -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); } /** diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/IncomingPackets.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/IncomingPackets.java index b06d18ab9b..c46983e2aa 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/IncomingPackets.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/IncomingPackets.java @@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs public enum IncomingPackets implements IIncomingPackets { 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), diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/Action.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/Action.java index 05cb3e912d..a2d1007bc0 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/Action.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/Action.java @@ -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) diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java deleted file mode 100644 index 6b00f49373..0000000000 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java +++ /dev/null @@ -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 . - */ -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); - } - } -} diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java index 1b107de541..71af0d06d2 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java @@ -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); diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java index 19cbdbfede..780eb34419 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java @@ -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()) { diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java index 993a5ede11..5e7783107d 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java @@ -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)) diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/util/FloodProtectors.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/util/FloodProtectors.java index b9cdcc6362..b9570c8687 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/util/FloodProtectors.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/util/FloodProtectors.java @@ -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; + } } diff --git a/L2J_Mobius_07.0_PreludeOfWar/dist/game/config/FloodProtector.ini b/L2J_Mobius_07.0_PreludeOfWar/dist/game/config/FloodProtector.ini index 28c86264fb..10bccf42b1 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/dist/game/config/FloodProtector.ini +++ b/L2J_Mobius_07.0_PreludeOfWar/dist/game/config/FloodProtector.ini @@ -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 diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/Config.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/Config.java index 22e714a535..8b8ba6930e 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/Config.java @@ -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); } /** diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/IncomingPackets.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/IncomingPackets.java index b06d18ab9b..c46983e2aa 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/IncomingPackets.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/IncomingPackets.java @@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs public enum IncomingPackets implements IIncomingPackets { 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), diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/Action.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/Action.java index 05cb3e912d..a2d1007bc0 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/Action.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/Action.java @@ -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) diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java deleted file mode 100644 index 6b00f49373..0000000000 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java +++ /dev/null @@ -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 . - */ -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); - } - } -} diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java index 1b107de541..71af0d06d2 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java @@ -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); diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java index 19cbdbfede..780eb34419 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java @@ -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()) { diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java index 993a5ede11..5e7783107d 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java @@ -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)) diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/FloodProtectors.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/FloodProtectors.java index b9cdcc6362..b9570c8687 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/FloodProtectors.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/util/FloodProtectors.java @@ -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; + } } diff --git a/L2J_Mobius_08.2_Homunculus/dist/game/config/FloodProtector.ini b/L2J_Mobius_08.2_Homunculus/dist/game/config/FloodProtector.ini index 28c86264fb..10bccf42b1 100644 --- a/L2J_Mobius_08.2_Homunculus/dist/game/config/FloodProtector.ini +++ b/L2J_Mobius_08.2_Homunculus/dist/game/config/FloodProtector.ini @@ -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 diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/Config.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/Config.java index de1b842f25..344188a3e4 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/Config.java @@ -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); } /** diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/IncomingPackets.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/IncomingPackets.java index b06d18ab9b..c46983e2aa 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/IncomingPackets.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/IncomingPackets.java @@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs public enum IncomingPackets implements IIncomingPackets { 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), diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/Action.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/Action.java index 05cb3e912d..a2d1007bc0 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/Action.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/Action.java @@ -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) diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java deleted file mode 100644 index 6b00f49373..0000000000 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java +++ /dev/null @@ -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 . - */ -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); - } - } -} diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java index 1b107de541..71af0d06d2 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java @@ -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); diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java index 19cbdbfede..780eb34419 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java @@ -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()) { diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java index 993a5ede11..5e7783107d 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java @@ -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)) diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/util/FloodProtectors.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/util/FloodProtectors.java index b9cdcc6362..b9570c8687 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/util/FloodProtectors.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/util/FloodProtectors.java @@ -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; + } } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/config/FloodProtector.ini b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/config/FloodProtector.ini index 28c86264fb..10bccf42b1 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/config/FloodProtector.ini +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/config/FloodProtector.ini @@ -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 diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/Config.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/Config.java index 42ad35dc67..dcbc384b86 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/Config.java @@ -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); } /** diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/IncomingPackets.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/IncomingPackets.java index b06d18ab9b..c46983e2aa 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/IncomingPackets.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/IncomingPackets.java @@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs public enum IncomingPackets implements IIncomingPackets { 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), diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/Action.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/Action.java index 05cb3e912d..a2d1007bc0 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/Action.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/Action.java @@ -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) diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java deleted file mode 100644 index 6b00f49373..0000000000 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java +++ /dev/null @@ -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 . - */ -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); - } - } -} diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java index 1b107de541..71af0d06d2 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java @@ -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); diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java index 19cbdbfede..780eb34419 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java @@ -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()) { diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java index 993a5ede11..5e7783107d 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java @@ -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)) diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/util/FloodProtectors.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/util/FloodProtectors.java index b9cdcc6362..b9570c8687 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/util/FloodProtectors.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/util/FloodProtectors.java @@ -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; + } } diff --git a/L2J_Mobius_10.0_MasterClass/dist/game/config/FloodProtector.ini b/L2J_Mobius_10.0_MasterClass/dist/game/config/FloodProtector.ini index 28c86264fb..10bccf42b1 100644 --- a/L2J_Mobius_10.0_MasterClass/dist/game/config/FloodProtector.ini +++ b/L2J_Mobius_10.0_MasterClass/dist/game/config/FloodProtector.ini @@ -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 diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/Config.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/Config.java index 9799ffbf03..4489753db7 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/Config.java @@ -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); } /** diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/IncomingPackets.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/IncomingPackets.java index b06d18ab9b..c46983e2aa 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/IncomingPackets.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/IncomingPackets.java @@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs public enum IncomingPackets implements IIncomingPackets { 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), diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/Action.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/Action.java index 05cb3e912d..a2d1007bc0 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/Action.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/Action.java @@ -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) diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java deleted file mode 100644 index 6b00f49373..0000000000 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java +++ /dev/null @@ -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 . - */ -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); - } - } -} diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java index 1b107de541..71af0d06d2 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java @@ -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); diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java index 19cbdbfede..780eb34419 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java @@ -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()) { diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java index 993a5ede11..5e7783107d 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java @@ -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)) diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/util/FloodProtectors.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/util/FloodProtectors.java index b9cdcc6362..b9570c8687 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/util/FloodProtectors.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/util/FloodProtectors.java @@ -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; + } } diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/game/config/protected/FloodProtector.ini b/L2J_Mobius_C4_ScionsOfDestiny/dist/game/config/protected/FloodProtector.ini index cdd17fe8f6..a1132e81a4 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/dist/game/config/protected/FloodProtector.ini +++ b/L2J_Mobius_C4_ScionsOfDestiny/dist/game/config/protected/FloodProtector.ini @@ -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 \ No newline at end of file +FloodProtectorMacroPunishmentTime = 0 + +# Player Action - Next Target, Attack, etc +FloodProtectorPlayerActionInterval = 3 +FloodProtectorPlayerActionLogFlooding = False +FloodProtectorPlayerActionPunishmentLimit = 0 +FloodProtectorPlayerActionPunishmentType = none +FloodProtectorPlayerActionPunishmentTime = 0 diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java index 9ec8fe6672..4fa8b57697 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java @@ -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) diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 9d068f73b9..33149b9a3e 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -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++) diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/clientpackets/Action.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/clientpackets/Action.java index 135a792cdf..3fc1e55259 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/clientpackets/Action.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/clientpackets/Action.java @@ -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) diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java index 0317249532..4d0daf423f 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java @@ -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) diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java index 8cadcda079..5312a44569 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java @@ -16,13 +16,11 @@ */ package org.l2jmobius.gameserver.util; -import java.util.HashMap; -import java.util.Map; +import java.util.Arrays; import java.util.concurrent.atomic.AtomicInteger; +import java.util.logging.Level; import java.util.logging.Logger; -import org.l2jmobius.commons.util.StringUtil; -import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance.PunishLevel; import org.l2jmobius.gameserver.network.ConnectionState; import org.l2jmobius.gameserver.network.GameClient; @@ -41,15 +39,15 @@ public class FloodProtectorAction /** * Client for this instance of flood protector. */ - private final GameClient client; + private final GameClient _client; /** * Configuration of this instance of flood protector. */ - private final FloodProtectorConfig config; + private final FloodProtectorConfig _config; /** * Next game tick when new request is allowed. */ - private volatile float _nextGameTick = GameTimeTaskManager.getGameTicks(); + private volatile int _nextGameTick = GameTimeTaskManager.getGameTicks(); /** * Request counter. */ @@ -62,25 +60,19 @@ public class FloodProtectorAction * Flag determining whether punishment application is in progress so that we do not apply punisment multiple times (flooding). */ private volatile boolean _punishmentInProgress; - /** - * Count from when the floodProtector start to block next action. - */ - private final int _untilBlock = 4; /** * Creates new instance of FloodProtectorAction. - * @param client for which flood protection is being created + * @param client the game client for which flood protection is being created * @param config flood protector configuration */ public FloodProtectorAction(GameClient client, FloodProtectorConfig config) { super(); - this.client = client; - this.config = config; + _client = client; + _config = config; } - private final Map received_commands_actions = new HashMap<>(); - /** * Checks whether the request is flood protected or not. * @param command command issued or short command description @@ -88,135 +80,51 @@ public class FloodProtectorAction */ public boolean tryPerformAction(String command) { - // Ignore flood protector for GM char - if ((client != null) && (client.getPlayer() != null) && client.getPlayer().isGM()) + if ((_client.getPlayer() != null) && _client.getPlayer().isGM()) { return true; } - if (!config.ALTERNATIVE_METHOD) - { - final int curTick = GameTimeTaskManager.getGameTicks(); - if ((curTick < _nextGameTick) || _punishmentInProgress) - { - if (config.LOG_FLOODING && !_logged) - { - LOGGER.warning(" called command " + command + " ~ " + ((config.FLOOD_PROTECTION_INTERVAL - (_nextGameTick - curTick)) * GameTimeTaskManager.MILLIS_IN_TICK) + " ms after previous command"); - _logged = true; - } - - _count.incrementAndGet(); - - if (!_punishmentInProgress && (config.PUNISHMENT_LIMIT > 0) && (_count.get() >= config.PUNISHMENT_LIMIT) && (config.PUNISHMENT_TYPE != null)) - { - _punishmentInProgress = true; - if ("kick".equals(config.PUNISHMENT_TYPE)) - { - kickPlayer(); - } - else if ("ban".equals(config.PUNISHMENT_TYPE)) - { - banAccount(); - } - else if ("jail".equals(config.PUNISHMENT_TYPE)) - { - jailChar(); - } - else if ("banchat".equals(config.PUNISHMENT_TYPE)) - { - banChat(); - } - - _punishmentInProgress = false; - } - - // Avoid macro issue - if ((config.FLOOD_PROTECTOR_TYPE.equals("UseItemFloodProtector")) || (config.FLOOD_PROTECTOR_TYPE.equals("ServerBypassFloodProtector"))) - { - // _untilBlock value is 4 - if (_count.get() > _untilBlock) - { - return false; - } - - return true; - } - - return false; - } - - if ((_count.get() > 0) && config.LOG_FLOODING) - { - LOGGER(" issued ", String.valueOf(_count), " extra requests within ~", String.valueOf(config.FLOOD_PROTECTION_INTERVAL * GameTimeTaskManager.MILLIS_IN_TICK), " ms"); - } - - _nextGameTick = curTick + config.FLOOD_PROTECTION_INTERVAL; - _logged = false; - _count.set(0); - - return true; - } - final int curTick = GameTimeTaskManager.getGameTicks(); if ((curTick < _nextGameTick) || _punishmentInProgress) { - if (config.LOG_FLOODING && !_logged) + if (_config.LOG_FLOODING && !_logged && LOGGER.isLoggable(Level.WARNING)) { - LOGGER.warning(" called command " + command + " ~ " + ((config.FLOOD_PROTECTION_INTERVAL - (_nextGameTick - curTick)) * GameTimeTaskManager.MILLIS_IN_TICK) + " ms after previous command"); + log(" called command ", command, " ~", String.valueOf((_config.FLOOD_PROTECTION_INTERVAL - (_nextGameTick - curTick)) * GameTimeTaskManager.MILLIS_IN_TICK), " ms after previous command"); _logged = true; } - AtomicInteger commandCount = received_commands_actions.get(command); - if (commandCount == null) - { - commandCount = new AtomicInteger(0); - } + _count.incrementAndGet(); - final int count = commandCount.incrementAndGet(); - received_commands_actions.put(command, commandCount); - - if (!_punishmentInProgress && (config.PUNISHMENT_LIMIT > 0) && (count >= config.PUNISHMENT_LIMIT) && (config.PUNISHMENT_TYPE != null)) + if (!_punishmentInProgress && (_config.PUNISHMENT_LIMIT > 0) && (_count.get() >= _config.PUNISHMENT_LIMIT) && (_config.PUNISHMENT_TYPE != null)) { _punishmentInProgress = true; - if ("kick".equals(config.PUNISHMENT_TYPE)) + if ("kick".equals(_config.PUNISHMENT_TYPE)) { kickPlayer(); } - else if ("ban".equals(config.PUNISHMENT_TYPE)) + else if ("ban".equals(_config.PUNISHMENT_TYPE)) { banAccount(); } - else if ("jail".equals(config.PUNISHMENT_TYPE)) + else if ("jail".equals(_config.PUNISHMENT_TYPE)) { jailChar(); } _punishmentInProgress = false; } - return false; } - AtomicInteger commandCount = received_commands_actions.get(command); - if (commandCount == null) + if ((_count.get() > 0) && _config.LOG_FLOODING && LOGGER.isLoggable(Level.WARNING)) { - commandCount = new AtomicInteger(0); - received_commands_actions.put(command, commandCount); + log(" issued ", String.valueOf(_count), " extra requests within ~", String.valueOf(_config.FLOOD_PROTECTION_INTERVAL * GameTimeTaskManager.MILLIS_IN_TICK), " ms"); } - if (commandCount.get() > 0) - { - if (config.LOG_FLOODING) - { - LOGGER.warning(" issued " + commandCount + " extra requests within ~ " + (config.FLOOD_PROTECTION_INTERVAL * GameTimeTaskManager.MILLIS_IN_TICK) + " ms"); - } - } - - _nextGameTick = curTick + config.FLOOD_PROTECTION_INTERVAL; + _nextGameTick = curTick + _config.FLOOD_PROTECTION_INTERVAL; _logged = false; - commandCount.set(0); - received_commands_actions.put(command, commandCount); - + _count.set(0); return true; } @@ -225,40 +133,18 @@ public class FloodProtectorAction */ private void kickPlayer() { - if (client.getPlayer() != null) + if (_client.getPlayer() != null) { - client.getPlayer().logout(); + _client.getPlayer().logout(); } else { - client.closeNow(); + _client.closeNow(); } - LOGGER("Client " + client + " kicked for flooding"); - } - - /** - * Kick player from game (close network connection). - */ - private void banChat() - { - if (client.getPlayer() != null) + if (LOGGER.isLoggable(Level.WARNING)) { - final PlayerInstance player = client.getPlayer(); - long newChatBanTime = 60000; // 1 minute - if (player.getPunishLevel() == PunishLevel.CHAT) - { - if (player.getPunishTimer() <= (60000 * 3)) // if less then 3 minutes (MAX CHAT BAN TIME), add 1 minute - { - newChatBanTime += player.getPunishTimer(); - } - else - { - newChatBanTime = player.getPunishTimer(); - } - } - - player.setPunishLevel(PunishLevel.CHAT, newChatBanTime); + log("kicked for flooding"); } } @@ -267,16 +153,14 @@ public class FloodProtectorAction */ private void banAccount() { - if (client.getPlayer() != null) + if (_client.getPlayer() != null) { - client.getPlayer().setPunishLevel(PunishLevel.ACC, config.PUNISHMENT_TIME); - - LOGGER(client.getPlayer().getName() + " banned for flooding"); - client.getPlayer().logout(); + _client.getPlayer().setPunishLevel(PunishLevel.ACC, _config.PUNISHMENT_TIME); + _client.getPlayer().logout(); } - else + if (LOGGER.isLoggable(Level.WARNING)) { - LOGGER(" unable to ban account: no active player"); + log(" banned for flooding ", _config.PUNISHMENT_TIME <= 0 ? "forever" : "for " + (_config.PUNISHMENT_TIME / 60000) + " mins"); } } @@ -285,27 +169,30 @@ public class FloodProtectorAction */ private void jailChar() { - if (client.getPlayer() != null) + if (_client.getPlayer() == null) { - client.getPlayer().setPunishLevel(PunishLevel.JAIL, config.PUNISHMENT_TIME); - - LOGGER.warning(client.getPlayer().getName() + " jailed for flooding"); + return; } - else + + _client.getPlayer().setPunishLevel(PunishLevel.JAIL, _config.PUNISHMENT_TIME); + + if (LOGGER.isLoggable(Level.WARNING)) { - LOGGER(" unable to jail: no active player"); + log(" jailed for flooding ", _config.PUNISHMENT_TIME <= 0 ? "forever" : "for " + (_config.PUNISHMENT_TIME / 60000) + " mins"); } } - private void LOGGER(String... lines) + private void log(String... lines) { - final StringBuilder output = StringUtil.startAppend(100, config.FLOOD_PROTECTOR_TYPE, ": "); + final StringBuilder output = new StringBuilder(100); + output.append(_config.FLOOD_PROTECTOR_TYPE); + output.append(": "); String address = null; try { - if (!client.isDetached()) + if (!_client.isDetached()) { - address = client.getConnectionAddress().getHostAddress(); + address = _client.getConnectionAddress().getHostAddress(); } } catch (Exception e) @@ -313,24 +200,27 @@ public class FloodProtectorAction // Ignore. } - final ConnectionState state = (ConnectionState) client.getConnectionState(); + final ConnectionState state = (ConnectionState) _client.getConnectionState(); switch (state) { case ENTERING: case IN_GAME: { - if (client.getPlayer() != null) + if (_client.getPlayer() != null) { - StringUtil.append(output, client.getPlayer().getName()); - StringUtil.append(output, "(", String.valueOf(client.getPlayer().getObjectId()), ") "); + output.append(_client.getPlayer().getName()); + output.append("("); + output.append(_client.getPlayer().getObjectId()); + output.append(") "); } break; } case AUTHENTICATED: { - if (client.getAccountName() != null) + if (_client.getAccountName() != null) { - StringUtil.append(output, client.getAccountName(), " "); + output.append(_client.getAccountName()); + output.append(" "); } break; } @@ -338,7 +228,7 @@ public class FloodProtectorAction { if (address != null) { - StringUtil.append(output, address); + output.append(address); } break; } @@ -348,7 +238,8 @@ public class FloodProtectorAction } } - StringUtil.append(output, lines); + Arrays.stream(lines).forEach(output::append); + LOGGER.warning(output.toString()); } } \ No newline at end of file diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/util/FloodProtectorConfig.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/util/FloodProtectorConfig.java index 4cabdf3033..f08ac51d49 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/util/FloodProtectorConfig.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/util/FloodProtectorConfig.java @@ -29,7 +29,7 @@ public class FloodProtectorConfig /** * Flood protection interval in game ticks. */ - public float FLOOD_PROTECTION_INTERVAL; + public int FLOOD_PROTECTION_INTERVAL; /** * Whether flooding should be logged. */ @@ -45,12 +45,7 @@ public class FloodProtectorConfig /** * For how long should the char/account be punished. */ - public int PUNISHMENT_TIME; - - /** - * Alternative flood protection method: check if in given FLOOD_PROTECTION_INTERVAL more then PUNISHMENT_LIMIT actions are performed: if this condition has been verified apply PUNISHMENT_TYPE for PUNISHMENT_TIME minutes - */ - public boolean ALTERNATIVE_METHOD; + public long PUNISHMENT_TIME; /** * Creates new instance of FloodProtectorConfig. @@ -60,18 +55,5 @@ public class FloodProtectorConfig { super(); FLOOD_PROTECTOR_TYPE = floodProtectorType; - ALTERNATIVE_METHOD = false; - } - - /** - * Creates new instance of FloodProtectorConfig. - * @param floodProtectorType {@link #FLOOD_PROTECTOR_TYPE} - * @param altFunc - */ - public FloodProtectorConfig(String floodProtectorType, boolean altFunc) - { - super(); - FLOOD_PROTECTOR_TYPE = floodProtectorType; - ALTERNATIVE_METHOD = altFunc; } } diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/util/FloodProtectors.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/util/FloodProtectors.java index 50d7d37f54..54a593ef76 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/util/FloodProtectors.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/util/FloodProtectors.java @@ -85,10 +85,6 @@ public class FloodProtectors * Character Select protector */ private final FloodProtectorAction _characterSelect; - /** - * Unknown Packets protector - */ - private final FloodProtectorAction _unknownPackets; /** * Party Invitation flood protector. */ @@ -101,10 +97,6 @@ public class FloodProtectors * Move Action protector */ private final FloodProtectorAction _moveAction; - /** - * Generic Action protector - */ - private final FloodProtectorAction _genericAction; /** * Macro protector */ @@ -113,10 +105,14 @@ public class FloodProtectors * Potion protector */ private final FloodProtectorAction _potion; + /** + * Player Action + */ + private final FloodProtectorAction _playerAction; /** * Creates new instance of FloodProtectors. - * @param client for which the collection of flood protectors is being created. + * @param client game client for which the collection of flood protectors is being created. */ public FloodProtectors(GameClient client) { @@ -136,13 +132,12 @@ public class FloodProtectors _manufacture = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_MANUFACTURE); _manor = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_MANOR); _characterSelect = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_CHARACTER_SELECT); - _unknownPackets = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_UNKNOWN_PACKETS); _partyInvitation = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_PARTY_INVITATION); _sayAction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_SAY_ACTION); _moveAction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_MOVE_ACTION); - _genericAction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_GENERIC_ACTION); _macro = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_MACRO); _potion = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_POTION); + _playerAction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_PLAYER_ACTION); } /** @@ -276,15 +271,6 @@ public class FloodProtectors return _characterSelect; } - /** - * Returns {@link #_unknownPackets}. - * @return {@link #_unknownPackets} - */ - public FloodProtectorAction getUnknownPackets() - { - return _unknownPackets; - } - /** * Returns {@link #_partyInvitation}. * @return {@link #_partyInvitation} @@ -312,15 +298,6 @@ public class FloodProtectors return _moveAction; } - /** - * Returns {@link #_genericAction}. - * @return {@link #_genericAction} - */ - public FloodProtectorAction getGenericAction() - { - return _genericAction; - } - /** * Returns {@link #_macro}. * @return {@link #_macro} @@ -338,4 +315,13 @@ public class FloodProtectors { return _potion; } + + /** + * Returns {@link #_playerAction}. + * @return {@link #_playerAction} + */ + public FloodProtectorAction getPlayerAction() + { + return _playerAction; + } } \ No newline at end of file diff --git a/L2J_Mobius_C6_Interlude/dist/game/config/protected/FloodProtector.ini b/L2J_Mobius_C6_Interlude/dist/game/config/protected/FloodProtector.ini index 323d742f83..82f351975a 100644 --- a/L2J_Mobius_C6_Interlude/dist/game/config/protected/FloodProtector.ini +++ b/L2J_Mobius_C6_Interlude/dist/game/config/protected/FloodProtector.ini @@ -127,13 +127,6 @@ FloodProtectorCharacterSelectPunishmentLimit = 0 FloodProtectorCharacterSelectPunishmentType = none FloodProtectorCharacterSelectPunishmentTime = 0 -# PacketUnknown - attempts to send unknown packets -FloodProtectorUnknownPacketsInterval = 5 -FloodProtectorUnknownPacketsLogFlooding = False -FloodProtectorUnknownPacketsPunishmentLimit = 3 -FloodProtectorUnknownPacketsPunishmentType = kick -FloodProtectorUnknownPacketsPunishmentTime = 0 - # Party Invitation - attempts to invite into party FloodProtectorPartyInvitationInterval = 5 FloodProtectorPartyInvitationLogFlooding = False @@ -155,16 +148,16 @@ FloodProtectorMoveActionPunishmentLimit = 0 FloodProtectorMoveActionPunishmentType = none FloodProtectorMoveActionPunishmentTime = 0 -# Generic Action -FloodProtectorGenericActionInterval = 5 -FloodProtectorGenericActionLogFlooding = false -FloodProtectorGenericActionPunishmentLimit = 0 -FloodProtectorGenericActionPunishmentType = none -FloodProtectorGenericActionPunishmentTime = 0 - # Macro - attempts to Macro system FloodProtectorMacroInterval = 8 FloodProtectorMacroLogFlooding = True FloodProtectorMacroPunishmentLimit = 6 FloodProtectorMacroPunishmentType = kick -FloodProtectorMacroPunishmentTime = 0 \ No newline at end of file +FloodProtectorMacroPunishmentTime = 0 + +# Player Action - Next Target, Attack, etc +FloodProtectorPlayerActionInterval = 3 +FloodProtectorPlayerActionLogFlooding = False +FloodProtectorPlayerActionPunishmentLimit = 0 +FloodProtectorPlayerActionPunishmentType = none +FloodProtectorPlayerActionPunishmentTime = 0 diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java index 6a5273f72c..14d02e5deb 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java @@ -813,13 +813,12 @@ public class Config public static FloodProtectorConfig FLOOD_PROTECTOR_MANUFACTURE; public static FloodProtectorConfig FLOOD_PROTECTOR_MANOR; public static FloodProtectorConfig FLOOD_PROTECTOR_CHARACTER_SELECT; - public static FloodProtectorConfig FLOOD_PROTECTOR_UNKNOWN_PACKETS; public static FloodProtectorConfig FLOOD_PROTECTOR_PARTY_INVITATION; public static FloodProtectorConfig FLOOD_PROTECTOR_SAY_ACTION; public static FloodProtectorConfig FLOOD_PROTECTOR_MOVE_ACTION; - public static FloodProtectorConfig FLOOD_PROTECTOR_GENERIC_ACTION; public static FloodProtectorConfig FLOOD_PROTECTOR_MACRO; public static FloodProtectorConfig FLOOD_PROTECTOR_POTION; + public static FloodProtectorConfig FLOOD_PROTECTOR_PLAYER_ACTION; public static boolean CHECK_SKILLS_ON_ENTER; public static boolean CHECK_NAME_ON_LOGIN; @@ -2276,13 +2275,12 @@ public class Config FLOOD_PROTECTOR_MANUFACTURE = new FloodProtectorConfig("ManufactureFloodProtector"); FLOOD_PROTECTOR_MANOR = new FloodProtectorConfig("ManorFloodProtector"); FLOOD_PROTECTOR_CHARACTER_SELECT = new FloodProtectorConfig("CharacterSelectFloodProtector"); - FLOOD_PROTECTOR_UNKNOWN_PACKETS = new FloodProtectorConfig("UnknownPacketsFloodProtector"); FLOOD_PROTECTOR_PARTY_INVITATION = new FloodProtectorConfig("PartyInvitationFloodProtector"); FLOOD_PROTECTOR_SAY_ACTION = new FloodProtectorConfig("SayActionFloodProtector"); FLOOD_PROTECTOR_MOVE_ACTION = new FloodProtectorConfig("MoveActionFloodProtector"); - FLOOD_PROTECTOR_GENERIC_ACTION = new FloodProtectorConfig("GenericActionFloodProtector", true); - FLOOD_PROTECTOR_MACRO = new FloodProtectorConfig("MacroFloodProtector", true); - FLOOD_PROTECTOR_POTION = new FloodProtectorConfig("PotionFloodProtector", true); + FLOOD_PROTECTOR_MACRO = new FloodProtectorConfig("MacroFloodProtector"); + FLOOD_PROTECTOR_POTION = new FloodProtectorConfig("PotionFloodProtector"); + FLOOD_PROTECTOR_PLAYER_ACTION = new FloodProtectorConfig("PlayerActionFloodProtector"); final PropertiesParser floodProtectConfig = new PropertiesParser(PROTECT_FLOOD_CONFIG_FILE); loadFloodProtectorConfigs(floodProtectConfig); @@ -2295,9 +2293,9 @@ public class Config * @param configString flood protector configuration string that determines for which flood protector configuration should be read * @param defaultInterval default flood protector interval */ - private static void loadFloodProtectorConfig(PropertiesParser properties, FloodProtectorConfig config, String configString, float defaultInterval) + private static void loadFloodProtectorConfig(PropertiesParser properties, FloodProtectorConfig config, String configString, int defaultInterval) { - config.FLOOD_PROTECTION_INTERVAL = properties.getFloat(StringUtil.concat("FloodProtector", configString, "Interval"), defaultInterval); + config.FLOOD_PROTECTION_INTERVAL = properties.getInt(StringUtil.concat("FloodProtector", configString, "Interval"), defaultInterval); config.LOG_FLOODING = properties.getBoolean(StringUtil.concat("FloodProtector", configString, "LogFlooding"), false); config.PUNISHMENT_LIMIT = properties.getInt(StringUtil.concat("FloodProtector", configString, "PunishmentLimit"), 0); config.PUNISHMENT_TYPE = properties.getString(StringUtil.concat("FloodProtector", configString, "PunishmentType"), "none"); @@ -2889,13 +2887,12 @@ public class Config loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_MANUFACTURE, "Manufacture", 3); loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_MANOR, "Manor", 30); loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_CHARACTER_SELECT, "CharacterSelect", 30); - loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_UNKNOWN_PACKETS, "UnknownPackets", 5); loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_PARTY_INVITATION, "PartyInvitation", 30); loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_SAY_ACTION, "SayAction", 100); loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_MOVE_ACTION, "MoveAction", 30); - loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_GENERIC_ACTION, "GenericAction", 5); loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_MACRO, "Macro", 10); loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_POTION, "Potion", 4); + loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_PLAYER_ACTION, "PlayerAction", 3); } public static void load(ServerMode serverMode) diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 88a35a9f47..1a44f93af7 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -390,7 +390,6 @@ public class PlayerInstance extends Playable private boolean _dietMode = false; // ignore weight penalty private boolean _exchangeRefusal = false; // Exchange refusal private Party _party; - private long _lastAttackPacket = 0; private PlayerInstance _activeRequester; private long _requestExpireTime = 0; private final Request _request = new Request(this); @@ -15538,16 +15537,6 @@ public class PlayerInstance extends Playable return this; } - public long getLastAttackPacket() - { - return _lastAttackPacket; - } - - public void setLastAttackPacket() - { - _lastAttackPacket = Chronos.currentTimeMillis(); - } - public void checkItemRestriction() { for (int i = 0; i < Inventory.PAPERDOLL_TOTALSLOTS; i++) diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/Action.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/Action.java index 135a792cdf..3fc1e55259 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/Action.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/Action.java @@ -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) diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java index 0317249532..4d0daf423f 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java @@ -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) diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java index 8cadcda079..5312a44569 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java @@ -16,13 +16,11 @@ */ package org.l2jmobius.gameserver.util; -import java.util.HashMap; -import java.util.Map; +import java.util.Arrays; import java.util.concurrent.atomic.AtomicInteger; +import java.util.logging.Level; import java.util.logging.Logger; -import org.l2jmobius.commons.util.StringUtil; -import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance.PunishLevel; import org.l2jmobius.gameserver.network.ConnectionState; import org.l2jmobius.gameserver.network.GameClient; @@ -41,15 +39,15 @@ public class FloodProtectorAction /** * Client for this instance of flood protector. */ - private final GameClient client; + private final GameClient _client; /** * Configuration of this instance of flood protector. */ - private final FloodProtectorConfig config; + private final FloodProtectorConfig _config; /** * Next game tick when new request is allowed. */ - private volatile float _nextGameTick = GameTimeTaskManager.getGameTicks(); + private volatile int _nextGameTick = GameTimeTaskManager.getGameTicks(); /** * Request counter. */ @@ -62,25 +60,19 @@ public class FloodProtectorAction * Flag determining whether punishment application is in progress so that we do not apply punisment multiple times (flooding). */ private volatile boolean _punishmentInProgress; - /** - * Count from when the floodProtector start to block next action. - */ - private final int _untilBlock = 4; /** * Creates new instance of FloodProtectorAction. - * @param client for which flood protection is being created + * @param client the game client for which flood protection is being created * @param config flood protector configuration */ public FloodProtectorAction(GameClient client, FloodProtectorConfig config) { super(); - this.client = client; - this.config = config; + _client = client; + _config = config; } - private final Map received_commands_actions = new HashMap<>(); - /** * Checks whether the request is flood protected or not. * @param command command issued or short command description @@ -88,135 +80,51 @@ public class FloodProtectorAction */ public boolean tryPerformAction(String command) { - // Ignore flood protector for GM char - if ((client != null) && (client.getPlayer() != null) && client.getPlayer().isGM()) + if ((_client.getPlayer() != null) && _client.getPlayer().isGM()) { return true; } - if (!config.ALTERNATIVE_METHOD) - { - final int curTick = GameTimeTaskManager.getGameTicks(); - if ((curTick < _nextGameTick) || _punishmentInProgress) - { - if (config.LOG_FLOODING && !_logged) - { - LOGGER.warning(" called command " + command + " ~ " + ((config.FLOOD_PROTECTION_INTERVAL - (_nextGameTick - curTick)) * GameTimeTaskManager.MILLIS_IN_TICK) + " ms after previous command"); - _logged = true; - } - - _count.incrementAndGet(); - - if (!_punishmentInProgress && (config.PUNISHMENT_LIMIT > 0) && (_count.get() >= config.PUNISHMENT_LIMIT) && (config.PUNISHMENT_TYPE != null)) - { - _punishmentInProgress = true; - if ("kick".equals(config.PUNISHMENT_TYPE)) - { - kickPlayer(); - } - else if ("ban".equals(config.PUNISHMENT_TYPE)) - { - banAccount(); - } - else if ("jail".equals(config.PUNISHMENT_TYPE)) - { - jailChar(); - } - else if ("banchat".equals(config.PUNISHMENT_TYPE)) - { - banChat(); - } - - _punishmentInProgress = false; - } - - // Avoid macro issue - if ((config.FLOOD_PROTECTOR_TYPE.equals("UseItemFloodProtector")) || (config.FLOOD_PROTECTOR_TYPE.equals("ServerBypassFloodProtector"))) - { - // _untilBlock value is 4 - if (_count.get() > _untilBlock) - { - return false; - } - - return true; - } - - return false; - } - - if ((_count.get() > 0) && config.LOG_FLOODING) - { - LOGGER(" issued ", String.valueOf(_count), " extra requests within ~", String.valueOf(config.FLOOD_PROTECTION_INTERVAL * GameTimeTaskManager.MILLIS_IN_TICK), " ms"); - } - - _nextGameTick = curTick + config.FLOOD_PROTECTION_INTERVAL; - _logged = false; - _count.set(0); - - return true; - } - final int curTick = GameTimeTaskManager.getGameTicks(); if ((curTick < _nextGameTick) || _punishmentInProgress) { - if (config.LOG_FLOODING && !_logged) + if (_config.LOG_FLOODING && !_logged && LOGGER.isLoggable(Level.WARNING)) { - LOGGER.warning(" called command " + command + " ~ " + ((config.FLOOD_PROTECTION_INTERVAL - (_nextGameTick - curTick)) * GameTimeTaskManager.MILLIS_IN_TICK) + " ms after previous command"); + log(" called command ", command, " ~", String.valueOf((_config.FLOOD_PROTECTION_INTERVAL - (_nextGameTick - curTick)) * GameTimeTaskManager.MILLIS_IN_TICK), " ms after previous command"); _logged = true; } - AtomicInteger commandCount = received_commands_actions.get(command); - if (commandCount == null) - { - commandCount = new AtomicInteger(0); - } + _count.incrementAndGet(); - final int count = commandCount.incrementAndGet(); - received_commands_actions.put(command, commandCount); - - if (!_punishmentInProgress && (config.PUNISHMENT_LIMIT > 0) && (count >= config.PUNISHMENT_LIMIT) && (config.PUNISHMENT_TYPE != null)) + if (!_punishmentInProgress && (_config.PUNISHMENT_LIMIT > 0) && (_count.get() >= _config.PUNISHMENT_LIMIT) && (_config.PUNISHMENT_TYPE != null)) { _punishmentInProgress = true; - if ("kick".equals(config.PUNISHMENT_TYPE)) + if ("kick".equals(_config.PUNISHMENT_TYPE)) { kickPlayer(); } - else if ("ban".equals(config.PUNISHMENT_TYPE)) + else if ("ban".equals(_config.PUNISHMENT_TYPE)) { banAccount(); } - else if ("jail".equals(config.PUNISHMENT_TYPE)) + else if ("jail".equals(_config.PUNISHMENT_TYPE)) { jailChar(); } _punishmentInProgress = false; } - return false; } - AtomicInteger commandCount = received_commands_actions.get(command); - if (commandCount == null) + if ((_count.get() > 0) && _config.LOG_FLOODING && LOGGER.isLoggable(Level.WARNING)) { - commandCount = new AtomicInteger(0); - received_commands_actions.put(command, commandCount); + log(" issued ", String.valueOf(_count), " extra requests within ~", String.valueOf(_config.FLOOD_PROTECTION_INTERVAL * GameTimeTaskManager.MILLIS_IN_TICK), " ms"); } - if (commandCount.get() > 0) - { - if (config.LOG_FLOODING) - { - LOGGER.warning(" issued " + commandCount + " extra requests within ~ " + (config.FLOOD_PROTECTION_INTERVAL * GameTimeTaskManager.MILLIS_IN_TICK) + " ms"); - } - } - - _nextGameTick = curTick + config.FLOOD_PROTECTION_INTERVAL; + _nextGameTick = curTick + _config.FLOOD_PROTECTION_INTERVAL; _logged = false; - commandCount.set(0); - received_commands_actions.put(command, commandCount); - + _count.set(0); return true; } @@ -225,40 +133,18 @@ public class FloodProtectorAction */ private void kickPlayer() { - if (client.getPlayer() != null) + if (_client.getPlayer() != null) { - client.getPlayer().logout(); + _client.getPlayer().logout(); } else { - client.closeNow(); + _client.closeNow(); } - LOGGER("Client " + client + " kicked for flooding"); - } - - /** - * Kick player from game (close network connection). - */ - private void banChat() - { - if (client.getPlayer() != null) + if (LOGGER.isLoggable(Level.WARNING)) { - final PlayerInstance player = client.getPlayer(); - long newChatBanTime = 60000; // 1 minute - if (player.getPunishLevel() == PunishLevel.CHAT) - { - if (player.getPunishTimer() <= (60000 * 3)) // if less then 3 minutes (MAX CHAT BAN TIME), add 1 minute - { - newChatBanTime += player.getPunishTimer(); - } - else - { - newChatBanTime = player.getPunishTimer(); - } - } - - player.setPunishLevel(PunishLevel.CHAT, newChatBanTime); + log("kicked for flooding"); } } @@ -267,16 +153,14 @@ public class FloodProtectorAction */ private void banAccount() { - if (client.getPlayer() != null) + if (_client.getPlayer() != null) { - client.getPlayer().setPunishLevel(PunishLevel.ACC, config.PUNISHMENT_TIME); - - LOGGER(client.getPlayer().getName() + " banned for flooding"); - client.getPlayer().logout(); + _client.getPlayer().setPunishLevel(PunishLevel.ACC, _config.PUNISHMENT_TIME); + _client.getPlayer().logout(); } - else + if (LOGGER.isLoggable(Level.WARNING)) { - LOGGER(" unable to ban account: no active player"); + log(" banned for flooding ", _config.PUNISHMENT_TIME <= 0 ? "forever" : "for " + (_config.PUNISHMENT_TIME / 60000) + " mins"); } } @@ -285,27 +169,30 @@ public class FloodProtectorAction */ private void jailChar() { - if (client.getPlayer() != null) + if (_client.getPlayer() == null) { - client.getPlayer().setPunishLevel(PunishLevel.JAIL, config.PUNISHMENT_TIME); - - LOGGER.warning(client.getPlayer().getName() + " jailed for flooding"); + return; } - else + + _client.getPlayer().setPunishLevel(PunishLevel.JAIL, _config.PUNISHMENT_TIME); + + if (LOGGER.isLoggable(Level.WARNING)) { - LOGGER(" unable to jail: no active player"); + log(" jailed for flooding ", _config.PUNISHMENT_TIME <= 0 ? "forever" : "for " + (_config.PUNISHMENT_TIME / 60000) + " mins"); } } - private void LOGGER(String... lines) + private void log(String... lines) { - final StringBuilder output = StringUtil.startAppend(100, config.FLOOD_PROTECTOR_TYPE, ": "); + final StringBuilder output = new StringBuilder(100); + output.append(_config.FLOOD_PROTECTOR_TYPE); + output.append(": "); String address = null; try { - if (!client.isDetached()) + if (!_client.isDetached()) { - address = client.getConnectionAddress().getHostAddress(); + address = _client.getConnectionAddress().getHostAddress(); } } catch (Exception e) @@ -313,24 +200,27 @@ public class FloodProtectorAction // Ignore. } - final ConnectionState state = (ConnectionState) client.getConnectionState(); + final ConnectionState state = (ConnectionState) _client.getConnectionState(); switch (state) { case ENTERING: case IN_GAME: { - if (client.getPlayer() != null) + if (_client.getPlayer() != null) { - StringUtil.append(output, client.getPlayer().getName()); - StringUtil.append(output, "(", String.valueOf(client.getPlayer().getObjectId()), ") "); + output.append(_client.getPlayer().getName()); + output.append("("); + output.append(_client.getPlayer().getObjectId()); + output.append(") "); } break; } case AUTHENTICATED: { - if (client.getAccountName() != null) + if (_client.getAccountName() != null) { - StringUtil.append(output, client.getAccountName(), " "); + output.append(_client.getAccountName()); + output.append(" "); } break; } @@ -338,7 +228,7 @@ public class FloodProtectorAction { if (address != null) { - StringUtil.append(output, address); + output.append(address); } break; } @@ -348,7 +238,8 @@ public class FloodProtectorAction } } - StringUtil.append(output, lines); + Arrays.stream(lines).forEach(output::append); + LOGGER.warning(output.toString()); } } \ No newline at end of file diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/util/FloodProtectorConfig.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/util/FloodProtectorConfig.java index 4cabdf3033..f08ac51d49 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/util/FloodProtectorConfig.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/util/FloodProtectorConfig.java @@ -29,7 +29,7 @@ public class FloodProtectorConfig /** * Flood protection interval in game ticks. */ - public float FLOOD_PROTECTION_INTERVAL; + public int FLOOD_PROTECTION_INTERVAL; /** * Whether flooding should be logged. */ @@ -45,12 +45,7 @@ public class FloodProtectorConfig /** * For how long should the char/account be punished. */ - public int PUNISHMENT_TIME; - - /** - * Alternative flood protection method: check if in given FLOOD_PROTECTION_INTERVAL more then PUNISHMENT_LIMIT actions are performed: if this condition has been verified apply PUNISHMENT_TYPE for PUNISHMENT_TIME minutes - */ - public boolean ALTERNATIVE_METHOD; + public long PUNISHMENT_TIME; /** * Creates new instance of FloodProtectorConfig. @@ -60,18 +55,5 @@ public class FloodProtectorConfig { super(); FLOOD_PROTECTOR_TYPE = floodProtectorType; - ALTERNATIVE_METHOD = false; - } - - /** - * Creates new instance of FloodProtectorConfig. - * @param floodProtectorType {@link #FLOOD_PROTECTOR_TYPE} - * @param altFunc - */ - public FloodProtectorConfig(String floodProtectorType, boolean altFunc) - { - super(); - FLOOD_PROTECTOR_TYPE = floodProtectorType; - ALTERNATIVE_METHOD = altFunc; } } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/util/FloodProtectors.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/util/FloodProtectors.java index 49b51806ce..5b0275b21d 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/util/FloodProtectors.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/util/FloodProtectors.java @@ -89,10 +89,6 @@ public class FloodProtectors * Character Select protector */ private final FloodProtectorAction _characterSelect; - /** - * Unknown Packets protector - */ - private final FloodProtectorAction _unknownPackets; /** * Party Invitation flood protector. */ @@ -105,10 +101,6 @@ public class FloodProtectors * Move Action protector */ private final FloodProtectorAction _moveAction; - /** - * Generic Action protector - */ - private final FloodProtectorAction _genericAction; /** * Macro protector */ @@ -117,10 +109,14 @@ public class FloodProtectors * Potion protector */ private final FloodProtectorAction _potion; + /** + * Player Action + */ + private final FloodProtectorAction _playerAction; /** * Creates new instance of FloodProtectors. - * @param client for which the collection of flood protectors is being created. + * @param client game client for which the collection of flood protectors is being created. */ public FloodProtectors(GameClient client) { @@ -141,13 +137,12 @@ public class FloodProtectors _manufacture = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_MANUFACTURE); _manor = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_MANOR); _characterSelect = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_CHARACTER_SELECT); - _unknownPackets = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_UNKNOWN_PACKETS); _partyInvitation = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_PARTY_INVITATION); _sayAction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_SAY_ACTION); _moveAction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_MOVE_ACTION); - _genericAction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_GENERIC_ACTION); _macro = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_MACRO); _potion = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_POTION); + _playerAction = new FloodProtectorAction(client, Config.FLOOD_PROTECTOR_PLAYER_ACTION); } /** @@ -290,15 +285,6 @@ public class FloodProtectors return _characterSelect; } - /** - * Returns {@link #_unknownPackets}. - * @return {@link #_unknownPackets} - */ - public FloodProtectorAction getUnknownPackets() - { - return _unknownPackets; - } - /** * Returns {@link #_partyInvitation}. * @return {@link #_partyInvitation} @@ -326,15 +312,6 @@ public class FloodProtectors return _moveAction; } - /** - * Returns {@link #_genericAction}. - * @return {@link #_genericAction} - */ - public FloodProtectorAction getGenericAction() - { - return _genericAction; - } - /** * Returns {@link #_macro}. * @return {@link #_macro} @@ -352,4 +329,13 @@ public class FloodProtectors { return _potion; } + + /** + * Returns {@link #_playerAction}. + * @return {@link #_playerAction} + */ + public FloodProtectorAction getPlayerAction() + { + return _playerAction; + } } \ No newline at end of file diff --git a/L2J_Mobius_CT_2.4_Epilogue/dist/game/config/FloodProtector.ini b/L2J_Mobius_CT_2.4_Epilogue/dist/game/config/FloodProtector.ini index 2b76e40882..7c50e3af92 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/dist/game/config/FloodProtector.ini +++ b/L2J_Mobius_CT_2.4_Epilogue/dist/game/config/FloodProtector.ini @@ -122,3 +122,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 diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/Config.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/Config.java index d1c4379a43..392b8f0ccd 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/Config.java @@ -707,6 +707,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 @@ -1379,6 +1380,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"); @@ -3241,6 +3243,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); } /** diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/IncomingPackets.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/IncomingPackets.java index 9ba6476106..24c94c4606 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/IncomingPackets.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/IncomingPackets.java @@ -32,7 +32,7 @@ import org.l2jmobius.gameserver.network.clientpackets.*; public enum IncomingPackets implements IIncomingPackets { 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), diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/clientpackets/Action.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/clientpackets/Action.java index 7ff268790a..e09342d716 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/clientpackets/Action.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/clientpackets/Action.java @@ -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) diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java deleted file mode 100644 index 879cfbbf11..0000000000 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java +++ /dev/null @@ -1,145 +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 . - */ -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().getBuffInfoByAbnormalType(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.canOverrideCond(PlayerCondOverride.TARGET_ALL)) - { - player.sendPacket(ActionFailed.STATIC_PACKET); - return; - } - - // Players can't attack objects in the other instances - // except from multiverse - else if ((target.getInstanceId() != player.getInstanceId()) && (player.getInstanceId() != -1)) - { - 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); - } - } - } -} \ No newline at end of file diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java index a2881bf767..0e1b9ab360 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java @@ -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().getBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY); if (info != null) { @@ -93,7 +106,7 @@ public class AttackRequest implements IClientIncomingPacket return; } - else if (!target.isTargetable() && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL)) + if (!target.isTargetable() && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL)) { player.sendPacket(ActionFailed.STATIC_PACKET); return; @@ -114,6 +127,8 @@ public class AttackRequest implements IClientIncomingPacket return; } + player.onActionRequest(); + if (player.getTarget() != target) { target.onAction(player); diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java index 993a5ede11..5e7783107d 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java @@ -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)) diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/util/FloodProtectors.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/util/FloodProtectors.java index b9cdcc6362..b9570c8687 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/util/FloodProtectors.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/util/FloodProtectors.java @@ -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; + } } diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/config/FloodProtector.ini b/L2J_Mobius_CT_2.6_HighFive/dist/game/config/FloodProtector.ini index 2b76e40882..7c50e3af92 100644 --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/config/FloodProtector.ini +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/config/FloodProtector.ini @@ -122,3 +122,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 diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java index 9e60c6efea..908fe9d40a 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java @@ -712,6 +712,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 @@ -1379,6 +1380,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"); @@ -3250,6 +3252,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); } /** diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/IncomingPackets.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/IncomingPackets.java index ac567d45de..2b558f976f 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/IncomingPackets.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/IncomingPackets.java @@ -32,7 +32,7 @@ import org.l2jmobius.gameserver.network.clientpackets.*; public enum IncomingPackets implements IIncomingPackets { 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), diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/Action.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/Action.java index 7ff268790a..e09342d716 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/Action.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/Action.java @@ -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) diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java deleted file mode 100644 index 879cfbbf11..0000000000 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java +++ /dev/null @@ -1,145 +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 . - */ -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().getBuffInfoByAbnormalType(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.canOverrideCond(PlayerCondOverride.TARGET_ALL)) - { - player.sendPacket(ActionFailed.STATIC_PACKET); - return; - } - - // Players can't attack objects in the other instances - // except from multiverse - else if ((target.getInstanceId() != player.getInstanceId()) && (player.getInstanceId() != -1)) - { - 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); - } - } - } -} \ No newline at end of file diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java index a2881bf767..0e1b9ab360 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java @@ -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().getBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY); if (info != null) { @@ -93,7 +106,7 @@ public class AttackRequest implements IClientIncomingPacket return; } - else if (!target.isTargetable() && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL)) + if (!target.isTargetable() && !player.canOverrideCond(PlayerCondOverride.TARGET_ALL)) { player.sendPacket(ActionFailed.STATIC_PACKET); return; @@ -114,6 +127,8 @@ public class AttackRequest implements IClientIncomingPacket return; } + player.onActionRequest(); + if (player.getTarget() != target) { target.onAction(player); diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java index 993a5ede11..5e7783107d 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java @@ -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)) diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/util/FloodProtectors.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/util/FloodProtectors.java index b9cdcc6362..b9570c8687 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/util/FloodProtectors.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/util/FloodProtectors.java @@ -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; + } } diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/FloodProtector.ini b/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/FloodProtector.ini index 28c86264fb..10bccf42b1 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/FloodProtector.ini +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/FloodProtector.ini @@ -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 diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java index 7773457638..b6781c9e42 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java @@ -630,6 +630,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 @@ -1325,6 +1326,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"); @@ -3624,6 +3626,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); } /** diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/IncomingPackets.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/IncomingPackets.java index b06d18ab9b..c46983e2aa 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/IncomingPackets.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/IncomingPackets.java @@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs public enum IncomingPackets implements IIncomingPackets { 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), diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/Action.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/Action.java index 05cb3e912d..a2d1007bc0 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/Action.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/Action.java @@ -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) diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java deleted file mode 100644 index 6b00f49373..0000000000 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java +++ /dev/null @@ -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 . - */ -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); - } - } -} diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java index 1b107de541..71af0d06d2 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java @@ -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); diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java index 993a5ede11..5e7783107d 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java @@ -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)) diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/FloodProtectors.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/FloodProtectors.java index b9cdcc6362..b9570c8687 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/FloodProtectors.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/util/FloodProtectors.java @@ -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; + } } diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/FloodProtector.ini b/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/FloodProtector.ini index 28c86264fb..10bccf42b1 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/FloodProtector.ini +++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/FloodProtector.ini @@ -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 diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/Config.java index b9aa453ae5..734dba5989 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/Config.java @@ -630,6 +630,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 @@ -1329,6 +1330,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"); @@ -3630,6 +3632,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); } /** diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/IncomingPackets.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/IncomingPackets.java index b06d18ab9b..c46983e2aa 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/IncomingPackets.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/IncomingPackets.java @@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs public enum IncomingPackets implements IIncomingPackets { 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), diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/Action.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/Action.java index 05cb3e912d..a2d1007bc0 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/Action.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/Action.java @@ -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) diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java deleted file mode 100644 index 6b00f49373..0000000000 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java +++ /dev/null @@ -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 . - */ -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); - } - } -} diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java index 1b107de541..71af0d06d2 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java @@ -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); diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java index 993a5ede11..5e7783107d 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java @@ -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)) diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/FloodProtectors.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/FloodProtectors.java index b9cdcc6362..b9570c8687 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/FloodProtectors.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/util/FloodProtectors.java @@ -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; + } } diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/FloodProtector.ini b/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/FloodProtector.ini index 28c86264fb..10bccf42b1 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/FloodProtector.ini +++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/FloodProtector.ini @@ -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 diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/Config.java index b9aa453ae5..734dba5989 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/Config.java @@ -630,6 +630,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 @@ -1329,6 +1330,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"); @@ -3630,6 +3632,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); } /** diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/IncomingPackets.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/IncomingPackets.java index b06d18ab9b..c46983e2aa 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/IncomingPackets.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/IncomingPackets.java @@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs public enum IncomingPackets implements IIncomingPackets { 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), diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/Action.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/Action.java index 05cb3e912d..a2d1007bc0 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/Action.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/Action.java @@ -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) diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java deleted file mode 100644 index 6b00f49373..0000000000 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java +++ /dev/null @@ -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 . - */ -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); - } - } -} diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java index 1b107de541..71af0d06d2 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java @@ -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); diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java index 19cbdbfede..780eb34419 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java @@ -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()) { diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java index 993a5ede11..5e7783107d 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java @@ -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)) diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/FloodProtectors.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/FloodProtectors.java index b9cdcc6362..b9570c8687 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/FloodProtectors.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/util/FloodProtectors.java @@ -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; + } } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/FloodProtector.ini b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/FloodProtector.ini index 28c86264fb..10bccf42b1 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/FloodProtector.ini +++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/FloodProtector.ini @@ -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 diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/Config.java index c08a7ed23f..adbe6f43f4 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/Config.java @@ -630,6 +630,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 @@ -1329,6 +1330,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"); @@ -3631,6 +3633,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); } /** diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/IncomingPackets.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/IncomingPackets.java index b06d18ab9b..c46983e2aa 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/IncomingPackets.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/IncomingPackets.java @@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs public enum IncomingPackets implements IIncomingPackets { 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), diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/Action.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/Action.java index 05cb3e912d..a2d1007bc0 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/Action.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/Action.java @@ -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) diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java deleted file mode 100644 index 6b00f49373..0000000000 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java +++ /dev/null @@ -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 . - */ -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); - } - } -} diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java index 1b107de541..71af0d06d2 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java @@ -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); diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java index 19cbdbfede..780eb34419 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java @@ -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()) { diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java index 993a5ede11..5e7783107d 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java @@ -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)) diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/FloodProtectors.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/FloodProtectors.java index b9cdcc6362..b9570c8687 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/FloodProtectors.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/util/FloodProtectors.java @@ -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; + } } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/config/FloodProtector.ini b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/config/FloodProtector.ini index 28c86264fb..10bccf42b1 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/config/FloodProtector.ini +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/config/FloodProtector.ini @@ -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 diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/Config.java index 597dc474e4..2d1918e618 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/Config.java @@ -630,6 +630,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 @@ -1334,6 +1335,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"); @@ -3640,6 +3642,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); } /** diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/IncomingPackets.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/IncomingPackets.java index b06d18ab9b..c46983e2aa 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/IncomingPackets.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/IncomingPackets.java @@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs public enum IncomingPackets implements IIncomingPackets { 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), diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/Action.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/Action.java index 05cb3e912d..a2d1007bc0 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/Action.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/Action.java @@ -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) diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java deleted file mode 100644 index 6b00f49373..0000000000 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java +++ /dev/null @@ -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 . - */ -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); - } - } -} diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java index 1b107de541..71af0d06d2 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java @@ -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); diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java index 19cbdbfede..780eb34419 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java @@ -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()) { diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java index 993a5ede11..5e7783107d 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java @@ -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)) diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/FloodProtectors.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/FloodProtectors.java index b9cdcc6362..b9570c8687 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/FloodProtectors.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/util/FloodProtectors.java @@ -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; + } } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/config/FloodProtector.ini b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/config/FloodProtector.ini index 28c86264fb..10bccf42b1 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/config/FloodProtector.ini +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/config/FloodProtector.ini @@ -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 diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/Config.java index 3a568e6b87..0016019f15 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/Config.java @@ -635,6 +635,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 @@ -1340,6 +1341,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"); @@ -3651,6 +3653,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); } /** diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/IncomingPackets.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/IncomingPackets.java index b06d18ab9b..c46983e2aa 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/IncomingPackets.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/IncomingPackets.java @@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs public enum IncomingPackets implements IIncomingPackets { 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), diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/Action.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/Action.java index 05cb3e912d..a2d1007bc0 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/Action.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/Action.java @@ -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) diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java deleted file mode 100644 index 6b00f49373..0000000000 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java +++ /dev/null @@ -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 . - */ -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); - } - } -} diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java index 1b107de541..71af0d06d2 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java @@ -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); diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java index 19cbdbfede..780eb34419 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java @@ -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()) { diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java index 993a5ede11..5e7783107d 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java @@ -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)) diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/FloodProtectors.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/FloodProtectors.java index b9cdcc6362..b9570c8687 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/FloodProtectors.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/util/FloodProtectors.java @@ -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; + } } diff --git a/L2J_Mobius_Classic_Interlude/dist/game/config/FloodProtector.ini b/L2J_Mobius_Classic_Interlude/dist/game/config/FloodProtector.ini index 28c86264fb..10bccf42b1 100644 --- a/L2J_Mobius_Classic_Interlude/dist/game/config/FloodProtector.ini +++ b/L2J_Mobius_Classic_Interlude/dist/game/config/FloodProtector.ini @@ -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 diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/Config.java index 18cde9cbe8..87185897df 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/Config.java @@ -637,6 +637,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 @@ -1333,6 +1334,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"); @@ -3628,6 +3630,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); } /** diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/IncomingPackets.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/IncomingPackets.java index b06d18ab9b..c46983e2aa 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/IncomingPackets.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/IncomingPackets.java @@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.network.clientpackets.friend.RequestSendFriendMs public enum IncomingPackets implements IIncomingPackets { 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), diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/Action.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/Action.java index 05cb3e912d..a2d1007bc0 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/Action.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/Action.java @@ -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) diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java deleted file mode 100644 index 6b00f49373..0000000000 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java +++ /dev/null @@ -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 . - */ -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); - } - } -} diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java index 1b107de541..71af0d06d2 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java @@ -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); diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java index 993a5ede11..5e7783107d 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java @@ -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)) diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/FloodProtectors.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/FloodProtectors.java index b9cdcc6362..b9570c8687 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/FloodProtectors.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/util/FloodProtectors.java @@ -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; + } } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/config/FloodProtector.ini b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/config/FloodProtector.ini index 28c86264fb..10bccf42b1 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/config/FloodProtector.ini +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/config/FloodProtector.ini @@ -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 diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/Config.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/Config.java index c7547b956e..00940b3565 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/Config.java @@ -639,6 +639,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 @@ -1361,6 +1362,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"); @@ -3697,6 +3699,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); } /** diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/IncomingPackets.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/IncomingPackets.java index e10278c95e..65628f0a83 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/IncomingPackets.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/IncomingPackets.java @@ -42,7 +42,7 @@ import org.l2jmobius.gameserver.network.clientpackets.pet.RequestPetUseItem; public enum IncomingPackets implements IIncomingPackets { 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), diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/Action.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/Action.java index 05cb3e912d..a2d1007bc0 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/Action.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/Action.java @@ -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) diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java deleted file mode 100644 index 6b00f49373..0000000000 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java +++ /dev/null @@ -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 . - */ -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); - } - } -} diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java index 1b107de541..71af0d06d2 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java @@ -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); diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java index 19cbdbfede..780eb34419 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java @@ -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()) { diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java index 993a5ede11..5e7783107d 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java @@ -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)) diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/util/FloodProtectors.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/util/FloodProtectors.java index b9cdcc6362..b9570c8687 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/util/FloodProtectors.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/util/FloodProtectors.java @@ -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; + } } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/config/FloodProtector.ini b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/config/FloodProtector.ini index 28c86264fb..10bccf42b1 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/config/FloodProtector.ini +++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/config/FloodProtector.ini @@ -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 diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/Config.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/Config.java index 77d24a3cf7..0743bf2d3d 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/Config.java @@ -639,6 +639,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 @@ -1364,6 +1365,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"); @@ -3703,6 +3705,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); } /** diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/IncomingPackets.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/IncomingPackets.java index e10278c95e..65628f0a83 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/IncomingPackets.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/IncomingPackets.java @@ -42,7 +42,7 @@ import org.l2jmobius.gameserver.network.clientpackets.pet.RequestPetUseItem; public enum IncomingPackets implements IIncomingPackets { 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), diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/Action.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/Action.java index 05cb3e912d..a2d1007bc0 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/Action.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/Action.java @@ -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) diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java deleted file mode 100644 index 6b00f49373..0000000000 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java +++ /dev/null @@ -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 . - */ -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); - } - } -} diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java index 1b107de541..71af0d06d2 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java @@ -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); diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java index 19cbdbfede..780eb34419 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java @@ -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()) { diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java index 993a5ede11..5e7783107d 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java @@ -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)) diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/util/FloodProtectors.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/util/FloodProtectors.java index b9cdcc6362..b9570c8687 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/util/FloodProtectors.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/util/FloodProtectors.java @@ -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; + } } diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/config/FloodProtector.ini b/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/config/FloodProtector.ini index 28c86264fb..10bccf42b1 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/config/FloodProtector.ini +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/dist/game/config/FloodProtector.ini @@ -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 diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/Config.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/Config.java index 77d24a3cf7..0743bf2d3d 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/Config.java @@ -639,6 +639,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 @@ -1364,6 +1365,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"); @@ -3703,6 +3705,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); } /** diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/IncomingPackets.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/IncomingPackets.java index e10278c95e..65628f0a83 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/IncomingPackets.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/IncomingPackets.java @@ -42,7 +42,7 @@ import org.l2jmobius.gameserver.network.clientpackets.pet.RequestPetUseItem; public enum IncomingPackets implements IIncomingPackets { 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), diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/Action.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/Action.java index 05cb3e912d..a2d1007bc0 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/Action.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/Action.java @@ -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) diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java deleted file mode 100644 index 6b00f49373..0000000000 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/Attack.java +++ /dev/null @@ -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 . - */ -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); - } - } -} diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java index 1b107de541..71af0d06d2 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java @@ -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); diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java index 19cbdbfede..780eb34419 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/RequestTargetActionMenu.java @@ -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()) { diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java index 993a5ede11..5e7783107d 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/util/FloodProtectorAction.java @@ -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)) diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/util/FloodProtectors.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/util/FloodProtectors.java index b9cdcc6362..b9570c8687 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/util/FloodProtectors.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/util/FloodProtectors.java @@ -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; + } }