essaxr

make a anti cheat plugin for my server so hackers cant joinn and if someone using freecam server will tell him you cant join with freecam same as donutsmp and when someone uses xray he will see fake ores alll around him so he cant see original ores and server will tell in chat that {username} started using xray and server will ban him for 24 hours and when someone try to use abusive language in the chat block the alll abusive words that exists in the world and when someone try to send it will be deleted automaticaly and server will say in chat watch you language

Kodari AI
KodariJul 5 at 7:50 am 1

I’ll create an anti-cheat plugin called AntiCheatGuard.

AntiCheatGuard
A comprehensive anti-cheat system with freecam detection on join, anti-xray that replaces real ores with fake ones for xray users, chat filter blocking all abusive language, and automatic 24-hour temp bans. Includes real-time detection, in-game announcements, violation tracking, and configurable punishment thresholds.

Let me plan the architecture before writing any code.

Files to create (in order):

  1. build.gradle — project build config

  2. src/main/resources/plugin.yml — plugin descriptor

  3. src/main/resources/config.yml — all configurable settings

  4. src/main/java/com/anticheatguard/AntiCheatGuard.java — main plugin

  5. src/main/java/com/anticheatguard/detectors/FreecamDetector.java — freecam detection

  6. src/main/java/com/anticheatguard/detectors/AntiXrayManager.java — xray detection + fake ores

  7. src/main/java/com/anticheatguard/detectors/ChatFilter.java — chat filtering

  8. src/main/java/com/anticheatguard/punishment/BanManager.java — temp ban system

  9. src/main/java/com/anticheatguard/utils/MessageUtil.java — message formatting



Here’s a summary of what was created:

Freecam Detector (FreecamDetector.java):

  • Checks client brand on join via Paper’s getClientBrandName() — kicks suspicious brands

  • Checks initial spawn position (freecam can spawn inside blocks)

  • Phase check: Detects when player’s head goes through solid blocks

  • Rotation check: Flags head rotation without body movement (freecam looking around while body stays)

  • Pitch check: Catches impossible pitch angles beyond normal limits

  • Violation level (VL) system with configurable thresholds and decay

Anti-Xray (AntiXrayManager.java):

  • Tracks every block a player mines with weighted ore scores (diamond=10, iron=2, etc.)

  • Calculates weighted ore-to-stone ratio over a configurable time window

  • When ratio exceeds threshold (default 0.15), triggers detection

  • Shows fake ores via sendBlockChange() — real ores appear as stone to the flagged player (radius 32 blocks, updating as they move)

  • Announces in chat: {username} started using xray!

  • Bans for 24 hours automatically

Chat Filter (ChatFilter.java):

  • Comprehensive word list with leetspeak regex patterns (@ for a, 3 for e, $ for s, etc.)

  • Whole-word boundary matching to prevent false positives in innocent words

  • Strips separators (dots, dashes, spaces) to catch k.i.l.l.y.o.u.r.s.e.l.f

  • Tracks warnings, punishes after configurable limit

  • Optionally checks commands too

Ban Manager (BanManager.java):

  • JSON file storage for bans (bans.json)

  • Auto-applies bans on player login (with expiry display)

  • Scheduled expiry cleanup

  • /anticheatguard unban <player> command

Commands: /anticheatguard reload, /anticheatguard unban <player>, /anticheatguard info [player]

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
10 1,289
src/main/java/com/anticheatguard/AntiCheatGuard.java
package com.anticheatguard;

import com.anticheatguard.detectors.AntiXrayManager;
import com.anticheatguard.detectors.ChatFilter;
import com.anticheatguard.detectors.FreecamDetector;
import com.anticheatguard.punishment.BanManager;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public class AntiCheatGuard extends JavaPlugin {

    private static AntiCheatGuard instance;
    private BanManager banManager;
    private FreecamDetector freecamDetector;
    private AntiXrayManager antiXrayManager;
    private ChatFilter chatFilter;

    @Override
    public void onEnable() {
        instance = this;
        saveDefaultConfig();
        reloadConfig();

        this.banManager = new BanManager(this);
        this.freecamDetector = new FreecamDetector(this);
        this.antiXrayManager = new AntiXrayManager(this);
        this.chatFilter = new ChatFilter(this);

        Bukkit.getPluginManager().registerEvents(freecamDetector, this);
        Bukkit.getPluginManager().registerEvents(antiXrayManager, this);
        Bukkit.getPluginManager().registerEvents(chatFilter, this);

        getCommand("anticheatguard").setExecutor(new AntiCheatCommand(this));

        banManager.loadBans();
        banManager.scheduleExpiryCheck();

        getLogger().info("AntiCheatGuard v" + getDescription().getVersion() + " enabled.");
    }

    @Override
    public void onDisable() {
        if (antiXrayManager != null) {
            antiXrayManager.cleanup();
        }
        if (banManager != null) {
            banManager.saveBans();
        }
        instance = null;
        getLogger().info("AntiCheatGuard disabled.");
    }

    public static AntiCheatGuard getInstance() {
        return instance;
    }

    public BanManager getBanManager() {
        return banManager;
    }

    public FreecamDetector getFreecamDetector() {
        return freecamDetector;
    }

    public AntiXrayManager getAntiXrayManager() {
        return antiXrayManager;
    }

    public ChatFilter getChatFilter() {
        return chatFilter;
    }
}