Fix contract with Player.getBedSpawnLocation. Fixes BUKKIT-3525

Getting the bed spawn location is supposed to check if the bed is
valid, however, it currently did not do so.
This commit is contained in:
feildmaster 2013-01-29 10:03:05 -06:00
parent 0576395ddd
commit 37975946a2

View file

@ -608,8 +608,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public Location getBedSpawnLocation() {
World world = getServer().getWorld(getHandle().spawnWorld);
if ((world != null) && (getHandle().getBed() != null)) {
return new Location(world, getHandle().getBed().x, getHandle().getBed().y, getHandle().getBed().z);
ChunkCoordinates bed = getHandle().getBed();
if (world != null) {
bed = EntityHuman.getBed(((CraftWorld) world).getHandle(), bed, getHandle().isRespawnForced());
if (bed != null) {
return new Location(world, bed.x, bed.y, bed.z);
}
}
return null;
}