Conner Speirs

Please finish coding my Minecraft Paper 26.2 plugin called CustomSMP. Use my uploaded starter project, keep it as one plugin, and add these features: Economy with balance, pay, starting balance configurable in config, shop GUI, sell command, auction house with buy now, no bidding, item-producing spawners, crates with keys, three special tools, teleportation commands, random teleport, leaderboard signs, protected spawn, crystal PvP practice arena, and a duel command with safe kits, no item loss, configurable with config files. Make it work for Paper 26.2, fix errors, and send me the compiled jar plus a zip."

Kodari AI
KodariOct 31 at 5:34 pm 1
CustomSMP
CustomSMP is a comprehensive Paper 26.2 plugin providing economy with configurable starting balance, pay and balance commands, a shop GUI with buy/sell functionality, an auction house with buy-now pricing, item-producing spawners, crate systems with keys, three special tools, teleportation commands including random teleport, leaderboard signs, protected spawn area, crystal PvP practice arena, and duel commands with safe kits. All features are configurable through YAML files with no item loss on death in duels.
  1. Create the Paper plugin foundation and configuration files.

  2. Implement economy, shop, selling, auctions, spawners, crates, and special tools.

  3. Add teleportation, protected spawn, leaderboard signs, and safe duel/practice flows.

  4. Register commands and listeners in one plugin entry point.

Created CustomSMP with economy, shop and selling, buy-now auctions, item-producing spawners, crate keys, three special tools, teleport commands, leaderboard signs, spawn protection, a crystal PvP practice arena, and safe duels with configurable kits. The settings are in config.yml, shop.yml, crates.yml, and kits.yml. Set your spawn with /setspawn; configure the arena and duel locations in config.yml.

To get the compiled jar, click Compile in the top bar (on phone: ⋮ → Compile Project), then click Compile in the window. When it succeeds, use Download on the build or Download CustomSMP.jar in chat. The Compile action provides the jar; it does not create a project ZIP.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
8 1,186
src/main/java/com/kodari/customsmp/CustomSMP.java
package com.kodari.customsmp;

import com.cryptomorin.xseries.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.block.data.Ageable;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockExplodeEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.NamespacedKey;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerBucketFillEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
import java.util.UUID;

public final class CustomSMP extends JavaPlugin implements Listener, CommandExecutor {
    private static final String PREFIX = "&8[&bCustomSMP&8] &r";
    private final Random random = new Random();
    private final Map<UUID, Double> balances = new HashMap<>();
    private final Map<UUID, UUID> teleportRequests = new HashMap<>();
    private final Map<UUID, UUID> duelInvites = new HashMap<>();
    private final Map<UUID, DuelSession> duels = new HashMap<>();
    private final Map<UUID, DuelSnapshot> pendingRestores = new HashMap<>();
    private final Map<String, String> spawners = new HashMap<>();
    private final Map<UUID, AuctionListing> auctions = new HashMap<>();
    private final NamespacedKey itemTypeKey = new NamespacedKey(this, "custom_type");
    private YamlConfiguration moneyData;
    private YamlConfiguration auctionData;
    private YamlConfiguration spawnerData;
    private YamlConfiguration homeData;
    private YamlConfiguration shopData;
    private YamlConfiguration crateData;
    private YamlConfiguration kitData;
    private BukkitTask spawnerTask;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        saveResource("shop.yml", false);
        saveResource("crates.yml", false);
        saveResource("kits.yml", false);
        moneyData = loadData("balances.yml");
        auctionData = loadData("auctions.yml");
        spawnerData = loadData("spawners.yml");
        homeData = loadData("homes.yml");
        shopData = YamlConfiguration.loadConfiguration(getDataFolder().toPath().resolve("shop.yml").toFile());
        crateData = YamlConfiguration.loadConfiguration(getDataFolder().toPath().resolve("crates.yml").toFile());
        kitData = YamlConfiguration.loadConfiguration(getDataFolder().toPath().resolve("kits.yml").toFile());
        loadBalances();
        loadAuctions();
        loadSpawners();
        for (String name : List.of("balance", "pay", "shop", "sell", "ah", "spawner", "crate", "tools", "tpa", "tpaccept", "spawn", "setspawn", "rtp", "sethome", "home", "arena", "duel")) {
            if (getCommand(name) != null) getCommand(name).setExecutor(this);
        }
        Bukkit.getPluginManager().registerEvents(this, this);
        long interval = Math.max(1, getConfig().getLong("spawners.interval-seconds", 300)) * 20L;
        spawnerTask = Bukkit.getScheduler().runTaskTimer(this, this::produceSpawnerItems, interval, interval);
        Bukkit.getScheduler().runTaskTimer(this, this::updateLeaderboardSigns, 100L, 200L);
    }

    @Override
    public void onDisable() {
        if (spawnerTask != null) spawnerTask.cancel();
        saveBalances();
        saveAuctions();
        saveSpawners();
        saveData("homes.yml", homeData);
    }

    private YamlConfiguration loadData(String fileName) {
        return YamlConfiguration.loadConfiguration(getDataFolder().toPath().resolve(fileName).toFile());
    }

    private void saveData(String fileName, YamlConfiguration data) {
        try {
            data.save(getDataFolder().toPath().resolve(fileName).toFile());
        } catch (Exception exception) {
            getLogger().severe("Could not save " + fileName + ": " + exception.getMessage());
        }
    }

    private void loadBalances() {
        ConfigurationSection section = moneyData.getConfigurationSection("balances");
        if (section == null) return;
        for (String id : section.getKeys(false)) {
            try {
                balances.put(UUID.fromString(id), section.getDouble(id));
            } catch (IllegalArgumentException ignored) {
            }
        }
    }

    private void saveBalances() {
        moneyData.set("balances", null);
        for (Map.Entry<UUID, Double> entry : balances.entrySet()) moneyData.set("balances." + entry.getKey(), entry.getValue());
        saveData("balances.yml", moneyData);
    }

    private double balance(UUID id) {
        return balances.computeIfAbsent(id, ignored -> getConfig().getDouble("starting-balance", 250.0));
    }

    private void deposit(UUID id, double amount) {
        balances.put(id, roundMoney(balance(id) + amount));
        saveBalances();
    }

    private boolean withdraw(UUID id, double amount) {
        if (amount <= 0 || balance(id) + 0.00001 < amount) return false;
        balances.put(id, roundMoney(balance(id) - amount));
        saveBalances();
        return true;
    }

    private double roundMoney(double amount) {
        return Math.round(amount * 100.0) / 100.0;
    }

    private void loadAuctions() {
        ConfigurationSection section = auctionData.getConfigurationSection("listings");
        if (section == null) return;
        for (String id : section.getKeys(false)) {
            try {
                UUID listingId = UUID.fromString(id);
                UUID seller = UUID.fromString(section.getString(id + ".seller", ""));
                ItemStack item = section.getItemStack(id + ".item");
                double price = section.getDouble(id + ".price");
                if (item != null && price > 0) auctions.put(listingId, new AuctionListing(listingId, seller, price, item));
            } catch (IllegalArgumentException ignored) {
            }
        }
    }

    private void saveAuctions() {
        auctionData.set("listings", null);
        for (AuctionListing listing : auctions.values()) {
            String path = "listings." + listing.id;
            auctionData.set(path + ".seller", listing.seller.toString());
            auctionData.set(path + ".price", listing.price);
            auctionData.set(path + ".item", listing.item);
        }
        saveData("auctions.yml", auctionData);
    }

    private void loadSpawners() {
        ConfigurationSection section = spawnerData.getConfigurationSection("spawners");
        if (section == null) return;
        for (String world : section.getKeys(false)) {
            ConfigurationSection worldSection = section.getConfigurationSection(world);
            if (worldSection == null) continue;