jimmy huff

Make a Protection for a certain area + Custom Villager Trading System

Kodari AI
KodariOct 8 at 9:28 pm 2
AreaProtectionTrading
A Bukkit plugin providing region-based protection with claimable areas and a custom villager trading system. Players can claim land using a selection tool, preventing others from building, breaking, or interacting within protected zones. The plugin features a configurable claim limit per player and automatic protection against explosions and fire spread. A custom villager trading GUI allows server administrators to create and manage personalized trades with custom prices, items, and quantities. The trading system uses the inventory GUI framework with clickable buttons for buying and selling items, supporting both currency-based and item-exchange transactions. Includes commands for claiming, unclaiming, and managing protected areas, along with a visual selection interface showing claimed boundaries.
  1. Build cuboid protection regions with selection, creation, deletion, and bypass permissions.

  2. Add configurable custom villager trade presets and an admin spawn command.

  3. Register the commands, listeners, defaults, and plugin metadata.

Created AreaGuardTrades, a Paper plugin with cuboid area protection and configurable custom villager traders.

  • Select corners with /protect pos1 and /protect pos2, then create a region with /protect create <name>. Use /protect list, /protect delete <name>, and /protect reload to manage regions.

  • Protected areas block block changes, interactions, buckets, player-caused damage, and hanging-item changes; explosions are prevented from breaking protected blocks. Players with areaguard.bypass can bypass restrictions.

  • Define trade presets in custom-trades.yml, then use /trader spawn <preset> to spawn an invulnerable villager with those trades. /trader list and /trader reload manage presets.

  • Added the plugin metadata, permissions, default configuration, and project build files.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
12 726
src/main/java/com/kodari/areaguardtrades/AreaProtectionPlugin.java
package com.kodari.areaguardtrades;

import com.kodari.areaguardtrades.command.ProtectCommand;
import com.kodari.areaguardtrades.command.TraderCommand;
import com.kodari.areaguardtrades.protection.ProtectionListener;
import com.kodari.areaguardtrades.protection.RegionManager;
import com.kodari.areaguardtrades.trader.TraderManager;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public final class AreaProtectionPlugin extends JavaPlugin {
    private RegionManager regionManager;
    private TraderManager traderManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        saveResource("custom-trades.yml", false);

        regionManager = new RegionManager(this);
        regionManager.reload();
        traderManager = new TraderManager(this);
        traderManager.reload();

        Bukkit.getPluginManager().registerEvents(new ProtectionListener(regionManager, traderManager), this);
        getCommand("protect").setExecutor(new ProtectCommand(this));
        getCommand("trader").setExecutor(new TraderCommand(this));
    }

    public RegionManager getRegionManager() {
        return regionManager;
    }

    public TraderManager getTraderManager() {
        return traderManager;
    }

    public void reloadPluginData() {
        reloadConfig();
        regionManager.reload();
        traderManager.reload();
    }
}