pala M-faction-1c: /f desc + /f help
This commit is contained in:
@@ -180,7 +180,16 @@ public final class PalaCommands {
|
||||
.then(Commands.literal("transfer")
|
||||
.then(Commands.argument("cible", EntityArgument.player())
|
||||
.executes(command -> fTransfer(command.getSource(),
|
||||
EntityArgument.getPlayer(command, "cible"))))));
|
||||
EntityArgument.getPlayer(command, "cible")))))
|
||||
|
||||
.then(Commands.literal("desc")
|
||||
.then(Commands.argument("texte",
|
||||
com.mojang.brigadier.arguments.StringArgumentType.greedyString())
|
||||
.executes(command -> fDesc(command.getSource(),
|
||||
com.mojang.brigadier.arguments.StringArgumentType
|
||||
.getString(command, "texte")))))
|
||||
.then(Commands.literal("help")
|
||||
.executes(command -> fHelp(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
|
||||
@@ -554,6 +563,37 @@ public final class PalaCommands {
|
||||
}
|
||||
}
|
||||
|
||||
// M-faction-1c : description (chef, 140 caracteres max, sans format) + aide.
|
||||
private static int fDesc(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 || !faction.owner.equals(player.getUUID().toString())) {
|
||||
source.sendFailure(Component.literal("§cSeul le chef peut decrire."));
|
||||
return 0;
|
||||
}
|
||||
if (texte.length() > 140 || !texte.matches("[A-Za-z0-9 _.,!?'()-]+")) {
|
||||
source.sendFailure(Component.literal("§c140 caracteres max, sans caracteres speciaux."));
|
||||
return 0;
|
||||
}
|
||||
faction.description = texte;
|
||||
fr.surviepote.pala.core.PalaFactions.get().markDirty();
|
||||
source.sendSuccess(() -> Component.literal(
|
||||
"§6[Faction] §7Description : " + texte), false);
|
||||
return Command.SINGLE_SUCCESS;
|
||||
} catch (com.mojang.brigadier.exceptions.CommandSyntaxException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static int fHelp(CommandSourceStack source) {
|
||||
source.sendSuccess(() -> Component.literal("§6[Faction] §7/f create|info|invite|join|"
|
||||
+ "leave|disband|kick|transfer|desc|help"), false);
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
private static int fDisband(CommandSourceStack source) {
|
||||
try {
|
||||
ServerPlayer player = source.getPlayerOrException();
|
||||
|
||||
Reference in New Issue
Block a user