ggpots

how does DonutSMP detect what mods you have like Freecam, Inventory Profiles Next? There's not really any way to get the list of mods when someone joins, can you create a plugin that detects fabric mods like DonutSMP does and kicks them when they try to join from a configured list of banned mods

Kodari AI
KodariApr 13 at 9:37 am 10,599 (v2)

I’ll create a mod detection plugin that can identify and kick players using banned client-side mods.

ModGuard
Advanced client-side mod detection system that identifies Fabric, Forge, and other mod loaders. Listens to plugin messaging channels during login to extract mod lists and kicks players using configured banned mods. Features include customizable ban lists, whitelist mode, regex pattern matching for mod names, configurable kick messages, staff notifications, and detailed logging. Supports detection of popular mods like Freecam, Inventory Profiles Next, and other client modifications.

I’ll create a plugin that detects client-side mods by intercepting plugin messaging channels that mod loaders use during login.

All files created! Here’s what ModGuard does:

How it works:

  • Registers multiple plugin messaging channels (minecraft:brand, minecraft:register, FML|HS, etc.)

  • Intercepts messages sent by Fabric/Forge mod loaders during player login

  • Parses brand strings to detect mod loaders (Fabric, Forge, Quilt, NeoForge)

  • Captures registered channels - many mods register custom channels exposing their presence

  • Checks detected mods against configurable ban list

  • Kicks players with banned mods after a configurable delay (40 ticks default)

Key features:

  • Blacklist/whitelist modes

  • Regex pattern matching support

  • Staff notifications with configurable permission

  • Detailed logging options

  • Bypass permission for trusted players

  • Debug mode to see all detected channels and brands

Detection methods:

  1. Brand detection - Mod loaders change the server brand string

  2. Channel registration - Mods register plugin channels (e.g., “fabric-freecam:main”)

  3. FML handshake - Forge sends mod lists during handshake

The config includes common banned mods like Freecam, Tweakeroo, Litematica, MiniHUD, and various hack clients that DonutSMP would block.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
9 744
src/main/java/com/modguard/ModGuard.java
package com.modguard;

import com.modguard.config.ConfigManager;
import com.modguard.detection.ModDetectionHandler;
import com.modguard.detection.ModDetectionListener;
import com.modguard.commands.ModGuardCommand;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.messaging.Messenger;

@Getter
public class ModGuard extends JavaPlugin {

    private ConfigManager configManager;
    private ModDetectionHandler detectionHandler;
    private ModDetectionListener detectionListener;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        this.configManager = new ConfigManager(this);
        this.detectionHandler = new ModDetectionHandler(this);
        this.detectionListener = new ModDetectionListener(this);

        registerPluginChannels();
        registerCommands();
        registerListeners();

        getLogger().info("ModGuard has been enabled!");
        getLogger().info("Monitoring for banned client modifications...");
    }

    @Override
    public void onDisable() {
        unregisterPluginChannels();
        getLogger().info("ModGuard has been disabled!");
    }

    private void registerPluginChannels() {
        Messenger messenger = getServer().getMessenger();
        
        messenger.registerIncomingPluginChannel(this, "minecraft:brand", detectionListener);
        messenger.registerIncomingPluginChannel(this, "minecraft:register", detectionListener);
        messenger.registerIncomingPluginChannel(this, "MC|Brand", detectionListener);
        messenger.registerIncomingPluginChannel(this, "REGISTER", detectionListener);
        messenger.registerIncomingPluginChannel(this, "FML|HS", detectionListener);
        messenger.registerIncomingPluginChannel(this, "fml:handshake", detectionListener);
        messenger.registerIncomingPluginChannel(this, "FML", detectionListener);
        messenger.registerIncomingPluginChannel(this, "fml:login", detectionListener);

        if (configManager.debug()) {
            getLogger().info("Registered plugin message channels for mod detection");
        }
    }

    private void unregisterPluginChannels() {
        Messenger messenger = getServer().getMessenger();
        messenger.unregisterIncomingPluginChannel(this);
    }

    private void registerCommands() {
        getCommand("modguard").setExecutor(new ModGuardCommand(this));
    }

    private void registerListeners() {
        getServer().getPluginManager().registerEvents(detectionListener, this);
    }

    public void reloadPlugin() {
        reloadConfig();
        configManager = new ConfigManager(this);
        detectionHandler = new ModDetectionHandler(this);
        getLogger().info("Configuration reloaded!");
    }
}