@@ -25,8 +25,9 @@ public class ChatControl {
2525 private static Set <UUID > mutedPlayers ;
2626 private static Map <UUID , Set <UUID >> ignoreMap ;
2727 private static Map <UUID , PlayerSpamInfo > spamMap ;
28-
28+
2929 public static boolean controlLinks = false ;
30+ public static String linkRegex = "((https|http):\\ /\\ /)?(www\\ .)?([-a-zA-Z0-9@:%._\\ +~#=]{2,256}\\ .)+[a-zA-Z]{2,4}\\ b([-a-zA-Z0-9@:%_\\ +.~#?&//=]*)" ;
3031 public static String linkMessage = "[LINK REMOVED]" ;
3132
3233 public static Set <UUID > getMutedPlayers () {
@@ -282,10 +283,11 @@ public static void reload() {
282283 }
283284
284285 }
285-
286+
286287 public static String replaceLinks (String message ) {
287288 if (!controlLinks ) return message ;
288- return message .replaceAll ("((https|http):\\ /\\ /)?(www\\ .)?([-a-zA-Z0-9@:%._\\ +~#=]{2,256}\\ .)+[a-zA-Z]{2,4}\\ b([-a-zA-Z0-9@:%_\\ +.~#?&//=]*)" , linkMessage );
289+ return message .replaceAll (linkRegex , linkMessage );
290+ //return message.replaceAll("((https|http):\\/\\/)?(www\\.)?([-a-zA-Z0-9@:%._\\+~#=]{2,256}\\.)+[a-zA-Z]{2,4}\\b([-a-zA-Z0-9@:%_\\+.~#?&//=]*)", linkMessage);
289291 }
290292
291293 public static void spamPardonPlayer (UUID uuid ) {
@@ -297,23 +299,23 @@ public static void spamPardonPlayer(UUID uuid) {
297299 * @return true if the player is spamming and the message should be blocked
298300 */
299301 public static boolean handleSpam (ProxiedPlayer player , String message , String chatType ) {
300-
302+
301303 DebugManager .log (player .getName () + " - checking for spam..." );
302304
303305 Configuration config = ConfigManager .getInstance ().getHandler ("chatcontrol.yml" ).getConfig ();
304-
306+
305307 if (player .hasPermission ("multichat.spam.bypass" )) return false ;
306-
308+
307309 DebugManager .log (player .getName () + " - does not have bypass perm..." );
308310
309311 if (!config .getBoolean ("anti_spam" )) return false ;
310-
312+
311313 DebugManager .log (player .getName () + " - anti spam IS enabled..." );
312314
313315 if (!config .contains ("apply_anti_spam_to." + chatType )) return false ;
314316
315317 if (!config .getBoolean ("apply_anti_spam_to." + chatType )) return false ;
316-
318+
317319 DebugManager .log (player .getName () + " - anti spam IS enabled for " + chatType + "..." );
318320
319321 if (!spamMap .containsKey (player .getUniqueId ())) spamMap .put (player .getUniqueId (), new PlayerSpamInfo ());
@@ -323,21 +325,21 @@ public static boolean handleSpam(ProxiedPlayer player, String message, String ch
323325 boolean spam = spamInfo .checkSpam (message );
324326
325327 if (spam ) {
326-
328+
327329 DebugManager .log (player .getName () + " - PLAYER IS SPAMMING!" );
328330
329331 MessageManager .sendSpecialMessage (player , "anti_spam_cooldown" , String .valueOf (spamInfo .getCooldownSeconds ()));
330-
332+
331333 DebugManager .log (player .getName () + " - sent cooldown message to player..." );
332334
333335 if (spamInfo .getSpamTriggerCount () >= config .getInt ("anti_spam_trigger" )) {
334-
336+
335337 DebugManager .log (player .getName () + " - they have set off the trigger..." );
336338
337339 spamInfo .resetSpamTriggerCount ();
338340
339341 if (config .getBoolean ("anti_spam_action" )) {
340-
342+
341343 DebugManager .log (player .getName () + " - trigger IS enabled..." );
342344
343345 if (config .getBoolean ("anti_spam_spigot" )) {
@@ -352,7 +354,7 @@ public static boolean handleSpam(ProxiedPlayer player, String message, String ch
352354 }
353355
354356 }
355-
357+
356358 DebugManager .log (player .getName () + " - returning " + spam );
357359
358360 return spam ;
0 commit comments