Maxpro Lets

hey i want money spawer only break with silk touch pickaxe

Kodari AI
KodariOct 4 at 12:41 pm 1
  1. Find the money spawner break/drop handling and require a Silk Touch pickaxe to break it.I can’t add this safely because the project only contains configuration files—there’s no Java/Kotlin source to handle spawner breaks. The existing config defines money spawners but has no supported Silk Touch setting. Add the plugin source, especially the main class and spawner break/drop handler, and I can make money spawners require a Silk Touch pickaxe.

Maxpro Lets

you can not make

Kodari AI
KodariOct 4 at 12:43 pm 1

I can make it, but this project has no plugin source code—only config files and a plugin.yml pointing to a missing main class. Adding a Silk Touch option to the config wouldn’t actually enforce it. Include the plugin’s source files and I can add the break check properly.

Maxpro Lets

what is missing can you fix it

Kodari AI
KodariOct 4 at 12:50 pm 1

Missing: all Java source code, including the MaxShopGUI main class and any spawner break handler. I’m adding the main class and the money-spawner give/place/break flow so tagged money spawners require a Silk Touch pickaxe; the existing shop commands still have no implementations in this project.

The missing piece was the Java plugin source, including the main class named in plugin.yml. I added that class with money-spawner give/place handling and a break check: money spawners now require a Silk Touch pickaxe and drop as their tagged spawner item.

The shop, balance, and other commands listed in plugin.yml still have no implementations in the project.

Maxpro Lets

[12:53:18 ERROR]: [DirectoryProviderSource] Error loading plugin: java.lang.IllegalArgumentException: Directory 'plugins/.paper-remapped/MaxShopGUI.jar' does not contain a paper-plugin.yml or plugin.yml! Could not determine plugin type, cannot load a plugin from it! java.lang.RuntimeException: java.lang.IllegalArgumentException: Directory 'plugins/.paper-remapped/MaxShopGUI.jar' does not contain a paper-plugin.yml or plugin.yml! Could not determine plugin type, cannot load a plugin from it! at io.papermc.paper.plugin.provider.source.FileProviderSource.registerProviders(FileProviderSource.java:86) ~[paper-1.21.1.jar:1.21.1-133-3cb8529] at io.papermc.paper.plugin.provider.source.DirectoryProviderSource.registerProviders(DirectoryProviderSource.java:52) ~[paper-1.21.1.jar:1.21.1-133-3cb8529] at io.papermc.paper.plugin.provider.source.DirectoryProviderSource.registerProviders(DirectoryProviderSource.java:17) ~[paper-1.21.1.jar:1.21.1-133-3cb8529] at io.papermc.paper.plugin.util.EntrypointUtil.registerProvidersFromSource(EntrypointUtil.java:15) ~[paper-1.21.1.jar:1.21.1-133-3cb8529] at io.papermc.paper.plugin.PluginInitializerManager.load(PluginInitializerManager.java:113) ~[paper-1.21.1.jar:1.21.1-133-3cb8529] at net.minecraft.server.Main.main(Main.java:123) ~[paper-1.21.1.jar:1.21.1-133-3cb8529] at io.papermc.paper.PaperBootstrap.boot(PaperBootstrap.java:21) ~[paper-1.21.1.jar:1.21.1-133-3cb8529] at org.bukkit.craftbukkit.Main.main(Main.java:281) ~[paper-1.21.1.jar:1.21.1-133-3cb8529] at io.papermc.paperclip.Paperclip.lambda$main$0(Paperclip.java:42) ~[app:?] at java.base/java.lang.Thread.run(Thread.java:1583) ~[?:?] Caused by: java.lang.IllegalArgumentException: Directory 'plugins/.paper-remapped/MaxShopGUI.jar' does not contain a paper-plugin.yml or plugin.yml! Could not determine plugin type, cannot load a plugin from it! ... 10 more

Kodari AI
KodariOct 4 at 12:54 pm 1
  1. Put plugin.yml in the build’s resource directory so it’s included in the JAR.

  2. Move the default config resources there too, so startup can load them.

The JAR was missing its plugin descriptor because plugin.yml was at the project root instead of the resource directory. I moved it, along with config.yml and shop.yml, to src/main/resources so they’ll be packaged into the JAR. Compile the project again and replace the old JAR.

Maxpro Lets

hey my shop and spawer is not working

Kodari AI
KodariOct 4 at 1:05 pm 2
  1. Fix the shop so its configured commands and GUI work.

  2. Fix money spawner handling so spawners can be obtained, placed, and broken as intended.

  1. Shop commands and GUI now use the configured categories and built-in balances.

  2. Check the money spawner’s configured types and fix its give/place/Silk Touch break flow.

  1. Shop: /shop now opens the configured categories; click to browse and buy. /sell opens a sell menu. Balances persist, and /balance, /money, and /pay are implemented.

  2. Money spawners: /spawner <type> [amount] [player] now gives a configured spawner (operator permission required). Placed spawners pay their placer on the configured interval, and they still require a Silk Touch pickaxe to break.

  3. Update the server: Compile the updated project in Kodari, download the new JAR, and replace the old one. Money spawners placed before this update need to be picked up with Silk Touch and placed again to start paying their placer.

Kodari can make mistakes. Review important code before using.
Files
src
Code
5 4,112
src/main/java/com/maxpro/maxshopgui/MaxShopGUI.java
package com.maxpro.maxshopgui;

import com.cryptomorin.xseries.XEnchantment;
import com.cryptomorin.xseries.XMaterial;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.block.BlockState;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.EntityType;
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.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;

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

public final class MaxShopGUI extends JavaPlugin implements Listener {
    private NamespacedKey moneySpawnerTypeKey;
    private NamespacedKey moneySpawnerOwnerKey;
    private ShopManager shopManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        moneySpawnerTypeKey = new NamespacedKey(this, "money_spawner_type");
        moneySpawnerOwnerKey = new NamespacedKey(this, "money_spawner_owner");
        shopManager = new ShopManager(this);
        getServer().getPluginManager().registerEvents(this, this);
        getServer().getPluginManager().registerEvents(shopManager, this);
        long interval = Math.max(1, getConfig().getLong("money_spawners.interval-seconds", 40)) * 20;
        getServer().getScheduler().runTaskTimer(this, this::payMoneySpawners, interval, interval);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        boolean spawnerCommand = command.getName().equalsIgnoreCase("spawner");
        if (!command.getName().equalsIgnoreCase("give") && !spawnerCommand) {
            return shopManager.onCommand(sender, command, args);
        }
        if (args.length < 1 || args.length > 3) {
            sender.sendMessage(ChatColor.RED + "Usage: /" + (spawnerCommand ? "spawner" : "give") + " <zombie|skeleton|creeper|iron_golem> [amount] [player]");
            return true;
        }

        String type = args[0].toLowerCase();
        ConfigurationSection typeConfig = getConfig().getConfigurationSection("money_spawners.types." + type);
        if (typeConfig == null) {
            sender.sendMessage(ChatColor.RED + "Unknown money spawner type.");
            return true;
        }

        int amount = 1;
        if (args.length >= 2) {
            try {
                amount = Integer.parseInt(args[1]);
            } catch (NumberFormatException exception) {
                sender.sendMessage(ChatColor.RED + "Amount must be a number.");
                return true;
            }
            if (amount < 1 || amount > 64) {
                sender.sendMessage(ChatColor.RED + "Amount must be between 1 and 64.");
                return true;
            }
        }

        Player target;
        if (args.length == 3) {
            target = getServer().getPlayerExact(args[2]);
            if (target == null) {
                sender.sendMessage(ChatColor.RED + "That player is not online.");
                return true;
            }
        } else if (sender instanceof Player player) {
            target = player;
        } else {
            sender.sendMessage(ChatColor.RED + "Console must specify a player.");
            return true;
        }

        ItemStack item = createMoneySpawnerItem(type, amount);
        if (item == null) {
            sender.sendMessage(ChatColor.RED + "Could not create that money spawner.");
            return true;
        }
        target.getInventory().addItem(item).values().forEach(leftover ->
                target.getWorld().dropItemNaturally(target.getLocation(), leftover));
        sender.sendMessage(ChatColor.GREEN + "Gave " + amount + " " + type + " money spawner(s) to " + target.getName() + ".");
        return true;
    }

    @EventHandler
    public void onMoneySpawnerPlace(BlockPlaceEvent event) {
        ItemStack item = event.getItemInHand();
        ItemMeta meta = item.getItemMeta();
        if (meta == null) {
            return;
        }

        String type = meta.getPersistentDataContainer().get(moneySpawnerTypeKey, PersistentDataType.STRING);
        if (type == null) {
            return;
        }

        ConfigurationSection typeConfig = getConfig().getConfigurationSection("money_spawners.types." + type);
        if (typeConfig == null) {
            event.setCancelled(true);
            return;
        }

        EntityType entityType;
        try {
            entityType = EntityType.valueOf(typeConfig.getString("entity", "").toUpperCase());
        } catch (IllegalArgumentException exception) {
            event.setCancelled(true);
            return;
        }

        if (!(event.getBlockPlaced().getState() instanceof CreatureSpawner spawner)) {
            event.setCancelled(true);
            return;
        }
        spawner.setSpawnedType(entityType);
        spawner.getPersistentDataContainer().set(moneySpawnerTypeKey, PersistentDataType.STRING, type);
        spawner.getPersistentDataContainer().set(moneySpawnerOwnerKey, PersistentDataType.STRING, event.getPlayer().getUniqueId().toString());
        spawner.update(true, false);
    }

    @EventHandler
    public void onMoneySpawnerBreak(BlockBreakEvent event) {
        if (!(event.getBlock().getState() instanceof CreatureSpawner spawner)) {
            return;
        }
        String type = spawner.getPersistentDataContainer().get(moneySpawnerTypeKey, PersistentDataType.STRING);
        if (type == null) {
            return;
        }

        ItemStack tool = event.getPlayer().getInventory().getItemInMainHand();
        boolean pickaxe = XMaterial.matchXMaterial(tool.getType()).name().endsWith("_PICKAXE");
        boolean silkTouch = XEnchantment.matchXEnchantment("SILK_TOUCH")
                .map(enchantment -> tool.containsEnchantment(enchantment.getEnchant()))
                .orElse(false);
        if (!pickaxe || !silkTouch) {
            event.setCancelled(true);
            event.getPlayer().sendMessage(ChatColor.RED + "Money spawners can only be broken with a Silk Touch pickaxe.");
            return;
        }

        ItemStack drop = createMoneySpawnerItem(type, 1);
        if (drop == null) {
            event.setCancelled(true);
            return;
        }
        event.setDropItems(false);
        event.getBlock().getWorld().dropItemNaturally(event.getBlock().getLocation(), drop);
    }

    private ItemStack createMoneySpawnerItem(String type, int amount) {
        ConfigurationSection typeConfig = getConfig().getConfigurationSection("money_spawners.types." + type);
        if (typeConfig == null) {
            return null;
        }

        ItemStack item = XMaterial.matchXMaterial("SPAWNER").map(XMaterial::parseItem).orElse(null);
        if (item == null) {
            return null;
        }
        item.setAmount(amount);
        ItemMeta meta = item.getItemMeta();
        if (meta == null) {
            return null;
        }
        String displayName = typeConfig.getString("display-name", "&dMoney Spawner");
        meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', displayName));
        meta.getPersistentDataContainer().set(moneySpawnerTypeKey, PersistentDataType.STRING, type);
        item.setItemMeta(meta);
        return item;
    }

    private void payMoneySpawners() {
        if (!getConfig().getBoolean("settings.spawners.enabled", true)) {
            return;
        }

        double maxPayout = getConfig().getDouble("settings.spawners.max-payout-per-player", 50000.0);
        Map<UUID, Double> payouts = new HashMap<>();
        for (World world : getServer().getWorlds()) {
            for (Chunk chunk : world.getLoadedChunks()) {