SPIGOT-6168: Fix error with Player.getBedSpawnLocation when world is unloaded while server running

This commit is contained in:
md_5 2020-10-06 18:36:43 +11:00
parent aa8206a857
commit 1f4693a8c3
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -720,14 +720,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public Location getBedSpawnLocation() {
World world = getHandle().server.getWorldServer(getHandle().getSpawnDimension()).getWorld();
WorldServer world = getHandle().server.getWorldServer(getHandle().getSpawnDimension());
BlockPosition bed = getHandle().getSpawn();
if (world != null && bed != null) {
Optional<Vec3D> spawnLoc = EntityHuman.getBed(((CraftWorld) world).getHandle(), bed, getHandle().getSpawnAngle(), getHandle().isSpawnForced(), true);
Optional<Vec3D> spawnLoc = EntityHuman.getBed(world, bed, getHandle().getSpawnAngle(), getHandle().isSpawnForced(), true);
if (spawnLoc.isPresent()) {
Vec3D vec = spawnLoc.get();
return new Location(world, vec.x, vec.y, vec.z);
return new Location(world.getWorld(), vec.x, vec.y, vec.z);
}
}
return null;