package net.mattias.cobblecensors;

import net.neoforged.fml.common.Mod;
import net.neoforged.fml.loading.FMLPaths;
import org.slf4j.Logger;

import com.mojang.logging.LogUtils;

import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.fml.config.ModConfig;
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.server.ServerStartingEvent;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

// The value here should match an entry in the META-INF/neoforge.mods.toml file
@Mod(CobbleCensors.MOD_ID)
public class CobbleCensors
{
    // Define mod id in a common place for everything to reference
    public static final String MOD_ID = "cobblecensors";
    // Directly reference a slf4j logger
    private static final Logger LOGGER = LogUtils.getLogger();

    public CobbleCensors(IEventBus modEventBus, ModContainer modContainer) {
        Path configDir = FMLPaths.CONFIGDIR.get();
        Path modConfigDir = configDir.resolve("cobblecensors");
        try {
            if (!Files.exists(modConfigDir)) {
                Files.createDirectories(modConfigDir);
            }
            Path bannedWordsFile = modConfigDir.resolve("banned_words.txt");
            if (!Files.exists(bannedWordsFile)) {
                Files.createFile(bannedWordsFile);
            }
            BannedWords.loadBannedWords(bannedWordsFile);
        } catch (IOException e) {
            LOGGER.error("Failed to load banned words", e);
        }

        new NameCensorHandler();

        modEventBus.addListener(this::commonSetup);

        NeoForge.EVENT_BUS.register(this);

        modContainer.registerConfig(ModConfig.Type.COMMON, Config.SPEC);
    }

    private void commonSetup(final FMLCommonSetupEvent event){

    }

    @SubscribeEvent
    public void onServerStarting(ServerStartingEvent event) {

    }

    @EventBusSubscriber(modid = MOD_ID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
    public static class ClientModEvents {
        @SubscribeEvent
        public static void onClientSetup(FMLClientSetupEvent event) {

        }
    }
}

package net.mattias.cobblecensors;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class BannedWords {
    private static List<String> bannedWords = new ArrayList<>();

    public static void loadBannedWords(Path filePath) {
        try {
            bannedWords = Files.lines(filePath)
                    .map(String::trim)
                    .filter(line -> !line.isEmpty())
                    .collect(Collectors.toList());
        } catch (IOException e) {
            bannedWords = new ArrayList<>();
        }
    }

    public static boolean containsBannedWord(String text) {
        if (text == null) return false;
        String lowerText = text.toLowerCase();
        return bannedWords.stream().anyMatch(word -> lowerText.contains(word.toLowerCase()));
    }
}

package net.mattias.cobblecensors;

import com.cobblemon.mod.common.api.Priority;
import com.cobblemon.mod.common.api.events.CobblemonEvents;
import com.cobblemon.mod.common.api.events.pokemon.PokemonNicknamedEvent;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import org.slf4j.Logger;
import com.mojang.logging.LogUtils;

public class NameCensorHandler {
    public static final String MOD_ID = "cobblecensors";
    private static final Logger LOGGER = LogUtils.getLogger();

    public NameCensorHandler() {
        CobblemonEvents.POKEMON_NICKNAMED.subscribe(Priority.NORMAL, new Function1<PokemonNicknamedEvent, Unit>() {
            @Override
            public Unit invoke(PokemonNicknamedEvent event) {
                onSetNickname(event);
                return Unit.INSTANCE;
            }
        });
    }

    private void onSetNickname(PokemonNicknamedEvent event) {
        MutableComponent nickname = event.getNickname();
        String newName = nickname != null ? nickname.getString() : "";
        String species = event.getPokemon().getSpecies().getName();
        LOGGER.info("Pokemon: '{}', Attempted nickname: '{}', length: {}", species, newName, newName.length());
        if (newName.matches("^#+$")) {
            LOGGER.info("Nickname is already censored: '{}', skipping", newName);
            return;
        }
        if (BannedWords.containsBannedWord(newName)) {
            String censored = new String(new char[newName.length()]).replace('\0', '#');
            LOGGER.info("Censoring to: '{}', length: {}", censored, censored.length());
            event.setNickname(Component.literal(censored));
        }
    }
}

Can we make it so it looks for the list in resources/assets/cobblecensors/banned_words and then I have the txt file named banned_words in there