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

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2020-10-06 18:36:43 +11:00
parent 753bccda7c
commit 5eb09a7d93

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;