From d27f207c431fd05efcf0934cb544b16c7b0b146d Mon Sep 17 00:00:00 2001 From: Zedadias Wick Date: Thu, 24 Mar 2016 00:38:16 +0000 Subject: [PATCH 01/32] Bumped version to 1.6 Added permissions for NOSPAM and NOREPEAT --- pom.xml | 2 +- .../bungeechatfilter/PlayerChatListener.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index b4b382b..4c87a38 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ BungeeChatFilter BungeeChatFilter - 1.5-SNAPSHOT + 1.6-SNAPSHOT jar BungeeChatFilter diff --git a/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java b/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java index e11cce3..9ba9bdf 100644 --- a/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java +++ b/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java @@ -18,7 +18,7 @@ public void playerChat( ChatEvent e ) { if ( !Main.COMMANDS && isChatCommand( e.getMessage() ) ) { return; } - if(Main.NOREPEAT){ + if(Main.NOREPEAT && !player.hasPermission( "bungeefilter.bypass.repeat" )){ if(repeatCheck(player.getName(), e.getMessage())){ e.setCancelled( true ); player.sendMessage( new TextComponent( ChatColor.RED + "Please do not spam" ) ); @@ -28,7 +28,7 @@ public void playerChat( ChatEvent e ) { } } - if ( Main.NOSPAM ) { + if ( Main.NOSPAM && !player.hasPermission( "bungeefilter.bypass.spam" ) ) { if ( spamCheck( player, e.getMessage(), System.currentTimeMillis()) ) { e.setCancelled( true ); player.sendMessage( new TextComponent( ChatColor.RED + "Please do not spam" ) ); From 5a25f24547ef0725bf38f2f269217b70e117de00 Mon Sep 17 00:00:00 2001 From: Zedadias Wick Date: Thu, 24 Mar 2016 02:58:07 +0000 Subject: [PATCH 02/32] reorder NOREPEAT after NOSPAM to avoid previously blocked for spam messages being subsequently blocked as a repeat when player tries to resubmit message after delay. --- .../bungeechatfilter/PlayerChatListener.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java b/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java index 9ba9bdf..0dc9074 100644 --- a/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java +++ b/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java @@ -18,24 +18,24 @@ public void playerChat( ChatEvent e ) { if ( !Main.COMMANDS && isChatCommand( e.getMessage() ) ) { return; } - if(Main.NOREPEAT && !player.hasPermission( "bungeefilter.bypass.repeat" )){ - if(repeatCheck(player.getName(), e.getMessage())){ + if ( Main.NOSPAM && !player.hasPermission( "bungeefilter.bypass.spam" ) ) { + if ( spamCheck( player, e.getMessage(), System.currentTimeMillis()) ) { e.setCancelled( true ); player.sendMessage( new TextComponent( ChatColor.RED + "Please do not spam" ) ); return; - }else{ - Main.ANTIREPEAT.put( player.getName(), e.getMessage() ); + } else { + Main.ANTISPAM.put( player.getName(),System.currentTimeMillis()); } - } - if ( Main.NOSPAM && !player.hasPermission( "bungeefilter.bypass.spam" ) ) { - if ( spamCheck( player, e.getMessage(), System.currentTimeMillis()) ) { + if(Main.NOREPEAT && !player.hasPermission( "bungeefilter.bypass.repeat" )){ + if(repeatCheck(player.getName(), e.getMessage())){ e.setCancelled( true ); player.sendMessage( new TextComponent( ChatColor.RED + "Please do not spam" ) ); return; - } else { - Main.ANTISPAM.put( player.getName(),System.currentTimeMillis()); + }else{ + Main.ANTIREPEAT.put( player.getName(), e.getMessage() ); } + } for ( Rule r : Main.RULES ) { if(r.hasPermission()){ From d48cdf49e0f682ec88d1320f3459bae0465cacd0 Mon Sep 17 00:00:00 2001 From: helptiger Date: Wed, 23 Mar 2016 13:54:10 +0100 Subject: [PATCH 03/32] Fix for sendMessage deprecated --- .../com/minecraftdimensions/bungeechatfilter/BFReload.java | 3 ++- .../com/minecraftdimensions/bungeechatfilter/Rule.java | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/minecraftdimensions/bungeechatfilter/BFReload.java b/src/main/java/com/minecraftdimensions/bungeechatfilter/BFReload.java index af3d0c2..228a87a 100644 --- a/src/main/java/com/minecraftdimensions/bungeechatfilter/BFReload.java +++ b/src/main/java/com/minecraftdimensions/bungeechatfilter/BFReload.java @@ -2,6 +2,7 @@ import com.minecraftdimensions.bungeechatfilter.configlibrary.Config; import net.md_5.bungee.api.CommandSender; +import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.plugin.Command; import java.util.ArrayList; @@ -30,6 +31,6 @@ public void execute( CommandSender sender, String[] args ) { Main.COMLIST = Main.c.getListString( "Commands", defaultList ); Main.NOSPAM = Main.c.getBoolean( "AntiSpam", true ); Main.loadRules(); - sender.sendMessage( "BungeeFilter Reloaded" ); + sender.sendMessage(new TextComponent( "BungeeFilter Reloaded" )); } } diff --git a/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java b/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java index 4a1ce66..7737691 100644 --- a/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java +++ b/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java @@ -2,6 +2,7 @@ import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.ChatEvent; @@ -61,15 +62,15 @@ public void performActions( ChatEvent event, ProxiedPlayer player ) { if ( action.equals( "deny" ) ) { event.setCancelled( true ); } else if ( action.equals( "message" ) ) { - player.sendMessage( color( actions.get( action )[0] ) ); + player.sendMessage(new TextComponent( color( actions.get( action )[0] ) )); } else if ( action.equals( "kick" ) ) { - player.disconnect( color( actions.get( action )[0] ) ); + player.disconnect(new TextComponent( color( actions.get( action )[0] ) )); } else if ( action.equals( "alert" ) ) { String alert = actions.get( action )[0].replace( "{player}", player.getDisplayName() ); if(message.split( " ", 2 ).length>1){ alert =alert.replace("{arguments}", message.split( " ", 2 )[1] ) ; } - ProxyServer.getInstance().broadcast( color( alert )); + ProxyServer.getInstance().broadcast(new TextComponent( color( alert ))); } else if ( action.equals( "scommand" ) ) { player.chat( actions.get( action )[0] ); } else if ( action.equals( "pcommand" ) ) { From 08bd84f7048616463906dca41142c5ec7a82469c Mon Sep 17 00:00:00 2001 From: Zedadias Wick Date: Sat, 26 Mar 2016 12:00:01 +0000 Subject: [PATCH 04/32] Ensure players' repeat message is wiped when disconnecting. --- .../minecraftdimensions/bungeechatfilter/PlayerChatListener.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java b/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java index 0dc9074..8fce32b 100644 --- a/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java +++ b/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java @@ -80,6 +80,7 @@ private boolean spamCheck( ProxiedPlayer player,String message, long time ) { public void playerLogOut( PlayerDisconnectEvent e ) { if(Main.ANTISPAM.containsKey( e.getPlayer().getName() )){ Main.ANTISPAM.remove( e.getPlayer().getName() ); + Main.ANTIREPEAT.remove( e.getPlayer().getName() ); } } From dadf0050294a5e67cf7127c153c4cb54fa4650bf Mon Sep 17 00:00:00 2001 From: Zedadias Wick Date: Sat, 26 Mar 2016 12:03:54 +0000 Subject: [PATCH 05/32] Bump version number for release + add version number to build name. --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 4c87a38..0b2b149 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ BungeeChatFilter BungeeChatFilter - 1.6-SNAPSHOT + 1.6.1 jar BungeeChatFilter @@ -40,7 +40,7 @@ - ${project.name} + ${project.name}-${project.version} ${project.basedir}/src/main/resources From 31f490c15d1c3f53786109775b85eacb8c7276f4 Mon Sep 17 00:00:00 2001 From: Zedadias Wick Date: Tue, 29 Mar 2016 20:24:59 +0100 Subject: [PATCH 06/32] Add an acceptable delay for repeat messages bump version up to 1.6.2-SNAPSHOT --- pom.xml | 2 +- .../bungeechatfilter/Main.java | 4 ++- .../bungeechatfilter/PlayerChatListener.java | 26 +++++++++++-------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 0b2b149..bb16a5f 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ BungeeChatFilter BungeeChatFilter - 1.6.1 + 1.6.2-SNAPSHOT jar BungeeChatFilter diff --git a/src/main/java/com/minecraftdimensions/bungeechatfilter/Main.java b/src/main/java/com/minecraftdimensions/bungeechatfilter/Main.java index 6ebe7d3..4e750eb 100644 --- a/src/main/java/com/minecraftdimensions/bungeechatfilter/Main.java +++ b/src/main/java/com/minecraftdimensions/bungeechatfilter/Main.java @@ -12,6 +12,7 @@ public class Main extends Plugin { public static long SPAMTIMER = 0; + public static long REPEATTIMER = 0; public static Boolean COMMANDS; public static List COMLIST; public static ArrayList RULES; @@ -69,7 +70,8 @@ private void initialiseConfig() { COMLIST = c.getListString( "Commands", defaultList ); NOSPAM = c.getBoolean( "AntiSpam", true ); NOREPEAT = c.getBoolean( "AntiRepeat", true ); - SPAMTIMER = c.getInt( "Minimum-Chat-Delay" ) ; + SPAMTIMER = c.getInt( "Minimum-Chat-Delay", 1500 ) ; + REPEATTIMER = c.getInt( "Minimum-Repeat-Delay", 60000 ) ; loadRules(); } diff --git a/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java b/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java index 8fce32b..ac2a589 100644 --- a/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java +++ b/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java @@ -23,12 +23,10 @@ public void playerChat( ChatEvent e ) { e.setCancelled( true ); player.sendMessage( new TextComponent( ChatColor.RED + "Please do not spam" ) ); return; - } else { - Main.ANTISPAM.put( player.getName(),System.currentTimeMillis()); } } if(Main.NOREPEAT && !player.hasPermission( "bungeefilter.bypass.repeat" )){ - if(repeatCheck(player.getName(), e.getMessage())){ + if(repeatCheck(player.getName(), e.getMessage(),System.currentTimeMillis())){ e.setCancelled( true ); player.sendMessage( new TextComponent( ChatColor.RED + "Please do not spam" ) ); return; @@ -37,6 +35,7 @@ public void playerChat( ChatEvent e ) { } } + Main.ANTISPAM.put( player.getName(),System.currentTimeMillis()); for ( Rule r : Main.RULES ) { if(r.hasPermission()){ if(!r.needsPerm && player.hasPermission( r.getPermission() )){ @@ -55,23 +54,28 @@ public void playerChat( ChatEvent e ) { } - private boolean repeatCheck( String name, String message ) { + private boolean spamCheck( ProxiedPlayer player,String message, long time ) { if(isChatCommand( message ) && !isMonitoredCommand( message )){ return false; } - if ( Main.ANTIREPEAT.containsKey( name ) ) { - return Main.ANTIREPEAT.get( name ).equals( message ); + if ( Main.ANTISPAM.containsKey( player.getName() ) ) { + Long diff = time-Main.ANTISPAM.get( player.getName() ); + return diff Date: Wed, 31 Aug 2016 11:58:33 +0100 Subject: [PATCH 07/32] Fixes #3 --- .../bungeechatfilter/PlayerChatListener.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java b/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java index ac2a589..c5614f6 100644 --- a/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java +++ b/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java @@ -39,10 +39,10 @@ public void playerChat( ChatEvent e ) { for ( Rule r : Main.RULES ) { if(r.hasPermission()){ if(!r.needsPerm && player.hasPermission( r.getPermission() )){ - return; + continue; } if(r.needsPerm && !player.hasPermission( r.getPermission() )){ - return; + continue; } } if ( r.doesMessageContainRegex( e.getMessage() ) ) { From 9ddbd08f3f92ed265734cb1dfbeb0f7854a681da Mon Sep 17 00:00:00 2001 From: Zedadias Wick Date: Wed, 31 Aug 2016 12:12:26 +0100 Subject: [PATCH 08/32] Bumped version to 1.6.2 for release. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bb16a5f..cafc58a 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ BungeeChatFilter BungeeChatFilter - 1.6.2-SNAPSHOT + 1.6.2 jar BungeeChatFilter From e5024476346e72f867cc10be3e07a2015df4ac45 Mon Sep 17 00:00:00 2001 From: Zedadias Wick Date: Wed, 31 Aug 2016 22:25:52 +0100 Subject: [PATCH 09/32] Monitored commands now affects all rules, not just antispam/antirepeat. Custom commands created using rules will not be monitored unless listed under commands in the config. Bumped version to 1.6.3-SNAPSHOT --- pom.xml | 2 +- .../bungeechatfilter/PlayerChatListener.java | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index cafc58a..c41f378 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ BungeeChatFilter BungeeChatFilter - 1.6.2 + 1.6.3-SNAPSHOT jar BungeeChatFilter diff --git a/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java b/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java index c5614f6..cc15efb 100644 --- a/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java +++ b/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java @@ -17,6 +17,8 @@ public void playerChat( ChatEvent e ) { if ( !player.hasPermission( "bungeefilter.bypass" ) ) { if ( !Main.COMMANDS && isChatCommand( e.getMessage() ) ) { return; + } else if( Main.COMMANDS && isChatCommand( e.getMessage() ) && !isMonitoredCommand( e.getMessage() )){ + return; } if ( Main.NOSPAM && !player.hasPermission( "bungeefilter.bypass.spam" ) ) { if ( spamCheck( player, e.getMessage(), System.currentTimeMillis()) ) { @@ -55,9 +57,6 @@ public void playerChat( ChatEvent e ) { } private boolean spamCheck( ProxiedPlayer player,String message, long time ) { - if(isChatCommand( message ) && !isMonitoredCommand( message )){ - return false; - } if ( Main.ANTISPAM.containsKey( player.getName() ) ) { Long diff = time-Main.ANTISPAM.get( player.getName() ); return diff Date: Wed, 31 Aug 2016 22:57:11 +0100 Subject: [PATCH 10/32] Add "Please do not spam" chat messages to config, sent when blocked by AntiSpam or AntiRepear Added AntiRepeat, Anti-Repeat-Delay, AntiRepeatMessage, AntiSpamMessage to default config. Version 0.6.3 --- pom.xml | 2 +- .../bungeechatfilter/PlayerChatListener.java | 4 ++-- src/main/resources/config.yml | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index c41f378..05c0fac 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ BungeeChatFilter BungeeChatFilter - 1.6.3-SNAPSHOT + 1.6.3 jar BungeeChatFilter diff --git a/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java b/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java index cc15efb..6e4b715 100644 --- a/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java +++ b/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java @@ -23,14 +23,14 @@ public void playerChat( ChatEvent e ) { if ( Main.NOSPAM && !player.hasPermission( "bungeefilter.bypass.spam" ) ) { if ( spamCheck( player, e.getMessage(), System.currentTimeMillis()) ) { e.setCancelled( true ); - player.sendMessage( new TextComponent( ChatColor.RED + "Please do not spam" ) ); + player.sendMessage( new TextComponent( ChatColor.RED + Main.c.getString("AntiSpamMessage", "Please do not spam") ) ); return; } } if(Main.NOREPEAT && !player.hasPermission( "bungeefilter.bypass.repeat" )){ if(repeatCheck(player.getName(), e.getMessage(),System.currentTimeMillis())){ e.setCancelled( true ); - player.sendMessage( new TextComponent( ChatColor.RED + "Please do not spam" ) ); + player.sendMessage( new TextComponent( ChatColor.RED + Main.c.getString("AntiSpamMessage", "Please do not spam") ) ); return; }else{ Main.ANTIREPEAT.put( player.getName(), e.getMessage() ); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 8d70812..9fbc361 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -23,8 +23,13 @@ Commands: #AntiSpam - Will use the minimum chat delay to force players to wait *1500ms or what ever you specified between messages AntiSpam: true +AntiRepeat: true #Minimum-Chat-Delay - The time in miliseconds a player must wait between messages Minimum-Chat-Delay: 1500 +Minimum-Repeat-Delay: 60000 +#Messages sent to the player in chat when they are blocked by AntiSpam or AntiRepeat +AntiSpamMessage: Please do not spam +AntiRepeatMessage: Please do not spam #Rules - Groups of rules which monitor the chat #rules: From dbe62f5271090c602bb92545a36af515cb88b717 Mon Sep 17 00:00:00 2001 From: Zedadias Wick Date: Wed, 31 Aug 2016 23:10:33 +0100 Subject: [PATCH 11/32] Updated default config Commands with all custom commands from rules Version 1.6.4 --- pom.xml | 2 +- src/main/resources/config.yml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 05c0fac..974562f 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ BungeeChatFilter BungeeChatFilter - 1.6.3 + 1.6.4 jar BungeeChatFilter diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 9fbc361..dcf9781 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -11,6 +11,7 @@ Monitor Commands: true Commands: - msg - message + - m - tell - whisper - w @@ -20,6 +21,10 @@ Commands: - l - local - hub + - url + - website + - warp + - hub #AntiSpam - Will use the minimum chat delay to force players to wait *1500ms or what ever you specified between messages AntiSpam: true From 3ab98256db49c01ca297afa49e7d27089b9d01eb Mon Sep 17 00:00:00 2001 From: Zedadias Wick Date: Thu, 6 Apr 2017 18:12:34 +0100 Subject: [PATCH 12/32] Fix for misleading config concerning pcommand and ccommand. --- pom.xml | 2 +- src/main/resources/config.yml | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 974562f..b4fc531 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ BungeeChatFilter BungeeChatFilter - 1.6.4 + 1.6.5 jar BungeeChatFilter diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index dcf9781..bac685a 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -47,15 +47,14 @@ AntiRepeatMessage: Please do not spam # message: (message) -this will send a message (message) to the player # kick: (message) - this will kick the player with the (message) # alert: (message) - this will send a broadcast to the server {player} will be replaced with the players display name -# command: /(command) - this will cause the player to send the (command) # remove: true - this will remove any matches from the players message # replace: - this will replace the matched word with a random word from the list below # - word1 # - word2 # lower: - this will change any matches into lowercase -# pcommand: /(command) - Proxy command, this will cause the player to send the (command) to the proxy server -# scommand: /(command) - Server command this will cause the player to send the (command) to their current server -# ccommand: /(command) - Console command, this will cause the proxy server console to execute the (command). +# pcommand: (command) - Proxy command, this will cause the player to send the (command) to the proxy server. Do not include a /. +# scommand: /(command) - Server command this will cause the player to send the (command) to their current server. You must include a /. +# ccommand: (command) - Console command, this will cause the proxy server console to execute the (command). Do not include a /. # Note that there is currently no way to execute a command as the current server console. From 6dea204931f463436a95b418288476c029556308 Mon Sep 17 00:00:00 2001 From: Zedadias Wick Date: Fri, 7 Apr 2017 15:25:52 +0100 Subject: [PATCH 13/32] Allows configurable chat color for AntiRepeatMessage & AntiSpamMessage (Resolves #6) Possible fix for new lines having color reset (#7) Version 1.6.6 --- pom.xml | 2 +- .../minecraftdimensions/bungeechatfilter/Main.java | 2 +- .../bungeechatfilter/PlayerChatListener.java | 4 ++-- .../minecraftdimensions/bungeechatfilter/Rule.java | 11 ++++------- src/main/resources/config.yml | 4 ++-- src/main/resources/plugin.yml | 3 ++- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index b4fc531..f0fd960 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ BungeeChatFilter BungeeChatFilter - 1.6.5 + 1.6.6 jar BungeeChatFilter diff --git a/src/main/java/com/minecraftdimensions/bungeechatfilter/Main.java b/src/main/java/com/minecraftdimensions/bungeechatfilter/Main.java index 4e750eb..234e05d 100644 --- a/src/main/java/com/minecraftdimensions/bungeechatfilter/Main.java +++ b/src/main/java/com/minecraftdimensions/bungeechatfilter/Main.java @@ -106,7 +106,7 @@ public static void loadRules() { } - public String color( String s ) { + public static String color( String s ) { return ChatColor.translateAlternateColorCodes( '&', s ); } } diff --git a/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java b/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java index 6e4b715..338f914 100644 --- a/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java +++ b/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java @@ -23,14 +23,14 @@ public void playerChat( ChatEvent e ) { if ( Main.NOSPAM && !player.hasPermission( "bungeefilter.bypass.spam" ) ) { if ( spamCheck( player, e.getMessage(), System.currentTimeMillis()) ) { e.setCancelled( true ); - player.sendMessage( new TextComponent( ChatColor.RED + Main.c.getString("AntiSpamMessage", "Please do not spam") ) ); + player.sendMessage( new TextComponent( TextComponent.fromLegacyText( Main.color( Main.c.getString("AntiSpamMessage", "&cPlease do not spam") ) ) ) ); return; } } if(Main.NOREPEAT && !player.hasPermission( "bungeefilter.bypass.repeat" )){ if(repeatCheck(player.getName(), e.getMessage(),System.currentTimeMillis())){ e.setCancelled( true ); - player.sendMessage( new TextComponent( ChatColor.RED + Main.c.getString("AntiSpamMessage", "Please do not spam") ) ); + player.sendMessage( new TextComponent( TextComponent.fromLegacyText( Main.color( Main.c.getString("AntiSpamMessage", "&cPlease do not spam") ) ) ) ); return; }else{ Main.ANTIREPEAT.put( player.getName(), e.getMessage() ); diff --git a/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java b/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java index 7737691..6601af2 100644 --- a/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java +++ b/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java @@ -10,6 +10,7 @@ import java.util.Random; import java.util.regex.Matcher; import java.util.regex.Pattern; +import net.md_5.bungee.api.chat.BaseComponent; public class Rule { @@ -62,15 +63,15 @@ public void performActions( ChatEvent event, ProxiedPlayer player ) { if ( action.equals( "deny" ) ) { event.setCancelled( true ); } else if ( action.equals( "message" ) ) { - player.sendMessage(new TextComponent( color( actions.get( action )[0] ) )); + player.sendMessage( TextComponent.fromLegacyText( Main.color( actions.get( action )[0] ) ) ); } else if ( action.equals( "kick" ) ) { - player.disconnect(new TextComponent( color( actions.get( action )[0] ) )); + player.disconnect( new TextComponent( TextComponent.fromLegacyText( Main.color( actions.get( action )[0] ) ) ) ); } else if ( action.equals( "alert" ) ) { String alert = actions.get( action )[0].replace( "{player}", player.getDisplayName() ); if(message.split( " ", 2 ).length>1){ alert =alert.replace("{arguments}", message.split( " ", 2 )[1] ) ; } - ProxyServer.getInstance().broadcast(new TextComponent( color( alert ))); + ProxyServer.getInstance().broadcast(new TextComponent( Main.color( alert ))); } else if ( action.equals( "scommand" ) ) { player.chat( actions.get( action )[0] ); } else if ( action.equals( "pcommand" ) ) { @@ -108,10 +109,6 @@ public void performActions( ChatEvent event, ProxiedPlayer player ) { event.setMessage( message ); } - public String color( String s ) { - return ChatColor.translateAlternateColorCodes( '&', s ); - } - public boolean hasPermission() { return permission != null; } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index bac685a..ddb1b70 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -33,8 +33,8 @@ AntiRepeat: true Minimum-Chat-Delay: 1500 Minimum-Repeat-Delay: 60000 #Messages sent to the player in chat when they are blocked by AntiSpam or AntiRepeat -AntiSpamMessage: Please do not spam -AntiRepeatMessage: Please do not spam +AntiSpamMessage: &cPlease do not spam +AntiRepeatMessage: &cPlease do not spam #Rules - Groups of rules which monitor the chat #rules: diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 7c4297e..1c871c3 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,4 +1,5 @@ name: BungeeChatFilter main : com.minecraftdimensions.bungeechatfilter.Main version: ${project.version}b-${build.number} -author: Bloodsplat \ No newline at end of file +author: Bloodsplat, Zedwick +website: https://www.spigotmc.org/resources/bungeechatfilter.20596/ \ No newline at end of file From 563c1ae2726d82e0ec2219d0fc05aabf94091ea9 Mon Sep 17 00:00:00 2001 From: leonfagan71 Date: Fri, 7 Apr 2017 22:26:15 +0100 Subject: [PATCH 14/32] added message param to ccommand --- .../java/com/minecraftdimensions/bungeechatfilter/Rule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java b/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java index 6601af2..f0792e3 100644 --- a/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java +++ b/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java @@ -77,7 +77,7 @@ public void performActions( ChatEvent event, ProxiedPlayer player ) { } else if ( action.equals( "pcommand" ) ) { ProxyServer.getInstance().getPluginManager().dispatchCommand( player, actions.get( action )[0] ); } else if( action.equals( "ccommand" )){ - ProxyServer.getInstance().getPluginManager().dispatchCommand( ProxyServer.getInstance().getConsole(), actions.get( action )[0].replace( "{player}", player.getName() ) ); + ProxyServer.getInstance().getPluginManager().dispatchCommand( ProxyServer.getInstance().getConsole(), actions.get( action )[0].replace( "{player}", player.getName() ).replace( "{message}", message ) ); } else if ( action.equals( "remove" ) ) { message = message.replaceAll( regex.pattern(), "" ); } else if ( action.equals( "replace" ) ) { From 40e06729d5d3e7f7fbc63463a7d8e7f611ddcfe6 Mon Sep 17 00:00:00 2001 From: Zedadias Wick Date: Fri, 7 Apr 2017 23:12:55 +0100 Subject: [PATCH 15/32] Version 1.6.7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f0fd960..781ba3b 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ BungeeChatFilter BungeeChatFilter - 1.6.6 + 1.6.7 jar BungeeChatFilter From f0b0802aef26eb2d74cfd20d81617b43827f8ef0 Mon Sep 17 00:00:00 2001 From: Zedadias Wick Date: Mon, 24 Apr 2017 22:32:37 +0100 Subject: [PATCH 16/32] Added support for Booleans in actions config --- .../bungeechatfilter/Main.java | 4 ++-- .../bungeechatfilter/Rule.java | 20 +++++++++---------- .../configlibrary/Config.java | 9 +++++++++ 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/minecraftdimensions/bungeechatfilter/Main.java b/src/main/java/com/minecraftdimensions/bungeechatfilter/Main.java index 234e05d..d28fc56 100644 --- a/src/main/java/com/minecraftdimensions/bungeechatfilter/Main.java +++ b/src/main/java/com/minecraftdimensions/bungeechatfilter/Main.java @@ -91,13 +91,13 @@ public static void loadRules() { } String perm = c.getString( "rules." + node + ".permission" ); String ignore = c.getString( "rules." + node + ".ignores" ); - HashMap actions = new HashMap<>(); + HashMap actions = new HashMap<>(); for ( String action : c.getSubNodes( "rules." + node + ".actions" ) ) { if ( action.equals( "replace" ) ) { List strlist = c.getListString( "rules." + node + ".actions.replace" ); actions.put( action, strlist.toArray( new String[strlist.size()] ) ); } else { - actions.put( action, new String[] { c.getString( "rules." + node + ".actions." + action ) } ); + actions.put( action, new Object[] { c.get( "rules." + node + ".actions." + action ) } ); } } RULES.add( new Rule( regex, actions, perm, ignore ) ); diff --git a/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java b/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java index f0792e3..1a5b48b 100644 --- a/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java +++ b/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java @@ -16,11 +16,11 @@ public class Rule { Pattern regex; Pattern ignore; - HashMap actions; + HashMap actions; String permission = null; boolean needsPerm; - public Rule( String regex, HashMap actions, String permission, String ignores ) { + public Rule( String regex, HashMap actions, String permission, String ignores ) { this.regex = Pattern.compile( regex ); if ( ignores == null ) { ignore = null; @@ -60,24 +60,24 @@ public void performActions( ChatEvent event, ProxiedPlayer player ) { } } for ( String action : actions.keySet() ) { - if ( action.equals( "deny" ) ) { + if ( action.equals( "deny" ) && (Boolean) actions.get( action )[0] ) { event.setCancelled( true ); } else if ( action.equals( "message" ) ) { - player.sendMessage( TextComponent.fromLegacyText( Main.color( actions.get( action )[0] ) ) ); + player.sendMessage( TextComponent.fromLegacyText( Main.color((String) actions.get( action )[0]) ) ); } else if ( action.equals( "kick" ) ) { - player.disconnect( new TextComponent( TextComponent.fromLegacyText( Main.color( actions.get( action )[0] ) ) ) ); + player.disconnect( new TextComponent( TextComponent.fromLegacyText( Main.color((String) actions.get( action )[0]) ) ) ); } else if ( action.equals( "alert" ) ) { - String alert = actions.get( action )[0].replace( "{player}", player.getDisplayName() ); + String alert = ((String) actions.get( action )[0]).replace( "{player}", player.getDisplayName() ); if(message.split( " ", 2 ).length>1){ alert =alert.replace("{arguments}", message.split( " ", 2 )[1] ) ; } ProxyServer.getInstance().broadcast(new TextComponent( Main.color( alert ))); } else if ( action.equals( "scommand" ) ) { - player.chat( actions.get( action )[0] ); + player.chat((String) actions.get( action )[0]); } else if ( action.equals( "pcommand" ) ) { - ProxyServer.getInstance().getPluginManager().dispatchCommand( player, actions.get( action )[0] ); + ProxyServer.getInstance().getPluginManager().dispatchCommand(player, (String) actions.get( action )[0]); } else if( action.equals( "ccommand" )){ - ProxyServer.getInstance().getPluginManager().dispatchCommand( ProxyServer.getInstance().getConsole(), actions.get( action )[0].replace( "{player}", player.getName() ).replace( "{message}", message ) ); + ProxyServer.getInstance().getPluginManager().dispatchCommand( ProxyServer.getInstance().getConsole(), ((String) actions.get( action )[0]).replace( "{player}", player.getName() ).replace( "{message}", message ) ); } else if ( action.equals( "remove" ) ) { message = message.replaceAll( regex.pattern(), "" ); } else if ( action.equals( "replace" ) ) { @@ -88,7 +88,7 @@ public void performActions( ChatEvent event, ProxiedPlayer player ) { while ( m.find() ) { int n = rand.nextInt( actions.get( action ).length ); sb.append( message.substring( last, m.start() ) ); - sb.append( actions.get( action )[n] ); + sb.append( (String) actions.get( action )[n] ); last = m.end(); } sb.append( message.substring( last ) ); diff --git a/src/main/java/com/minecraftdimensions/bungeechatfilter/configlibrary/Config.java b/src/main/java/com/minecraftdimensions/bungeechatfilter/configlibrary/Config.java index 32051f3..c8ecc65 100644 --- a/src/main/java/com/minecraftdimensions/bungeechatfilter/configlibrary/Config.java +++ b/src/main/java/com/minecraftdimensions/bungeechatfilter/configlibrary/Config.java @@ -49,6 +49,15 @@ public void createFile() { } } } + + public Object get( String key ) { + + if ( fconfig.contains( key ) ) { + return fconfig.get( key ); + } else{ + return null; + } + } public String getString( String key, String def ) { From 37c18e640417b1e90d6beba954a818989d106dbc Mon Sep 17 00:00:00 2001 From: Zedadias Wick Date: Tue, 25 Apr 2017 01:27:59 +0100 Subject: [PATCH 17/32] + Variables are now supported across all (String-based) actions. (Resolves #13) + All string-based actions now support Lists, allowing for multiple lines in messages and running multiple commands (Resolves #14) + Fixed Boolean support for lower and remove actions --- .../bungeechatfilter/Main.java | 14 ++-- .../bungeechatfilter/PlayerChatListener.java | 4 +- .../bungeechatfilter/Rule.java | 39 +++++------ .../bungeechatfilter/util.java | 64 +++++++++++++++++++ 4 files changed, 96 insertions(+), 25 deletions(-) create mode 100644 src/main/java/com/minecraftdimensions/bungeechatfilter/util.java diff --git a/src/main/java/com/minecraftdimensions/bungeechatfilter/Main.java b/src/main/java/com/minecraftdimensions/bungeechatfilter/Main.java index d28fc56..ae5abed 100644 --- a/src/main/java/com/minecraftdimensions/bungeechatfilter/Main.java +++ b/src/main/java/com/minecraftdimensions/bungeechatfilter/Main.java @@ -91,13 +91,20 @@ public static void loadRules() { } String perm = c.getString( "rules." + node + ".permission" ); String ignore = c.getString( "rules." + node + ".ignores" ); - HashMap actions = new HashMap<>(); + HashMap actions = new HashMap<>(); for ( String action : c.getSubNodes( "rules." + node + ".actions" ) ) { + Object obj = c.get( "rules." + node + ".actions." + action ); if ( action.equals( "replace" ) ) { List strlist = c.getListString( "rules." + node + ".actions.replace" ); actions.put( action, strlist.toArray( new String[strlist.size()] ) ); + } else if ( obj instanceof List ) { + actions.put( action, c.getListString("rules." + node + ".actions." + action ) ); + } else if ( obj instanceof String ) { + List stringList = new ArrayList(); + stringList.add( c.getString("rules." + node + ".actions." + action ) ); + actions.put( action, stringList ); } else { - actions.put( action, new Object[] { c.get( "rules." + node + ".actions." + action ) } ); + actions.put( action, c.get( "rules." + node + ".actions." + action ) ); } } RULES.add( new Rule( regex, actions, perm, ignore ) ); @@ -106,7 +113,4 @@ public static void loadRules() { } - public static String color( String s ) { - return ChatColor.translateAlternateColorCodes( '&', s ); - } } diff --git a/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java b/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java index 338f914..045896e 100644 --- a/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java +++ b/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java @@ -23,14 +23,14 @@ public void playerChat( ChatEvent e ) { if ( Main.NOSPAM && !player.hasPermission( "bungeefilter.bypass.spam" ) ) { if ( spamCheck( player, e.getMessage(), System.currentTimeMillis()) ) { e.setCancelled( true ); - player.sendMessage( new TextComponent( TextComponent.fromLegacyText( Main.color( Main.c.getString("AntiSpamMessage", "&cPlease do not spam") ) ) ) ); + player.sendMessage( new TextComponent( TextComponent.fromLegacyText(util.color( Main.c.getString("AntiSpamMessage", "&cPlease do not spam") ) ) ) ); return; } } if(Main.NOREPEAT && !player.hasPermission( "bungeefilter.bypass.repeat" )){ if(repeatCheck(player.getName(), e.getMessage(),System.currentTimeMillis())){ e.setCancelled( true ); - player.sendMessage( new TextComponent( TextComponent.fromLegacyText( Main.color( Main.c.getString("AntiSpamMessage", "&cPlease do not spam") ) ) ) ); + player.sendMessage( new TextComponent( TextComponent.fromLegacyText(util.color( Main.c.getString("AntiSpamMessage", "&cPlease do not spam") ) ) ) ); return; }else{ Main.ANTIREPEAT.put( player.getName(), e.getMessage() ); diff --git a/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java b/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java index 1a5b48b..b4951d1 100644 --- a/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java +++ b/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java @@ -7,6 +7,7 @@ import net.md_5.bungee.api.event.ChatEvent; import java.util.HashMap; +import java.util.List; import java.util.Random; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -16,11 +17,11 @@ public class Rule { Pattern regex; Pattern ignore; - HashMap actions; + HashMap actions; String permission = null; boolean needsPerm; - public Rule( String regex, HashMap actions, String permission, String ignores ) { + public Rule( String regex, HashMap actions, String permission, String ignores ) { this.regex = Pattern.compile( regex ); if ( ignores == null ) { ignore = null; @@ -60,25 +61,27 @@ public void performActions( ChatEvent event, ProxiedPlayer player ) { } } for ( String action : actions.keySet() ) { - if ( action.equals( "deny" ) && (Boolean) actions.get( action )[0] ) { + if ( action.equals( "deny" ) && (Boolean) actions.get( action ) ) { event.setCancelled( true ); } else if ( action.equals( "message" ) ) { - player.sendMessage( TextComponent.fromLegacyText( Main.color((String) actions.get( action )[0]) ) ); + player.sendMessage( util.MessageFromStringList( (List) actions.get( action ), event ) ); } else if ( action.equals( "kick" ) ) { - player.disconnect( new TextComponent( TextComponent.fromLegacyText( Main.color((String) actions.get( action )[0]) ) ) ); + player.disconnect( util.MessageFromStringList( (List) actions.get( action ), event ) ); } else if ( action.equals( "alert" ) ) { - String alert = ((String) actions.get( action )[0]).replace( "{player}", player.getDisplayName() ); - if(message.split( " ", 2 ).length>1){ - alert =alert.replace("{arguments}", message.split( " ", 2 )[1] ) ; - } - ProxyServer.getInstance().broadcast(new TextComponent( Main.color( alert ))); + ProxyServer.getInstance().broadcast( util.MessageFromStringList( (List) actions.get( action ), event ) ); } else if ( action.equals( "scommand" ) ) { - player.chat((String) actions.get( action )[0]); + for ( String scommand : (List) actions.get( action ) ) { + player.chat( util.ParseVariables( scommand, event ) ); + } } else if ( action.equals( "pcommand" ) ) { - ProxyServer.getInstance().getPluginManager().dispatchCommand(player, (String) actions.get( action )[0]); - } else if( action.equals( "ccommand" )){ - ProxyServer.getInstance().getPluginManager().dispatchCommand( ProxyServer.getInstance().getConsole(), ((String) actions.get( action )[0]).replace( "{player}", player.getName() ).replace( "{message}", message ) ); - } else if ( action.equals( "remove" ) ) { + for ( String pcommand : (List) actions.get( action ) ) { + ProxyServer.getInstance().getPluginManager().dispatchCommand(player, util.ParseVariables(pcommand, event) ); + } + } else if( action.equals( "ccommand" ) ) { + for ( String ccommand : (List) actions.get( action ) ) { + ProxyServer.getInstance().getPluginManager().dispatchCommand( ProxyServer.getInstance().getConsole(), util.ParseVariables(ccommand, event) ); + } + } else if ( action.equals( "remove" ) && (Boolean) actions.get( action ) ) { message = message.replaceAll( regex.pattern(), "" ); } else if ( action.equals( "replace" ) ) { Random rand = new Random(); @@ -86,14 +89,14 @@ public void performActions( ChatEvent event, ProxiedPlayer player ) { StringBuilder sb = new StringBuilder(); int last = 0; while ( m.find() ) { - int n = rand.nextInt( actions.get( action ).length ); + int n = rand.nextInt( ((String[]) actions.get( action )).length ); sb.append( message.substring( last, m.start() ) ); - sb.append( (String) actions.get( action )[n] ); + sb.append( util.ParseVariables(((String[]) actions.get( action ))[n], event) ); last = m.end(); } sb.append( message.substring( last ) ); message = sb.toString(); - } else if ( action.equals( "lower" ) ) { + } else if ( action.equals( "lower" ) && (Boolean) actions.get( action ) ) { Matcher m = getMatcher( message ); StringBuilder sb = new StringBuilder(); int last = 0; diff --git a/src/main/java/com/minecraftdimensions/bungeechatfilter/util.java b/src/main/java/com/minecraftdimensions/bungeechatfilter/util.java new file mode 100644 index 0000000..65b5c05 --- /dev/null +++ b/src/main/java/com/minecraftdimensions/bungeechatfilter/util.java @@ -0,0 +1,64 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.minecraftdimensions.bungeechatfilter; + +import java.util.Iterator; +import java.util.List; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.chat.BaseComponent; +import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.connection.Connection; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.event.ChatEvent; + +/** + * + * @author zedwick + */ +public class util { + + public static String color(String s) { + return ChatColor.translateAlternateColorCodes('&', s); + } + public static TextComponent MessageFromStringList(List StringList, ChatEvent event) { + TextComponent message = new TextComponent(); + + for (Iterator it = StringList.iterator(); it.hasNext();) { + String string = it.next(); + string = ParseVariables(string, event); + String newLine = ""; + if ( it.hasNext() ) { + newLine = "\n"; + } + message.addExtra(new TextComponent(StringToBaseComponent(string+newLine))); + } + + return message; + } + + public static BaseComponent[] StringToBaseComponent(String string) { + return TextComponent.fromLegacyText(color(string)); + } + + public static String ParseVariables(String string, ChatEvent event) { + ProxiedPlayer player = (ProxiedPlayer) event.getSender(); + String message = event.getMessage(); + String arguments = ""; + + if(message.split( " ", 2 ).length>1) { + arguments = message.split( " ", 2 )[1]; + } + + string = string + .replace("{player}", player.getDisplayName()) + .replace("{message}", message) + .replace("{arguments}", arguments); + + + + return string; + } +} From b5f03a6dc5fb2e70d684aa1e3965bb22367d1f5c Mon Sep 17 00:00:00 2001 From: Zedadias Wick Date: Tue, 25 Apr 2017 02:17:48 +0100 Subject: [PATCH 18/32] Version 1.7 --- pom.xml | 2 +- src/main/resources/config.yml | 43 +++++++++++++++++++++-------------- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/pom.xml b/pom.xml index 781ba3b..a7fb189 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ BungeeChatFilter BungeeChatFilter - 1.6.7 + 1.7 jar BungeeChatFilter diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index ddb1b70..51ca4eb 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,7 +1,7 @@ ########################################## ## ## ## Bungee Chat Filter Config ## -## v1.2 ## +## v1.7 ## ########################################## #Monitor commands - Monitor commands send by the players as chat @@ -38,25 +38,31 @@ AntiRepeatMessage: &cPlease do not spam #Rules - Groups of rules which monitor the chat #rules: -# rulename: - the name of the rule -# regex: - the string regex that the rule will check for -# ignores: - If the message contains a value that matches ignore then none of the actions will be performed -# permission: - the permission required to bypass this rule -# actions: - here is the list of actions the rule will perform if matched -# deny: true - this will deny the message and cancel the event -# message: (message) -this will send a message (message) to the player -# kick: (message) - this will kick the player with the (message) -# alert: (message) - this will send a broadcast to the server {player} will be replaced with the players display name -# remove: true - this will remove any matches from the players message -# replace: - this will replace the matched word with a random word from the list below +# rulename: - the name of the rule. +# regex: - the string regex that the rule will check for. +# ignores: - If the message contains a value that matches ignore then none of the actions will be performed. +# permission: - the permission required to bypass this rule. +# actions: - here is the list of actions the rule will perform if matched. +# deny: true - this will deny the message and cancel the event. +# message: - this will send a message - this will kick the player with the . (Supports Placeholders, see below) +# alert: - this will send the to all players connected to the proxy server. (Supports Placeholders, see below) +# remove: true - this will remove any matches from the player's message. +# replace: - this will replace the matched word with a random word from the list below. (Supports Placeholders, see below) # - word1 # - word2 -# lower: - this will change any matches into lowercase -# pcommand: (command) - Proxy command, this will cause the player to send the (command) to the proxy server. Do not include a /. -# scommand: /(command) - Server command this will cause the player to send the (command) to their current server. You must include a /. -# ccommand: (command) - Console command, this will cause the proxy server console to execute the (command). Do not include a /. +# lower: true - this will change any matches into lowercase. +# pcommand: (command) - Proxy command, this will cause the player to send the (command) to the proxy server. Do not include a /. (Supports Placeholders, see below) +# scommand: /(command) - Server command this will cause the player to send the (command) to their current server. You must include a /. (Supports Placeholders, see below) +# ccommand: (command) - Console command, this will cause the proxy server console to execute the (command). Do not include a /. (Supports Placeholders, see below) # Note that there is currently no way to execute a command as the current server console. +#Placeholders - These placeholders can be used in any action strings. +# +# {player} - Replaced with the display name of the player sending the message +# {message} - Replaced with the original message as sent by the player +# {arguments} - Intended for use with commands, this will be replaced by all of the arguments following the first word of the player's message. +# (for example a player sending "/send Zedwick Hello!" will return "Zedwick Hello!" in place of {arguments}) rules: @@ -164,7 +170,10 @@ rules: regex: /broadcast permission: "!bungeefilter.broadcast" actions: - alert: '&5[Broadcast]&a{player}&f:{arguments}' + alert: + - '' + - '&5[Broadcast] &a{player}&f: {arguments}' + - '' deny: true #Shortcut for website URL can use either /url or /website From 5403c2efbedafb4343397556763c32c07d8a34d0 Mon Sep 17 00:00:00 2001 From: Zedadias Wick Date: Tue, 25 Apr 2017 02:21:37 +0100 Subject: [PATCH 19/32] Updated monitored commands in config updated README --- README | 56 +++++++++++++++++++++++------------ src/main/resources/config.yml | 4 +-- 2 files changed, 39 insertions(+), 21 deletions(-) diff --git a/README b/README index 8d70812..a0af973 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ ########################################## ## ## ## Bungee Chat Filter Config ## -## v1.2 ## +## v1.7 ## ########################################## #Monitor commands - Monitor commands send by the players as chat @@ -11,6 +11,7 @@ Monitor Commands: true Commands: - msg - message + - m - tell - whisper - w @@ -19,35 +20,49 @@ Commands: - s - l - local + - url + - website - hub + - shop + - broadcast #AntiSpam - Will use the minimum chat delay to force players to wait *1500ms or what ever you specified between messages AntiSpam: true +AntiRepeat: true #Minimum-Chat-Delay - The time in miliseconds a player must wait between messages Minimum-Chat-Delay: 1500 +Minimum-Repeat-Delay: 60000 +#Messages sent to the player in chat when they are blocked by AntiSpam or AntiRepeat +AntiSpamMessage: &cPlease do not spam +AntiRepeatMessage: &cPlease do not spam #Rules - Groups of rules which monitor the chat #rules: -# rulename: - the name of the rule -# regex: - the string regex that the rule will check for -# ignores: - If the message contains a value that matches ignore then none of the actions will be performed -# permission: - the permission required to bypass this rule -# actions: - here is the list of actions the rule will perform if matched -# deny: true - this will deny the message and cancel the event -# message: (message) -this will send a message (message) to the player -# kick: (message) - this will kick the player with the (message) -# alert: (message) - this will send a broadcast to the server {player} will be replaced with the players display name -# command: /(command) - this will cause the player to send the (command) -# remove: true - this will remove any matches from the players message -# replace: - this will replace the matched word with a random word from the list below +# rulename: - the name of the rule. +# regex: - the string regex that the rule will check for. +# ignores: - If the message contains a value that matches ignore then none of the actions will be performed. +# permission: - the permission required to bypass this rule. +# actions: - here is the list of actions the rule will perform if matched. +# deny: true - this will deny the message and cancel the event. +# message: - this will send a message - this will kick the player with the . (Supports Placeholders, see below) +# alert: - this will send the to all players connected to the proxy server. (Supports Placeholders, see below) +# remove: true - this will remove any matches from the player's message. +# replace: - this will replace the matched word with a random word from the list below. (Supports Placeholders, see below) # - word1 # - word2 -# lower: - this will change any matches into lowercase -# pcommand: /(command) - Proxy command, this will cause the player to send the (command) to the proxy server -# scommand: /(command) - Server command this will cause the player to send the (command) to their current server -# ccommand: /(command) - Console command, this will cause the proxy server console to execute the (command). +# lower: true - this will change any matches into lowercase. +# pcommand: (command) - Proxy command, this will cause the player to send the (command) to the proxy server. Do not include a /. (Supports Placeholders, see below) +# scommand: /(command) - Server command this will cause the player to send the (command) to their current server. You must include a /. (Supports Placeholders, see below) +# ccommand: (command) - Console command, this will cause the proxy server console to execute the (command). Do not include a /. (Supports Placeholders, see below) # Note that there is currently no way to execute a command as the current server console. +#Placeholders - These placeholders can be used in any action strings. +# +# {player} - Replaced with the display name of the player sending the message +# {message} - Replaced with the original message as sent by the player +# {arguments} - Intended for use with commands, this will be replaced by all of the arguments following the first word of the player's message. +# (for example a player sending "/send Zedwick Hello!" will return "Zedwick Hello!" in place of {arguments}) rules: @@ -155,7 +170,10 @@ rules: regex: /broadcast permission: "!bungeefilter.broadcast" actions: - alert: '&5[Broadcast]&a{player}&f:{arguments}' + alert: + - '' + - '&5[Broadcast] &a{player}&f: {arguments}' + - '' deny: true #Shortcut for website URL can use either /url or /website @@ -163,4 +181,4 @@ rules: regex: (/url)|(/website) actions: message: "&l&6[Check it out]&3 This server's website is &6www.minecraftserver.com" - deny: true \ No newline at end of file + deny: true diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 51ca4eb..188ef84 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -20,11 +20,11 @@ Commands: - s - l - local - - hub - url - website - - warp - hub + - shop + - broadcast #AntiSpam - Will use the minimum chat delay to force players to wait *1500ms or what ever you specified between messages AntiSpam: true From d421fa106cfa5734cfae7e15121b41752f4cebde Mon Sep 17 00:00:00 2001 From: Behoston Date: Sat, 29 Apr 2017 20:09:24 +0200 Subject: [PATCH 20/32] UTF-8 charset fix :P --- .../bungeechatfilter/configlibrary/FileConfiguration.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/minecraftdimensions/bungeechatfilter/configlibrary/FileConfiguration.java b/src/main/java/com/minecraftdimensions/bungeechatfilter/configlibrary/FileConfiguration.java index 73437a9..7942753 100644 --- a/src/main/java/com/minecraftdimensions/bungeechatfilter/configlibrary/FileConfiguration.java +++ b/src/main/java/com/minecraftdimensions/bungeechatfilter/configlibrary/FileConfiguration.java @@ -1,6 +1,7 @@ package com.minecraftdimensions.bungeechatfilter.configlibrary; import java.io.*; +import java.nio.charset.StandardCharsets; public abstract class FileConfiguration extends MemoryConfiguration { public FileConfiguration() { @@ -38,7 +39,7 @@ public void load( File file ) throws FileNotFoundException, IOException, Invalid public void load( InputStream stream ) throws IOException, InvalidConfigurationException { - InputStreamReader reader = new InputStreamReader( stream ); + InputStreamReader reader = new InputStreamReader( stream , StandardCharsets.UTF_8 ); StringBuilder builder = new StringBuilder(); BufferedReader input = new BufferedReader( reader ); From 2eabb262239215f7a0a63183a919ce4e5aa6ce1b Mon Sep 17 00:00:00 2001 From: Zedadias Wick Date: Tue, 13 Jun 2017 18:20:04 +0100 Subject: [PATCH 21/32] compile unicode regex patterns --- .../java/com/minecraftdimensions/bungeechatfilter/Rule.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java b/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java index b4951d1..4ea34e1 100644 --- a/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java +++ b/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java @@ -22,11 +22,11 @@ public class Rule { boolean needsPerm; public Rule( String regex, HashMap actions, String permission, String ignores ) { - this.regex = Pattern.compile( regex ); + this.regex = Pattern.compile( regex , Pattern.UNICODE_CHARACTER_CLASS); if ( ignores == null ) { ignore = null; } else{ - this.ignore = Pattern.compile( ignores ); + this.ignore = Pattern.compile( ignores , Pattern.UNICODE_CHARACTER_CLASS); } this.actions = actions; if(permission!=null && permission.startsWith( "!" )){ From 4afba323c71eea0183a54e9663b9582156e97ea7 Mon Sep 17 00:00:00 2001 From: Zedadias Wick Date: Tue, 13 Jun 2017 19:57:19 +0100 Subject: [PATCH 22/32] Avoid errors due to poorly formatted config (fails silently) Resolves #19 --- .../minecraftdimensions/bungeechatfilter/Rule.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java b/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java index 4ea34e1..1793c07 100644 --- a/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java +++ b/src/main/java/com/minecraftdimensions/bungeechatfilter/Rule.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.List; import java.util.Random; +import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; import net.md_5.bungee.api.chat.BaseComponent; @@ -88,11 +89,14 @@ public void performActions( ChatEvent event, ProxiedPlayer player ) { Matcher m = getMatcher( message ); StringBuilder sb = new StringBuilder(); int last = 0; - while ( m.find() ) { - int n = rand.nextInt( ((String[]) actions.get( action )).length ); - sb.append( message.substring( last, m.start() ) ); - sb.append( util.ParseVariables(((String[]) actions.get( action ))[n], event) ); - last = m.end(); + String[] replacements = (String[]) actions.get( action ); + if ( replacements.length > 0 ){ + while ( m.find() ) { + int n = rand.nextInt( replacements.length ); + sb.append( message.substring( last, m.start() ) ); + sb.append( util.ParseVariables(((String[]) actions.get( action ))[n], event) ); + last = m.end(); + } } sb.append( message.substring( last ) ); message = sb.toString(); From 129520c36de1b56937d1eff13194c946af573e59 Mon Sep 17 00:00:00 2001 From: Zedadias Wick Date: Tue, 13 Jun 2017 19:57:44 +0100 Subject: [PATCH 23/32] Update to Java 1.8 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index a7fb189..152a078 100644 --- a/pom.xml +++ b/pom.xml @@ -56,8 +56,8 @@ maven-compiler-plugin 3.1 - 1.7 - 1.7 + 1.8 + 1.8 true true From d7aa4e40ca83557e779cfdbd5fdd55cce85d69b7 Mon Sep 17 00:00:00 2001 From: Zedadias Wick Date: Tue, 13 Jun 2017 23:44:18 +0100 Subject: [PATCH 24/32] Add plugin description to plugin.yml --- src/main/resources/plugin.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 1c871c3..5a5a882 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -2,4 +2,5 @@ name: BungeeChatFilter main : com.minecraftdimensions.bungeechatfilter.Main version: ${project.version}b-${build.number} author: Bloodsplat, Zedwick -website: https://www.spigotmc.org/resources/bungeechatfilter.20596/ \ No newline at end of file +website: https://www.spigotmc.org/resources/bungeechatfilter.20596/ +description: Chat and command filter control for BungeeCord using regex From c3c118f2f8a35c078217ae3760c83858806d271c Mon Sep 17 00:00:00 2001 From: Zedadias Wick Date: Tue, 13 Jun 2017 23:45:00 +0100 Subject: [PATCH 25/32] Version 1.8 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 152a078..cc165dc 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ BungeeChatFilter BungeeChatFilter - 1.7 + 1.8 jar BungeeChatFilter From 93b436a43082dee70a9bdd9124d4e82fb2971d5d Mon Sep 17 00:00:00 2001 From: Zedadias Wick Date: Sun, 20 Aug 2017 18:09:38 +0100 Subject: [PATCH 26/32] Fixed rules.CommandShortcut.pcommand in default config; should not have a leading / --- src/main/resources/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 188ef84..db821a8 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -155,7 +155,7 @@ rules: CommandShortcut: regex: /hub actions: - pcommand: /server hub + pcommand: server hub deny: true #When a player uses the command /shop they will instead send a command to the server they are on /warp shop. From b48fc73a9e19580408170393e26a8f86d24a91d9 Mon Sep 17 00:00:00 2001 From: Zedadias Wick Date: Sun, 20 Aug 2017 18:12:37 +0100 Subject: [PATCH 27/32] Removed word from default swerfilter2 --- src/main/resources/config.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index db821a8..a14b19d 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -87,8 +87,7 @@ rules: - queer - bitch - bastard - - dick - - gay) + - dick) actions: replace: - lovely From d3e959f85c54f82aab0c7b1f708f31ffa3cc1970 Mon Sep 17 00:00:00 2001 From: prozhong Date: Fri, 1 Dec 2017 05:07:02 +0800 Subject: [PATCH 28/32] small fix to correct the AntiRepeatMessage message (#24) --- .../bungeechatfilter/PlayerChatListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java b/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java index 045896e..f58ca1b 100644 --- a/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java +++ b/src/main/java/com/minecraftdimensions/bungeechatfilter/PlayerChatListener.java @@ -30,7 +30,7 @@ public void playerChat( ChatEvent e ) { if(Main.NOREPEAT && !player.hasPermission( "bungeefilter.bypass.repeat" )){ if(repeatCheck(player.getName(), e.getMessage(),System.currentTimeMillis())){ e.setCancelled( true ); - player.sendMessage( new TextComponent( TextComponent.fromLegacyText(util.color( Main.c.getString("AntiSpamMessage", "&cPlease do not spam") ) ) ) ); + player.sendMessage( new TextComponent( TextComponent.fromLegacyText(util.color( Main.c.getString("AntiRepeatMessage", "&cPlease do not spam") ) ) ) ); return; }else{ Main.ANTIREPEAT.put( player.getName(), e.getMessage() ); From b08c6fbf7a7af056f4f8e1c02af74d308e3977d2 Mon Sep 17 00:00:00 2001 From: Zedadias Wick Date: Mon, 28 May 2018 18:35:14 +0100 Subject: [PATCH 29/32] Added initial jenkinsfile --- jenkinsfile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 jenkinsfile diff --git a/jenkinsfile b/jenkinsfile new file mode 100644 index 0000000..0482a7c --- /dev/null +++ b/jenkinsfile @@ -0,0 +1,15 @@ +pipeline { + agent { + docker { + image 'maven:3-alpine' + args '-v /root/.m2:/root/.m2' + } + } + stages { + stage('Build') { + steps { + sh 'mvn -B -DskipTests clean package' + } + } + } +} From dcc32ef49892f340b011a9d84ad4ee3c6cbb4c31 Mon Sep 17 00:00:00 2001 From: zedwick Date: Mon, 28 May 2018 18:49:13 +0100 Subject: [PATCH 30/32] Rename jenkinsfile to Jenkinsfile --- jenkinsfile => Jenkinsfile | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename jenkinsfile => Jenkinsfile (100%) diff --git a/jenkinsfile b/Jenkinsfile similarity index 100% rename from jenkinsfile rename to Jenkinsfile From 8738e5f4f25d788d9ba8160c96551319c8fa4828 Mon Sep 17 00:00:00 2001 From: Zedadias Wick Date: Mon, 28 May 2018 21:10:23 +0100 Subject: [PATCH 31/32] Jenkinsfile: archiveArtifacts after build --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0482a7c..5041c25 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,7 +8,8 @@ pipeline { stages { stage('Build') { steps { - sh 'mvn -B -DskipTests clean package' + sh 'mvn -B -DskipTests clean package' + archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true } } } From c61afefdd34c28d59136ce8efe4030a9acf7f5c4 Mon Sep 17 00:00:00 2001 From: zedwick Date: Tue, 31 Dec 2019 00:08:36 +0000 Subject: [PATCH 32/32] Create CODEOWNERS See https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners --- CODEOWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 CODEOWNERS diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..7a8c469 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +* @zedwick