summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java3
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandhome.java5
-rw-r--r--Essentials/src/com/earth2me/essentials/craftbukkit/BedLocationFix.java27
-rw-r--r--EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java5
4 files changed, 35 insertions, 5 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
index f92f9d808..0ae77fbe5 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
@@ -1,5 +1,6 @@
package com.earth2me.essentials;
+import com.earth2me.essentials.craftbukkit.BedLocationFix;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.textreader.IText;
import com.earth2me.essentials.textreader.KeywordReplacer;
@@ -233,7 +234,7 @@ public class EssentialsPlayerListener extends PlayerListener
{
Location loc = user.getHome(user.getLocation());
if (loc == null) {
- loc = user.getBedSpawnLocation();
+ loc = BedLocationFix.getBedSpawnLocation(user);
}
if (loc != null) {
user.setCompassTarget(loc);
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java
index 090cebd4c..60b1d1147 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java
@@ -4,6 +4,7 @@ import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
+import com.earth2me.essentials.craftbukkit.BedLocationFix;
import java.util.List;
import java.util.Locale;
import org.bukkit.Location;
@@ -44,7 +45,7 @@ public class Commandhome extends EssentialsCommand
try
{
if ("bed".equalsIgnoreCase(homeName)) {
- final Location bed = player.getBedSpawnLocation();
+ final Location bed = BedLocationFix.getBedSpawnLocation(player);
if (bed != null)
{
user.getTeleport().teleport(bed, charge);
@@ -57,7 +58,7 @@ public class Commandhome extends EssentialsCommand
final List<String> homes = player.getHomes();
if (homes.isEmpty() && player.equals(user))
{
- final Location loc = player.getBedSpawnLocation();
+ final Location loc = BedLocationFix.getBedSpawnLocation(player);
if (loc == null)
{
if (ess.getSettings().spawnIfNoHome())
diff --git a/Essentials/src/com/earth2me/essentials/craftbukkit/BedLocationFix.java b/Essentials/src/com/earth2me/essentials/craftbukkit/BedLocationFix.java
new file mode 100644
index 000000000..dc4818284
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/craftbukkit/BedLocationFix.java
@@ -0,0 +1,27 @@
+package com.earth2me.essentials.craftbukkit;
+
+import org.bukkit.Location;
+import org.bukkit.World;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.entity.Player;
+
+
+public class BedLocationFix
+{
+ /*
+ * Adds missing null pointer check to getHandle().getBed()
+ */
+ public static Location getBedSpawnLocation(final Player player)
+ {
+ final CraftPlayer cplayer = (CraftPlayer)player;
+ final World world = player.getServer().getWorld(cplayer.getHandle().spawnWorld);
+ if (world != null && cplayer.getHandle().getBed() != null)
+ {
+ return new Location(world, cplayer.getHandle().getBed().x, cplayer.getHandle().getBed().y, cplayer.getHandle().getBed().z);
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java
index 57b842c82..a14f8bb71 100644
--- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java
+++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java
@@ -3,6 +3,7 @@ package com.earth2me.essentials.spawn;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.User;
+import com.earth2me.essentials.craftbukkit.BedLocationFix;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Location;
@@ -31,7 +32,7 @@ public class EssentialsSpawnPlayerListener extends PlayerListener
Location home = user.getHome(user.getLocation());
if (home == null)
{
- home = user.getBedSpawnLocation();
+ home = BedLocationFix.getBedSpawnLocation(user);
}
if (home != null)
{
@@ -51,7 +52,7 @@ public class EssentialsSpawnPlayerListener extends PlayerListener
{
final User user = ess.getUser(event.getPlayer());
- if (!user.isNew() || user.getBedSpawnLocation() != null)
+ if (!user.isNew() || BedLocationFix.getBedSpawnLocation(user) != null)
{
return;
}