Leo Flanagan

make a plugin where you cant say the word 'nigger' nigga' or 'kys' in chat

Kodari AI
KodariNov 1 at 12:26 am 1
ChatFilterGuard
A Minecraft plugin that monitors all chat messages and blocks prohibited slurs and toxic phrases. It intercepts player chat events, scans for banned words including racial slurs and harmful abbreviations, and prevents the message from being sent. The plugin also sends a warning message to the offending player, logs the violation to console, and optionally notifies server admins. It supports configurable banned words list, case-insensitive matching, and can be extended with additional moderation features like mute or kick actions.
  • Create the Gradle project for a Paper plugin.

  • Filter the three specified words case-insensitively as standalone words in chat.

  • Cancel offending messages and privately notify the sender.

Created a Paper chat filter plugin that blocks those three words case-insensitively when they appear as standalone words. The message is canceled, and the sender receives a private notice.

Leo Flanagan

make it so if your message has this word in then it can send so for example 'he is a nigger' would be blocked

Kodari AI
KodariNov 1 at 3:36 pm 1
  • Change the filter to block the terms even when they appear inside a longer message, such as the example.

Updated the filter to block those terms anywhere in a message, including “he is a nigger” and terms embedded within longer text.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
3 60
src/main/java/com/kodari/chatwordfilter/ChatWordFilterPlugin.java
package com.kodari.chatwordfilter;

import java.util.regex.Pattern;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.plugin.java.JavaPlugin;

public final class ChatWordFilterPlugin extends JavaPlugin implements Listener {
    private static final Pattern BLOCKED_WORDS = Pattern.compile(
            "(?iu)(?:nigger|nigga|kys)"
    );

    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this);
    }

    @EventHandler
    public void onPlayerChat(AsyncPlayerChatEvent event) {
        if (!BLOCKED_WORDS.matcher(event.getMessage()).find()) {
            return;
        }

        event.setCancelled(true);
        Bukkit.getScheduler().runTask(this, () -> event.getPlayer().sendMessage(
                ChatColor.RED + "Your message contains a prohibited word and was not sent."
        ));
    }
}