From 287b636b66fbafd4b723e9a20fb0829917aee2b7 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 2 Mar 2013 09:17:52 +1100 Subject: [PATCH] Pull CraftBukkit #1028 by @EdGruberman to address a few issues with plugins and beds. --- ...ion-itself-instead-of-next-to-bed-Fi.patch | 48 +++++++++++++++++++ ...y-on-CraftPlayer.getBedSpawnLocation.patch | 35 ++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 CraftBukkit-Patches/0034-Return-bed-location-itself-instead-of-next-to-bed-Fi.patch create mode 100644 CraftBukkit-Patches/0035-Remove-dependency-on-CraftPlayer.getBedSpawnLocation.patch diff --git a/CraftBukkit-Patches/0034-Return-bed-location-itself-instead-of-next-to-bed-Fi.patch b/CraftBukkit-Patches/0034-Return-bed-location-itself-instead-of-next-to-bed-Fi.patch new file mode 100644 index 000000000..098534460 --- /dev/null +++ b/CraftBukkit-Patches/0034-Return-bed-location-itself-instead-of-next-to-bed-Fi.patch @@ -0,0 +1,48 @@ +From 66987b733cfa6bae2ce639c9d75cbb5521ca7795 Mon Sep 17 00:00:00 2001 +From: EdGruberman +Date: Fri, 22 Feb 2013 09:23:51 -0700 +Subject: [PATCH] Return bed location itself instead of next to bed; Fixes + BUKKIT-3604 + +--- + .../org/bukkit/craftbukkit/entity/CraftPlayer.java | 22 ++++++++++++++++++++-- + 1 file changed, 20 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 c79f352..8395560 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +@@ -619,10 +619,28 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + ChunkCoordinates bed = getHandle().getBed(); + + if (world != null && bed != null) { +- bed = EntityHuman.getBed(((CraftWorld) world).getHandle(), bed, getHandle().isRespawnForced()); +- if (bed != null) { ++ if (getHandle().isRespawnForced()) { + return new Location(world, bed.x, bed.y, bed.z); + } ++ ++ int cx = bed.x >> 4; ++ int cz = bed.z >> 4; ++ boolean before = world.isChunkLoaded(cx, cz); ++ ++ if (!before) { ++ world.loadChunk(cx, cz); ++ } ++ ++ Location location = null; ++ if (world.getBlockTypeIdAt(bed.x, bed.y, bed.z) == Block.BED.id) { ++ location = new Location(world, bed.x, bed.y, bed.z); ++ } ++ ++ if (!before) { ++ world.unloadChunk(cx, cz); ++ } ++ ++ return location; + } + return null; + } +-- +1.8.1-rc2 + diff --git a/CraftBukkit-Patches/0035-Remove-dependency-on-CraftPlayer.getBedSpawnLocation.patch b/CraftBukkit-Patches/0035-Remove-dependency-on-CraftPlayer.getBedSpawnLocation.patch new file mode 100644 index 000000000..505a2750a --- /dev/null +++ b/CraftBukkit-Patches/0035-Remove-dependency-on-CraftPlayer.getBedSpawnLocation.patch @@ -0,0 +1,35 @@ +From b4cc885d617030d855a069079d7962ae42fe6373 Mon Sep 17 00:00:00 2001 +From: EdGruberman +Date: Tue, 12 Feb 2013 16:17:31 -0700 +Subject: [PATCH] Remove dependency on CraftPlayer.getBedSpawnLocation; Fixes + BUKKIT-3604 + +--- + src/main/java/net/minecraft/server/PlayerList.java | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java +index 6c19ad7..5743822 100644 +--- a/src/main/java/net/minecraft/server/PlayerList.java ++++ b/src/main/java/net/minecraft/server/PlayerList.java +@@ -439,8 +439,15 @@ public abstract class PlayerList { + boolean useTravelAgent = false; // don't use agent for custom worlds or return from THE_END + if (exitWorld != null) { + if ((cause == TeleportCause.END_PORTAL) && (i == 0)) { +- // THE_END -> NORMAL; use bed if available, otherwise default spawn +- exit = ((CraftPlayer) entityplayer.getBukkitEntity()).getBedSpawnLocation(); ++ // THE_END -> NORMAL; use bed if available, otherwise default spawn (code modeled after vanilla moveToWorld) ++ ChunkCoordinates chunkcoordinates = entityplayer.getBed(); ++ CraftWorld spawnWorld = (CraftWorld) this.server.server.getWorld(entityplayer.spawnWorld); ++ if (spawnWorld != null && chunkcoordinates != null) { ++ ChunkCoordinates chunkcoordinates1 = EntityHuman.getBed(spawnWorld.getHandle(), chunkcoordinates, entityplayer.isRespawnForced()); ++ if (chunkcoordinates1 != null) { ++ exit = new Location(spawnWorld, chunkcoordinates1.x + 0.5, chunkcoordinates1.y, chunkcoordinates1.z + 0.5); ++ } ++ } + if (exit == null || ((CraftWorld) exit.getWorld()).getHandle().dimension != 0) { + exit = exitWorld.getWorld().getSpawnLocation(); + } +-- +1.8.1-rc2 +