GastinelClaims 1.1.2 : /friend ignore les profils Microsoft du cache en mode hors-ligne
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cette révision appartient à :
1 Parent
57f3a208fa
révision
b1fa18248c
5 fichiers modifiés
+40
-3
Aucun fichier ne correspond à votre recherche
@@ -1,7 +1,7 @@
|
||||
org.gradle.jvmargs=-Xmx2G
|
||||
org.gradle.parallel=true
|
||||
|
||||
mod_version=1.1.1
|
||||
mod_version=1.1.2
|
||||
mod_group_id=com.gastinelclaims
|
||||
mod_id=gastinelclaims
|
||||
|
||||
|
||||
@@ -204,7 +204,9 @@ public final class ClaimCommands {
|
||||
for (ServerPlayer sp : server.getPlayerList().getPlayers()) {
|
||||
enLigne.add(new Profil(sp.getUUID(), sp.getGameProfile().getName()));
|
||||
}
|
||||
return PseudoMatcher.resoudre(saisie, enLigne, profilsDuCache(server));
|
||||
List<Profil> cache = profilsDuCache(server);
|
||||
if (!server.usesAuthentication()) cache = PseudoMatcher.garderHorsLigne(cache);
|
||||
return PseudoMatcher.resoudre(saisie, enLigne, cache);
|
||||
}
|
||||
|
||||
/** Lit usercache.json (écrit par le serveur à chaque ajout) ; liste vide en cas de problème. */
|
||||
|
||||
@@ -92,6 +92,22 @@ public final class PseudoMatcher {
|
||||
return new ArrayList<>(out);
|
||||
}
|
||||
|
||||
/** UUID qu'un serveur en mode hors-ligne attribue à ce pseudo (version 3 de « OfflinePlayer:<pseudo> »). */
|
||||
public static UUID uuidHorsLigne(String nom) {
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + nom).getBytes(java.nio.charset.StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
/**
|
||||
* Serveur hors-ligne : ne garde que les profils joignables, c'est-à-dire dont l'UUID est l'UUID hors-ligne du
|
||||
* pseudo. Les UUID Microsoft du cache (venus de whitelist/ops) ne peuvent pas se connecter et rendraient le
|
||||
* pseudo ambigu (deux « totoche10 »).
|
||||
*/
|
||||
public static List<Profil> garderHorsLigne(Collection<Profil> profils) {
|
||||
List<Profil> out = new ArrayList<>();
|
||||
for (Profil p : profils) if (p != null && p.nom() != null && uuidHorsLigne(p.nom()).equals(p.id())) out.add(p);
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Un seul groupe de profils (ex. les joueurs en ligne, ou les amis). */
|
||||
public static Resultat resoudreParmi(String saisie, Collection<Profil> profils) {
|
||||
return resoudre(saisie, profils, List.of());
|
||||
|
||||
@@ -4,7 +4,7 @@ license="MIT"
|
||||
|
||||
[[mods]]
|
||||
modId="gastinelclaims"
|
||||
version="1.1.1"
|
||||
version="1.1.2"
|
||||
displayName="GastinelClaims"
|
||||
authors="Théo Gastinel"
|
||||
description='''Protection de terrains par chunk (/claim, /unclaim, /friend) et zones protégées (spawn incassable, /zoneprotegee). Mod côté serveur uniquement.'''
|
||||
|
||||
@@ -160,4 +160,23 @@ class PseudoMatcherTest {
|
||||
assertEquals(List.of("gabybou201", "totoche10", "gabybou201x"),
|
||||
PseudoMatcher.suggestions(List.of("gabybou201\"", "totoche10", "gabybou201", "\"\"", "gabybou201x")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void horsLigne_uuidConnusDesPseudos() {
|
||||
// Valeurs relevées sur le serveur (usercache.json, 13/10/2026).
|
||||
assertEquals(UUID.fromString("e1769fd1-91f1-377b-b2ac-999a4a7c9c9e"), PseudoMatcher.uuidHorsLigne("totoche10"));
|
||||
assertEquals(UUID.fromString("128c0f10-9643-37ff-941d-afa49cdb30ec"), PseudoMatcher.uuidHorsLigne("gabybou201\""));
|
||||
}
|
||||
|
||||
@Test
|
||||
void horsLigne_uuidMicrosoftIgnore_plusDAmbiguite() {
|
||||
Profil horsLigne = new Profil(PseudoMatcher.uuidHorsLigne("totoche10"), "totoche10");
|
||||
Profil microsoft = new Profil(UUID.fromString("25b71084-eb1b-4988-8cfe-458026f7e514"), "totoche10");
|
||||
assertEquals(Statut.AMBIGU, PseudoMatcher.resoudre("totoche10", List.of(), List.of(horsLigne, microsoft)).statut());
|
||||
var cache = PseudoMatcher.garderHorsLigne(List.of(horsLigne, microsoft));
|
||||
assertEquals(List.of(horsLigne), cache);
|
||||
var r = PseudoMatcher.resoudre("totoche10", List.of(), cache);
|
||||
assertEquals(Statut.TROUVE, r.statut());
|
||||
assertEquals(horsLigne.id(), r.profil().id());
|
||||
}
|
||||
}
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur