pala M-faction-4: /f map (carte ASCII claims 9x9)
This commit is contained in:
@@ -235,7 +235,9 @@ public final class PalaCommands {
|
||||
.then(Commands.literal("home")
|
||||
.executes(command -> fHome(command.getSource())))
|
||||
.then(Commands.literal("top")
|
||||
.executes(command -> fTop(command.getSource()))));
|
||||
.executes(command -> fTop(command.getSource())))
|
||||
.then(Commands.literal("map")
|
||||
.executes(command -> fMap(command.getSource()))));
|
||||
dispatcher.register(Commands.literal("fc")
|
||||
.then(Commands.argument("texte",
|
||||
com.mojang.brigadier.arguments.StringArgumentType.greedyString())
|
||||
@@ -647,7 +649,7 @@ public final class PalaCommands {
|
||||
private static int fHelp(CommandSourceStack source) {
|
||||
source.sendSuccess(() -> Component.literal("§6[Faction] §7/f create|info|invite|join|"
|
||||
+ "leave|disband|kick|transfer|desc|help|claim|unclaim|list|sethome|home|"
|
||||
+ "promote|demote|top"), false);
|
||||
+ "promote|demote|top|map"), false);
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1043,6 +1045,41 @@ public final class PalaCommands {
|
||||
}
|
||||
}
|
||||
|
||||
// M-faction-4 (wiki grades, permission "Voir les territoires") : carte ASCII 9x9
|
||||
// des claims autour du joueur (. = libre, initiale faction, vert = la sienne).
|
||||
private static int fMap(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 mine =
|
||||
fa.byMember(player.getUUID().toString());
|
||||
String dim = player.level().dimension().identifier().toString();
|
||||
int baseX = (player.blockPosition().getX() >> 4) - 4;
|
||||
int baseZ = (player.blockPosition().getZ() >> 4) - 4;
|
||||
StringBuilder out = new StringBuilder("§6[Carte]");
|
||||
for (int dz = 0; dz < 9; dz++) {
|
||||
out.append("\n§7");
|
||||
for (int dx = 0; dx < 9; dx++) {
|
||||
String key = dim + ":" + (baseX + dx) + ":" + (baseZ + dz);
|
||||
fr.surviepote.pala.core.PalaFactions.Faction owner = fa.byClaim(key);
|
||||
if (owner == null) {
|
||||
out.append("§8.");
|
||||
} else if (mine != null && owner.name.equals(mine.name)) {
|
||||
out.append("§a").append(Character.toUpperCase(owner.name.charAt(0)));
|
||||
} else {
|
||||
out.append("§c").append(Character.toUpperCase(owner.name.charAt(0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
out.append("\n§7. = libre, §ainitiale verte = vous§7, §crouge = autres");
|
||||
source.sendSuccess(() -> Component.literal(out.toString()), 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();
|
||||
|
||||
Reference in New Issue
Block a user