Fixed potential NPE with bed leave event.

This commit is contained in:
sk89q 2011-04-11 17:07:20 -07:00
parent 86c467cb50
commit 8de85b8afb

View File

@ -662,7 +662,12 @@ public abstract class EntityHuman extends EntityLiving {
if (this.getBukkitEntity() instanceof Player) { if (this.getBukkitEntity() instanceof Player) {
Player player = (Player) this.getBukkitEntity(); Player player = (Player) this.getBukkitEntity();
CraftServer server = ((WorldServer) world).getServer(); CraftServer server = ((WorldServer) world).getServer();
org.bukkit.block.Block bed = ((WorldServer) world).getWorld().getBlockAt(this.b.a, this.b.b, this.b.c); org.bukkit.block.Block bed;
if (chunkcoordinates != null) {
bed = ((WorldServer) world).getWorld().getBlockAt(chunkcoordinates.a, chunkcoordinates.b, chunkcoordinates.c);
} else {
bed = ((WorldServer) world).getWorld().getBlockAt(player.getLocation());
}
PlayerBedLeaveEvent event = new PlayerBedLeaveEvent(player, bed); PlayerBedLeaveEvent event = new PlayerBedLeaveEvent(player, bed);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
} }