Fixed ejected players being stuck in SPECTATOR gamemode

If the player don't have an island, we try to teleport him to the "gamemode spawn".
If the "gamemode spawn" doesn't exist, we teleport it the hard way to the world's programmatic spawn and switch him back to the default gamemode.
That may not be the correct handling there, but at least it's working and it should prevent most of the cases.

Fixes #382.
This commit is contained in:
Florian CUNY 2019-01-20 09:33:28 +01:00
parent dc61f06554
commit 5cbbbabcbf
2 changed files with 16 additions and 2 deletions

View File

@ -138,6 +138,20 @@ public class LockAndBanListener extends FlagListener {
// Teleport player to their home
if (getIslands().hasIsland(player.getWorld(), player.getUniqueId())) {
getIslands().homeTeleport(player.getWorld(), player);
} // else, TODO: teleport somewhere else?
} else if (getIslands().getSpawn(player.getWorld()).isPresent()) {
// Else, try to teleport him to the world spawn
getIslands().spawnTeleport(player.getWorld(), player);
} else {
// There's nothing much we can do.
// We'll try to teleport him to the spawn...
player.teleport(player.getWorld().getSpawnLocation());
// Switch him back to the default gamemode. He may die, sorry :(
player.setGameMode(getIWM().getDefaultGameMode(player.getWorld()));
// Log
getPlugin().log("Could not teleport '" + player.getName() + "' back to his island or the spawn.");
getPlugin().log("Please consider setting a spawn for this world using the admin setspawn command.");
}
}
}

View File

@ -639,7 +639,7 @@ public class IslandsManager {
player.updateInventory();
}
}
user.sendMessage("commands.island.spawn.teleporting");
player.teleport(spawn.get().getSpawnPoint(World.Environment.NORMAL));