Cleanup adjust spawn logic

This commit is contained in:
Ben Woo 2023-09-11 16:03:36 +08:00
parent a4a5be20f9
commit 404a2f4183
No known key found for this signature in database
GPG Key ID: FB2A3645536E12C8

View File

@ -60,11 +60,13 @@ public class LoadedMultiverseWorld extends MultiverseWorld {
}
private Location readSpawnFromWorld(World world) {
// TODO: Refactor... this is copy pasted and bad
Location location = world.getSpawnLocation();
// Set the worldspawn to our configspawn
// Verify that location was safe
if (!blockSafety.playerCanSpawnHereSafely(location)) {
if (blockSafety.playerCanSpawnHereSafely(location)) {
return location;
}
if (!this.getAdjustSpawn()) {
Logging.fine("Spawn location from world.dat file was unsafe!!");
Logging.fine("NOT adjusting spawn for '" + this.getAlias() + "' because you told me not to.");
@ -72,7 +74,8 @@ public class LoadedMultiverseWorld extends MultiverseWorld {
Logging.fine("/mvm set adjustspawn true " + this.getAlias());
return location;
}
// If it's not, find a better one.
// The location is not safe, so we need to find a better one.
Logging.warning("Spawn location from world.dat file was unsafe. Adjusting...");
Logging.warning("Original Location: " + locationManipulation.strCoordsRaw(location));
Location newSpawn = safeTTeleporter.getSafeLocation(location,
@ -84,19 +87,19 @@ public class LoadedMultiverseWorld extends MultiverseWorld {
Logging.info("New Spawn for '%s' is located at: %s",
this.getName(), locationManipulation.locationToString(newSpawn));
return newSpawn;
} else {
}
// If it's a standard end world, let's check in a better place:
Logging.fine("Checking for a safe location using top block...");
Location newerSpawn;
newerSpawn = blockSafety.getTopBlock(new Location(world, 0, 0, 0));
if (newerSpawn != null) {
Logging.info("New Spawn for '%s' is located at: %s",
this.getName(), locationManipulation.locationToString(newerSpawn));
return newerSpawn;
} else {
}
Logging.severe("Safe spawn NOT found!!!");
}
}
}
return location;
}