Prechádzať zdrojové kódy

Floodprotection of the items transactions (pet get/give, private store buy/sell, warehouse put/withdraw, freight, destroy).
Thanks ZaKaX.

_DS_ 15 rokov pred
rodič
commit
4c5df09cae

+ 7 - 0
L2_GameServer/java/config/floodprotector.properties

@@ -77,3 +77,10 @@ FloodProtectorMultiSellLogFlooding = False
 FloodProtectorMultiSellPunishmentLimit = 0
 FloodProtectorMultiSellPunishmentType = none
 FloodProtectorMultiSellPunishmentTime = 0
+
+# All kind of other transactions - to/from pet, private store, warehouse, destroy
+FloodProtectorTransactionInterval = 10
+FloodProtectorTransactionLogFlooding = False
+FloodProtectorTransactionPunishmentLimit = 0
+FloodProtectorTransactionPunishmentType = none
+FloodProtectorTransactionPunishmentTime = 0

+ 3 - 0
L2_GameServer/java/net/sf/l2j/Config.java

@@ -532,6 +532,8 @@ public final class Config
 		new FloodProtectorConfig("ServerBypassFloodProtector");
 	public static final FloodProtectorConfig FLOOD_PROTECTOR_MULTISELL =
 		new FloodProtectorConfig("MultiSellFloodProtector");
+	public static final FloodProtectorConfig FLOOD_PROTECTOR_TRANSACTION =
+		new FloodProtectorConfig("TransactionFloodProtector");
 
 
 	//--------------------------------------------------
@@ -2481,6 +2483,7 @@ public final class Config
 		loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_DROP_ITEM, "DropItem", "10");
 		loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_SERVER_BYPASS, "ServerBypass", "5");
 		loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_MULTISELL, "MultiSell", "1");
+		loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_TRANSACTION, "Transaction", "10");
 	}
 	
 	/**

+ 6 - 0
L2_GameServer/java/net/sf/l2j/gameserver/network/clientpackets/RequestDestroyItem.java

@@ -67,6 +67,12 @@ public final class RequestDestroyItem extends L2GameClientPacket
 			return;
 		}
 
+		if (!activeChar.getFloodProtectors().getTransaction().tryPerformAction("destroy"))
+		{
+			activeChar.sendMessage("You destroying items too fast.");
+			return;
+		}
+		
 		long count = _count;
 
 		if (activeChar.getPrivateStoreType() != 0)

+ 7 - 0
L2_GameServer/java/net/sf/l2j/gameserver/network/clientpackets/RequestGetItemFromPet.java

@@ -50,6 +50,13 @@ public final class RequestGetItemFromPet extends L2GameClientPacket
 		L2PcInstance player = getClient().getActiveChar();
 		if (player == null || !(player.getPet() instanceof L2PetInstance))
 			return;
+
+		if (!player.getFloodProtectors().getTransaction().tryPerformAction("getfrompet"))
+		{
+			player.sendMessage("You get items from pet too fast.");
+			return;
+		}
+
 		L2PetInstance pet = (L2PetInstance) player.getPet();
 		if (player.getActiveEnchantItem() != null)
 			return;

+ 8 - 1
L2_GameServer/java/net/sf/l2j/gameserver/network/clientpackets/RequestGiveItemToPet.java

@@ -51,7 +51,14 @@ public final class RequestGiveItemToPet extends L2GameClientPacket
 		L2PcInstance player = getClient().getActiveChar();
 		if (player == null || !(player.getPet() instanceof L2PetInstance))
 			return;
-        if (player.getActiveEnchantItem() != null)
+		
+		if (!player.getFloodProtectors().getTransaction().tryPerformAction("giveitemtopet"))
+		{
+			player.sendMessage("You give items to pet too fast.");
+			return;
+		}
+
+		if (player.getActiveEnchantItem() != null)
         	return;
 		// Alt game - Karma punishment
 		if (!Config.ALT_GAME_KARMA_PLAYER_CAN_TRADE && player.getKarma() > 0)

+ 6 - 0
L2_GameServer/java/net/sf/l2j/gameserver/network/clientpackets/RequestPackageSend.java

@@ -78,6 +78,12 @@ public final class RequestPackageSend extends L2GameClientPacket
 		if (player == null)
 			return;
 
+		if (!player.getFloodProtectors().getTransaction().tryPerformAction("freight"))
+		{
+			player.sendMessage("You using freight too fast.");
+			return;
+		}
+
 		// Alt game - Karma punishment
 		if (!Config.ALT_GAME_KARMA_PLAYER_CAN_USE_WAREHOUSE && player.getKarma() > 0)
 			return;

+ 6 - 0
L2_GameServer/java/net/sf/l2j/gameserver/network/clientpackets/RequestPrivateStoreBuy.java

@@ -83,6 +83,12 @@ public final class RequestPrivateStoreBuy extends L2GameClientPacket
 			return;
 		}
 
+		if (!player.getFloodProtectors().getTransaction().tryPerformAction("privatestorebuy"))
+		{
+			player.sendMessage("You buying items too fast.");
+			return;
+		}
+
 		L2Object object = L2World.getInstance().findObject(_storePlayerId);
 		if (!(object instanceof L2PcInstance))
 			return;

+ 6 - 0
L2_GameServer/java/net/sf/l2j/gameserver/network/clientpackets/RequestPrivateStoreSell.java

@@ -85,6 +85,12 @@ public final class RequestPrivateStoreSell extends L2GameClientPacket
 			return;
 		}
 
+		if (!player.getFloodProtectors().getTransaction().tryPerformAction("privatestoresell"))
+		{
+			player.sendMessage("You selling items too fast");
+			return;
+		}
+
 		L2Object object = L2World.getInstance().findObject(_storePlayerId);
 		if (!(object instanceof L2PcInstance))
 			return;

+ 6 - 0
L2_GameServer/java/net/sf/l2j/gameserver/network/clientpackets/SendWareHouseDepositList.java

@@ -82,6 +82,12 @@ public final class SendWareHouseDepositList extends L2GameClientPacket
 		if (player == null)
 			return;
 
+		if (!player.getFloodProtectors().getTransaction().tryPerformAction("deposit"))
+		{
+			player.sendMessage("You depositing items too fast.");
+			return;
+		}
+
 		final ItemContainer warehouse = player.getActiveWarehouse();
 		if (warehouse == null)
 			return;

+ 6 - 0
L2_GameServer/java/net/sf/l2j/gameserver/network/clientpackets/SendWareHouseWithDrawList.java

@@ -82,6 +82,12 @@ public final class SendWareHouseWithDrawList extends L2GameClientPacket
 		if (player == null)
 			return;
 
+		if (!player.getFloodProtectors().getTransaction().tryPerformAction("withdraw"))
+		{
+			player.sendMessage("You withdrawing items too fast.");
+			return;
+		}
+
 		final ItemContainer warehouse = player.getActiveWarehouse();
 		if (warehouse == null)
 			return;

+ 15 - 0
L2_GameServer/java/net/sf/l2j/gameserver/util/FloodProtectors.java

@@ -63,6 +63,10 @@ public final class FloodProtectors
 	 * Multisell flood protector.
 	 */
 	private final FloodProtectorAction _multiSell;
+	/**
+	 * Transaction flood protector.
+	 */
+	private final FloodProtectorAction _transaction;
 	
 	/**
 	 * Creates new instance of FloodProtectors.
@@ -83,6 +87,7 @@ public final class FloodProtectors
 		_dropItem = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_DROP_ITEM);
 		_serverBypass = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_SERVER_BYPASS);
 		_multiSell = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_MULTISELL);
+		_transaction = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_TRANSACTION);
 	}
 	
 	/**
@@ -185,4 +190,14 @@ public final class FloodProtectors
 		return _multiSell;
 	}
 
+	/**
+	 * Returns {@link #_transaction}.
+	 * 
+	 * @return {@link #_transaction}
+	 */
+	public FloodProtectorAction getTransaction()
+	{
+		return _transaction;
+	}
+
 }