eclipsepeakstudio
πŸ“Ž 1 file 6,644 chars
πŸ“„
pasted-code-1793929384348.txt
txt 232 lines
β–Ά
# FATAL CRAFT – Complete Minecraft SMP Plugin

## 1. General Overview

I want a Minecraft Java Edition plugin for my server called **Fatal Craft**.

The plugin should be heavily inspired by Donut SMP. I want a complete survival economy experience with money, player shops, orders, auctions, homes, teleportation, leaderboards, and a clean GUI system.

Everything should be connected together and easy to use. Players should be able to access most features through commands and inventory GUIs.

The plugin should be optimized, reliable, and compatible with modern Paper/Spigot servers.

## 2. Economy System

Create a complete money system.

Features:
- Every player starts with $500.
- Players can earn money by selling items, completing orders, and trading.
- Players can send money to other players.
- Players can check their balance.
- Economy should save automatically.
- Economy should support decimal amounts.

Commands:
- /bal – Check your balance.
- /baltop – View the richest players.
- /pay [player] [amount] – Send money.
- /withdraw [amount] – Convert money into physical money if supported.
- /sell – Sell items.
- /sellall – Sell all sellable items.

## 3. Orders System

Create an order system inspired by Donut SMP.

Players should be able to:
- Open an orders GUI.
- See available item orders.
- See how many items are required.
- See how much money each order pays.
- Complete orders by handing in the required items.
- Receive money automatically after completion.
- Have new orders rotate periodically.

Example orders:
- 64 Diamonds – $15,000
- 32 Netherite Ingots – $50,000
- 128 Emeralds – $8,000
- 64 Gold Blocks – $12,000

Include different order difficulties and rewards.

## 4. Auction House (AH)

Create a fully working auction house.

Commands:
- /ah – Open auction house.
- /ah sell [price] – List the item in your hand.
- /ah search [item] – Search listings.
- /ah expired – View expired listings.
- /ah collect – Collect unsold items.

GUI features:
- Display items for sale.
- Show seller name.
- Show item price.
- Show remaining listing time.
- Allow players to purchase items.
- Include next and previous page buttons.
- Include category filters.
- Include a search option.
- Include confirmation before purchases.

## 5. Homes System

Players can create and teleport to their own homes.

Commands:
- /sethome [name]
- /home [name]
- /homes
- /delhome [name]

Features:
- Players start with 2 homes.
- Additional homes can be unlocked through permissions.
- Homes must save after restarting the server.
- Include a GUI showing all saved homes.
- Show coordinates and world names.
- Allow players to teleport from the GUI.

## 6. TPA System

Create a complete teleport request system.

Commands:
- /tpa [player]
- /tpahere [player]
- /tpaccept
- /tpdeny
- /tpcancel
- /tpatoggle

Features:
- Requests expire after 60 seconds.
- Players can accept or deny requests.
- Add a teleport countdown.
- Cancel teleport if the player moves.
- Add configurable teleport cooldowns.
- Prevent teleporting into dangerous situations if configured.

## 7. Leaderboard System

Create a leaderboard GUI and physical leaderboard support.

Commands:
- /leaderboard
- /baltop
- /kills
- /deaths

Track:
- Richest players.
- Most kills.
- Most deaths.
- Most blocks mined.
- Most playtime.
- Most orders completed.

Make the leaderboard update automatically.

## 8. Player GUI System

Create a clean, modern GUI design.

Use a consistent black, dark red, and gray theme to match Fatal Craft.

Main GUI command:
- /menu

The main menu should contain:

1. Economy
2. Orders
3. Auction House
4. Homes
5. Teleport Requests
6. Leaderboards
7. Player Statistics
8. Settings

GUI requirements:
- Use custom item names and lore.
- Use clear icons for every feature.
- Use red stained glass panes for decorative borders.
- Use black stained glass panes for backgrounds.
- Make navigation simple.
- Include back buttons.
- Include confirmation menus for important actions.
- Avoid clutter and unnecessary decorations.

## 9. Owner Permissions and Commands

IMPORTANT: There must only be ONE owner account.

The only owner username is:

**Hiddencpvp**

Only Hiddencpvp should have access to owner commands.

Regular players, administrators, moderators, and other OP players must NOT automatically receive these owner commands.

Owner commands:

- /fcadmin – Open owner control GUI.
- /fcadmin give [player] [amount] – Give money to a player.
- /fcadmin take [player] [amount] – Remove money from a player.
- /fcadmin set [player] [amount] – Set a player's balance.
- /fcadmin reload – Reload plugin configuration.
- /fcadmin stats [player] – View player statistics.
- /fcadmin broadcast [message] – Send a server-wide announcement.

SECURITY REQUIREMENTS:

- Verify the player's Minecraft UUID against the configured owner UUID.
- Hiddencpvp is the only authorized owner.
- Do not rely only on OP status or permissions.
- Other players must never be able to execute owner commands.
- Log all money modifications.
- Prevent command spoofing and unauthorized access.
- Owner commands should work even if another player has operator permissions, but those players must not gain owner access.

## 10. Additional Features

Include:
- Player statistics.
- Kill and death tracking.
- Playtime tracking.
- Customizable messages.
- Economy transaction logs.
- Automatic data saving.
- Configurable prices.
- Configurable cooldowns.
- Sound effects for GUI interactions.
- PlaceholderAPI support if possible.
- Persistent data after server restarts.

## 11. Technical Requirements

- Minecraft Java Edition.
- Paper server compatibility.
- Modern Java version.
- Use a reliable database or persistent storage.
- Keep the plugin optimized.
- Avoid lag and unnecessary repeating tasks.
- Include a config.yml for customization.
- Include messages.yml for messages.
- Include permissions documentation.
- Include installation instructions.
- Make sure all commands work.
- Make sure all GUIs work properly.

## 12. Final Goal

I want this to feel like a complete Donut SMP inspired server experience, but branded as **Fatal Craft**.

The plugin should combine all the features into one organized system with clean GUIs, a functional economy, orders, an auction house, homes, TPA, leaderboards, and secure owner controls.

Do not create unfinished menus or placeholder features. All advertised features should actually work.
Kodari AI
KodariNov 6 at 1:48 am 2
FatalCraftSMP
A comprehensive survival multiplayer economy plugin inspired by Donut SMP. Features a full money system with starting balances, payments, withdrawals, and item selling. Includes a rotating orders system with GUI-based item delivery, a complete auction house with search, filters, and expired listings, player homes with GUI management, TPA system with cooldowns and movement cancellation, and automatic leaderboards tracking wealth, kills, deaths, and playtime. Features a themed black and dark red GUI system with a main menu, secure owner-only commands verified by UUID for the sole owner Hiddencpvp, persistent data storage, configurable messages, and PlaceholderAPI support.
  1. Set up Fatal Craft’s plugin entry point, configuration, and persistent player/listing data.

  2. Implement economy, orders, auction house, homes, teleport requests, statistics, and owner-only controls.

  3. Add shared inventory menus and register every command/listener.

Created Fatal Craft with persistent economy, money notes, selling, rotating orders, auction listings with search/categories/pagination and purchase confirmation, homes, TPA requests, player statistics, leaderboards, and UUID-locked owner commands.

Before using owner commands: set owner.uuid in config.yml to Hiddencpvp’s UUID. Access requires both that UUID and the configured username; OP status alone does not grant access.

Physical sign leaderboards, PlaceholderAPI placeholders, and GUI sound effects are not included.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
README.md
Code
6 1,101
src/main/java/com/fatalcraft/FatalCraft.java
package com.fatalcraft;

import com.cryptomorin.xseries.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.NamespacedKey;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;

public final class FatalCraft extends JavaPlugin implements Listener {
    private final Map<UUID, PlayerRecord> records = new HashMap<>();
    private final List<Listing> listings = new ArrayList<>();
    private final Map<UUID, Request> requestsByTarget = new HashMap<>();
    private final Map<UUID, UUID> outgoingRequests = new HashMap<>();
    private final Map<UUID, Location> pendingTeleports = new HashMap<>();
    private final Map<UUID, Long> lastTpa = new HashMap<>();
    private final Set<UUID> tpaDisabled = new HashSet<>();
    private final Map<UUID, MenuState> menus = new HashMap<>();
    private final DecimalFormat moneyFormat = new DecimalFormat("#,##0.00");
    private NamespacedKey moneyNoteKey;
    private org.bukkit.configuration.file.FileConfiguration messages;
    private BukkitTask saveTask;
    private long nextOrderRotation;
    private List<Order> activeOrders = new ArrayList<>();

    @Override
    public void onEnable() {
        saveDefaultConfig();
        saveResource("messages.yml", false);
        loadMessages();
        moneyNoteKey = new NamespacedKey(this, "money_note");
        loadData();
        rotateOrders();
        Bukkit.getPluginManager().registerEvents(this, this);
        for (String name : getDescription().getCommands().keySet()) {
            if (getCommand(name) != null) getCommand(name).setExecutor(this);
        }
        saveTask = Bukkit.getScheduler().runTaskTimer(this, () -> {
            Bukkit.getOnlinePlayers().forEach(this::updatePlaytime);
            saveData();
        }, 6000L, 6000L);
        Bukkit.getScheduler().runTaskTimer(this, () -> {
            if (System.currentTimeMillis() >= nextOrderRotation) rotateOrders();
        }, 1200L, 1200L);
    }

    @Override
    public void onDisable() {
        if (saveTask != null) saveTask.cancel();
        for (Player player : Bukkit.getOnlinePlayers()) updatePlaytime(player);
        saveData();
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        String cmd = command.getName().toLowerCase(Locale.ROOT);
        Player player = sender instanceof Player ? (Player) sender : null;
        switch (cmd) {
            case "bal" -> {
                if (args.length > 0 && senderIsOwner(sender)) return sendBalance(sender, Bukkit.getOfflinePlayer(args[0]));
                if (player == null) return playerOnly(sender);
                player.sendMessage(msg("prefix") + "Balance: &a$" + format(balance(player.getUniqueId())));
            }
            case "baltop" -> showBalanceTop(sender);
            case "pay" -> {
                if (player == null) return playerOnly(sender);
                if (args.length != 2) return usage(sender, "/pay <player> <amount>");
                Player target = Bukkit.getPlayerExact(args[0]);
                double amount = parseAmount(args[1]);
                if (target == null || target == player) return tell(sender, "&cThat player is not online or is yourself.");
                if (!validAmount(amount)) return tell(sender, msg("invalid-amount"));
                if (balance(player.getUniqueId()) < amount) return tell(sender, msg("not-enough-money"));
                changeBalance(player.getUniqueId(), -amount);
                changeBalance(target.getUniqueId(), amount);
                tell(player, "&aSent $" + format(amount) + " to " + target.getName() + ".");
                tell(target, "&aReceived $" + format(amount) + " from " + player.getName() + ".");
            }
            case "withdraw" -> {
                if (player == null) return playerOnly(sender);
                if (args.length != 1) return usage(sender, "/withdraw <amount>");
                double amount = parseAmount(args[0]);
                if (!validAmount(amount)) return tell(sender, msg("invalid-amount"));
                if (balance(player.getUniqueId()) < amount) return tell(sender, msg("not-enough-money"));
                ItemStack note = item("PAPER", "&a$" + format(amount) + " Fatal Craft Note", List.of("&7Right-click to redeem"));
                if (note == null) return tell(sender, "&cCould not create a money note.");
                ItemMeta meta = note.getItemMeta();
                meta.getPersistentDataContainer().set(moneyNoteKey, PersistentDataType.DOUBLE, amount);
                note.setItemMeta(meta);
                if (!player.getInventory().addItem(note).isEmpty()) return tell(sender, "&cMake room in your inventory first.");
                changeBalance(player.getUniqueId(), -amount);
                tell(sender, "&aWithdrew $" + format(amount) + ".");
            }
            case "sell", "sellall" -> {
                if (player == null) return playerOnly(sender);
                sellItems(player, cmd.equals("sellall"));
            }
            case "orders" -> {
                if (player == null) return playerOnly(sender);
                openOrders(player);
            }
            case "ah" -> handleAuction(sender, player, args);
            case "sethome" -> {
                if (player == null) return playerOnly(sender);
                if (args.length != 1) return usage(sender, "/sethome <name>");
                PlayerRecord record = record(player.getUniqueId());
                String home = cleanName(args[0]);
                if (!record.homes.containsKey(home) && record.homes.size() >= homeLimit(player)) return tell(sender, "&cYou have reached your home limit.");
                record.homes.put(home, player.getLocation().clone());
                saveData();
                tell(sender, "&aHome '&f" + home + "&a' set.");
            }
            case "home" -> {
                if (player == null) return playerOnly(sender);
                if (args.length != 1) return usage(sender, "/home <name>");
                Location location = record(player.getUniqueId()).homes.get(cleanName(args[0]));
                if (location == null || location.getWorld() == null) return tell(sender, "&cThat home does not exist.");
                beginTeleport(player, location);
            }
            case "homes" -> { if (player == null) return playerOnly(sender); openHomes(player); }
            case "delhome" -> {
                if (player == null) return playerOnly(sender);
                if (args.length != 1) return usage(sender, "/delhome <name>");
                if (record(player.getUniqueId()).homes.remove(cleanName(args[0])) == null) return tell(sender, "&cThat home does not exist.");
                saveData();
                tell(sender, "&aHome deleted.");
            }
            case "tpa", "tpahere" -> {
                if (player == null) return playerOnly(sender);
                if (args.length != 1) return usage(sender, "/" + cmd + " <player>");
                Player target = Bukkit.getPlayerExact(args[0]);
                if (target == null || target == player) return tell(sender, "&cThat player is not online or is yourself.");
                sendRequest(player, target, cmd.equals("tpahere"));
            }
            case "tpaccept" -> { if (player == null) return playerOnly(sender); acceptRequest(player); }
            case "tpdeny" -> { if (player == null) return playerOnly(sender); denyRequest(player); }
            case "tpcancel" -> { if (player == null) return playerOnly(sender); cancelRequest(player); }
            case "tpatoggle" -> {
                if (player == null) return playerOnly(sender);
                if (!tpaDisabled.add(player.getUniqueId())) tpaDisabled.remove(player.getUniqueId());
                tell(sender, tpaDisabled.contains(player.getUniqueId()) ? "&cTeleport requests disabled." : "&aTeleport requests enabled.");
            }
            case "leaderboard" -> { if (player == null) showBalanceTop(sender); else openLeaderboard(player, "balance"); }
            case "stats" -> {
                UUID targetId = player == null ? null : player.getUniqueId();
                String targetName = player == null ? "Console" : player.getName();
                if (args.length > 0) {
                    OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]);
                    targetId = target.getUniqueId();
                    targetName = target.getName() == null ? args[0] : target.getName();
                }
                if (targetId == null) return usage(sender, "/stats <player>");
                PlayerRecord stats = record(targetId);
                tell(sender, "&eStats for &f" + targetName + "&e: Balance &a$" + format(stats.balance) + "&e, Kills &f" + stats.kills + "&e, Deaths &f" + stats.deaths + "&e, Blocks mined &f" + stats.blocksMined + "&e, Orders &f" + stats.ordersCompleted + "&e, Playtime &f" + (stats.playtimeSeconds / 3600) + "h " + (stats.playtimeSeconds / 60 % 60) + "m");
            }
            case "kills", "deaths" -> {
                String key = cmd;
                if (player == null) showStatTop(sender, key); else openLeaderboard(player, key);
            }
            case "menu" -> { if (player == null) return playerOnly(sender); openMainMenu(player); }
            case "fcadmin" -> handleAdmin(sender, player, args);
            default -> { return false; }
        }
        return true;
    }

    private void handleAuction(CommandSender sender, Player player, String[] args) {
        if (player == null) { tell(sender, msg("player-only")); return; }