From 37975946a274889c647294283afa6c1366481264 Mon Sep 17 00:00:00 2001 From: feildmaster Date: Tue, 29 Jan 2013 10:03:05 -0600 Subject: [PATCH] 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. --- .../java/org/bukkit/craftbukkit/entity/CraftPlayer.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index f0e24d2f4f..6adc3cd048 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -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; }