pala M-faction-1b: /f kick + /f transfer

This commit is contained in:
Anaïs Saraiva
2026-10-19 04:15:27 +02:00
parent d5a88d4516
commit a57b614de7
3 changed files with 69 additions and 1 deletions
@@ -172,7 +172,15 @@ public final class PalaCommands {
.then(Commands.literal("leave")
.executes(command -> fLeave(command.getSource())))
.then(Commands.literal("disband")
.executes(command -> fDisband(command.getSource()))));
.executes(command -> fDisband(command.getSource())))
.then(Commands.literal("kick")
.then(Commands.argument("cible", EntityArgument.player())
.executes(command -> fKick(command.getSource(),
EntityArgument.getPlayer(command, "cible")))))
.then(Commands.literal("transfer")
.then(Commands.argument("cible", EntityArgument.player())
.executes(command -> fTransfer(command.getSource(),
EntityArgument.getPlayer(command, "cible"))))));
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
@@ -490,6 +498,62 @@ public final class PalaCommands {
}
}
// M-faction-1b : kick (chef, pas sur soi-meme) + transfer (passation chef, debloque /f leave).
private static int fKick(CommandSourceStack source, ServerPlayer cible) {
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 || !faction.owner.equals(player.getUUID().toString())) {
source.sendFailure(Component.literal("§cSeul le chef peut exclure."));
return 0;
}
if (cible.getUUID().equals(player.getUUID())) {
source.sendFailure(Component.literal("§cVous ne pouvez pas vous exclure."));
return 0;
}
if (!faction.members.remove(cible.getUUID().toString())) {
source.sendFailure(Component.literal("§cCe joueur n'est pas dans votre faction."));
return 0;
}
fr.surviepote.pala.core.PalaFactions.get().markDirty();
cible.sendSystemMessage(Component.literal(
"§6[Faction] §7Vous avez ete exclu de " + faction.name + "."));
source.sendSuccess(() -> Component.literal("§6[Faction] §7"
+ cible.getScoreboardName() + " exclu de " + faction.name + "."), false);
return Command.SINGLE_SUCCESS;
} catch (com.mojang.brigadier.exceptions.CommandSyntaxException e) {
return 0;
}
}
private static int fTransfer(CommandSourceStack source, ServerPlayer cible) {
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 || !faction.owner.equals(player.getUUID().toString())) {
source.sendFailure(Component.literal("§cSeul le chef peut transferer."));
return 0;
}
if (!faction.members.contains(cible.getUUID().toString())) {
source.sendFailure(Component.literal("§cCe joueur n'est pas dans votre faction."));
return 0;
}
faction.owner = cible.getUUID().toString();
fr.surviepote.pala.core.PalaFactions.get().markDirty();
source.getServer().getPlayerList().broadcastSystemMessage(
Component.literal("§6[Faction] §e" + cible.getScoreboardName()
+ " §7est le nouveau chef de §e" + faction.name + " §7!"),
false);
return Command.SINGLE_SUCCESS;
} catch (com.mojang.brigadier.exceptions.CommandSyntaxException e) {
return 0;
}
}
private static int fDisband(CommandSourceStack source) {
try {
ServerPlayer player = source.getPlayerOrException();