Jump to content

[Share] Chat filter system.


Recommended Posts

Chat filter system, with a log to write the words you don't allow in your server.

 

Index: /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/network/clientpackets/Say2.java
===================================================================
--- /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/network/clientpackets/Say2.java (revision 12)
+++ /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/network/clientpackets/Say2.java (revision 130)
@@ -192,4 +192,48 @@

			_logChat.log(record);
+		}
+		
+		if (L2Config.USE_CHAT_FILTER)
+		{            
+            if (_type == SHOUT || _type == TRADE || _type == HERO_VOICE)
+            {
+            	String filteredText = _text;
+            	filteredText = filteredText.replace("=", "");
+        		filteredText = filteredText.replace("*", "");
+        		filteredText = filteredText.replace(" ", "");
+        		filteredText = filteredText.replace("-", "");
+        		filteredText = filteredText.replace("_", "");
+        		filteredText = filteredText.replace(".", "");
+        		filteredText = filteredText.replace(",", "");
+    			filteredText = filteredText.replace("'", "");
+    			filteredText = filteredText.replace("/", "");
+    			filteredText = filteredText.replace("+", "");
+    			filteredText = filteredText.toLowerCase();
+            	if(!activeChar.inObserverMode() && !activeChar.isInDuel() && !activeChar.isInOlympiadMode() 
+            			&& L2Config.CHAT_FILTER_PUNISHMENT.equalsIgnoreCase("jail") && !activeChar.isInCombat()) {
+	    			for (int i = 0; i < L2Config.FILTER_LIST.size(); i++)
+	    			{
+	    				if(filteredText.contains(L2Config.FILTER_LIST.get(i).toString())) {
+	    					int punishmentLength = 0;                
+	    					punishmentLength = L2Config.CHAT_FILTER_PUNISHMENT_PARAM1 + (L2Config.CHAT_FILTER_PUNISHMENT_PARAM2*activeChar.ChatFilterCount);                
+	    					activeChar.sendMessage("[ChatFilterSystem] Be careful whith words"); 
+	    					activeChar.sendMessage("[ChatFilterSystem] Word " + L2Config.FILTER_LIST.get(i).toString()+ " is untolerable");
+	    					activeChar.setInJail(true, punishmentLength);
+	    					activeChar.ChatFilterCount += 1;
+	    					_text = "[CFS] Jailed for " + punishmentLength + "mins";
+	    					break;
+	    				}
+	    			}
+            	} else {
+	    			for (int i = 0; i < L2Config.FILTER_LIST.size(); i++)
+	    			{
+	    				if(filteredText.contains(L2Config.FILTER_LIST.get(i).toString())) {
+	    					activeChar.sendMessage("[ChatFilterSystem] Be careful whith words");
+	    					activeChar.sendMessage("[ChatFilterSystem] Word " + L2Config.FILTER_LIST.get(i).toString()+ " is untolerable");
+	    					_text = "[CFS] Text cleared";
+	    				}
+	    			}
+            	}
+            }
		}
        
Index: /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 105)
+++ /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 130)
@@ -216,6 +216,6 @@
	private static final String DELETE_SKILL_SAVE = "DELETE FROM character_skills_save WHERE char_obj_id=? AND class_index=?";

-    private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,str=?,con=?,dex=?,_int=?,men=?,wit=?,face=?,hairStyle=?,hairColor=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,maxload=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,in_jail=?,jail_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=? WHERE obj_id=?";
-    private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, acc, crit, evasion, mAtk, mDef, mSpd, pAtk, pDef, pSpd, runSpd, walkSpd, str, con, dex, _int, men, wit, face, hairStyle, hairColor, sex, heading, x, y, z, movement_multiplier, attack_speed_multiplier, colRad, colHeight, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, maxload, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, in_jail, jail_timer, newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level FROM characters WHERE obj_id=?";
+    private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,str=?,con=?,dex=?,_int=?,men=?,wit=?,face=?,hairStyle=?,hairColor=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,maxload=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,in_jail=?,jail_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,chat_filter_count=? WHERE obj_id=?";
+    private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, acc, crit, evasion, mAtk, mDef, mSpd, pAtk, pDef, pSpd, runSpd, walkSpd, str, con, dex, _int, men, wit, face, hairStyle, hairColor, sex, heading, x, y, z, movement_multiplier, attack_speed_multiplier, colRad, colHeight, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, maxload, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, in_jail, jail_timer, newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,chat_filter_count FROM characters WHERE obj_id=?";
    private static final String RESTORE_CHAR_SUBCLASSES = "SELECT class_id,exp,sp,level,class_index FROM character_subclasses WHERE char_obj_id=? ORDER BY class_index ASC";
    private static final String ADD_CHAR_SUBCLASS = "INSERT INTO character_subclasses (char_obj_id,class_id,exp,sp,level,class_index) VALUES (?,?,?,?,?,?)";
@@ -5910,5 +5910,6 @@

                player.setDeathPenaltyBuffLevel(rset.getInt("death_penalty_level"));
-
+                player.setChatFilterCount(rset.getInt("chat_filter_count"));
+                
				// Add the L2PcInstance object in _allObjects
				//L2World.getInstance().storeObject(player);
@@ -6274,5 +6275,6 @@
			statement.setString(55, getName());
			statement.setLong(56, getDeathPenaltyBuffLevel());
-            statement.setInt(57, getObjectId());
+			statement.setInt(57, getChatFilterCount());
+            statement.setInt(58, getObjectId());

			statement.execute();
@@ -6393,5 +6395,16 @@
		finally { try { con.close(); } catch (Exception e) {} }
	}
-
+   
+	/** ChatFilterCounter */
+	public int ChatFilterCount = 0;
+	
+	public void setChatFilterCount(int cfcount)
+	{
+		ChatFilterCount = cfcount;
+	}
+	public int getChatFilterCount()
+	{
+		return ChatFilterCount;
+	}
	/**
	 * Return True if the L2PcInstance is on line.<BR><BR>
Index: /trunk/Eclipse-Game/java/net/sf/l2j/L2Config.java
===================================================================
--- /trunk/Eclipse-Game/java/net/sf/l2j/L2Config.java (revision 128)
+++ /trunk/Eclipse-Game/java/net/sf/l2j/L2Config.java (revision 130)
@@ -6,4 +6,7 @@
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.LineNumberReader;
+import java.io.BufferedReader;
+import java.io.FileReader;
import java.math.BigInteger;
import java.util.List;
@@ -60,4 +63,5 @@
    public static final String  DATAPACK_VERSION_FILE         = "./config/l2jdp-version.properties";
    public static final String  LOGIN_CONFIGURATION_FILE      = "./config/loginserver.properties";
+    public static final String  CHAT_FILTER_FILE              = "./config/ChatFilter.txt";
    public static int   MAX_ITEM_IN_PACKET;

@@ -770,6 +774,10 @@
	public static final FloodProtectorConfig FLOOD_PROTECTOR_WEREHOUSE = new FloodProtectorConfig("WerehouseFloodProtector");
    public static final FloodProtectorConfig FLOOD_PROTECTOR_MISC = new FloodProtectorConfig("MiscFloodProtector");
-	public static final FloodProtectorConfig FLOOD_PROTECTOR_CHAT = new FloodProtectorConfig("ChatFloodProtector");
-
+	public static final FloodProtectorConfig FLOOD_PROTECTOR_CHAT = new FloodProtectorConfig("ChatFloodProtector");  
+    public static boolean	USE_CHAT_FILTER;
+    public static List<String> FILTER_LIST = new FastList<String>();
+    public static String	CHAT_FILTER_PUNISHMENT;
+    public static int	CHAT_FILTER_PUNISHMENT_PARAM1;
+    public static int	CHAT_FILTER_PUNISHMENT_PARAM2;
    
    // Class Balance 
@@ -2100,4 +2108,33 @@
                floodprotectorSettings.load(is);
                is.close();
+                
+                USE_CHAT_FILTER                  = Boolean.parseBoolean(floodprotectorSettings.getProperty("UseChatFilter", "True"));
+                CHAT_FILTER_PUNISHMENT           = floodprotectorSettings.getProperty("ChatFilterPunishment", "off");
+                CHAT_FILTER_PUNISHMENT_PARAM1    = Integer.parseInt(floodprotectorSettings.getProperty("ChatFilterPunishmentParam1", "1")); 
+                CHAT_FILTER_PUNISHMENT_PARAM2    = Integer.parseInt(floodprotectorSettings.getProperty("ChatFilterPunishmentParam2", "1")); 
+
+                if (USE_CHAT_FILTER)
+                {
+                    try
+                    {
+                        LineNumberReader lnr = new LineNumberReader(new BufferedReader(new FileReader(new File(CHAT_FILTER_FILE))));
+                        String line = null;
+                        while ((line = lnr.readLine()) != null)
+                        {
+                            if (line.trim().length() == 0 || line.startsWith("#"))
+                            {
+                                continue;
+                            }
+                            FILTER_LIST.add(line.trim());
+                        }
+                        _log.info("Chat Filter: Loaded " + FILTER_LIST.size() + " words");
+                    }
+                    catch (Exception e)
+                    {
+                        e.printStackTrace();
+                        throw new Error("Failed to Load "+CHAT_FILTER_FILE+" File.");
+                    }
+                }
+                
                loadFloodProtectorConfigs(floodprotectorSettings);
                _log.info("# " + FLOODPROTECTOR_CONFIG_FILE + " Sucessfully LOADED #");
Index: /trunk/Eclipse-Game/config/ChatFilter.txt
===================================================================
--- /trunk/Eclipse-Game/config/ChatFilter.txt (revision 130)
+++ /trunk/Eclipse-Game/config/ChatFilter.txt (revision 130)
@@ -0,0 +1,7 @@
+lag
+laag
+laaag
+laaaag
+laaaaag
+laaaaaag
+laaaaaaag
Index: /trunk/Eclipse-Game/config/Custom/FloodProtector.properties
===================================================================
--- /trunk/Eclipse-Game/config/Custom/FloodProtector.properties (revision 76)
+++ /trunk/Eclipse-Game/config/Custom/FloodProtector.properties (revision 130)
@@ -7,4 +7,16 @@
# PunishmentType - type of the punishment ('none', 'ban', 'jail'), used only, if PunishmentLimit is greater than zero
# PunishmentTime - for how many minutes should be the player/account punished, player is punished in case of 'jail', account is punishedin case of 'ban' (0 = forever)
+
+#---------------------------------------------------------------
+# Chat Filter system                                           -
+#---------------------------------------------------------------
+# Enable chat filter
+UseChatFilter = False
+# Player punishment for illegal word: off, jail
+ChatFilterPunishment = off
+# How long the punishment is in effect, min
+ChatFilterPunishmentParam1 = 10
+# How much to increase every new punishment for player, min
+ChatFilterPunishmentParam2 = 5

FloodProtectorUseItemInterval = 4

 

Credits: one guy from L2JForum, and ŚyśţęmƒяәдҚς for some modifications, nothing special, just removal effect.

Link to comment
Share on other sites

  • 2 weeks later...

This is nice.I was looking for something like this, as i want to open a new server soon

 

you have client and server side filter added in any pack (at least ones i tryed.. but im sure its a common feature).. so im not completely sure why this code was made.. maybe to log what you dont want to see ig lol? if so.. then its way too long for just this 2 features.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   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.



  • Posts

    • Good luck with ur server looks decent the legend is back 🙂
    • The Photoshop Pen Tool, denoted by a pen nib icon, is a versatile tool for precise selections and paths. Click to create anchor points, drag for curves, and close paths to make selections. Refine with the Direct Selection Tool. Useful for intricate designs, cutouts, and precise selections in just a few clicks.
    • My experience with the "Developer" Ban L2JDEV.   On September 22nd, after much effort, I made the terrible decision to work with this individual. At first, everything went smoothly, even pleasantly one could say. In summary, from September 22nd to the present date, he has delivered 2 versions of the pack. The first one seemed like a beta made by someone inexperienced in development. The second one was an even older version. The latest version delivered on December 1st is an older version of ACIS and has nothing to do with what I initially purchased. There were some "improvements" he claimed to have made regarding the drop system, which, in reality, doesn't work at all; it's a delay in time. He asked for 2 more days to add everything I wanted, and, adapting to that pack because time was running out, on December 5th, he claimed he was sick (classic). On December 6th, I informed him of some issues with his drop MOD. On December 7th, I began calling and messaging him to find out what was happening, but to this date, I have never received a response from him. He is always online but never shows up. I will leave a couple of YouTube links with the entire conversation from day one through Discord and WhatsApp, including images of payments and everything else, in case someone is interested in the matter. I know time and money won't be returned with this post, but besides venting, I would appreciate everyone's support in spreading this to prevent more people from being scammed by this individual.       Minha experiência com o "Desenvolvedor" Ban L2JDEV.   Em 22 de setembro, após muito esforço, tomei a terrível decisão de trabalhar com este indivíduo. No início, tudo correu bem, até agradavelmente, poderia-se dizer. Em resumo, do dia 22 de setembro até a presente data, ele entregou 2 versões do pacote. O primeiro parecia uma versão beta feita por alguém inexperiente no mundo do desenvolvimento. O segundo era uma versão ainda mais antiga. A última versão entregue em 1º de dezembro é uma versão mais antiga do ACIS e não tem nada a ver com o que eu comprei inicialmente. Houve algumas "melhorias" que ele afirmou ter feito no sistema de drop, que na realidade não funciona de maneira alguma; é um atraso no tempo. Ele pediu mais 2 dias para adicionar tudo o que eu queria, adaptando-me a esse pacote porque o tempo estava se esgotando. Em 5 de dezembro, ele respondeu que estava doente (clássico). Em 6 de dezembro, informei sobre alguns problemas com o MOD de drop dele. Em 7 de dezembro, comecei a ligar e escrever para saber o que estava acontecendo, mas até a presente data, nunca recebi uma resposta dele. Ele está sempre online, mas nunca se manifesta. Deixarei alguns links do YouTube com toda a conversa desde o primeiro dia pelo Discord e WhatsApp, incluindo imagens dos pagamentos e tudo o mais, caso alguém esteja interessado no assunto. Eu sei que o tempo e o dinheiro não serão recuperados com este post, mas além de desabafar, eu apreciaria o apoio de todos para divulgar isso e evitar que mais pessoas sejam enganadas por este indivíduo.         Mi experiencia con el "Desarrollador" Ban L2JDEV.   el 22 de septiembre después de mucho esfuerzo, tome la terrible decisión de trabajar con este individuo, al principio todo fue fluido, hasta agradable se podría decir. Haciendo resumen, desde el 22 de septiembre a la fecha, me ha entregado 2 versiones del pack, el primero que parecía beta hecha por algún pasante por el mundo del desarrollo. Y el segundo una versión mas antigua... la ultima versión entregada el 1ro de diciembre es una versión mas antigua del acis y no tenia nada que ver con lo que había comprado al principio, unas "mejoras" de parte de el con el tema del drop, cosa que no funciona para nada, es un retraso en el tiempo. Me pidió 2 días mas para agregar todo lo que yo quería, adaptándome a ese pack porque ya el tiempo me ganaba, el 5 de diciembre me responde que estuvo enfermo, clásica. El día 6 le informo de unos problemas con su MOD de drop. el día 7 empiezo a llamarlo y a escribirle para saber que pasaba, cosa que hasta la fecha nunca he tenido una respuesta de su parte. Siempre esta en lineal, solo no da la cara. Dejare un par de links de youtube, con toda la conversación desde el primer día por discord y WhatsApp, imagenes los pagos y todo el resto por si alguien esta interesado en el tema. Se que el tiempo ni el dinero serán retornados con este post, pero además de desahogarme, agradecería el apoyo de todos para regar esto y evitar que mas gente sea estafada por este individuo Links:       
    • THE PROBLEM SOLVED!    YOU CAN LOCK THE TOPIC!          Reset PC connection, and everything will be fine, if anyone will meet a problem like that. 
  • Topics

×
×
  • Create New...