Implement the QuirkEconomy plugin fully in this project, using the linked main plugin dependency at /links/KDR-202610-G8VH8QLR. The linked project is SomnabulistQuirk, plugin main class com.midnightplugin.MidnightPlugin; its successful latest API exposes public boolean isQuirkUnlocked(UUID playerId, String quirkKey) and public boolean unlockQuirk(UUID playerId, String quirkKey). Compile against that direct project dependency; do not shade/bundle it. The main plugin's plugin.yml name is MidnightSomnambulist. The task classes listed below are private inner classes and must NOT be called/referenced as executable APIs: associate them informationally in each category's GUI lore only.

Create the requested inventory shop opened via /quirkshop, with five category purchases and these exact canonical unlock keys, prices, fragment counts, and associated existing task names:

  • Somnambulist; key somnambulist; 2000 coins + 2 Quirk Fragments; SleepTask.
  • Telekinesis; key telekinesis; 4000 + 4; GrabTask, TelekineticCompressionTask.
  • Electrification; key electrification; 6000 + 6; ElectromagneticStormTask, ElectrostaticNetTask, VoltageChargeTask, VoltaicDartTask.
  • Ice; key ice; 6000 + 6; BlizzardTask, FrostRayTask, IceAgeBlizzardTask, IceShardTask, IceSkatingTask.
  • Fairy; key fairy; 8000 + 8; FairyBombTask, FairyFlightTask, FairyMachineGunTask, FairyPetrificationTask.

Use Vault API net.milkbowl.vault.economy.Economy for balance checks and withdrawal, compatible with EssentialsX economy through Vault's registered provider. Configure Gradle with a suitable compileOnly VaultAPI dependency and needed repositories, plus Paper API. plugin.yml should declare /quirkshop, and depend on both MidnightSomnambulist and Vault (or an equivalent safe dependency arrangement that provides the linked class and Vault at runtime). Implement an economy provider check on enable and clear user-facing errors if missing.

Define the physical fragment as a Nether Star with display name exactly §d§lQuirk Fragment and one lore line exactly §7A fragment imbued with mysterious energy.... Create a helper to construct the item and recognize valid fragment stacks by material and exact required display name/lore. On clicking a category item, cancel inventory interaction, make sure the click is in the shop, reject an already-unlocked key, require sufficient Vault balance AND at least the category's exact required count of valid physical fragment items, then withdraw the configured coins, consume exactly that many matching fragments (not other nether stars), call MidnightPlugin.unlockQuirk(player UUID, canonical key) to persist permanently, and message the player on success. Provide clear insufficient-currency/fragments/already-owned/failure messages. Ensure no charging/consuming when checks fail. Handle click/drag events so items cannot be moved into/out of the shop; close handling if useful. Protect menus from stale clicks, check the current shop holder/menu identity, and run all Bukkit/Vault operations on the main thread.

The shop should clearly show the price, fragment requirement, unlocked status, and associated task names in item name/lore. A fragment grant command is not required. Use a dedicated InventoryHolder or robust namespaced persistent-data identifiers for shop buttons. Implement clean enable/disable lifecycle and avoid null command executors. Update build.gradle, src/main/resources/plugin.yml, and all required Java source. Java 21 / Paper 1.21.1 compatibility. Do not compile; coordinator compiles after completion. Keep scope limited to requested feature; done means all code and metadata are in place and ready for coordinator compilation.

Kodari AI
KodariOct 3 at 8:57 am 1
QuirkEconomy
QuirkEconomy is a Minecraft plugin that adds a GUI-based quirk shop accessible via /quirkshop. Players can purchase five distinct quirks (Somnambulist, Telekinesis, Electrification, Ice, Fairy) using Vault economy coins and physical Quirk Fragment items. The shop displays prices, fragment requirements, unlock status, and associated task names in item lore. Purchases validate balance and fragment counts before withdrawing currency and consuming items, then persist unlocks through the linked MidnightPlugin API. The plugin integrates with Vault for economy and Paper API for inventory GUI functionality.
  1. Add Gradle and plugin metadata for Paper, Vault, and the linked plugin.

  2. Implement the fragment matcher/consumer and category shop with guarded purchases and GUI event handling.

  3. Register /quirkshop and validate dependencies/provider during startup.

Implemented QuirkEconomy with /quirkshop, all five configured quirk purchases, exact fragment validation and consumption, Vault balance checks, and unlock calls to MidnightPlugin. Added the Paper/Vault Gradle setup and plugin metadata declaring dependencies on MidnightSomnambulist and Vault. The linked plugin is used at runtime and is not bundled.

Compilation was not run, as requested.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
5 384
src/main/java/com/midnightplugin/quirkeconomy/QuirkEconomyPlugin.java
package com.midnightplugin.quirkeconomy;

import com.cryptomorin.xseries.XMaterial;
import com.midnightplugin.MidnightPlugin;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
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.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.meta.ItemMeta;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

public final class QuirkEconomyPlugin extends JavaPlugin implements Listener, CommandExecutor {
    private static final Map<Integer, QuirkCategory> SHOP_SLOTS = Map.of(
            10, QuirkCategory.SOMNAMBULIST,
            11, QuirkCategory.TELEKINESIS,
            12, QuirkCategory.ELECTRIFICATION,
            14, QuirkCategory.ICE,
            15, QuirkCategory.FAIRY
    );

    private final Map<UUID, ShopHolder> openShops = new HashMap<>();
    private MidnightPlugin midnightPlugin;
    private Economy economy;

    @Override
    public void onEnable() {
        if (getServer().getPluginManager().getPlugin("Vault") == null) {
            getLogger().severe("Vault is missing. Install Vault and an economy provider such as EssentialsX Economy.");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }

        if (!(getServer().getPluginManager().getPlugin("MidnightSomnambulist") instanceof MidnightPlugin linkedPlugin)) {
            getLogger().severe("MidnightSomnambulist is missing or has an incompatible main class; QuirkEconomy cannot start.");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }
        midnightPlugin = linkedPlugin;

        RegisteredServiceProvider<Economy> registration = getServer().getServicesManager().getRegistration(Economy.class);
        if (registration == null || registration.getProvider() == null) {
            getLogger().severe("No Vault economy provider is registered. Install/configure an economy provider such as EssentialsX Economy.");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }
        economy = registration.getProvider();

        if (getCommand("quirkshop") == null) {
            getLogger().severe("The /quirkshop command is missing from plugin.yml; QuirkEconomy cannot start.");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }

        getCommand("quirkshop").setExecutor(this);
        getServer().getPluginManager().registerEvents(this, this);
    }

    @Override
    public void onDisable() {
        for (Map.Entry<UUID, ShopHolder> entry : new ArrayList<>(openShops.entrySet())) {
            Player player = Bukkit.getPlayer(entry.getKey());
            if (player != null && player.getOpenInventory().getTopInventory() == entry.getValue().getInventory()) {
                player.closeInventory();
            }
        }
        openShops.clear();
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player player)) {
            sender.sendMessage("Only players can open the Quirk shop.");
            return true;
        }
        openShop(player);
        return true;
    }

    private void openShop(Player player) {
        ShopHolder holder = new ShopHolder(player.getUniqueId());
        populateShop(holder, player);
        openShops.put(player.getUniqueId(), holder);
        player.openInventory(holder.getInventory());
    }

    private void populateShop(ShopHolder holder, Player player) {
        for (Map.Entry<Integer, QuirkCategory> entry : SHOP_SLOTS.entrySet()) {
            QuirkCategory category = entry.getValue();
            ItemStack item = XMaterial.matchXMaterial(category.icon)
                    .map(XMaterial::parseItem)
                    .orElse(null);
            if (item == null) {
                getLogger().warning("Unable to create the shop icon for " + category.displayName + ".");
                continue;
            }

            ItemMeta meta = item.getItemMeta();
            meta.setDisplayName("§b§l" + category.displayName);
            List<String> lore = new ArrayList<>();
            lore.add("§7Unlock key: §f" + category.key);
            lore.add("§7Price: §6" + category.price + " coins");
            lore.add("§7Required: §d" + category.fragments + " Quirk Fragments");
            lore.add("§7Status: " + (midnightPlugin.isQuirkUnlocked(player.getUniqueId(), category.key)
                    ? "§aUnlocked" : "§cLocked"));
            lore.add("§7Associated tasks:");
            for (String task : category.tasks) {
                lore.add("§8• §7" + task);
            }
            meta.setLore(lore);
            item.setItemMeta(meta);
            holder.getInventory().setItem(entry.getKey(), item);
        }
    }

    @EventHandler
    public void onInventoryClick(InventoryClickEvent event) {
        Inventory top = event.getView().getTopInventory();
        if (!(top.getHolder() instanceof ShopHolder holder) || holder.getInventory() != top) {
            return;
        }

        event.setCancelled(true);
        if (!(event.getWhoClicked() instanceof Player player)
                || !isActiveShop(player, holder)
                || event.getRawSlot() < 0
                || event.getRawSlot() >= top.getSize()) {
            return;
        }

        QuirkCategory category = SHOP_SLOTS.get(event.getRawSlot());
        if (category != null) {
            purchase(player, holder, category);
        }
    }

    @EventHandler
    public void onInventoryDrag(InventoryDragEvent event) {
        Inventory top = event.getView().getTopInventory();
        if (top.getHolder() instanceof ShopHolder holder && holder.getInventory() == top) {
            event.setCancelled(true);
        }
    }

    @EventHandler
    public void onInventoryClose(InventoryCloseEvent event) {
        Inventory inventory = event.getInventory();
        if (!(inventory.getHolder() instanceof ShopHolder holder) || holder.getInventory() != inventory) {
            return;
        }
        openShops.remove(holder.getOwner(), holder);
    }

    private boolean isActiveShop(Player player, ShopHolder holder) {
        return holder.getOwner().equals(player.getUniqueId())
                && openShops.get(player.getUniqueId()) == holder
                && player.getOpenInventory().getTopInventory() == holder.getInventory();
    }

    private void purchase(Player player, ShopHolder holder, QuirkCategory category) {
        UUID playerId = player.getUniqueId();
        if (midnightPlugin.isQuirkUnlocked(playerId, category.key)) {
            player.sendMessage("§cYou already own the " + category.displayName + " quirk.");
            return;
        }
        if (economy.getBalance(player) < category.price) {
            player.sendMessage("§cYou need " + category.price + " coins to unlock " + category.displayName + ".");
            return;
        }
        if (QuirkFragment.count(player) < category.fragments) {
            player.sendMessage("§cYou need " + category.fragments + " valid Quirk Fragments to unlock " + category.displayName + ".");
            return;
        }

        EconomyResponse withdrawal = economy.withdrawPlayer(player, category.price);
        if (!withdrawal.transactionSuccess()) {
            player.sendMessage("§cYour payment could not be processed. No fragments were consumed.");
            return;
        }

        if (!midnightPlugin.unlockQuirk(playerId, category.key)) {
            EconomyResponse refund = economy.depositPlayer(player, category.price);
            if (midnightPlugin.isQuirkUnlocked(playerId, category.key)) {