Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
49 changes: 48 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,49 @@
# ChatFilter
Chat Filter is a chat management plugin for reducing spam, swearing, advertisement of IPs and URLs. Stop repetition in chat and add as many swear words, IPs and URLs as you want to make sure your server chat is controlled! This plugin also filters books, signs, commands and anvils.
Chat Filter is a chat management plugin for reducing spam, swearing, advertisement of IPs and URLs. Stop repetition in chat and add as many swear words, IPs and URLs as you want to make sure your server chat is controlled! This plugin also filters books, signs, commands and anvils. More details below!

## Features
- **Regex filtering:** Utilizes the use of regex to prevent bypassing of the filter.
- **Multiple Filters:** Filter words, IPs and URLs covering chat, anvils, signs, commands and books.
- **Unicode support:** Prevents the use of certain Unicode common with hacked clients. (hacker font)
- **Anti Spam:** Stop repetitive or similar messages aswell as excessive CAPS and character spam. (Player names exempt)
- **Punishments:** Execute commands when a player is caught by the filter.
- **Commands:** In-game regex generator for words, whitelisting of words, pause and clear chat.
- **Notify staff:** Alerts and highlights swearing and advertising to players with the correct permission.
- **Customizability:** All messages are fully modifiable - Hex compatible.
- **Preset words:** Over 55+ preset English words.
- **No bloat features:** ChatFilter has been made to stay simple and basic.
- **Languages files:** ChatFilter currently supports English, Danish, Chinese (Thanks to Zhaomengran) and Spanish.

## Commands
- `/clearchat (/cf clear)` – Clears the chat.
- `/cf help` – Displays a list of the plugin’s commands.
- `/cf reload` – Reloads the plugin config.
- `/cf blacklist (ip/word) list/add/remove <args/word/IP>` – Blacklists a chosen word or IP. (Will not allow this word/IP to go throught the filter)
- `/cf whitelist (ip/word) list/add/remove <args/word/IP>` – Whitelists a chosen word or IP. (Will allow a string of characters/a word or IP to go through the filter)
- `/cf import` - Import plain text words
- `/cf pause` – Pause chat for players that do not have the bypass perm.

## Permissions
- `chatfilter.reload` – Allows players to use /cf reload
- `chatfilter.blacklist` – Allows players to use /cf blacklist
- `chatfilter.whitelist` – Allows players to use /cf whitelist
- `chatfilter.blacklist.remove` – Allows players to use /cf whitelist remove
- `chatfilter.whitelist.remove` – Allows players to use /cf whitelist remove
- `chatfilter.view` – Allows players to to view what gets caught in the filter
- `chatfilter.pause` – Allows players to pause the chat
- `chatfilter.bypass` – Allows the player to bypass all filters(Chat, Signs, Books, Anvils, Decaps, pause chat and repeat messages)
- `chatfilter.bypass.chat` – Allows the player to bypass in chat
- `chatfilter.bypass.sign` – Allows the player to bypass on a sign
- `chatfilter.bypass.anvil` – Allows the player to bypass in a anvil
- `chatfilter.bypass.book` – Allows the player to bypass in books
- `chatfilter.bypass.command` – Allows the player to bypass in commands
- `chatfilter.bypass.repeat` – Allows the player to bypass repeat messages
- `chatfilter.bypass.caps` –Allows the player to bypass chat decapping
- `chatfilter.bypass.pause` – Allows the player to bypass paused chat
- `chatfilter.bypass.swear` – Allows the player to bypass all swear filters (chat ,books, commands etc)
- chatfilter.bypass.swear.<config entry>` – Allows the player to bypass set config entries (chat ,books, commands etc)
Copy link

Copilot AI Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing opening backtick before 'chatfilter.bypass.swear.' - should be chatfilter.bypass.swear.<config entry> for consistency with other permission entries.

Suggested change
- chatfilter.bypass.swear.<config entry>` – Allows the player to bypass set config entries (chat ,books, commands etc)
- `chatfilter.bypass.swear.<config entry>` – Allows the player to bypass set config entries (chat ,books, commands etc)

Copilot uses AI. Check for mistakes.
- chatfilter.bypass.ip.<config entry>` – Allows the player to bypass set config entries (chat ,books, commands etc)
chatfilter.bypass.ip` – Allows the player to bypass all ip filters (chat ,books, commands etc)
Copy link

Copilot AI Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing opening backtick before 'chatfilter.bypass.ip.' - should be chatfilter.bypass.ip.<config entry> for consistency with other permission entries.

Suggested change
chatfilter.bypass.ip` – Allows the player to bypass all ip filters (chat ,books, commands etc)
- `chatfilter.bypass.swear.<config entry>` – Allows the player to bypass set config entries (chat ,books, commands etc)
- `chatfilter.bypass.ip.<config entry>` – Allows the player to bypass set config entries (chat ,books, commands etc)
- `chatfilter.bypass.ip` – Allows the player to bypass all ip filters (chat ,books, commands etc)

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing opening backtick and dash formatting before 'chatfilter.bypass.ip' - should be - chatfilter.bypass.ip` for consistency with other permission entries.

Suggested change
chatfilter.bypass.ip` – Allows the player to bypass all ip filters (chat ,books, commands etc)
- `chatfilter.bypass.ip` – Allows the player to bypass all ip filters (chat ,books, commands etc)

Copilot uses AI. Check for mistakes.

# DISCLAIMER
This fork implements Folia with minimal code changes.
42 changes: 31 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<modelVersion>4.0.0</modelVersion>

<groupId>a4.papers.chatfilter</groupId>
<artifactId>chatFilter</artifactId>
<version>1.1.8</version>
<artifactId>ChatFilter</artifactId>
<version>2.0.15</version>
<packaging>jar</packaging>

<name>ChatFilter</name>
Expand All @@ -21,7 +21,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.14.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
Expand All @@ -30,7 +30,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<version>3.6.0</version>
<executions>
<execution>
<phase>package</phase>
Expand All @@ -39,7 +39,17 @@
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<outputFile>C:\Users\A4pap\Desktop\Output\ChatFilter.jar</outputFile>
<artifactSet>
<includes>
<include>com.github.Anon8281:UniversalScheduler</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>com.github.Anon8281.universalScheduler</pattern>
<shadedPattern>a4.papers.chatfilter.universalScheduler</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
Expand All @@ -55,21 +65,31 @@

<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
<id>papermc</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.21.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.Anon8281</groupId>
<artifactId>UniversalScheduler</artifactId>
<version>0.1.7</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
53 changes: 50 additions & 3 deletions src/main/java/a4/papers/chatfilter/chatfilter/ChatFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@
import a4.papers.chatfilter.chatfilter.shared.lang.LangManager;
import a4.papers.chatfilter.chatfilter.shared.regexHandler.LoadFilters;
import a4.papers.chatfilter.chatfilter.shared.regexHandler.RegexpGenerator;

import com.github.Anon8281.universalScheduler.scheduling.schedulers.TaskScheduler;
import com.github.Anon8281.universalScheduler.UniversalScheduler;

import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
Expand All @@ -38,8 +43,13 @@
import java.util.concurrent.Callable;
import java.util.regex.Pattern;

@SuppressWarnings("deprecation")
public class ChatFilter extends JavaPlugin {

private static TaskScheduler scheduler;
private static ChatFilter instance;
private static final LegacyComponentSerializer LEGACY_SERIALIZER = LegacyComponentSerializer.legacyAmpersand();

public ConsoleCommandSender consoleSender = Bukkit.getConsoleSender();
public ChatFilter chatFilter;
public ChatFilters chatFilters;
Expand Down Expand Up @@ -132,6 +142,10 @@ public void onEnable() {
} catch (MalformedURLException e) {
e.printStackTrace();
}

scheduler = UniversalScheduler.getScheduler(this);
instance = this;

createCustomConfig();
loadVariables();
getCommand("chatfilter").setExecutor(new CommandMain(this));
Expand Down Expand Up @@ -236,9 +250,11 @@ public void loadVariables() {

public String colour(String s) {
if (manager.supported("hex")) {
return manager.colorStringHex(s);
return Manager.colorStringHex(s);
Copy link

Copilot AI Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method call Manager.colorStringHex(s) should be manager.colorStringHex(s) to maintain consistency with the instance variable usage pattern in this class.

Suggested change
return Manager.colorStringHex(s);
return manager.colorStringHex(s);

Copilot uses AI. Check for mistakes.
} else {
return ChatColor.translateAlternateColorCodes('&', s);
return LEGACY_SERIALIZER.serialize(
LEGACY_SERIALIZER.deserialize(s)
);
}
}

Expand Down Expand Up @@ -349,4 +365,35 @@ public void reloadConfigs() throws Exception {
wordConfig.load(wordConfigFile);
unicodeConfig.load(unicodeConfigFile);
}

public static Object runTask(Runnable runnable) {
if (scheduler != null) {
return scheduler.runTask(runnable);
} else {
Bukkit.getScheduler().runTask(instance, runnable);
return null;
}
}

public static Object runTaskLater(Runnable runnable, long delay) {
if (scheduler != null) {
return scheduler.runTaskLater(runnable, delay);
} else {
Bukkit.getScheduler().runTaskLater(instance, runnable, delay);
return null;
}
}

public static Object runTaskTimer(Runnable runnable, long delay, long period) {
if (scheduler != null) {
return scheduler.runTaskTimer(runnable, delay, period);
} else {
Bukkit.getScheduler().runTaskTimer(instance, runnable, delay, period);
return null;
}
}

public static TaskScheduler getScheduler() {
return scheduler;
}
}
3 changes: 0 additions & 3 deletions src/main/java/a4/papers/chatfilter/chatfilter/Manager.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;

import java.awt.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import a4.papers.chatfilter.chatfilter.ChatFilter;
import a4.papers.chatfilter.chatfilter.shared.lang.EnumStrings;
import a4.papers.chatfilter.chatfilter.shared.lang.LangManager;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import a4.papers.chatfilter.chatfilter.shared.Result;
import a4.papers.chatfilter.chatfilter.shared.Types;
import a4.papers.chatfilter.chatfilter.shared.lang.EnumStrings;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventException;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.plugin.EventExecutor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import a4.papers.chatfilter.chatfilter.shared.Result;
import a4.papers.chatfilter.chatfilter.shared.Types;
import a4.papers.chatfilter.chatfilter.shared.lang.EnumStrings;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
Expand All @@ -14,7 +13,6 @@
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.plugin.EventExecutor;

import java.util.List;

public class SignListener implements EventExecutor, Listener {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package a4.papers.chatfilter.chatfilter.shared;

import a4.papers.chatfilter.chatfilter.ChatFilter;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

import java.util.*;
Expand Down
7 changes: 4 additions & 3 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: ChatFilter
version: 2.0.14
name: ${project.name}
version: ${project.version}
main: a4.papers.chatfilter.chatfilter.ChatFilter
api-version: 1.13
api-version: 1.21
folia-supported: true
authors: [ A4_Papers ]
description: Basic Regex chat, book and anvil filter
commands:
Expand Down