coldflux

coldflux a /killshop command players kill other players specific kills gains you specific items mace being the best and add a op command called /killshop additem and when you enter it opens a gui and it opens a like chest UI you put an item and then in the lower layer a red concrete on the left side and a lime concrete on the right side clicking the red concrete kicks you out the gui and the lime concrete when pressed a sign ui appears saying Set the kill price and then when you type it and press esc button it sets it and returns to the ui but now it says a menu saying Are you sure you want to add this item to the shop. if you click the left red concrete kick but if lime it continues and its added on the shop for everyone to buy and in the /killshop a gui appears with slots for diffrent weapons that the admin put and each kill is counted by the plugin for each player and shows in the gui in the lowest layer in the ui a block in the middle saying Kills : and types a number of kills that the player has and buys it once its bought it goes in the player's inventory and a command called /pay for kills here is the syntax /pay Username amount of kills and it transfers to him he can use it in the shop and make when a player dies a lightning hits where they died and a block.amethyst_block.break sound appears but not for all players only the players near the person who got killed and make if players are not near whoever died the death message doesnt appear only if another player is 32 blocks away from the person who died they get the death message but more far will not get it

Kodari AI
KodariSep 14 at 9:39 pm 2
KillShop
A kill-based shop plugin where players earn kills to purchase items. Admins use /killshop additem to open a GUI, place an item, set a kill price via sign input, and confirm with red/lime concrete buttons. Players use /killshop to browse items, view their kill count, and buy weapons. /pay transfers kills between players. Deaths trigger lightning and amethyst block break sounds for nearby players, with death messages only shown within 32 blocks.
  1. Create the Gradle/Paper plugin skeleton and configuration.

  2. Implement persistent kill balances and admin-managed shop items.

  3. Add /killshop, /killshop additem, /pay, GUI flows, sign price input, purchases, and nearby death effects.

Implemented the ColdFlux kill shop plugin from scratch.

  • Added Gradle/Paper plugin setup and plugin configuration.

  • Added persistent kill balances and admin-managed shop items.

  • Added /killshop and /killshop additem.

  • Added chest GUI item submission with red cancel and lime confirmation buttons.

  • Added sign-based kill price entry.

  • Added shop purchasing with kill credits.

  • Added /pay <username> <amount>.

  • Added kill tracking when a player kills another player.

  • Added nearby death messages, lightning effect, and amethyst block break sound within 32 blocks.

  • Added item persistence through config.yml.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
8 619
src/main/java/com/coldflux/ColdFluxPlugin.java
package com.coldflux;

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

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.configuration.ConfigurationSection;

public class ColdFluxPlugin extends JavaPlugin {
    private final List<ShopItem> shopItems = new ArrayList<>();
    private KillShopListener listener;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        loadShopItems();

        listener = new KillShopListener(this);
        Bukkit.getPluginManager().registerEvents(listener, this);

        KillShopCommand command = new KillShopCommand(this);
        if (getCommand("killshop") != null) {
            getCommand("killshop").setExecutor(command);
        }
        if (getCommand("pay") != null) {
            getCommand("pay").setExecutor(command);
        }
    }

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

    private void loadShopItems() {
        shopItems.clear();
        ConfigurationSection section = getConfig().getConfigurationSection("items");
        if (section == null) {
            return;
        }

        for (String id : section.getKeys(false)) {
            ItemStack item = section.getItemStack(id + ".item");
            int price = section.getInt(id + ".price", 0);
            if (item != null && price > 0) {
                shopItems.add(new ShopItem(id, item, price));
            }
        }
    }

    public void saveShopItems() {
        getConfig().set("items", null);
        for (ShopItem shopItem : shopItems) {
            String path = "items." + shopItem.getId();
            getConfig().set(path + ".item", shopItem.getItem());
            getConfig().set(path + ".price", shopItem.getPrice());
        }
        saveConfig();
    }

    public List<ShopItem> getShopItems() {
        return Collections.unmodifiableList(shopItems);
    }

    public void addShopItem(ItemStack item, int price) {
        shopItems.add(new ShopItem(UUID.randomUUID().toString(), item.clone(), price));
        saveShopItems();
    }

    public int getKills(UUID uuid) {
        return getConfig().getInt("kills." + uuid, 0);
    }

    public void addKill(UUID uuid) {
        setKills(uuid, getKills(uuid) + 1);
        saveConfig();
    }

    public boolean transferKills(Player sender, Player recipient, int amount) {
        if (getKills(sender.getUniqueId()) < amount) {
            return false;
        }

        setKills(sender.getUniqueId(), getKills(sender.getUniqueId()) - amount);
        setKills(recipient.getUniqueId(), getKills(recipient.getUniqueId()) + amount);
        saveConfig();
        return true;
    }

    public boolean purchase(Player player, ShopItem shopItem) {
        if (getKills(player.getUniqueId()) < shopItem.getPrice()) {
            return false;
        }

        setKills(player.getUniqueId(), getKills(player.getUniqueId()) - shopItem.getPrice());
        Map<Integer, ItemStack> leftovers = player.getInventory().addItem(shopItem.getItem().clone());
        for (ItemStack leftover : leftovers.values()) {
            player.getWorld().dropItemNaturally(player.getLocation(), leftover);
        }
        saveConfig();
        return true;
    }

    private void setKills(UUID uuid, int amount) {
        getConfig().set("kills." + uuid, Math.max(0, amount));
    }

    public void openShop(Player player) {
        Inventory inventory = Bukkit.createInventory(null, 54, KillShopListener.SHOP_TITLE);
        Map<Integer, ShopItem> displayedItems = new java.util.HashMap<>();
        int slot = 0;
        for (ShopItem shopItem : shopItems) {
            if (slot >= 45) {
                break;
            }
            inventory.setItem(slot, createShopIcon(shopItem));
            displayedItems.put(slot, shopItem);
            slot++;
        }
        inventory.setItem(49, createKillsIcon(player));
        listener.registerShop(inventory, displayedItems);
        player.openInventory(inventory);
    }

    public void openAddItem(Player player) {
        Inventory inventory = Bukkit.createInventory(null, 27, KillShopListener.ADD_TITLE);
        inventory.setItem(18, createControl("RED_CONCRETE", "&cCancel", "&7Leave without adding the item."));
        inventory.setItem(26, createControl("LIME_CONCRETE", "&aSet Price", "&7Set the kill price."));
        player.openInventory(inventory);
    }

    public ItemStack createShopIcon(ShopItem shopItem) {
        ItemStack icon = shopItem.getItem().clone();
        ItemMeta meta = icon.getItemMeta();
        if (meta != null) {
            List<String> lore = meta.hasLore() && meta.getLore() != null
                    ? new ArrayList<>(meta.getLore()) : new ArrayList<>();
            lore.add(color("&8Price: &e" + shopItem.getPrice() + " kills"));
            meta.setLore(lore);
            icon.setItemMeta(meta);
        }
        return icon;
    }

    public ItemStack createKillsIcon(Player player) {
        ItemStack icon = new ItemStack(material("AMETHYST_BLOCK"));
        ItemMeta meta = icon.getItemMeta();
        if (meta != null) {
            meta.setDisplayName(color("&eKills: &f" + getKills(player.getUniqueId())));
            meta.setLore(Collections.singletonList(color("&7Spend these in the kill shop.")));
            icon.setItemMeta(meta);
        }
        return icon;
    }

    public ItemStack createControl(String materialName, String name, String loreLine) {
        ItemStack item = new ItemStack(material(materialName));
        ItemMeta meta = item.getItemMeta();
        if (meta != null) {
            meta.setDisplayName(color(name));
            meta.setLore(Collections.singletonList(color(loreLine)));
            item.setItemMeta(meta);
        }
        return item;
    }

    private Material material(String name) {
        Material material = Material.matchMaterial(name);
        if (material == null) {
            material = Material.matchMaterial("STONE");
        }
        return material;
    }

    public static String color(String message) {
        return org.bukkit.ChatColor.translateAlternateColorCodes('&', message);
    }
}