mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-10-02 16:38:24 +02:00
Improves spawn choice if undefined (#1880)
* Improves spawn choice if undefined #1700 * Just a missing line <.< * Moves the checks into the "default" case
This commit is contained in:
parent
d87fa860e6
commit
fadda43d13
@ -180,6 +180,16 @@ public class SpawnLoader implements Reloadable {
|
||||
switch (priority.toLowerCase().trim()) {
|
||||
case "default":
|
||||
if (world.getSpawnLocation() != null) {
|
||||
if (!isValidSpawnPoint(world.getSpawnLocation())) {
|
||||
for (World spawnWorld : Bukkit.getWorlds()) {
|
||||
if (isValidSpawnPoint(spawnWorld.getSpawnLocation())) {
|
||||
world = spawnWorld;
|
||||
break;
|
||||
}
|
||||
}
|
||||
logger.warning("Seems like AuthMe is unable to find a proper spawn location. "
|
||||
+ "Set a location with the command '/authme setspawn'");
|
||||
}
|
||||
spawnLoc = world.getSpawnLocation();
|
||||
}
|
||||
break;
|
||||
@ -206,9 +216,24 @@ public class SpawnLoader implements Reloadable {
|
||||
}
|
||||
}
|
||||
logger.debug("Fall back to default world spawn location. World: `{0}`", world.getName());
|
||||
|
||||
return world.getSpawnLocation(); // return default location
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a given location is a valid spawn point [!= (0,0,0)].
|
||||
*
|
||||
* @param location The location to check
|
||||
*
|
||||
* @return True upon success, false otherwise
|
||||
*/
|
||||
private boolean isValidSpawnPoint(Location location) {
|
||||
if (location.getX() == 0 && location.getY() == 0 && location.getZ() == 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the location under the given prefix.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user