summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorErik Broes <erikbroes@grum.nl>2012-01-17 22:35:31 +0100
committerErik Broes <erikbroes@grum.nl>2012-01-17 22:35:31 +0100
commitf5f268f939a4acea62c01287451f205715d5dfd6 (patch)
tree9b9b94493fd4fd7dbbddd0582189df8fc204ca49 /src/main
parentb22e727cda3e8a7a4a5953636243fe02f7d1f325 (diff)
downloadcraftbukkit-f5f268f939a4acea62c01287451f205715d5dfd6.tar
craftbukkit-f5f268f939a4acea62c01287451f205715d5dfd6.tar.gz
craftbukkit-f5f268f939a4acea62c01287451f205715d5dfd6.tar.lz
craftbukkit-f5f268f939a4acea62c01287451f205715d5dfd6.tar.xz
craftbukkit-f5f268f939a4acea62c01287451f205715d5dfd6.zip
Implement Player.setBedSpawnLocation(Location). Thanks md_5
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java13
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java13
2 files changed, 22 insertions, 4 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
index 9534c587..5772e4a2 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
@@ -7,6 +7,7 @@ import net.minecraft.server.EntityPlayer;
import net.minecraft.server.NBTTagCompound;
import net.minecraft.server.WorldNBTStorage;
import org.bukkit.Bukkit;
+import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
@@ -185,4 +186,16 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
public boolean hasPlayedBefore() {
return getData() != null;
}
+
+ public Location getBedSpawnLocation() {
+ NBTTagCompound data = getData();
+ if (data.hasKey("SpawnX") && data.hasKey("SpawnY") && data.hasKey("SpawnZ")) {
+ String spawnWorld = data.getString("SpawnWorld");
+ if (spawnWorld.equals("")) {
+ spawnWorld = server.getWorlds().get(0).getName();
+ }
+ return new Location(server.getWorld(spawnWorld), data.getInt("SpawnX"), data.getInt("SpawnY"), data.getInt("SpawnZ"));
+ }
+ return null;
+ }
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 06a43586..81099584 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -11,6 +11,7 @@ import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
+import net.minecraft.server.ChunkCoordinates;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.NBTTagCompound;
import net.minecraft.server.Packet131ItemData;
@@ -545,18 +546,22 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public boolean getAllowFlight() {
return getHandle().itemInWorldManager.player.abilities.canFly;
}
-
+
public void setAllowFlight(boolean flight) {
getHandle().itemInWorldManager.player.abilities.canFly = flight;
}
-
+
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);
- } else {
- return null;
}
+ return null;
+ }
+
+ public void setBedSpawnLocation(Location location) {
+ getHandle().a(new ChunkCoordinates(location.getBlockX(), location.getBlockY(), location.getBlockZ()));
+ getHandle().spawnWorld = location.getWorld().getName();
}
public Map<String, Object> serialize() {