pala M-faction-2b: /f claim/unclaim/list + /fc chat faction
This commit is contained in:
@@ -616,6 +616,10 @@ avant M4 (TODO:crafts-machines).
|
||||
quota factionMaxClaims=10 UNVERIFIED) + protection stricte (membres+OP, wilderness libre).
|
||||
Lecon : ResourceKey.location() n'existe plus en 26.3 -> identifier(). Grades/regions/elo :
|
||||
M-faction-3. VERIFIE : build SUCCESSFUL, boot Done, 0 erreur. UNVERIFIED en jeu.
|
||||
- M-faction-2b LIVRE 2026-10-19 ~04:40 : commandes claim manquantes du commit precedent
|
||||
(trou detecte a la relecture) + /f list + /fc (chat faction, membres connectes).
|
||||
Lecon : chirurgie brigadier par indices de lignes + parencheck.py avant build.
|
||||
VERIFIE : build SUCCESSFUL, boot Done, 0 erreur. UNVERIFIED en jeu.
|
||||
- M-palaforge LIVRE 2026-10-19 ~03:55 : bloc + BE partagee (3e mode) + gate mineur 14 +
|
||||
table fonte wiki §3.2 (31 items, ratio floor usure) + fuels bois (+buche/planches/baton,
|
||||
lave exclue : seau non rendu) + craft (1 findium + 4 furnaces + 4 briques, positions
|
||||
|
||||
@@ -189,7 +189,21 @@ public final class PalaCommands {
|
||||
com.mojang.brigadier.arguments.StringArgumentType
|
||||
.getString(command, "texte")))))
|
||||
.then(Commands.literal("help")
|
||||
.executes(command -> fHelp(command.getSource()))));
|
||||
.executes(command -> fHelp(command.getSource())))
|
||||
.then(Commands.literal("claim")
|
||||
.executes(command -> fClaim(command.getSource())))
|
||||
.then(Commands.literal("unclaim")
|
||||
.executes(command -> fUnclaim(command.getSource(), false)))
|
||||
.then(Commands.literal("unclaimall")
|
||||
.executes(command -> fUnclaim(command.getSource(), true)))
|
||||
.then(Commands.literal("list")
|
||||
.executes(command -> fList(command.getSource()))));
|
||||
dispatcher.register(Commands.literal("fc")
|
||||
.then(Commands.argument("texte",
|
||||
com.mojang.brigadier.arguments.StringArgumentType.greedyString())
|
||||
.executes(command -> fChat(command.getSource(),
|
||||
com.mojang.brigadier.arguments.StringArgumentType
|
||||
.getString(command, "texte")))));
|
||||
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
|
||||
@@ -594,6 +608,125 @@ public final class PalaCommands {
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
// M-faction-2b : claims (chunk du joueur, quota config) + liste + chat faction.
|
||||
private static int fClaim(CommandSourceStack source) {
|
||||
try {
|
||||
ServerPlayer player = source.getPlayerOrException();
|
||||
fr.surviepote.pala.core.PalaFactions fa =
|
||||
fr.surviepote.pala.core.PalaFactions.get();
|
||||
fr.surviepote.pala.core.PalaFactions.Faction faction =
|
||||
fa.byMember(player.getUUID().toString());
|
||||
if (faction == null) {
|
||||
source.sendFailure(Component.literal("§cVous n'etes dans aucune faction."));
|
||||
return 0;
|
||||
}
|
||||
String key = fr.surviepote.pala.events.PalaFactionProtect.key(
|
||||
player.level(), player.blockPosition());
|
||||
if (fa.byClaim(key) != null) {
|
||||
source.sendFailure(Component.literal("§cChunk deja revendique."));
|
||||
return 0;
|
||||
}
|
||||
if (faction.claims.size()
|
||||
>= fr.surviepote.pala.core.PalaConfig.get().factionMaxClaims) {
|
||||
source.sendFailure(Component.literal("§cLimite de claims atteinte."));
|
||||
return 0;
|
||||
}
|
||||
faction.claims.add(key);
|
||||
fa.markDirty();
|
||||
final int n = faction.claims.size();
|
||||
source.sendSuccess(() -> Component.literal(
|
||||
"§6[Faction] §7Chunk revendique (" + n + ")."), false);
|
||||
return Command.SINGLE_SUCCESS;
|
||||
} catch (com.mojang.brigadier.exceptions.CommandSyntaxException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static int fUnclaim(CommandSourceStack source, boolean all) {
|
||||
try {
|
||||
ServerPlayer player = source.getPlayerOrException();
|
||||
fr.surviepote.pala.core.PalaFactions fa =
|
||||
fr.surviepote.pala.core.PalaFactions.get();
|
||||
fr.surviepote.pala.core.PalaFactions.Faction faction =
|
||||
fa.byMember(player.getUUID().toString());
|
||||
if (faction == null) {
|
||||
source.sendFailure(Component.literal("§cVous n'etes dans aucune faction."));
|
||||
return 0;
|
||||
}
|
||||
if (!faction.owner.equals(player.getUUID().toString())) {
|
||||
source.sendFailure(Component.literal("§cSeul le chef peut unclaim."));
|
||||
return 0;
|
||||
}
|
||||
if (all) {
|
||||
final int n = faction.claims.size();
|
||||
faction.claims.clear();
|
||||
fa.markDirty();
|
||||
source.sendSuccess(() -> Component.literal(
|
||||
"§6[Faction] §7" + n + " claims liberes."), false);
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
String key = fr.surviepote.pala.events.PalaFactionProtect.key(
|
||||
player.level(), player.blockPosition());
|
||||
if (!faction.claims.remove(key)) {
|
||||
source.sendFailure(Component.literal("§cCe chunk n'est pas a vous."));
|
||||
return 0;
|
||||
}
|
||||
fa.markDirty();
|
||||
source.sendSuccess(() -> Component.literal("§6[Faction] §7Chunk libere."), false);
|
||||
return Command.SINGLE_SUCCESS;
|
||||
} catch (com.mojang.brigadier.exceptions.CommandSyntaxException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static int fList(CommandSourceStack source) {
|
||||
java.util.List<String> names =
|
||||
new java.util.ArrayList<>(fr.surviepote.pala.core.PalaFactions.get().names());
|
||||
java.util.Collections.sort(names);
|
||||
StringBuilder out = new StringBuilder("§6[Factions]");
|
||||
if (names.isEmpty()) {
|
||||
out.append("\n§7aucune faction.");
|
||||
}
|
||||
for (String name : names) {
|
||||
fr.surviepote.pala.core.PalaFactions.Faction faction =
|
||||
fr.surviepote.pala.core.PalaFactions.get().byName(name);
|
||||
out.append("\n§e").append(name).append(" §7(").append(faction.members.size())
|
||||
.append(" membres, ").append(faction.claims.size()).append(" claims)");
|
||||
}
|
||||
source.sendSuccess(() -> Component.literal(out.toString()), false);
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
private static int fChat(CommandSourceStack source, String texte) {
|
||||
try {
|
||||
ServerPlayer player = source.getPlayerOrException();
|
||||
fr.surviepote.pala.core.PalaFactions.Faction faction =
|
||||
fr.surviepote.pala.core.PalaFactions.get()
|
||||
.byMember(player.getUUID().toString());
|
||||
if (faction == null) {
|
||||
source.sendFailure(Component.literal("§cVous n'etes dans aucune faction."));
|
||||
return 0;
|
||||
}
|
||||
Component msg = Component.literal("§2[F" + faction.name + "] "
|
||||
+ player.getScoreboardName() + " §f" + texte);
|
||||
for (String uuid : faction.members) {
|
||||
ServerPlayer member;
|
||||
try {
|
||||
member = source.getServer().getPlayerList().getPlayer(
|
||||
java.util.UUID.fromString(uuid));
|
||||
} catch (IllegalArgumentException e) {
|
||||
continue;
|
||||
}
|
||||
if (member != null) {
|
||||
member.sendSystemMessage(msg);
|
||||
}
|
||||
}
|
||||
return Command.SINGLE_SUCCESS;
|
||||
} catch (com.mojang.brigadier.exceptions.CommandSyntaxException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static int fDisband(CommandSourceStack source) {
|
||||
try {
|
||||
ServerPlayer player = source.getPlayerOrException();
|
||||
|
||||
@@ -92,6 +92,15 @@ public final class PalaFactions {
|
||||
return factions.size();
|
||||
}
|
||||
|
||||
/** Noms des factions (cles minuscules d'enregistrement). */
|
||||
public java.util.List<String> names() {
|
||||
java.util.List<String> out = new java.util.ArrayList<>();
|
||||
for (Faction faction : factions.values()) {
|
||||
out.add(faction.name);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public void load() {
|
||||
Path path = file();
|
||||
if (!Files.exists(path)) {
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user