GastinelTpa 1.1.1 : recharge 1 s silencieuse, message d'attente, delai TPA cache et messages verts
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Cette révision appartient à :
1 Parent
53cfd9f02f
révision
1e0f9f9071
9 fichiers modifiés
+83
-11
Aucun fichier ne correspond à votre recherche
+1
-1
@@ -19,4 +19,4 @@ Un point n'est examiné que si le chunk **et ses 8 voisins** sont déjà chargé
|
||||
`outils/beaux_spots.py` (+ `nbt_anvil.py`, `beaux-spots-config.json`) : lit une **copie** des fichiers région (jamais le monde en service), note chaque chunk complet (relief, vue, eau 5-30 %, végétation, variété/rareté des biomes, Terralith, sûreté ; pénalités océan profond, désert plat, danger), garde 300 spots espacés d'au moins 96 blocs, score 0-10. Lancer sur cornafserver : `nice -n 19 python3 -I beaux_spots.py --monde <copie-du-monde> --config beaux-spots-config.json --sortie beaux-spots.json` (82 s pour 89 397 chunks). Limite : les scores saturent près de 10 en tête (42 spots ≥ 9,5), le tirage pondéré du top 60 est donc presque uniforme.
|
||||
|
||||
## Build (sur cornafserver)
|
||||
`sh envoyer-et-compiler.sh` depuis le PC, ou `sh build-sur-cornafserver.sh` sur le serveur (JDK 21 jetable, `nice`, 4 Go max). Tests JUnit (`core/`) puis `build/libs/gastineltpa-neoforge-1.21.1-1.1.0.jar`.
|
||||
`sh envoyer-et-compiler.sh` depuis le PC, ou `sh build-sur-cornafserver.sh` sur le serveur (JDK 21 jetable, `nice`, 4 Go max). Tests JUnit (`core/`) puis `build/libs/gastineltpa-neoforge-1.21.1-1.1.1.jar`.
|
||||
@@ -6,5 +6,5 @@ tar czf /tmp/gastineltpa-src.tgz --exclude=build --exclude=.gradle --exclude=bui
|
||||
scp /tmp/gastineltpa-src.tgz cornafserver:gastineltpa-src.tgz
|
||||
ssh cornafserver 'set -e; rm -rf "$HOME/staging/GastinelTpa"; mkdir -p "$HOME/staging/GastinelTpa"; tar xzf "$HOME/gastineltpa-src.tgz" -C "$HOME/staging/GastinelTpa"; rm "$HOME/gastineltpa-src.tgz"; cd "$HOME/staging/GastinelTpa" && sh build-sur-cornafserver.sh'
|
||||
mkdir -p build-out
|
||||
scp 'cornafserver:staging/GastinelTpa/build/libs/gastineltpa-neoforge-1.21.1-1.1.0.jar' build-out/
|
||||
scp 'cornafserver:staging/GastinelTpa/build/libs/gastineltpa-neoforge-1.21.1-1.1.1.jar' build-out/
|
||||
ls -l build-out
|
||||
@@ -1,7 +1,7 @@
|
||||
org.gradle.jvmargs=-Xmx2G
|
||||
org.gradle.parallel=true
|
||||
|
||||
mod_version=1.1.0
|
||||
mod_version=1.1.1
|
||||
mod_group_id=com.gastineltpa
|
||||
mod_id=gastineltpa
|
||||
|
||||
|
||||
@@ -388,7 +388,10 @@ public final class SpawnRtpCommands {
|
||||
private static boolean disponible(CommandContext<CommandSourceStack> ctx, ServerPlayer p, String cmd) {
|
||||
int reste = RECHARGES.remaining(p.getUUID(), cmd);
|
||||
if (reste > 0) {
|
||||
echec(ctx, "Patiente encore " + duree(reste) + " avant de refaire /" + cmd + ".");
|
||||
// Recharge courte : appel ignoré en silence, sauf si afficherMessageRecharge = true.
|
||||
if (Cooldowns.doitAfficherMessage(reste, TpConfig.afficherMessageRecharge())) {
|
||||
echec(ctx, "Patiente encore " + duree(reste) + " avant de refaire /" + cmd + ".");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -401,7 +404,7 @@ public final class SpawnRtpCommands {
|
||||
}
|
||||
ATTENTES.start(p.getUUID(), cmd, p.getX(), p.getY(), p.getZ(), delaiSecondes * 20);
|
||||
ACTIONS.put(p.getUUID(), action);
|
||||
p.sendSystemMessage(info("Téléportation dans " + delaiSecondes + " s, ne bouge pas…"));
|
||||
p.sendSystemMessage(info(Cooldowns.messageAttente(delaiSecondes)));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -16,6 +16,8 @@ public final class TpConfig {
|
||||
public static final ModConfigSpec.IntValue ZONE_X_MIN, ZONE_X_MAX, ZONE_Z_MIN, ZONE_Z_MAX;
|
||||
public static final ModConfigSpec.IntValue ZONE_CENTRE_X, ZONE_CENTRE_Z, ZONE_RAYON;
|
||||
|
||||
public static final ModConfigSpec.BooleanValue AFFICHER_MSG_RECHARGE;
|
||||
public static final ModConfigSpec.IntValue TPA_DELAI;
|
||||
public static final ModConfigSpec.IntValue SPAWN_RTP_RECHARGE;
|
||||
public static final ModConfigSpec.IntValue SPAWN_RTP_TOP;
|
||||
public static final ModConfigSpec.ConfigValue<String> SPOTS_FICHIER;
|
||||
@@ -23,19 +25,29 @@ public final class TpConfig {
|
||||
static {
|
||||
ModConfigSpec.Builder b = new ModConfigSpec.Builder();
|
||||
|
||||
b.comment("Recharges de /spawn et /rtp").push("recharge");
|
||||
AFFICHER_MSG_RECHARGE = b.comment("Afficher « Patiente encore X… » quand /spawn ou /rtp est appelé pendant la recharge ?",
|
||||
"false = l'appel est ignoré en silence.").define("afficherMessageRecharge", false);
|
||||
b.pop();
|
||||
|
||||
b.comment("/tpa, /tpahere : délai technique caché après acceptation (pas de message, pas annulé si le joueur bouge).")
|
||||
.push("tpa");
|
||||
TPA_DELAI = b.comment("Secondes entre l'acceptation et la téléportation.").defineInRange("delaiSecondes", 1, 0, 60);
|
||||
b.pop();
|
||||
|
||||
b.comment("/spawn : téléporte au point de spawn du monde (lu dans level.dat, défini par /setworldspawn).")
|
||||
.push("spawn");
|
||||
SPAWN_DELAI = b.comment("Délai avant téléportation, en secondes (annulé si le joueur bouge ou est blessé).")
|
||||
.defineInRange("delaiSecondes", 3, 0, 60);
|
||||
SPAWN_RECHARGE = b.comment("Temps de recharge entre deux /spawn, en secondes.")
|
||||
.defineInRange("rechargeSecondes", 60, 0, 86400);
|
||||
.defineInRange("rechargeSecondes", 1, 0, 86400);
|
||||
b.pop();
|
||||
|
||||
b.comment("/rtp : téléportation aléatoire dans la zone DÉJÀ générée (jamais de nouveau chunk).")
|
||||
.push("rtp");
|
||||
RTP_DELAI = b.comment("Délai avant téléportation, en secondes.").defineInRange("delaiSecondes", 3, 0, 60);
|
||||
RTP_RECHARGE = b.comment("Temps de recharge entre deux /rtp, en secondes.")
|
||||
.defineInRange("rechargeSecondes", 300, 0, 86400);
|
||||
.defineInRange("rechargeSecondes", 1, 0, 86400);
|
||||
RTP_ESSAIS = b.comment("Nombre d'endroits essayés avant d'abandonner.").defineInRange("essais", 100, 1, 300);
|
||||
b.comment("Zone de tirage (blocs). Mesuré le 09/10/2026 sur une copie de neW512 (outils/beaux_spots.py) :",
|
||||
"89 397 chunks complets, de x -512..6831 et z -5632..1167 (pas un rectangle plein : beaucoup",
|
||||
@@ -67,6 +79,10 @@ public final class TpConfig {
|
||||
return SPEC.isLoaded() ? v.get() : v.getDefault();
|
||||
}
|
||||
|
||||
static boolean afficherMessageRecharge() {
|
||||
return SPEC.isLoaded() ? AFFICHER_MSG_RECHARGE.get() : AFFICHER_MSG_RECHARGE.getDefault();
|
||||
}
|
||||
|
||||
static String get(ModConfigSpec.ConfigValue<String> v) {
|
||||
return SPEC.isLoaded() ? v.get() : v.getDefault();
|
||||
}
|
||||
|
||||
@@ -32,6 +32,12 @@ import java.util.UUID;
|
||||
/** /tpa, /tpahere, /tpaccept, /tpadeny */
|
||||
public final class TpaCommands {
|
||||
|
||||
private record Depart(UUID voyageur, UUID destination, boolean tpa, int[] ticks) {
|
||||
Depart(UUID v, UUID d, boolean tpa, int t) { this(v, d, tpa, new int[]{t}); }
|
||||
}
|
||||
|
||||
private static final List<Depart> EN_COURS = new ArrayList<>();
|
||||
|
||||
private static final TpaRegistry REGISTRE = new TpaRegistry(System::currentTimeMillis);
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -72,6 +78,22 @@ public final class TpaCommands {
|
||||
if (server.getTickCount() % 20 == 0) {
|
||||
nettoyerExpirees(server);
|
||||
}
|
||||
for (java.util.Iterator<Depart> it = EN_COURS.iterator(); it.hasNext(); ) {
|
||||
Depart d = it.next();
|
||||
if (d.ticks()[0]-- > 0) continue;
|
||||
it.remove();
|
||||
ServerPlayer v = server.getPlayerList().getPlayer(d.voyageur());
|
||||
ServerPlayer dest = server.getPlayerList().getPlayer(d.destination());
|
||||
if (v == null || dest == null) {
|
||||
ServerPlayer reste = v != null ? v : dest;
|
||||
if (reste != null) reste.sendSystemMessage(erreur("Téléportation annulée : l'autre joueur s'est déconnecté."));
|
||||
continue;
|
||||
}
|
||||
teleporter(v, dest);
|
||||
String nv = v.getGameProfile().getName(), nd = dest.getGameProfile().getName();
|
||||
v.sendSystemMessage(succes(d.tpa() ? "Tu te téléportes vers " + nd + "." : "Tu es téléporté vers " + nd + "."));
|
||||
dest.sendSystemMessage(succes(nv + " arrive vers toi."));
|
||||
}
|
||||
}
|
||||
|
||||
/** Un joueur qui se déconnecte annule toutes ses invitations (envoyées et reçues). */
|
||||
@@ -79,6 +101,7 @@ public final class TpaCommands {
|
||||
public static void onLogout(PlayerEvent.PlayerLoggedOutEvent event) {
|
||||
if (!(event.getEntity() instanceof ServerPlayer parti)) return;
|
||||
MinecraftServer server = parti.server;
|
||||
EN_COURS.removeIf(d -> d.voyageur().equals(parti.getUUID()) || d.destination().equals(parti.getUUID()));
|
||||
for (Request r : REGISTRE.removeInvolving(parti.getUUID())) {
|
||||
UUID autreId = r.from().equals(parti.getUUID()) ? r.to() : r.from();
|
||||
ServerPlayer autre = server.getPlayerList().getPlayer(autreId);
|
||||
@@ -168,10 +191,10 @@ public final class TpaCommands {
|
||||
// TPA : le demandeur va vers moi. TPAHERE : je vais vers le demandeur.
|
||||
ServerPlayer voyageur = r.type() == Type.TPA ? demandeur : moi;
|
||||
ServerPlayer destination = r.type() == Type.TPA ? moi : demandeur;
|
||||
teleporter(voyageur, destination);
|
||||
|
||||
ctx.getSource().sendSuccess(() -> succes("Demande de " + nomDem + " acceptée."), false);
|
||||
demandeur.sendSystemMessage(succes(nomMoi + " a accepté ta demande de téléportation."));
|
||||
// Délai technique caché (pas de message ni de compte à rebours) ; les messages partent à l'arrivée.
|
||||
EN_COURS.add(new Depart(voyageur.getUUID(), destination.getUUID(), r.type() == Type.TPA,
|
||||
Math.max(0, TpConfig.get(TpConfig.TPA_DELAI)) * 20));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,16 @@ public final class Cooldowns {
|
||||
return commande + "|" + joueur;
|
||||
}
|
||||
|
||||
/** Vrai si le message « Patiente encore… » doit être envoyé (sinon l'appel est ignoré en silence). */
|
||||
public static boolean doitAfficherMessage(int resteSecondes, boolean afficherMessageRecharge) {
|
||||
return resteSecondes > 0 && afficherMessageRecharge;
|
||||
}
|
||||
|
||||
/** Message de délai avant téléportation (singulier si 1 seconde). */
|
||||
public static String messageAttente(int secondes) {
|
||||
return "Veuillez attendre " + secondes + (secondes == 1 ? " seconde" : " secondes") + " sans bouger.";
|
||||
}
|
||||
|
||||
/** Démarre la recharge (durée en secondes ; 0 ou moins = pas de recharge). */
|
||||
public void start(UUID joueur, String commande, int secondes) {
|
||||
if (secondes <= 0) {
|
||||
|
||||
@@ -4,7 +4,7 @@ license="MIT"
|
||||
|
||||
[[mods]]
|
||||
modId="gastineltpa"
|
||||
version="1.1.0"
|
||||
version="1.1.1"
|
||||
displayName="GastinelTpa"
|
||||
authors="Théo Gastinel"
|
||||
description='''Demandes de téléportation entre joueurs (/tpa, /tpahere, /tpaccept, /tpadeny), /spawn, /rtp et /rtp spawn (blocs de commande). Mod côté serveur uniquement.'''
|
||||
|
||||
@@ -11,6 +11,26 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class SpawnRtpCoreTest {
|
||||
|
||||
@Test
|
||||
void rechargeSilencieuseParDefaut() {
|
||||
assertFalse(Cooldowns.doitAfficherMessage(1, false));
|
||||
assertTrue(Cooldowns.doitAfficherMessage(1, true));
|
||||
assertFalse(Cooldowns.doitAfficherMessage(0, true));
|
||||
AtomicLong t = new AtomicLong(0);
|
||||
Cooldowns c = new Cooldowns(t::get);
|
||||
UUID a = UUID.randomUUID();
|
||||
c.start(a, "spawn", 1);
|
||||
assertEquals(1, c.remaining(a, "spawn"));
|
||||
t.set(1_000);
|
||||
assertEquals(0, c.remaining(a, "spawn"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void messageAttente() {
|
||||
assertEquals("Veuillez attendre 3 secondes sans bouger.", Cooldowns.messageAttente(3));
|
||||
assertEquals("Veuillez attendre 1 seconde sans bouger.", Cooldowns.messageAttente(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
void recharge() {
|
||||
AtomicLong t = new AtomicLong(0);
|
||||
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur