tunderhack client

stówrz mi launcher mc aura shop

Kodari AI
KodariOct 11 at 8:48 am 1
AuraShopLauncher
A Minecraft plugin that adds a fully-featured in-game shop system with a custom GUI, allowing players to buy and sell items using a virtual currency economy. Features include configurable item prices, shop categories, admin management commands, and a persistent data storage system. The plugin integrates with Vault for economy support and provides a seamless shopping experience through intuitive menus and transaction logging.
  1. Создам AuraShop как Bukkit-плагин с командой /aurashop и GUI-магазином.

  2. Добавлю покупки за внутреннюю валюту, сохранение баланса и админ-команду для выдачи монет.

  3. Настрою товары, цены и оформление через config.yml.

Stworzyłem AuraShop jako plugin Minecraft: /aurashop otwiera sklep GUI, /aurashop balance pokazuje saldo, a /aurashop give <gracz> <ilość> (OP) dodaje walutę. Produkty, ceny i wygląd można zmieniać w config.yml.

Jeśli przez „launcher” chodziło Ci o osobną aplikację do uruchamiania Minecrafta, a nie sklepowy plugin, doprecyzuj.

Kodari can make mistakes. Review important code before using.
Files
src
Code
3 315
src/main/java/com/kodari/aurashop/AuraShopPlugin.java
package com.kodari.aurashop;

import com.cryptomorin.xseries.XMaterial;
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.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.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

public final class AuraShopPlugin extends JavaPlugin implements Listener, CommandExecutor {
    private static final String PREFIX = "&b&lAuraShop &8» &r";

    private File balancesFile;
    private YamlConfiguration balances;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        balancesFile = new File(getDataFolder(), "balances.yml");
        if (!balancesFile.exists()) {
            try {
                getDataFolder().mkdirs();
                new YamlConfiguration().save(balancesFile);
            } catch (IOException exception) {
                getLogger().severe("Could not create balances.yml: " + exception.getMessage());
            }
        }
        balances = YamlConfiguration.loadConfiguration(balancesFile);
        getCommand("aurashop").setExecutor(this);
        getServer().getPluginManager().registerEvents(this, this);
    }

    @Override
    public void onDisable() {
        saveBalances();
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (args.length > 0 && args[0].equalsIgnoreCase("give")) {
            if (!sender.hasPermission("aurashop.admin")) {
                send(sender, "&cNie masz uprawnień do tej komendy.");
                return true;
            }
            if (args.length != 3) {
                send(sender, "&cUżycie: /aurashop give <gracz> <ilość>");
                return true;
            }

            Player target = Bukkit.getPlayerExact(args[1]);
            if (target == null) {
                send(sender, "&cTen gracz musi być online.");
                return true;
            }

            long amount;
            try {
                amount = Long.parseLong(args[2]);
            } catch (NumberFormatException exception) {
                send(sender, "&cPodaj poprawną ilość.");
                return true;
            }
            if (amount <= 0) {
                send(sender, "&cIlość musi być większa od zera.");
                return true;
            }

            long current = getBalance(target.getUniqueId());
            if (amount > Long.MAX_VALUE - current) {
                send(sender, "&cSaldo gracza jest zbyt duże.");
                return true;
            }
            setBalance(target.getUniqueId(), current + amount);
            send(sender, "&aDodano " + amount + " monet graczowi &f" + target.getName() + "&a.");
            send(target, "&aOtrzymujesz " + amount + " monet.");
            return true;
        }

        if (args.length > 0 && args[0].equalsIgnoreCase("balance")) {
            if (!(sender instanceof Player)) {
                send(sender, "&cTej komendy może użyć tylko gracz.");
                return true;
            }
            Player player = (Player) sender;
            send(player, "&7Twoje saldo: &e" + getBalance(player.getUniqueId()) + " monet");
            return true;
        }

        if (!(sender instanceof Player)) {
            send(sender, "&cSklep może otworzyć tylko gracz.");
            return true;
        }
        openShop((Player) sender);
        return true;
    }

    @EventHandler
    public void onInventoryClick(InventoryClickEvent event) {
        Inventory top = event.getView().getTopInventory();
        if (!(top.getHolder() instanceof ShopHolder)) {
            return;
        }
        event.setCancelled(true);
        if (!(event.getWhoClicked() instanceof Player) || event.getRawSlot() < 0 || event.getRawSlot() >= top.getSize()) {
            return;
        }

        Player player = (Player) event.getWhoClicked();
        ShopHolder holder = (ShopHolder) top.getHolder();
        String productKey = holder.products.get(event.getRawSlot());
        if (productKey == null || event.isShiftClick() || !event.isLeftClick()) {
            return;
        }

        ConfigurationSection product = getConfig().getConfigurationSection("shop.items." + productKey);
        if (product == null) {
            return;
        }
        Material material = resolveMaterial(product.getString("material", ""));
        if (material == null) {
            return;
        }
        ItemStack purchase = createItem(product, material);
        if (!hasSpace(player, purchase)) {
            send(player, "&cNie masz miejsca w ekwipunku.");
            return;
        }

        long price = Math.max(0L, product.getLong("price", 0L));
        long balance = getBalance(player.getUniqueId());
        if (balance < price) {
            send(player, "&cNie masz wystarczającej liczby monet. Saldo: &e" + balance);
            return;
        }

        player.getInventory().addItem(purchase);
        setBalance(player.getUniqueId(), balance - price);
        send(player, "&aKupiono &f" + product.getString("name", productKey) + " &aza &e" + price + " monet.");
    }

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

    private void openShop(Player player) {
        String title = color(getConfig().getString("shop.title", "&8Aura Shop"));
        ShopHolder holder = new ShopHolder();
        Inventory inventory = Bukkit.createInventory(holder, 27, title);
        holder.inventory = inventory;

        ConfigurationSection items = getConfig().getConfigurationSection("shop.items");
        if (items != null) {
            for (String key : items.getKeys(false)) {
                ConfigurationSection product = items.getConfigurationSection(key);
                if (product == null) {
                    continue;
                }
                int slot = product.getInt("slot", -1);
                Material material = resolveMaterial(product.getString("material", ""));
                int amount = product.getInt("amount", 1);
                if (slot < 0 || slot >= inventory.getSize() || material == null || amount < 1 || amount > material.getMaxStackSize()) {
                    getLogger().warning("Skipping invalid shop item: " + key);
                    continue;
                }
                inventory.setItem(slot, createItem(product, material));
                holder.products.put(slot, key);
            }
        }
        player.openInventory(inventory);
    }

    private ItemStack createItem(ConfigurationSection product, Material material) {
        ItemStack item = new ItemStack(material, product.getInt("amount", 1));
        ItemMeta meta = item.getItemMeta();
        if (meta != null) {
            meta.setDisplayName(color(product.getString("name", "&fItem")));