ayanshkro

Create a anti xray minecraft plugin

Kodari AI
KodariSep 21 at 10:24 am 2
AntiXrayPro
A comprehensive anti-xray plugin that obfuscates ores and valuable blocks from players who have not yet mined them. It intercepts chunk data sent to clients, replacing diamond, gold, iron, and other specified ores with stone or deepslate variants based on the world's Y-level. The plugin features per-world configuration, permission-based bypass for trusted players, and an engine mode that balances server performance with protection strength. It includes a built-in ore distribution system that maintains realistic block patterns to avoid detection, plus a cache system to minimize CPU usage during chunk generation. Administrators can customize which blocks are hidden, adjust the obfuscation radius, and monitor effectiveness through detailed statistics. The plugin integrates seamlessly with popular terrain generators and supports both Bukkit and Spigot server software.

Created a Paper 1.21.4 AntiXray plugin from scratch.

Features:

  • Hides configured underground ores with stone using per-player block changes.

  • Only hides ores that are not exposed to air or transparent blocks.

  • Processes chunks gradually with a configurable per-tick block budget.

  • Refreshes nearby blocks after mining, placing, and explosions.

  • Supports /antixray reload.

  • Adds antixray.admin and antixray.bypass permissions.

  • Configurable scan height, replacement block, hidden ores, and processing limits.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
9 551
src/main/java/com/kodari/antixray/AntiXrayPlugin.java
package com.kodari.antixray;

import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;

public final class AntiXrayPlugin extends JavaPlugin {
    private AntiXrayConfig settings;
    private AntiXrayProcessor processor;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        settings = AntiXrayConfig.load(this);
        processor = new AntiXrayProcessor(this, settings);

        getServer().getPluginManager().registerEvents(new AntiXrayListener(processor), this);
        getServer().getScheduler().runTaskTimer(this, processor::tick, 1L, 1L);

        PluginCommand command = getCommand("antixray");
        if (command != null) {
            AntiXrayCommand executor = new AntiXrayCommand(this);
            command.setExecutor(executor);
            command.setTabCompleter(executor);
        }
    }

    public void reloadAntiXray() {
        reloadConfig();
        settings = AntiXrayConfig.load(this);
        processor.setSettings(settings);
    }

    public AntiXrayConfig getSettings() {
        return settings;
    }
}