Spear FFA

make 7unoxshop

Kodari AI
KodariOct 29 at 12:40 am 1
UnoxShop
A Minecraft Bukkit/Spigot plugin that enables players to create, manage, and operate their own shops. Players can set up shop locations, define items for sale, set prices in various currencies, and manage inventory. The plugin provides a comprehensive shop management system with features including shop creation, item listing, price configuration, purchase/sale transactions, and shop administration. It includes a user-friendly interface for browsing available shops, viewing item listings, and completing transactions. Shop owners can track sales history, manage stock levels, and customize shop displays. The system supports multiple shop types, including item shops, service shops, and bulk trading. It integrates with common economy plugins for currency support and includes configurable permissions for shop creation limits, transaction fees, and tax rates. The plugin offers both GUI-based and command-based interactions for seamless player experience.
  1. Create the Gradle project and plugin metadata for 7unoxshop.

  2. Add a configurable shop GUI with Vault-based buying and selling.

  3. Implement command, inventory handling, and default shop configuration.

Created 7unoxShop with a configurable shop GUI, Vault economy support, and /7unoxshop (/shop) commands. Players can buy with left-click, buy a stack with shift-left, sell one item with right-click, and sell all matching items with shift-right. Shop items, prices, names, and GUI settings are in config.yml; admins can reload with /7unoxshop reload.

Build the requested Minecraft shop plugin in this project. Inspect the starter project files and adapt to its existing Minecraft/API/build setup; implement production plugin code only (do not add tests). User confirmed this is a new plugin project and wants the downloadable plugin artifact/JAR named 7unoxshop if the build system permits it.

Required behavior:

  • /shop opens a polished inventory GUI listing items that admins configured. Players click an item to buy it.
  • Include a clearly visible Sell button in the /shop GUI. Clicking it switches to the sell interface/mode. Add /sell as a command that directly opens the same sell interface. In sell mode, clicking a catalog item sells one matching item (prefer a full stack when the player has one), removes sold items from the player's inventory, and credits the configured sell price per item. Prevent selling items that are not in the catalog.
  • /shopconfig is admin-only and opens an editable inventory GUI where admins can place item stacks to add/update shop entries and remove entries. Save changes persistently when the editor closes (and safely on shutdown); do not lose products on restart. Give admins concise in-game instructions for the price lore format. Ensure GUI interaction cannot let normal players take catalog items or use the config editor.
  • Prices must be configured in the item lore as requested. Use/document a clear, case-insensitive line format, e.g. Buy: 100 and Sell: 50 (optionally accept $ prefixes). Parse decimal prices safely; missing/invalid/nonpositive prices disable that action, and items with no usable price should not be purchasable/sellable. Preserve the item lore and item meta in the shop. Make price displays clear in GUI.
  • Use Vault economy integration for charging/refunding/crediting if this starter supports Bukkit/Paper plugins. If Vault is unavailable, fail safely with a clear player/admin message rather than silently granting items or deleting inventory. Declare/build against the needed API using the project's normal dependency mechanism; do not bundle Vault itself. Handle insufficient funds and inventory full without loss/charge; transactional behavior is required for purchases and sales.
  • Use permission checks for admin config, sensible player-facing feedback, and register commands/permissions/plugin metadata as needed. Prevent exploits from moving GUI items, shift-clicking, number-key/hotbar swaps, or manipulating editor items in a way that bypasses save logic.
  • Set the artifact output/final JAR base name to exactly 7unoxshop (without requiring a leading plugin-name restriction workaround), while keeping a valid internal plugin name if needed. Preserve the existing project conventions and do not ask the user more questions.

Done means both commands, saved GUI item configuration with lore-based prices, buy/sell flows, economy handling, plugin metadata, and the requested artifact naming are implemented.

Kodari AI
KodariOct 29 at 12:43 am 2
  1. Inspect the existing project and shop implementation.

  2. Complete the saved editor, secure GUI interactions, and transactional Vault buy/sell flows.

  3. Verify metadata, command registration, and the 7unoxshop artifact name.

Implemented the shop plugin with /shop, /sell, and the admin-only /shopconfig editor. Catalog items and metadata persist when the editor closes or the server shuts down; prices are read from case-insensitive lore lines such as Buy: 100 and Sell: $50.

Shop GUIs block item movement, purchases check funds and inventory capacity, and sales match the configured item metadata. Transactions fail safely when Vault economy is unavailable. The output JAR is named 7unoxshop.jar.

Spear FFA

it looks terrible, make the sell like nothing in it and remove everything in the current shop let me add items for sell also just make everything sell for 10 dollars no matter what it is.

Kodari AI
KodariOct 29 at 12:48 am 1
  1. Clear the default catalog and remove the sell menu’s filler panes.

  2. Make every configured sell item pay a fixed $10 per item, regardless of lore.

  3. Update editor instructions so you can add products and know the fixed sell rate.

Cleared the default catalog, so /shop and /sell start empty apart from their menu button. Add sellable items with /shopconfig; each configured item now sells for $10 per item, regardless of its lore. Buy prices still use Buy: 100 lore lines.

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

import com.cryptomorin.xseries.XMaterial;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
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.PlayerInventory;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public final class SevenUnoxShop extends JavaPlugin implements Listener, CommandExecutor, TabCompleter {
    private static final Pattern PRICE_LINE = Pattern.compile("(?i)^\\s*(buy|sell)\\s*:\\s*\\$?\\s*([0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)\\s*$");
    private static final String ADMIN_PERMISSION = "7unoxshop.admin";
    private static final double SELL_PRICE_PER_ITEM = 10.0;

    private final Map<Integer, ShopEntry> shopEntries = new LinkedHashMap<>();
    private Economy economy;
    private EditorHolder activeEditor;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        economy = setupEconomy();
        if (economy == null) {
            getLogger().warning("Vault or a Vault economy provider was not found. Shop transactions will be disabled until one is available.");
        }

        loadShopEntries();
        Bukkit.getPluginManager().registerEvents(this, this);
        for (String commandName : List.of("shop", "sell", "shopconfig")) {
            if (getCommand(commandName) != null) {
                getCommand(commandName).setExecutor(this);
                getCommand(commandName).setTabCompleter(this);
            }
        }
    }

    @Override
    public void onDisable() {
        if (activeEditor != null) {
            saveEditor(activeEditor);
            activeEditor = null;
        }
        saveConfig();
    }

    private Economy setupEconomy() {
        if (Bukkit.getPluginManager().getPlugin("Vault") == null) {
            return null;
        }
        RegisteredServiceProvider<Economy> provider = getServer().getServicesManager().getRegistration(Economy.class);
        return provider == null ? null : provider.getProvider();
    }

    private void loadShopEntries() {
        shopEntries.clear();
        ConfigurationSection items = getConfig().getConfigurationSection("items");
        if (items == null) {
            return;
        }

        int inventorySize = getInventorySize();
        int sellButtonSlot = getSellButtonSlot();
        for (String key : items.getKeys(false)) {
            ConfigurationSection section = items.getConfigurationSection(key);
            if (section == null) {
                continue;
            }

            int slot;
            try {
                slot = Integer.parseInt(key);
            } catch (NumberFormatException exception) {
                slot = section.getInt("slot", -1);
            }
            if (slot < 0 || slot >= inventorySize || slot == sellButtonSlot) {
                getLogger().warning("Skipping shop entry '" + key + "': its slot is invalid or reserved for the sell button.");
                continue;
            }

            ItemStack item = section.getItemStack("item");
            if (item == null) {
                item = createLegacyItem(section);
            }
            if (item == null || item.getType().isAir()) {
                getLogger().warning("Skipping shop entry '" + key + "': no valid item was configured.");
                continue;
            }

            shopEntries.put(slot, new ShopEntry(slot, item.clone(), readPrice(item, "buy"), SELL_PRICE_PER_ITEM));
        }
    }

    private ItemStack createLegacyItem(ConfigurationSection section) {
        String materialName = section.getString("material", "");
        Material material = XMaterial.matchXMaterial(materialName)
                .map(XMaterial::parseMaterial)
                .orElse(null);
        if (material == null || material.isAir()) {
            return null;
        }

        int amount = Math.max(1, Math.min(section.getInt("amount", 1), material.getMaxStackSize()));
        ItemStack item = new ItemStack(material, amount);
        ItemMeta meta = item.getItemMeta();
        if (meta == null) {
            return item;
        }
        if (section.contains("name")) {
            meta.setDisplayName(color(section.getString("name", "")));
        }
        List<String> lore = section.getStringList("lore");
        if (lore.isEmpty()) {
            double buyPrice = section.getDouble("buy-price", -1.0);
            double sellPrice = section.getDouble("sell-price", -1.0);
            if (Double.isFinite(buyPrice) && buyPrice > 0.0) {
                lore.add("Buy: " + buyPrice);
            }
            if (Double.isFinite(sellPrice) && sellPrice > 0.0) {
                lore.add("Sell: " + sellPrice);
            }
        }
        if (!lore.isEmpty()) {
            meta.setLore(lore.stream().map(this::color).toList());
        }
        item.setItemMeta(meta);
        return item;
    }

    private double readPrice(ItemStack item, String action) {
        ItemMeta meta = item.getItemMeta();
        if (meta == null || meta.getLore() == null) {
            return -1.0;
        }

        double price = -1.0;
        for (String line : meta.getLore()) {
            String plain = ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', line));
            Matcher matcher = PRICE_LINE.matcher(plain == null ? "" : plain);
            if (!matcher.matches() || !matcher.group(1).equalsIgnoreCase(action)) {
                continue;
            }
            try {
                double parsed = Double.parseDouble(matcher.group(2));
                price = Double.isFinite(parsed) && parsed > 0.0 ? parsed : -1.0;
            } catch (NumberFormatException ignored) {
                price = -1.0;
            }
        }
        return price;
    }

    private int getInventorySize() {
        int size = Math.max(9, Math.min(54, getConfig().getInt("gui.size", 54)));
        return (size / 9) * 9;
    }

    private int getSellButtonSlot() {
        int size = getInventorySize();
        int configured = getConfig().getInt("gui.sell-button-slot", size - 5);
        return configured >= 0 && configured < size ? configured : size - 1;
    }

    private void openShop(Player player, boolean sellMode) {
        ShopHolder holder = new ShopHolder(sellMode);
        String titleKey = sellMode ? "gui.sell-title" : "gui.title";
        String defaultTitle = sellMode ? "&8&lSell Items" : "&8&lShop";
        Inventory inventory = Bukkit.createInventory(holder, getInventorySize(), color(getConfig().getString(titleKey, defaultTitle)));
        holder.setInventory(inventory);

        fillShopBackground(inventory);
        for (ShopEntry entry : shopEntries.values()) {
            inventory.setItem(entry.slot(), createShopDisplay(entry, sellMode));