Add player-spawn config for stuck players and limit teleport height
- Add PlayerSpawnConfig for separate spawn location when players are stuck in blocks - Add PlayerSpawnConfigLoader for YAML parsing - Update MineConfig with playerSpawn section and getSpawnForStuckPlayer() helper - Update ConfigLoader to include playerSpawn configuration - Update MineFileManager to preserve playerSpawn when saving - Update MineResetHandler.teleportPlayers() to use player-spawn location - Update defaults.yml with player-spawn documentation - Limit findSafeTeleportLocation() to max 3 blocks upward search - Priority: same level nearby, then up (max 3), then down, then diagonal - Prevents teleporting players too high in the air If player-spawn is not configured, falls back to teleport.location for backward compatibility.
This commit is contained in:
parent
0603096f60
commit
bb2e47a917
8 changed files with 195 additions and 16 deletions
|
|
@ -171,11 +171,13 @@ public final class MineResetHandler {
|
|||
}
|
||||
|
||||
/**
|
||||
* Teleports players standing inside the mine to a safe location near the configured destination.
|
||||
* Teleports players standing inside the mine to a safe location.
|
||||
* Uses player-spawn location if configured, otherwise uses teleport location.
|
||||
* Prevents players from suffocating in blocks by finding a safe teleport spot.
|
||||
*/
|
||||
private void teleportPlayers() {
|
||||
var destOpt = mine.getConfig().teleport().getLocation();
|
||||
// Get spawn location for stuck players (player-spawn config) or fall back to teleport location
|
||||
var destOpt = mine.getConfig().getSpawnForStuckPlayer();
|
||||
if (destOpt.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -184,8 +186,8 @@ public final class MineResetHandler {
|
|||
return;
|
||||
}
|
||||
|
||||
// Find a safe teleport location to prevent suffocation
|
||||
Location safeDest = BlockUpdateUtil.findSafeTeleportLocation(dest);
|
||||
// Find a safe teleport location (max 3 blocks up to avoid teleporting too high)
|
||||
Location safeDest = BlockUpdateUtil.findSafeTeleportLocation(dest, 3);
|
||||
|
||||
for (Player p : dest.getWorld().getPlayers()) {
|
||||
if (mine.contains(p.getLocation())) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue