pala M-faction-2c: /f sethome + /f home multi-dimensions

This commit is contained in:
Anaïs Saraiva
2026-10-19 04:54:03 +02:00
parent 76cc105f19
commit 7878f006bd
4 changed files with 85 additions and 1 deletions
+4
View File
@@ -620,6 +620,10 @@ avant M4 (TODO:crafts-machines).
(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-faction-2c LIVRE 2026-10-19 ~04:50 : /f sethome (chef) + /f home (membres, multi-dim).
ECART : sans grades (GUI, M-faction-3), regle simplifiee chef/membres. Lecon : la ligne
/f list finissait par 4 parentheses (register inclus) — assert endswith trompeur.
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
@@ -197,7 +197,11 @@ public final class PalaCommands {
.then(Commands.literal("unclaimall")
.executes(command -> fUnclaim(command.getSource(), true)))
.then(Commands.literal("list")
.executes(command -> fList(command.getSource()))));
.executes(command -> fList(command.getSource())))
.then(Commands.literal("sethome")
.executes(command -> fSetHome(command.getSource())))
.then(Commands.literal("home")
.executes(command -> fHome(command.getSource()))));
dispatcher.register(Commands.literal("fc")
.then(Commands.argument("texte",
com.mojang.brigadier.arguments.StringArgumentType.greedyString())
@@ -727,6 +731,80 @@ public final class PalaCommands {
}
}
// M-faction-2c : home faction (chef pose, membres utilisent). Sans systeme de grades
// (GUI, M-faction-3) : regle simplifiee, ECART documente.
private static int fSetHome(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 || !faction.owner.equals(player.getUUID().toString())) {
source.sendFailure(Component.literal("§cSeul le chef peut definir le home."));
return 0;
}
net.minecraft.core.BlockPos pos = player.blockPosition();
faction.home = player.level().dimension().identifier().toString() + ":"
+ pos.getX() + ":" + pos.getY() + ":" + pos.getZ();
fa.markDirty();
source.sendSuccess(() -> Component.literal("§6[Faction] §7Home defini."), false);
return Command.SINGLE_SUCCESS;
} catch (com.mojang.brigadier.exceptions.CommandSyntaxException e) {
return 0;
}
}
private static int fHome(CommandSourceStack source) {
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;
}
if (faction.home == null || faction.home.isEmpty()) {
source.sendFailure(Component.literal("§cAucun home defini (/f sethome)."));
return 0;
}
String[] parts = faction.home.split(":");
if (parts.length != 4) {
source.sendFailure(Component.literal("§cHome corrompu."));
return 0;
}
net.minecraft.server.MinecraftServer server = source.getServer();
net.minecraft.server.level.ServerLevel target = null;
for (net.minecraft.server.level.ServerLevel level : server.getAllLevels()) {
if (level.dimension().identifier().toString().equals(parts[0])) {
target = level;
break;
}
}
if (target == null) {
source.sendFailure(Component.literal("§cDimension inconnue."));
return 0;
}
int x;
int y;
int z;
try {
x = Integer.parseInt(parts[1]);
y = Integer.parseInt(parts[2]);
z = Integer.parseInt(parts[3]);
} catch (NumberFormatException e) {
source.sendFailure(Component.literal("§cHome corrompu."));
return 0;
}
teleportPlayer(player, target,
new net.minecraft.core.BlockPos(x, y, z));
return Command.SINGLE_SUCCESS;
} catch (com.mojang.brigadier.exceptions.CommandSyntaxException e) {
return 0;
}
}
private static int fDisband(CommandSourceStack source) {
try {
ServerPlayer player = source.getPlayerOrException();
@@ -32,6 +32,8 @@ public final class PalaFactions {
public List<String> invites = new ArrayList<>();
// M-faction-2 : chunks revendiques ("dimension:x:z").
public List<String> claims = new ArrayList<>();
// M-faction-2c : home ("dimension:x:y:z", vide = non defini).
public String home = "";
}
private final Map<String, Faction> factions = new HashMap<>();
Binary file not shown.