pala M-rtp: teleportation aleatoire safe + cooldown 15min (wiki)
This commit is contained in:
@@ -40,6 +40,8 @@ public final class PalaCommands {
|
||||
private static final java.util.Map<java.util.UUID, TpaTask> TPA_QUEUE = new java.util.HashMap<>();
|
||||
// M-msg (wiki commandes) : dernier expediteur par destinataire (pour /r).
|
||||
private static final java.util.Map<java.util.UUID, java.util.UUID> LAST_MSG = new java.util.HashMap<>();
|
||||
// M-rtp (wiki commandes) : dernier /rtp par joueur (tick). Cooldown 15 min (config).
|
||||
private static final java.util.Map<java.util.UUID, Long> RTP_LAST = new java.util.HashMap<>();
|
||||
|
||||
private record TpaRequest(java.util.UUID from, long expireTick) {
|
||||
}
|
||||
@@ -141,6 +143,8 @@ public final class PalaCommands {
|
||||
.executes(command -> baltop(command.getSource())));
|
||||
dispatcher.register(Commands.literal("balance")
|
||||
.executes(command -> balance(command.getSource())));
|
||||
dispatcher.register(Commands.literal("rtp")
|
||||
.executes(command -> rtp(command.getSource())));
|
||||
net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents.END_SERVER_TICK
|
||||
.register(PalaCommands::tickSpawnQueue);
|
||||
net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents.END_SERVER_TICK
|
||||
@@ -237,6 +241,54 @@ public final class PalaCommands {
|
||||
}
|
||||
}
|
||||
|
||||
// M-rtp (wiki commandes) : teleportation aleatoire dans l'overworld, cooldown 15 min.
|
||||
// ECART : pas de limite "3 utilisations par version" (notion de version/serveur faction
|
||||
// sans objet ici) ; rayon borne en config (wiki sans borne).
|
||||
private static int rtp(CommandSourceStack source) {
|
||||
try {
|
||||
ServerPlayer player = source.getPlayerOrException();
|
||||
MinecraftServer server = source.getServer();
|
||||
long cooldown = (long) PalaConfig.get().rtpCooldownMinutes * 60L * 20L;
|
||||
Long last = RTP_LAST.get(player.getUUID());
|
||||
long now = server.getTickCount();
|
||||
if (last != null && now - last < cooldown) {
|
||||
long wait = (cooldown - (now - last)) / 20L;
|
||||
source.sendFailure(Component.literal("§cProchain /rtp dans " + wait + " s."));
|
||||
return 0;
|
||||
}
|
||||
ServerLevel overworld = server.overworld();
|
||||
BlockPos spawn = overworld.getRespawnData().pos();
|
||||
int radius = Math.max(100, PalaConfig.get().rtpRadius);
|
||||
java.util.Random random = new java.util.Random();
|
||||
BlockPos target = null;
|
||||
for (int i = 0; i < 16 && target == null; i++) {
|
||||
int x = spawn.getX() + random.nextInt(radius * 2 + 1) - radius;
|
||||
int z = spawn.getZ() + random.nextInt(radius * 2 + 1) - radius;
|
||||
BlockPos ground = overworld.getHeightmapPos(
|
||||
net.minecraft.world.level.levelgen.Heightmap.Types.MOTION_BLOCKING_NO_LEAVES,
|
||||
new BlockPos(x, 0, z));
|
||||
// Refuse l'ocean profond et les zones trop hautes/basses.
|
||||
if (ground.getY() < overworld.getMinY() + 2 || ground.getY() > 200) {
|
||||
continue;
|
||||
}
|
||||
if (overworld.getFluidState(ground).isSource()
|
||||
|| overworld.getFluidState(ground.above()).isSource()) {
|
||||
continue;
|
||||
}
|
||||
target = ground.above();
|
||||
}
|
||||
if (target == null) {
|
||||
source.sendFailure(Component.literal("§cAucun endroit sur (reessayez)."));
|
||||
return 0;
|
||||
}
|
||||
RTP_LAST.put(player.getUUID(), now);
|
||||
teleportPlayer(player, overworld, target.below());
|
||||
return Command.SINGLE_SUCCESS;
|
||||
} catch (com.mojang.brigadier.exceptions.CommandSyntaxException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// M1 : prospecte les minerais pala dans un cube de rayon N autour du joueur.
|
||||
// Affiche comptes par minerai + histogramme Y (8 bandes de 16) pour amethyste/titane.
|
||||
// Test distribution worldgen (couches 6-10 + deep ocean). Rayon capé à 32 (65^3 lectures).
|
||||
|
||||
@@ -85,6 +85,11 @@ public final class PalaConfig {
|
||||
// M-afk (wiki reglement/grades) : kick apres N minutes sans activite (defaut 10).
|
||||
public int afkKickMinutes = 10;
|
||||
|
||||
// M-rtp (wiki commandes) : cooldown minutes entre deux /rtp (wiki : 15).
|
||||
public int rtpCooldownMinutes = 15;
|
||||
// Rayon max du /rtp autour du spawn (blocs). UNVERIFIED (wiki : "aleatoire", sans borne).
|
||||
public int rtpRadius = 3000;
|
||||
|
||||
// Cooldowns sticks PvP en secondes. UNVERIFIED (durees balance staff, M5).
|
||||
public Map<String, Integer> stickCooldowns = new HashMap<>(Map.of(
|
||||
"heal_stick", 60, "speed_stick", 30, "hyper_jump_stick", 30,
|
||||
@@ -229,7 +234,7 @@ public final class PalaConfig {
|
||||
"crusherResults", "crusherFuels", "crusherInfiniteFuels",
|
||||
"furnaceSmelts", "furnaceFuels",
|
||||
"serverName", "wikiUrl", "discordUrl", "shopUrl",
|
||||
"afkKickMinutes");
|
||||
"afkKickMinutes", "rtpCooldownMinutes", "rtpRadius");
|
||||
boolean complete = true;
|
||||
try (Reader keysReader = Files.newBufferedReader(path)) {
|
||||
com.google.gson.JsonObject obj =
|
||||
|
||||
Reference in New Issue
Block a user