Skip to content

Need to add a white list of words #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d27f207
Bumped version to 1.6
zedwick Mar 24, 2016
5a25f24
reorder NOREPEAT after NOSPAM to avoid previously blocked for spam me…
zedwick Mar 24, 2016
d48cdf4
Fix for sendMessage deprecated
Mar 23, 2016
08bd84f
Ensure players' repeat message is wiped when disconnecting.
zedwick Mar 26, 2016
dadf005
Bump version number for release + add version number to build name.
zedwick Mar 26, 2016
31f490c
Add an acceptable delay for repeat messages
zedwick Mar 29, 2016
26b6d87
Fixes #3
zedwick Aug 31, 2016
9ddbd08
Bumped version to 1.6.2 for release.
zedwick Aug 31, 2016
e502447
Monitored commands now affects all rules, not just antispam/antirepeat.
zedwick Aug 31, 2016
b98690e
Add "Please do not spam" chat messages to config, sent when blocked b…
zedwick Aug 31, 2016
dbe62f5
Updated default config Commands with all custom commands from rules
zedwick Aug 31, 2016
3ab9825
Fix for misleading config concerning pcommand and ccommand.
zedwick Apr 6, 2017
6dea204
Allows configurable chat color for AntiRepeatMessage & AntiSpamMessag…
zedwick Apr 7, 2017
563c1ae
added message param to ccommand
leonfagan71 Apr 7, 2017
1413a37
Merge pull request #9 from leonfagan71/patch-1
zedwick Apr 7, 2017
40e0672
Version 1.6.7
zedwick Apr 7, 2017
f0b0802
Added support for Booleans in actions config
zedwick Apr 24, 2017
37c18e6
+ Variables are now supported across all (String-based) actions. (Res…
zedwick Apr 25, 2017
b5f03a6
Version 1.7
zedwick Apr 25, 2017
5403c2e
Updated monitored commands in config
zedwick Apr 25, 2017
d421fa1
UTF-8 charset fix :P
Behoston Apr 29, 2017
2eabb26
compile unicode regex patterns
zedwick Jun 13, 2017
4afba32
Avoid errors due to poorly formatted config (fails silently) Resolves…
zedwick Jun 13, 2017
129520c
Update to Java 1.8
zedwick Jun 13, 2017
d7aa4e4
Add plugin description to plugin.yml
zedwick Jun 13, 2017
c3c118f
Version 1.8
zedwick Jun 13, 2017
93b436a
Fixed rules.CommandShortcut.pcommand in default config; should not ha…
zedwick Aug 20, 2017
b48fc73
Removed word from default swerfilter2
zedwick Aug 20, 2017
d3e959f
small fix to correct the AntiRepeatMessage message (#24)
prozhong Nov 30, 2017
b08c6fb
Added initial jenkinsfile
zedwick May 28, 2018
f48ee45
Merge branch 'master' of https://github.com/zedwick/BungeeChatFilter
zedwick May 28, 2018
dcc32ef
Rename jenkinsfile to Jenkinsfile
zedwick May 28, 2018
8738e5f
Jenkinsfile: archiveArtifacts after build
zedwick May 28, 2018
c61afef
Create CODEOWNERS
zedwick Dec 31, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @zedwick
16 changes: 16 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
pipeline {
agent {
docker {
image 'maven:3-alpine'
args '-v /root/.m2:/root/.m2'
}
}
stages {
stage('Build') {
steps {
sh 'mvn -B -DskipTests clean package'
archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true
}
}
}
}
56 changes: 37 additions & 19 deletions README
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##########################################
## ##
## Bungee Chat Filter Config ##
## v1.2 ##
## v1.7 ##
##########################################

#Monitor commands - Monitor commands send by the players as chat
Expand All @@ -11,6 +11,7 @@ Monitor Commands: true
Commands:
- msg
- message
- m
- tell
- whisper
- w
Expand All @@ -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: <message> - this will send a message <message to the player. (Supports Placeholders, see below)
# kick: <message> - this will kick the player with the <message>. (Supports Placeholders, see below)
# alert: <message> - this will send the <message> 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:

Expand Down Expand Up @@ -155,12 +170,15 @@ 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
CreateCommand2:
regex: (/url)|(/website)
actions:
message: "&l&6[Check it out]&3 This server's website is &6www.minecraftserver.com"
deny: true
deny: true
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>BungeeChatFilter</groupId>
<artifactId>BungeeChatFilter</artifactId>
<version>1.5-SNAPSHOT</version>
<version>1.8</version>
<packaging>jar</packaging>

<name>BungeeChatFilter</name>
Expand Down Expand Up @@ -40,7 +40,7 @@
</dependency>
</dependencies>
<build>
<finalName>${project.name}</finalName>
<finalName>${project.name}-${project.version}</finalName>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
Expand All @@ -56,8 +56,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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" ));
}
}
18 changes: 12 additions & 6 deletions src/main/java/com/minecraftdimensions/bungeechatfilter/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> COMLIST;
public static ArrayList<Rule> RULES;
Expand Down Expand Up @@ -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();
}

Expand All @@ -89,13 +91,20 @@ public static void loadRules() {
}
String perm = c.getString( "rules." + node + ".permission" );
String ignore = c.getString( "rules." + node + ".ignores" );
HashMap<String, String[]> actions = new HashMap<>();
HashMap<String, Object> actions = new HashMap<>();
for ( String action : c.getSubNodes( "rules." + node + ".actions" ) ) {
Object obj = c.get( "rules." + node + ".actions." + action );
if ( action.equals( "replace" ) ) {
List<String> 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<String> stringList = new ArrayList();
stringList.add( c.getString("rules." + node + ".actions." + action ) );
actions.put( action, stringList );
} else {
actions.put( action, new String[] { c.getString( "rules." + node + ".actions." + action ) } );
actions.put( action, c.get( "rules." + node + ".actions." + action ) );
}
}
RULES.add( new Rule( regex, actions, perm, ignore ) );
Expand All @@ -104,7 +113,4 @@ public static void loadRules() {
}


public String color( String s ) {
return ChatColor.translateAlternateColorCodes( '&', s );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,34 @@ 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.NOREPEAT){
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" ) );
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() );
}

}
if ( Main.NOSPAM ) {
if ( spamCheck( player, e.getMessage(), System.currentTimeMillis()) ) {
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( TextComponent.fromLegacyText(util.color( Main.c.getString("AntiRepeatMessage", "&cPlease do not spam") ) ) ) );
return;
} else {
Main.ANTISPAM.put( player.getName(),System.currentTimeMillis());
}else{
Main.ANTIREPEAT.put( player.getName(), e.getMessage() );
}

}
Main.ANTISPAM.put( player.getName(),System.currentTimeMillis());
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() ) ) {
Expand All @@ -55,31 +56,31 @@ public void playerChat( ChatEvent e ) {

}

private boolean repeatCheck( String name, String message ) {
if(isChatCommand( message ) && !isMonitoredCommand( message )){
return false;
}
if ( Main.ANTIREPEAT.containsKey( name ) ) {
return Main.ANTIREPEAT.get( name ).equals( message );
}
return false;
}

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<Main.SPAMTIMER;
}
return false;
}

private boolean repeatCheck( String name, String message, long time ) {
if ( Main.ANTISPAM.containsKey( name) && Main.ANTIREPEAT.containsKey( name ) ) {
Long diff = time-Main.ANTISPAM.get( name );
if ( diff<Main.REPEATTIMER ) {
return Main.ANTIREPEAT.get( name ).equals( message );
} else {
return false;
}
}
return false;
}

@EventHandler
public void playerLogOut( PlayerDisconnectEvent e ) {
if(Main.ANTISPAM.containsKey( e.getPlayer().getName() )){
Main.ANTISPAM.remove( e.getPlayer().getName() );
Main.ANTIREPEAT.remove( e.getPlayer().getName() );
}
}

Expand Down
Loading