GastinelTpa 1.2.0 : /tpacancel, homes (/sethome /home /delhome /homes), protection 15 s apres /rtp, message de mort prive
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Cette révision appartient à :
1 Parent
1e0f9f9071
révision
608528fba1
18 fichiers modifiés
+1098
-9
Aucun fichier ne correspond à votre recherche
@@ -62,6 +62,12 @@ public final class TpaCommands {
|
||||
.suggests(TpaCommands::suggererDemandeurs)
|
||||
.executes(ctx -> repondre(ctx, StringArgumentType.getString(ctx, "joueur"), true))));
|
||||
|
||||
d.register(Commands.literal("tpacancel")
|
||||
.executes(ctx -> annuler(ctx, null))
|
||||
.then(Commands.argument("joueur", StringArgumentType.word())
|
||||
.suggests(TpaCommands::suggererCibles)
|
||||
.executes(ctx -> annuler(ctx, StringArgumentType.getString(ctx, "joueur")))));
|
||||
|
||||
d.register(Commands.literal("tpadeny")
|
||||
.executes(ctx -> repondre(ctx, null, false))
|
||||
.then(Commands.argument("joueur", StringArgumentType.word())
|
||||
@@ -198,6 +204,43 @@ public final class TpaCommands {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** /tpacancel [joueur] : annule la dernière demande envoyée (ou celle vers ce joueur) et prévient la cible. */
|
||||
private static int annuler(CommandContext<CommandSourceStack> ctx, String nomCible) throws CommandSyntaxException {
|
||||
ServerPlayer moi = ctx.getSource().getPlayerOrException();
|
||||
MinecraftServer server = moi.server;
|
||||
nettoyerExpirees(server);
|
||||
|
||||
Optional<Request> annulee;
|
||||
if (nomCible == null) {
|
||||
annulee = REGISTRE.cancel(moi.getUUID(), null);
|
||||
if (annulee.isEmpty()) return echec(ctx, "Tu n'as aucune demande de téléportation en cours à annuler.");
|
||||
} else {
|
||||
ServerPlayer cible = server.getPlayerList().getPlayerByName(nomCible);
|
||||
annulee = cible == null ? Optional.empty() : REGISTRE.cancel(moi.getUUID(), cible.getUUID());
|
||||
if (annulee.isEmpty()) return echec(ctx, "Tu n'as aucune demande en cours vers " + nomCible + ".");
|
||||
}
|
||||
|
||||
ServerPlayer cible = server.getPlayerList().getPlayer(annulee.get().to());
|
||||
String nomVers = cible != null ? cible.getGameProfile().getName() : "?";
|
||||
ctx.getSource().sendSuccess(() -> info("Demande de téléportation à " + nomVers + " annulée."), false);
|
||||
if (cible != null) {
|
||||
cible.sendSystemMessage(info(moi.getGameProfile().getName() + " a annulé sa demande de téléportation."));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static java.util.concurrent.CompletableFuture<com.mojang.brigadier.suggestion.Suggestions>
|
||||
suggererCibles(CommandContext<CommandSourceStack> ctx, com.mojang.brigadier.suggestion.SuggestionsBuilder b)
|
||||
throws CommandSyntaxException {
|
||||
ServerPlayer moi = ctx.getSource().getPlayerOrException();
|
||||
List<String> noms = new ArrayList<>();
|
||||
for (Request r : REGISTRE.pendingFrom(moi.getUUID())) {
|
||||
ServerPlayer p = moi.server.getPlayerList().getPlayer(r.to());
|
||||
if (p != null) noms.add(p.getGameProfile().getName());
|
||||
}
|
||||
return SharedSuggestionProvider.suggest(noms, b);
|
||||
}
|
||||
|
||||
// --- Utilitaires ---
|
||||
|
||||
/** Téléporte vers la position de la destination (même dimension ou non), en gardant le regard du voyageur. */
|
||||
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur