Build Ducky Economy 2.1 – Survival Edition for Minecraft NeoForge 26.2, a multiplayer survival economy mod for DUCKY SMP. Implement as much of this comprehensive design as feasible, prioritizing a working, secure server-authoritative foundation over placeholders. Persistent per-player Ducky Coins balances (default 500), integer amounts, configurable currency, prices, tax and limits; atomic validated transfers and transaction logs; commands /duckyeconomy, /money, /pay, /baltop, /transactions, /shop, /market, /sell, /missions, /arena, /stats and permission-restricted /duckyadmin. Implement server shop and player listings with item escrow, validated purchases and delivery, history, server-configurable prices and safeguards; survival monster rewards without changing normal drops; daily/weekly missions and player statistics; GUI with gold accents and client/server networking where possible. Arena design includes queue, safe dedicated arena generation/templates, teleportation, modes 1v1/2v2/FFA/LMS/tournament, countdown, winner rewards, cleanup and configurable 50% stake penalty only for arena deaths, preserving survival inventory and locations. Admin configuration and secure permissions. Persist data across restarts, guard against negative values, duplication and concurrent transactions. Do not claim unfinished features are implemented: document scope, configuration, installation and limitations clearly. Avoid test files. Prioritize core reliability and usable features if full scope cannot fit.

Kodari AI
KodariNov 11 at 12:46 pm 5
DuckyEconomySurvival
Server-authoritative economy mod for Ducky SMP providing persistent Ducky Coins balances, atomic validated transfers, transaction logging, and configurable currency/tax settings. Implements commands for balance checking, payments, leaderboards, transaction history, player shops with item escrow, server shop, sell system, missions, arena with queue and PvP modes, and statistics tracking. Features GUI with gold accents, permission-restricted admin commands, survival monster rewards, and robust anti-duplication safeguards with full data persistence across restarts.
  • Build a server-authoritative ledger with atomic transfers and per-world persistence.

  • Add balance, payment, leaderboard, history, statistics, and permission-restricted admin commands.

  • Add configurable monster rewards and document the features that remain out of scope.

Built the server-authoritative economy foundation: persistent balances, payments, tax, transaction history, leaderboards, monster rewards, statistics, and admin balance controls.

In survival, players start with 500 Ducky Coins and earn configurable rewards by directly killing hostile monsters. Configuration and installation details are in README.md.

Shops, markets, missions, arenas, and the GUI are not implemented. The build has not been verified.

Stan Vandervoort

Shops, markets, missions, arenas, and the GUI are not implemented maak hier een mod voor

Kodari AI
KodariNov 11 at 1:10 pm 3
  1. Voeg een servershop en spelersmarkt toe met veilige transacties en itembewaring.

  2. Voeg missies met beloningen toe.

  3. Voeg een arena toe zonder de survivalinventaris in gevaar te brengen.

  4. Voeg een bruikbare interface toe en documenteer eventuele beperkingen.

Dagelijkse en wekelijkse missies toegevoegd. Dood vijandige monsters, bekijk je voortgang met /missions en claim je beloning met /missions claim daily of /missions claim weekly. Doelen en beloningen zijn configureerbaar.

Nog niet geïmplementeerd: winkels, spelersmarkt, arena’s en de GUI. Die vereisen onder meer veilige itembewaring en bescherming van survivalinventarissen; de beperkingen staan in README.md. De build is nog niet geverifieerd.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
README.md
settings.gradle
Code
6 454
src/main/java/com/duckysmp/economy/DuckyEconomy.java
package com.duckysmp.economy;

import com.mojang.brigadier.arguments.LongArgumentType;
import com.mojang.brigadier.context.CommandContext;
import java.io.IOException;
import java.util.List;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.permissions.Permissions;
import net.minecraft.world.entity.monster.Monster;
import net.minecraft.world.level.storage.LevelResource;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.RegisterCommandsEvent;
import net.neoforged.neoforge.event.entity.living.LivingDropsEvent;
import net.neoforged.neoforge.event.server.ServerStartingEvent;
import net.neoforged.neoforge.event.server.ServerStoppedEvent;

@Mod("duckyeconomy")
public final class DuckyEconomy {
    private Ledger ledger;

    public DuckyEconomy() {
        NeoForge.EVENT_BUS.addListener(ServerStartingEvent.class, this::start);
        NeoForge.EVENT_BUS.addListener(ServerStoppedEvent.class, event -> ledger = null);
        NeoForge.EVENT_BUS.addListener(RegisterCommandsEvent.class, this::commands);
        NeoForge.EVENT_BUS.addListener(LivingDropsEvent.class, this::monsterDrops);
    }

    private void start(ServerStartingEvent event) {
        try {
            ledger = new Ledger(event.getServer().getWorldPath(LevelResource.ROOT).resolve("ducky-economy"));
        } catch (IOException e) {
            throw new IllegalStateException("Cannot load Ducky Economy; refusing to start with an unsafe ledger", e);
        }
    }

    private void monsterDrops(LivingDropsEvent event) {
        if (ledger == null || !(event.getEntity() instanceof Monster) || !(event.getSource().getEntity() instanceof ServerPlayer player)) return;
        try {
            ledger.reward(player.getUUID(), player.getName().getString());
        } catch (IOException e) {
            System.err.println("Ducky Economy could not save monster reward: " + e);
            player.sendSystemMessage(Component.literal("Ducky Economy could not save your monster reward."));
        }
    }

    private void commands(RegisterCommandsEvent event) {
        var dispatcher = event.getDispatcher();
        dispatcher.register(Commands.literal("duckyeconomy").executes(ctx -> {
            message(ctx.getSource(), "Ducky Economy: /money, /pay, /baltop, /transactions, /stats, /missions. Admin: /duckyadmin set.");
            return 1;
        }));
        dispatcher.register(Commands.literal("money").executes(ctx -> run(ctx, () -> {
            ServerPlayer player = ctx.getSource().getPlayerOrException();
            long balance = ledger.touch(player.getUUID(), player.getName().getString());
            message(ctx.getSource(), "Balance: " + balance + " " + ledger.currency);
        })));
        dispatcher.register(Commands.literal("pay")
            .then(Commands.argument("player", EntityArgument.player())
                .then(Commands.argument("amount", LongArgumentType.longArg(1))
                    .executes(ctx -> run(ctx, () -> {
                        ServerPlayer sender = ctx.getSource().getPlayerOrException();
                        ServerPlayer target = EntityArgument.getPlayer(ctx, "player");
                        long amount = LongArgumentType.getLong(ctx, "amount");
                        ledger.transfer(sender.getUUID(), sender.getName().getString(), target.getUUID(), target.getName().getString(), amount);
                        long tax = amount * ledger.taxPercent / 100;
                        message(ctx.getSource(), "Paid " + target.getName().getString() + ": " + amount + " " + ledger.currency + " (tax " + tax + ").");
                        target.sendSystemMessage(Component.literal(sender.getName().getString() + " paid you " + (amount - tax) + " " + ledger.currency + "."));
                    })))));
        dispatcher.register(Commands.literal("baltop").executes(ctx -> run(ctx, () -> {
            message(ctx.getSource(), "Top balances:");
            show(ctx.getSource(), ledger.top());
        })));
        dispatcher.register(Commands.literal("transactions").executes(ctx -> run(ctx, () -> {
            ServerPlayer player = ctx.getSource().getPlayerOrException();
            message(ctx.getSource(), "Recent transactions:");
            show(ctx.getSource(), ledger.history(player.getUUID()));
        })));
        dispatcher.register(Commands.literal("stats").executes(ctx -> run(ctx, () -> {
            ServerPlayer player = ctx.getSource().getPlayerOrException();
            long balance = ledger.touch(player.getUUID(), player.getName().getString());
            message(ctx.getSource(), "Balance: " + balance + " " + ledger.currency + "; rewarded monster kills: " + ledger.kills(player.getUUID()));
        })));
        dispatcher.register(Commands.literal("missions")
            .executes(ctx -> run(ctx, () -> {
                ServerPlayer player = ctx.getSource().getPlayerOrException();
                show(ctx.getSource(), ledger.missions(player.getUUID()));
                message(ctx.getSource(), "Claim with /missions claim daily or /missions claim weekly. Resets at 00:00 UTC.");
            }))
            .then(Commands.literal("claim")
                .then(Commands.literal("daily").executes(ctx -> run(ctx, () -> {
                    ServerPlayer player = ctx.getSource().getPlayerOrException();
                    long reward = ledger.claimMission(player.getUUID(), player.getName().getString(), false);
                    message(ctx.getSource(), "Daily mission claimed: " + reward + " " + ledger.currency + ".");
                })))
                .then(Commands.literal("weekly").executes(ctx -> run(ctx, () -> {
                    ServerPlayer player = ctx.getSource().getPlayerOrException();
                    long reward = ledger.claimMission(player.getUUID(), player.getName().getString(), true);
                    message(ctx.getSource(), "Weekly mission claimed: " + reward + " " + ledger.currency + ".");
                })))));
        dispatcher.register(Commands.literal("duckyadmin")
            .requires(source -> source.permissions().hasPermission(Permissions.COMMANDS_ADMIN))
            .then(Commands.literal("set")
                .then(Commands.argument("player", EntityArgument.player())
                    .then(Commands.argument("amount", LongArgumentType.longArg(0))
                        .executes(ctx -> run(ctx, () -> {
                            ServerPlayer target = EntityArgument.getPlayer(ctx, "player");
                            long amount = LongArgumentType.getLong(ctx, "amount");
                            ledger.set(target.getUUID(), target.getName().getString(), amount);
                            message(ctx.getSource(), "Set " + target.getName().getString() + " balance to " + amount + " " + ledger.currency + ".");
                        }))))));
    }

    @FunctionalInterface
    private interface Action { void run() throws Exception; }

    private int run(CommandContext<CommandSourceStack> ctx, Action action) {
        if (ledger == null) {
            ctx.getSource().sendFailure(Component.literal("Economy is not ready."));
            return 0;
        }
        try {
            action.run();
            return 1;
        } catch (IllegalArgumentException e) {
            ctx.getSource().sendFailure(Component.literal(e.getMessage()));
        } catch (IOException e) {
            System.err.println("Ducky Economy ledger write failed: " + e);
            ctx.getSource().sendFailure(Component.literal("Economy storage failed; no transaction was applied."));
        } catch (Exception e) {
            ctx.getSource().sendFailure(Component.literal("Command failed: " + e.getMessage()));
        }
        return 0;
    }

    private static void message(CommandSourceStack source, String text) {
        source.sendSuccess(() -> Component.literal(text), false);
    }

    private static void show(CommandSourceStack source, List<String> lines) {
        if (lines.isEmpty()) message(source, "None yet.");
        else for (String line : lines) message(source, line);
    }
}