diff --git a/PALAMOD_CDC.md b/PALAMOD_CDC.md index a16a382..68fe92c 100644 --- a/PALAMOD_CDC.md +++ b/PALAMOD_CDC.md @@ -544,6 +544,9 @@ avant M4 (TODO:crafts-machines). - M-infos LIVRE 2026-10-19 ~03:00 : /serv /wiki /discord /boutique /couleurs (wiki commandes, liens en config : serverName/wikiUrl/discordUrl/shopUrl). VERIFIE : build SUCCESSFUL, boot Done, 0 erreur, 17 cles config persistees (auto-complete +4). UNVERIFIED en jeu. +- M-eco LIVRE 2026-10-19 ~03:05 : /pay (transfert, fonds verifies) + /baltop (top 10 via + PalaStorage.topMoney) + /balance (solde). ECART : connectes uniquement (wiki suggere pseudo + offline). VERIFIE : build SUCCESSFUL, boot Done, 0 erreur. UNVERIFIED en jeu (2 joueurs). - Client/mod : boucle visuelle OPERATIONNELLE 2026-10-19 (Xvfb :99 + runClient SDL x11 + captures Java Robot + pilotage xdotool + vision_analyze) : menu, Select World, monde New World (creatif, cheats), /give, pose de bloc, inventaire, F3+T. Screens : scratch vis*.png. diff --git a/mods/pala/src/main/java/fr/surviepote/pala/PalaCommands.java b/mods/pala/src/main/java/fr/surviepote/pala/PalaCommands.java index e09f456..df75773 100644 --- a/mods/pala/src/main/java/fr/surviepote/pala/PalaCommands.java +++ b/mods/pala/src/main/java/fr/surviepote/pala/PalaCommands.java @@ -128,6 +128,19 @@ public final class PalaCommands { dispatcher.register(Commands.literal("couleurs") .executes(command -> infoText(command.getSource(), "§6[Pala] §7Couleurs : §00 §11 §22 §33 §44 §55 §66 §77 §88 §99 §aa §bb §cc §dd §ee §ff"))); + dispatcher.register(Commands.literal("pay") + .then(Commands.argument("cible", EntityArgument.player()) + .then(Commands.argument("montant", + com.mojang.brigadier.arguments.DoubleArgumentType + .doubleArg(0.01)) + .executes(command -> pay(command.getSource(), + EntityArgument.getPlayer(command, "cible"), + com.mojang.brigadier.arguments.DoubleArgumentType + .getDouble(command, "montant")))))); + dispatcher.register(Commands.literal("baltop") + .executes(command -> baltop(command.getSource()))); + dispatcher.register(Commands.literal("balance") + .executes(command -> balance(command.getSource()))); net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents.END_SERVER_TICK .register(PalaCommands::tickSpawnQueue); net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents.END_SERVER_TICK @@ -162,6 +175,68 @@ public final class PalaCommands { return Command.SINGLE_SUCCESS; } + // M-eco (wiki commandes/economie) : monnaie persistee (PalaStorage.money). + // /pay : transfert immediat entre connectes (ECART : wiki autorise un pseudo hors ligne ; + // ici connectes uniquement, EntityArgument). /baltop : top 10. /balance : solde. + private static int pay(CommandSourceStack source, ServerPlayer cible, double montant) { + try { + ServerPlayer player = source.getPlayerOrException(); + if (player.getUUID().equals(cible.getUUID())) { + source.sendFailure(Component.literal("§cPaiement vers soi-meme impossible.")); + return 0; + } + PalaStorage.PlayerData from = PalaStorage.get().data(player.getUUID()); + if (from.money < montant) { + source.sendFailure(Component.literal("§cFonds insuffisants (solde : " + + String.format("%.2f", from.money) + ").")); + return 0; + } + from.money -= montant; + PalaStorage.get().data(cible.getUUID()).money += montant; + PalaStorage.get().markDirty(); + player.sendSystemMessage(Component.literal("§6[Pala] §7Vous avez envoye §e" + + String.format("%.2f", montant) + " §7a " + cible.getScoreboardName() + ".")); + cible.sendSystemMessage(Component.literal("§6[Pala] §7Vous avez recu §e" + + String.format("%.2f", montant) + " §7de " + player.getScoreboardName() + ".")); + return Command.SINGLE_SUCCESS; + } catch (com.mojang.brigadier.exceptions.CommandSyntaxException e) { + return 0; + } + } + + private static int baltop(CommandSourceStack source) { + StringBuilder out = new StringBuilder("§6[Joueurs les plus riches]"); + java.util.List> top = + PalaStorage.get().topMoney(10); + if (top.isEmpty()) { + out.append("\n§7aucun joueur connu."); + } + int rank = 1; + for (java.util.Map.Entry entry : top) { + ServerPlayer online = source.getServer().getPlayerList() + .getPlayer(java.util.UUID.fromString(entry.getKey())); + String name = online == null + ? entry.getKey().substring(0, 8) + "..." : online.getScoreboardName(); + out.append("\n§e").append(rank).append(". §7").append(name).append(" : §a") + .append(String.format("%.2f", entry.getValue())); + rank++; + } + source.sendSuccess(() -> Component.literal(out.toString()), false); + return Command.SINGLE_SUCCESS; + } + + private static int balance(CommandSourceStack source) { + try { + ServerPlayer player = source.getPlayerOrException(); + double money = PalaStorage.get().data(player.getUUID()).money; + source.sendSuccess(() -> Component.literal( + "§6[Pala] §7Solde : §e" + String.format("%.2f", money)), false); + return Command.SINGLE_SUCCESS; + } catch (com.mojang.brigadier.exceptions.CommandSyntaxException e) { + return 0; + } + } + // M1 : prospecte les minerais pala dans un cube de rayon N autour du joueur. // Affiche comptes par minerai + histogramme Y (8 bandes de 16) pour amethyste/titane. // Test distribution worldgen (couches 6-10 + deep ocean). Rayon capé à 32 (65^3 lectures). diff --git a/mods/pala/src/main/java/fr/surviepote/pala/core/PalaStorage.java b/mods/pala/src/main/java/fr/surviepote/pala/core/PalaStorage.java index cf4a140..b406eb4 100644 --- a/mods/pala/src/main/java/fr/surviepote/pala/core/PalaStorage.java +++ b/mods/pala/src/main/java/fr/surviepote/pala/core/PalaStorage.java @@ -107,4 +107,15 @@ public final class PalaStorage { public int playerCount() { return players.size(); } + + /** Top N joueurs par monnaie (M-eco, /baltop). UUID string -> money. */ + public java.util.List> topMoney(int n) { + java.util.List> out = new java.util.ArrayList<>(); + for (java.util.Map.Entry entry : players.entrySet()) { + out.add(new java.util.AbstractMap.SimpleEntry<>(entry.getKey(), + entry.getValue().money)); + } + out.sort((a, b) -> Double.compare(b.getValue(), a.getValue())); + return out.subList(0, Math.min(n, out.size())); + } } diff --git a/server/mods/pala-0.2.1.jar b/server/mods/pala-0.2.1.jar index b46eb21..3d08998 100644 Binary files a/server/mods/pala-0.2.1.jar and b/server/mods/pala-0.2.1.jar differ