GastinelTpa : correctif securite pseudos (pas de 'exact gagne' en cas de collision, boutons TPA par UUID)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Cette révision appartient à :
Theo GastineletClaude Sonnet 5.5 a révisé 2026-10-11 00:26:21 +02:00
1 Parent 4b7f16c5af
révision 184dbbf82a
3 fichiers modifiés
+113 -30

Aucun fichier ne correspond à votre recherche

+12 -2
Voir le fichier
@@ -150,9 +150,9 @@ public final class TpaCommands {
.append(Component.literal(type == Type.TPA
? nomMoi + " souhaite se téléporter vers toi. "
: nomMoi + " souhaite que tu te téléportes vers lui. ").withStyle(ChatFormatting.YELLOW))
.append(bouton("[Accepter]", "/tpaccept " + PseudoMatcher.tapable(nomMoi), ChatFormatting.GREEN, "Accepter la demande"))
.append(bouton("[Accepter]", "/tpaccept " + PseudoMatcher.argumentBouton(moi.getUUID(), nomMoi), ChatFormatting.GREEN, "Accepter la demande"))
.append(Component.literal(" "))
.append(bouton("[Refuser]", "/tpadeny " + PseudoMatcher.tapable(nomMoi), ChatFormatting.RED, "Refuser la demande"))
.append(bouton("[Refuser]", "/tpadeny " + PseudoMatcher.argumentBouton(moi.getUUID(), nomMoi), ChatFormatting.RED, "Refuser la demande"))
.append(Component.literal(" (expire dans 60 s)").withStyle(ChatFormatting.GRAY));
cible.sendSystemMessage(msg);
return 1;
@@ -171,6 +171,13 @@ public final class TpaCommands {
if (trouvee.isEmpty()) {
return echec(ctx, "Aucune demande de téléportation en attente.");
}
} else if (PseudoMatcher.parseUuidStrict(nomDemandeur).isPresent()) {
// Bouton / UUID : recherche directe dans le registre des demandes, jamais par pseudo.
UUID id = PseudoMatcher.parseUuidStrict(nomDemandeur).get();
trouvee = REGISTRE.find(moi.getUUID(), id);
if (trouvee.isEmpty()) {
return echec(ctx, "Aucune demande en attente de la part de ce joueur (peut-être expirée).");
}
} else {
Cherche c = chercherEnLigne(server, nomDemandeur);
if (c.ambigu != null) return echec(ctx, c.ambigu);
@@ -220,6 +227,9 @@ public final class TpaCommands {
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 if (PseudoMatcher.parseUuidStrict(nomCible).isPresent()) {
annulee = REGISTRE.cancel(moi.getUUID(), PseudoMatcher.parseUuidStrict(nomCible).get());
if (annulee.isEmpty()) return echec(ctx, "Tu n'as aucune demande en cours vers ce joueur.");
} else {
Cherche c = chercherEnLigne(server, nomCible);
if (c.ambigu != null) return echec(ctx, c.ambigu);