From 8de85b8afbac46b845799dc75eaa54fd1c9fd66d Mon Sep 17 00:00:00 2001 From: sk89q Date: Mon, 11 Apr 2011 17:07:20 -0700 Subject: [PATCH] Fixed potential NPE with bed leave event. --- src/main/java/net/minecraft/server/EntityHuman.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java index 50835358ff..f77ea7cf29 100644 --- a/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java @@ -662,7 +662,12 @@ public abstract class EntityHuman extends EntityLiving { if (this.getBukkitEntity() instanceof Player) { Player player = (Player) this.getBukkitEntity(); 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); server.getPluginManager().callEvent(event); }