diff options
author | feildmaster <admin@feildmaster.com> | 2012-08-04 03:35:53 -0500 |
---|---|---|
committer | feildmaster <admin@feildmaster.com> | 2012-08-04 04:11:21 -0500 |
commit | 9bed5272d3a38c3ccdbb6d79c51c51a76c7e1971 (patch) | |
tree | a2f12dde3c20523a8c713cf1fe89d98b17faccf3 /src/main/java/net/minecraft/server/NetServerHandler.java | |
parent | 823e3fb0c6cd03a3142fdf28438e82969eab4552 (diff) | |
download | craftbukkit-9bed5272d3a38c3ccdbb6d79c51c51a76c7e1971.tar craftbukkit-9bed5272d3a38c3ccdbb6d79c51c51a76c7e1971.tar.gz craftbukkit-9bed5272d3a38c3ccdbb6d79c51c51a76c7e1971.tar.lz craftbukkit-9bed5272d3a38c3ccdbb6d79c51c51a76c7e1971.tar.xz craftbukkit-9bed5272d3a38c3ccdbb6d79c51c51a76c7e1971.zip |
Re-implement code missing from leaving the end. Fixes BUKKIT-2003
Diffstat (limited to 'src/main/java/net/minecraft/server/NetServerHandler.java')
-rw-r--r-- | src/main/java/net/minecraft/server/NetServerHandler.java | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java index e512b2b7..e878ac8a 100644 --- a/src/main/java/net/minecraft/server/NetServerHandler.java +++ b/src/main/java/net/minecraft/server/NetServerHandler.java @@ -14,6 +14,7 @@ import java.util.logging.Level; import java.util.HashSet; import org.bukkit.Location; +import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.inventory.CraftInventoryView; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.util.LazyPlayerSet; @@ -36,6 +37,7 @@ import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.event.player.PlayerToggleSprintEvent; import org.bukkit.event.inventory.*; import org.bukkit.event.inventory.InventoryType.SlotType; +import org.bukkit.event.player.PlayerPortalEvent; import org.bukkit.event.player.PlayerToggleFlightEvent; import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.InventoryView; @@ -1026,7 +1028,26 @@ public class NetServerHandler extends NetHandler { public void a(Packet205ClientCommand packet205clientcommand) { if (packet205clientcommand.a == 1) { if (this.player.viewingCredits) { - this.player = this.minecraftServer.getServerConfigurationManager().moveToWorld(this.player, 0, true); + // CraftBukkit start + org.bukkit.craftbukkit.PortalTravelAgent pta = new org.bukkit.craftbukkit.PortalTravelAgent(); + Location toLocation; + + if (this.player.getBukkitEntity().getBedSpawnLocation() == null) { + CraftWorld cworld = (CraftWorld) this.server.getWorlds().get(0); + ChunkCoordinates chunkcoordinates = cworld.getHandle().getSpawn(); + toLocation = new Location(cworld, chunkcoordinates.x + 0.5, chunkcoordinates.y, chunkcoordinates.z + 0.5); + this.player.netServerHandler.sendPacket(new Packet70Bed(0, 0)); + } else { + toLocation = this.player.getBukkitEntity().getBedSpawnLocation(); + toLocation = new Location(toLocation.getWorld(), toLocation.getX() + 0.5, toLocation.getY(), toLocation.getZ() + 0.5); + } + + PlayerPortalEvent event = new PlayerPortalEvent(this.player.getBukkitEntity(), this.player.getBukkitEntity().getLocation(), toLocation, pta, PlayerPortalEvent.TeleportCause.END_PORTAL); + event.useTravelAgent(false); + + org.bukkit.Bukkit.getServer().getPluginManager().callEvent(event); + this.player = this.minecraftServer.getServerConfigurationManager().moveToWorld(this.player, 0, true, event.getTo()); + // CraftBukkit end } else if (this.player.q().getWorldData().isHardcore()) { if (this.minecraftServer.H() && this.player.name.equals(this.minecraftServer.G())) { this.player.netServerHandler.disconnect("You have died. Game over, man, it\'s game over!"); |