Jump to content
  • 0

[Help] Chat Flood ?


Question

Posted

i import chat flood protect but idk why its dont accept config delay

i change to 10 min or 1 sec but it still same i do it in java and config but not effect

 

say2.java

import com.l2.gameserver.util.FloodProtectorConfig;
...................
..........
....
break;
		case SHOUT:
                if (Config.DEFAULT_GLOBAL_CHAT.equalsIgnoreCase("on") ||
                        (Config.DEFAULT_GLOBAL_CHAT.equalsIgnoreCase("gm") && activeChar.isGM()))
                {
                    if (!FloodProtector.getInstance().tryPerformAction(activeChar.getObjectId(), FloodProtector.PROTECTED_GLOBALCHAT))
                    {
                    	activeChar.sendMessage("Action failed. Players are only able to use channel once every 20 seconds.");
					return;
                    }
                    int region = MapRegionTable.getInstance().getMapRegion(activeChar.getX(), activeChar.getY());
                    for (L2PcInstance player : L2World.getInstance().getAllPlayers())
                    {
                        if (region == MapRegionTable.getInstance().getMapRegion(player.getX(),player.getY()))
                            player.sendPacket(cs);
                    }
                }
                else if (Config.DEFAULT_GLOBAL_CHAT.equalsIgnoreCase("global"))
                {
                    if (!FloodProtector.getInstance().tryPerformAction(activeChar.getObjectId(), FloodProtector.PROTECTED_GLOBALCHAT))
                    {
                    	activeChar.sendMessage("Action failed. Players are only able to use channel once every 20 seconds.");
					return;
                    	
                    }
                    if (activeChar.getPvpKills()< Config.L2JMOD_MIN_PVP_POINTS_TO_TALK)
                    {
                    	activeChar.sendMessage("You need "+ Integer.toString(Config.L2JMOD_MIN_PVP_POINTS_TO_TALK)+ " pvp points to use Global chat.");
                    	return;
                    }
                    for (L2PcInstance player : L2World.getInstance().getAllPlayers())
                    {
                        player.sendPacket(cs);
                    }
                }
                break;
		case TRADE:
			if (Config.DEFAULT_TRADE_CHAT.equalsIgnoreCase("on") ||
					(Config.DEFAULT_TRADE_CHAT.equalsIgnoreCase("gm") && activeChar.isGM()))
			{
                    if (!FloodProtector.getInstance().tryPerformAction(activeChar.getObjectId(), FloodProtector.PROTECTED_GLOBALCHAT))
                    {
                    	activeChar.sendMessage("Action failed. Players are only able to use channel once every 20 seconds.");
					return;
                    }
                    if (activeChar.getPvpKills()< Config.L2JMOD_MIN_PVP_POINTS_TO_TALK)
                    {
                    	activeChar.sendMessage("You need "+ Integer.toString(Config.L2JMOD_MIN_PVP_POINTS_TO_TALK)+ " pvp points to use Global chat.");
                    	return;
                    }
				for (L2PcInstance player : L2World.getInstance().getAllPlayers())
				{
						player.sendPacket(cs);
				}
			} else if (Config.DEFAULT_TRADE_CHAT.equalsIgnoreCase("limited"))
                {
                    if (!FloodProtector.getInstance().tryPerformAction(activeChar.getObjectId(), FloodProtector.PROTECTED_GLOBALCHAT))
                    {
                    	activeChar.sendMessage("Action failed. Players are only able to use channel once every 20 seconds.");
					return;
                    }
                    int region = MapRegionTable.getInstance().getMapRegion(activeChar.getX(), activeChar.getY());
                    for (L2PcInstance player : L2World.getInstance().getAllPlayers())
                    {
                        if (region == MapRegionTable.getInstance().getMapRegion(player.getX(),player.getY()))
                            player.sendPacket(cs);
                    }
                }
                break;
		case ALL:
			if (_text.startsWith("."))
			{
                    if (!FloodProtector.getInstance().tryPerformAction(activeChar.getObjectId(), FloodProtector.PROTECTED_GLOBALCHAT))
                    {
                    	activeChar.sendMessage("Action failed. Players are only able to use channel once every 20 seconds.");
					return;
                    }

case HERO_VOICE:
			if (activeChar.isGM())
			{
				if (!FloodProtector.getInstance().tryPerformAction(activeChar.getObjectId(), FloodProtector.PROTECTED_HEROVOICE))
				{
					//Nothing here xD
				}
				for (L2PcInstance player : L2World.getInstance().getAllPlayers())
					if (!BlockList.isBlocked(player, activeChar))
						player.sendPacket(cs);
			}
			else if (activeChar.isHero())
			{
				if (!FloodProtector.getInstance().tryPerformAction(activeChar.getObjectId(), FloodProtector.PROTECTED_HEROVOICE))
				{
					activeChar.sendMessage("Action failed. Heroes are only able to speak in the global channel once every 10 seconds.");
					return;
				}
				for (L2PcInstance player : L2World.getInstance().getAllPlayers())
					if (!BlockList.isBlocked(player, activeChar))
						player.sendPacket(cs);
			}

 

config.java

 

private static void loadFloodProtectorConfigs(final Properties properties)
{
	loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_USE_ITEM, "UseItem", "4");
	loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_ROLL_DICE, "RollDice", "42");
	loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_FIREWORK, "Firework", "42");
	loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_ITEM_PET_SUMMON, "ItemPetSummon", "16");
	loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_HERO_VOICE, "HeroVoice", "100");
	loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_GLOBAL_CHAT, "GlobalChat", "20000");
	loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_SUBCLASS, "Subclass", "20");
	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", "100");
	loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_MANUFACTURE, "Manufacture", "3");
	loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_MANOR, "Manor", "30");
	loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_SENDMAIL, "SendMail", "100");
	loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_CHARACTER_SELECT, "CharacterSelect", "30");
	loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_ITEM_AUCTION, "ItemAuction", "9");
}

private static void loadFloodProtectorConfig(final Properties properties, final FloodProtectorConfig config, final String configString, final String defaultInterval)
{
	config.FLOOD_PROTECTION_INTERVAL = Integer.parseInt(properties.getProperty(StringUtil.concat("FloodProtector", configString, "Interval"), defaultInterval));
	config.LOG_FLOODING = Boolean.parseBoolean(properties.getProperty(StringUtil.concat("FloodProtector", configString, "LogFlooding"), "False"));
	config.PUNISHMENT_LIMIT = Integer.parseInt(properties.getProperty(StringUtil.concat("FloodProtector", configString, "PunishmentLimit"), "0"));
	config.PUNISHMENT_TYPE = properties.getProperty(StringUtil.concat("FloodProtector", configString, "PunishmentType"), "none");
	config.PUNISHMENT_TIME = Integer.parseInt(properties.getProperty(StringUtil.concat("FloodProtector", configString, "PunishmentTime"), "0"));
}

6 answers to this question

Recommended Posts

  • 0
Posted

somewhere there should be created new runneable seek for

ThreadPoolManager.getInstance().scheduleGeneral(new Something () , delay);

why that ?

all others options work fine

  • 0
Posted

It depends where the flood protector is put (which chathandler). For an global effect on all chats, see directly Say2 packet.

 

Added to that which is your L2 pack, cause normally you got chathandlers, and L2World doesnt use anymore

L2World.getInstance().getAllPlayers()

from what I know.

  • 0
Posted

like that ?

 

 

else if (activeChar.isHero())

{

if (!FloodProtector.getInstance().tryPerformAction(activeChar.getObjectId(), FloodProtector.PROTECTED_HEROVOICE))

{

activeChar.sendMessage("Action failed. Heroes are only able to speak in the global channel once every 10 seconds.");

return;

}

for (L2PcInstance player : L2World.getInstance().getAllPlayers())

if (!BlockList.isBlocked(player, activeChar))

player.sendPacket(cs);

  • 0
Posted

Im kinda lost here, what you want is that if some1 start to spam at any chat, forbid him to talk for x time?

and you want to change that time?

then your problem is in

if (!FloodProtector.getInstance().tryPerformAction(activeChar.getObjectId(), FloodProtector.PROTECTED_HEROVOICE))

thats what determinate if he can or cant talk

and inside it (in the implementation) there must be or some kind of Map that save who and when said anything, or (most probably) a Runneable.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...