notxdgg

xDRestrict – Premium Region Restriction Plugin

Create a premium, production-ready Minecraft plugin called xDRestrict for Paper & Folia 1.21.11 using Java 21 and Gradle.

The plugin allows server owners to restrict specific items and abilities inside WorldGuard regions while also providing configurable item cooldowns. It must be lightweight, highly optimized, thread-safe, fully configurable, and designed for large public servers.

---

Platform

Paper 1.21.11

Folia 1.21.11

Java 21

Gradle

Maven Publish Ready

---

Dependencies

Required

WorldGuard

WorldEdit

Optional

PlaceholderAPI

---

Core Features

Region-Based Restrictions

The plugin must automatically detect the player's current WorldGuard region and apply configured restrictions.

Every region can have completely different settings.

Supported features:

Disable Mace usage

Disable Wind Charge usage

Ender Pearl cooldown

Enchanted Golden Apple cooldown

Everything must be configurable.

---

Mace Restriction

When enabled:

Prevent all Mace attacks.

Prevent Mace smash attacks.

Prevent Mace damage.

Cancel attack before damage is dealt.

Send configurable ActionBar.

Optional chat message.

Optional title.

Play configurable sound.

Example:

> You cannot use a Mace in this region.

---

Wind Charge Restriction

When enabled:

Prevent throwing Wind Charges.

Cancel projectile launch.

Prevent Wind Charge abilities.

Send configurable ActionBar.

Optional message.

Optional title.

Play configurable sound.

Example:

> You cannot use Wind Charges in this region.

---

Ender Pearl Cooldown

Players may use Ender Pearls normally.

After a successful throw:

Apply cooldown.

Cooldown length configurable per region.

Prevent additional throws while active.

Show remaining cooldown in ActionBar/chat.

Play configurable sound.

---

Enchanted Golden Apple Cooldown

After consuming an Enchanted Golden Apple:

Apply configurable cooldown.

Prevent eating another until cooldown expires.

Show remaining cooldown.

Configurable messages.

Configurable sounds.

---

Region Support

Every WorldGuard region has its own settings.

Example:

Spawn

Mace disabled

Wind Charge disabled

Pearl cooldown 15 seconds

Enchanted Golden Apple cooldown 60 seconds

Arena

Mace enabled

Wind Charge enabled

Pearl cooldown 8 seconds

Enchanted Golden Apple cooldown 30 seconds

Warzone

No restrictions

---

Config.yml

settings: check-worldguard: true debug: false

messages: prefix: "&c&lxDRestrict &8»"

mace-blocked: "&cYou cannot use a Mace in this region." wind-charge-blocked: "&cYou cannot use Wind Charges in this region."

pearl-cooldown: "&cEnder Pearl cooldown: &e%time%s" gapple-cooldown: "&6Enchanted Golden Apple cooldown: &e%time%s"

actionbar: enabled: true

titles: enabled: false

sounds: blocked: BLOCK_NOTE_BLOCK_BASS cooldown: BLOCK_NOTE_BLOCK_PLING

regions:

spawn:

disable-mace: true

disable-wind-charge: true

ender-pearl: enabled: true cooldown: 15

enchanted-golden-apple: enabled: true cooldown: 60

arena:

disable-mace: false

disable-wind-charge: false

ender-pearl: enabled: true cooldown: 8

enchanted-golden-apple: enabled: true cooldown: 30

warzone:

disable-mace: false

disable-wind-charge: false

ender-pearl: enabled: false cooldown: 0

enchanted-golden-apple: enabled: false cooldown: 0

---

Commands

/xdrestrict reload /xdrestrict version /xdrestrict info

Aliases

/xdr /restrict

---

Permissions

xdrestrict.admin xdrestrict.reload xdrestrict.bypass

Players with xdrestrict.bypass ignore all restrictions and cooldowns.

---

PlaceholderAPI

%xdrestrict_region% %xdrestrict_pearl% %xdrestrict_gapple% %xdrestrict_mace% %xdrestrict_windcharge%

---

Public API

boolean canUseMace(Player player);

boolean canUseWindCharge(Player player);

boolean isPearlOnCooldown(Player player);

int getPearlCooldown(Player player);

boolean isGappleOnCooldown(Player player);

String getCurrentRegion(Player player);

---

Performance

Full Folia compatibility

Thread-safe scheduler

Java 21

Efficient WorldGuard region lookups

Region caching

Cooldown caching

Minimal memory usage

No TPS impact

Supports 500+ concurrent players

---

Project Structure

dev.xd.restrict │ ├── api ├── commands ├── config ├── cooldown ├── listeners ├── managers ├── placeholder ├── region ├── utils ├── hooks └── xDRestrict.java

---

Future Expansion

Design the plugin with a modular restriction system so new restrictions can be added by simply adding new config entries and listeners.

---

Quality Requirements

Clean, modular, object-oriented code

Proper error handling and logging

Hot /xdrestrict reload without restart

Config validation with automatic defaults

100% configurable messages, sounds, titles, and cooldowns

Fully documented code with Javadocs

Optimized for public PvP, Lifesteal, Practice, KitPvP, Factions, and Survival servers

Production-ready, premium-quality implementation with no memory leaks or unnecessary synchronous operations.

Kodari AI
KodariAug 2 at 8:28 pm 2
XDRestrict
xDRestrict is a high-performance Paper and Folia region restriction plugin for Minecraft 1.21.11. It integrates with WorldGuard to configure independent restrictions per region, including Mace attacks, Wind Charges, Ender Pearls, and Enchanted Golden Apples. It provides thread-safe cooldown tracking, configurable ActionBar, chat, title, and sound feedback, bypass permissions, PlaceholderAPI support, hot configuration reloads, public API access, and Maven publishing support.
  1. Create the Gradle project and plugin metadata.

  2. Implement configuration, region detection, cooldowns, notifications, and the public API.

  3. Add restriction listeners, commands, cleanup handling, and PlaceholderAPI integration.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
19 1,693
src/main/java/dev/xd/restrict/xDRestrict.java
package dev.xd.restrict;

import dev.xd.restrict.api.RestrictionAPI;
import dev.xd.restrict.commands.RestrictCommand;
import dev.xd.restrict.config.ConfigManager;
import dev.xd.restrict.cooldown.CooldownManager;
import dev.xd.restrict.listeners.CooldownListener;
import dev.xd.restrict.listeners.MaceRestrictionListener;
import dev.xd.restrict.listeners.PlayerCleanupListener;
import dev.xd.restrict.listeners.WindChargeRestrictionListener;
import dev.xd.restrict.managers.RestrictionManager;
import dev.xd.restrict.placeholder.XDPlaceholderExpansion;
import dev.xd.restrict.region.RegionManager;
import dev.xd.restrict.utils.NotificationManager;
import org.bukkit.Bukkit;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;

/**
 * Main xDRestrict plugin class.
 */
public final class xDRestrict extends JavaPlugin implements RestrictionAPI {

    private ConfigManager configManager;
    private RegionManager regionManager;
    private CooldownManager cooldownManager;
    private RestrictionManager restrictionManager;
    private NotificationManager notificationManager;

    /**
     * Enables the plugin and registers all services and listeners.
     */
    @Override
    public void onEnable() {
        configManager = new ConfigManager(this);
        configManager.load();

        regionManager = new RegionManager(this, configManager);
        cooldownManager = new CooldownManager();
        restrictionManager = new RestrictionManager(
                configManager,
                regionManager,
                cooldownManager
        );
        notificationManager = new NotificationManager(configManager);

        Bukkit.getPluginManager().registerEvents(
                new MaceRestrictionListener(restrictionManager, notificationManager),
                this
        );
        Bukkit.getPluginManager().registerEvents(
                new WindChargeRestrictionListener(restrictionManager, notificationManager),
                this
        );
        Bukkit.getPluginManager().registerEvents(
                new CooldownListener(restrictionManager, notificationManager),
                this
        );
        Bukkit.getPluginManager().registerEvents(
                new PlayerCleanupListener(regionManager, cooldownManager),
                this
        );

        PluginCommand command = getCommand("xdrestrict");
        if (command != null) {
            RestrictCommand restrictCommand = new RestrictCommand(this);
            command.setExecutor(restrictCommand);
            command.setTabCompleter(restrictCommand);
        }

        if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
            new XDPlaceholderExpansion(this).register();
            getLogger().info("PlaceholderAPI expansion registered.");
        }

        getLogger().info("xDRestrict enabled for Paper/Folia.");
    }

    /**
     * Disables the plugin and releases per-player state.
     */
    @Override
    public void onDisable() {
        if (cooldownManager != null) {
            cooldownManager.clear();
        }
        if (regionManager != null) {
            regionManager.clearCache();
        }
    }

    /**
     * Gets the configuration manager.
     *
     * @return configuration manager
     */
    public ConfigManager getConfigManager() {
        return configManager;
    }

    /**
     * Gets the region manager.
     *
     * @return region manager
     */
    public RegionManager getRegionManager() {
        return regionManager;
    }

    /**
     * Gets the cooldown manager.
     *
     * @return cooldown manager
     */
    public CooldownManager getCooldownManager() {
        return cooldownManager;
    }

    /**
     * Gets the restriction manager.
     *
     * @return restriction manager
     */
    public RestrictionManager getRestrictionManager() {
        return restrictionManager;
    }

    /**
     * Gets the public API.
     *
     * @return this plugin API
     */
    public RestrictionAPI getApi() {
        return this;
    }

    /**
     * Checks whether a player may use a Mace.
     *
     * @param player player to check
     * @return true when allowed
     */
    @Override
    public boolean canUseMace(org.bukkit.entity.Player player) {
        return restrictionManager.canUseMace(player);
    }

    /**
     * Checks whether a player may use a Wind Charge.
     *
     * @param player player to check
     * @return true when allowed
     */
    @Override
    public boolean canUseWindCharge(org.bukkit.entity.Player player) {
        return restrictionManager.canUseWindCharge(player);
    }

    /**
     * Checks whether an Ender Pearl cooldown is active.
     *
     * @param player player to check
     * @return true when active
     */
    @Override
    public boolean isPearlOnCooldown(org.bukkit.entity.Player player) {
        return restrictionManager.isPearlOnCooldown(player);
    }

    /**
     * Gets the remaining Ender Pearl cooldown.
     *
     * @param player player to check
     * @return remaining seconds
     */
    @Override
    public int getPearlCooldown(org.bukkit.entity.Player player) {
        return restrictionManager.getPearlCooldown(player);
    }

    /**
     * Checks whether an Enchanted Golden Apple cooldown is active.
     *
     * @param player player to check
     * @return true when active
     */
    @Override
    public boolean isGappleOnCooldown(org.bukkit.entity.Player player) {
        return restrictionManager.isGappleOnCooldown(player);
    }

    /**
     * Gets the remaining Enchanted Golden Apple cooldown.
     *
     * @param player player to check
     * @return remaining seconds
     */
    public int getGappleCooldown(org.bukkit.entity.Player player) {
        return restrictionManager.getGappleCooldown(player);
    }