Nehemiah
📎 1 file 2,333 chars
📄
pasted-code-1794414374328.txt
txt 99 lines
▶
The project will use a built-in coin economy, so Vault and EssentialsX are not required. Player balances will persist across restarts in a YAML data file.

One compatibility detail: Paper 26.3 uses the newer `26.3.build...` API version format and requires Java 25. 

[image](https://www.google.com/s2/favicons?domain=https://docs.papermc.io\&sz=32)

PaperMC Docs+1



Source project created

## Download the plugin source

PvPEssentialsShop-source.zip

Complete Java + Gradle source project · 7 KB

Download PvP Essentials Shop

## Included features

| Feature                    | Status   |
| -------------------------- | -------- |
| Premium chest GUI          | Included |
| Internal coin economy      | Included |
| Persistent player balances | Included |
| Configurable item prices   | Included |
| Armor and defensive gear   | Included |
| Food and utility supplies  | Included |
| `/shop`                    | Included |
| `/balance`                 | Included |
| `/sell`                    | Included |
| `/shop reload`             | Included |

## Build instructions (Windows)

1\. Install Java 25

Check your Java version:

```
java -version
```

2\. Extract the ZIP

Extract `PvPEssentialsShop-source.zip`.

3\. Open PowerShell inside the extracted folder.

Run:

```
gradle build
```

4\. Find your compiled plugin

```
build/
  libs/
    PvPEssentialsShop-1.0.0.jar
```

5\. Install

1. Stop your Paper/Purpur server.
2. Put the JAR in your server's `plugins` folder.
3. Start the server.
4. Type `/shop`.

Build not yet verified

I verified the project files and YAML configuration, but couldn't run Gradle in this environment because Gradle isn't installed. The JAR will be generated when you build it locally.

## Next improvement

I can help develop a second version with animated menus, daily rewards, custom shop categories and an admin price editor.

Would you like monthly checks for Minecraft 26.3 API compatibility too?

⛏️Check Minecraft API updates monthlyTap to set up

Task successfully created

Your Minecraft API updates check is scheduled monthly.

⛏️Check Minecraft API updatesMonthly · ⁨5⁩th

Run now

It will monitor:

- Minecraft Java 26.3 updates.
- Paper/Purpur API changes.
- Java version requirements.
- Plugin compatibility and deprecated features.
- Changes affecting PvPEssentialsShop.
Kodari AI
KodariNov 11 at 4:27 pm 4
PvPEssentialsShop
A premium PvP server shop plugin with a built-in coin economy, eliminating the need for Vault or EssentialsX. Features a polished chest GUI for browsing and purchasing armor, weapons, food, and utility items with configurable prices. Players can check balances via /balance, sell items for coins through /sell, and admins can reload prices with /shop reload. Player balances persist across restarts in a YAML data file, ensuring a seamless and self-contained economy system for PvP-focused gameplay.

Created PvP Essentials Shop with a configurable chest GUI, persistent coin balances, and /shop, /balance, /sell, and /coins commands.

/sell all sells the held stack. Admins can use /coins set|give|take and /shop reload. The project targets the Paper 1.21.4 API; Paper 26.3 compatibility has not been verified.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
5 352
src/main/java/com/kodari/pvpshop/PvPShop.java
package com.kodari.pvpshop;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
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.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.UUID;

public final class PvPShop extends JavaPlugin implements Listener {
    private File dataFile;
    private YamlConfiguration balances;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        dataFile = new File(getDataFolder(), "balances.yml");
        balances = YamlConfiguration.loadConfiguration(dataFile);
        getServer().getPluginManager().registerEvents(this, this);
    }

    private long balance(UUID id) {
        String key = id.toString();
        if (!balances.contains(key)) {
            balances.set(key, Math.max(0, getConfig().getLong("starting-balance", 500)));
            saveBalances();
        }
        return balances.getLong(key);
    }

    private void setBalance(UUID id, long amount) {
        balances.set(id.toString(), amount);
        saveBalances();
    }

    private void saveBalances() {
        try {
            balances.save(dataFile);
        } catch (IOException ex) {
            getLogger().severe("Could not save balances: " + ex.getMessage());
        }
    }

    private String color(String text) {
        return ChatColor.translateAlternateColorCodes('&', text);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (command.getName().equalsIgnoreCase("coins")) {
            return coins(sender, args);
        }
        if (command.getName().equalsIgnoreCase("shop") && args.length == 1 && args[0].equalsIgnoreCase("reload")) {
            if (!sender.hasPermission("pvpshop.admin")) {
                sender.sendMessage(color("&cYou don't have permission."));
                return true;
            }
            reloadConfig();
            sender.sendMessage(color("&aShop configuration reloaded."));
            return true;
        }
        if (!(sender instanceof Player)) {
            sender.sendMessage("Only players can use this command.");
            return true;
        }
        Player player = (Player) sender;
        if (command.getName().equalsIgnoreCase("balance")) {
            player.sendMessage(color("&6Balance: &e" + balance(player.getUniqueId()) + " coins"));
            return true;
        }
        if (command.getName().equalsIgnoreCase("sell")) {
            if (args.length > 1 || (args.length == 1 && !args[0].equalsIgnoreCase("all"))) return false;
            sell(player, args.length == 1);
            return true;
        }
        if (args.length != 0) return false;
        openShop(player);
        return true;
    }

    private boolean coins(CommandSender sender, String[] args) {
        if (!sender.hasPermission("pvpshop.admin")) {
            sender.sendMessage(color("&cYou don't have permission."));
            return true;
        }
        if (args.length != 3) return false;
        String operation = args[0].toLowerCase(java.util.Locale.ROOT);
        if (!operation.equals("set") && !operation.equals("give") && !operation.equals("take")) return false;
        long amount;
        try {
            amount = Long.parseLong(args[2]);
            if (amount < 0) throw new NumberFormatException();
        } catch (NumberFormatException ex) {
            sender.sendMessage(color("&cEnter a non-negative whole number."));
            return true;
        }
        @SuppressWarnings("deprecation")
        OfflinePlayer target = Bukkit.getOfflinePlayer(args[1]);
        if (!target.hasPlayedBefore() && !target.isOnline()) {
            sender.sendMessage(color("&cThat player has never joined this server."));
            return true;
        }
        long current = balance(target.getUniqueId());
        long updated;
        if (operation.equals("set")) updated = amount;
        else if (operation.equals("take")) updated = amount >= current ? 0 : current - amount;
        else {
            if (amount > Long.MAX_VALUE - current) {
                sender.sendMessage(color("&cBalance would be too large."));
                return true;
            }
            updated = current + amount;
        }
        setBalance(target.getUniqueId(), updated);
        sender.sendMessage(color("&a" + target.getName() + " now has " + updated + " coins."));
        return true;
    }

    private static final class ShopHolder implements InventoryHolder {
        private Inventory inventory;
        @Override public Inventory getInventory() { return inventory; }
    }

    private void openShop(Player player) {
        ShopHolder holder = new ShopHolder();
        holder.inventory = Bukkit.createInventory(holder, 27, color(getConfig().getString("shop-title", "&8PvP Shop")));
        ConfigurationSection items = getConfig().getConfigurationSection("items");
        if (items != null) {
            for (String key : items.getKeys(false)) {
                ConfigurationSection item = items.getConfigurationSection(key);
                if (item == null) continue;
                Material material = Material.matchMaterial(item.getString("material", ""));
                int slot = item.getInt("slot", -1);
                int amount = item.getInt("amount", 1);
                long price = item.getLong("buy", -1);
                if (material == null || !material.isItem() || slot < 0 || slot >= 27 || amount < 1 || amount > material.getMaxStackSize() || price < 0) continue;
                ItemStack icon = new ItemStack(material, amount);
                ItemMeta meta = icon.getItemMeta();
                meta.setDisplayName(color("&b" + key.replace('-', ' ')));
                meta.setLore(Arrays.asList(color("&7Amount: &f" + amount), color("&7Price: &6" + price + " coins"), color("&eClick to purchase")));
                icon.setItemMeta(meta);
                holder.inventory.setItem(slot, icon);
            }
        }
        player.openInventory(holder.inventory);
    }

    @EventHandler
    public void onClick(InventoryClickEvent event) {
        if (!(event.getView().getTopInventory().getHolder() instanceof ShopHolder)) return;
        event.setCancelled(true);
        if (!(event.getWhoClicked() instanceof Player) || event.getRawSlot() < 0 || event.getRawSlot() >= event.getView().getTopInventory().getSize()) return;
        ConfigurationSection items = getConfig().getConfigurationSection("items");
        if (items == null) return;
        for (String key : items.getKeys(false)) {
            ConfigurationSection item = items.getConfigurationSection(key);
            if (item == null || item.getInt("slot", -1) != event.getRawSlot()) continue;
            Material material = Material.matchMaterial(item.getString("material", ""));
            int amount = item.getInt("amount", 1);
            long price = item.getLong("buy", -1);
            if (material == null || !material.isItem() || amount < 1 || amount > material.getMaxStackSize() || price < 0) return;
            Player player = (Player) event.getWhoClicked();
            long current = balance(player.getUniqueId());
            if (current < price) {
                player.sendMessage(color("&cYou don't have enough coins."));
                return;
            }
            ItemStack purchase = new ItemStack(material, amount);
            if (player.getInventory().firstEmpty() == -1) {
                player.sendMessage(color("&cYou need an empty inventory slot."));
                return;
            }
            setBalance(player.getUniqueId(), current - price);
            player.getInventory().addItem(purchase);
            player.sendMessage(color("&aPurchased " + amount + " " + key.replace('-', ' ') + " for " + price + " coins."));
            return;
        }
    }

    @EventHandler
    public void onDrag(InventoryDragEvent event) {
        if (event.getView().getTopInventory().getHolder() instanceof ShopHolder) event.setCancelled(true);
    }