diff options
author | EdGruberman <ed@rjump.com> | 2013-01-22 18:36:03 -0700 |
---|---|---|
committer | feildmaster <admin@feildmaster.com> | 2013-01-23 20:11:01 -0600 |
commit | 9df87d339971b55cd8bf0bbfea2fdc031bd0bd4c (patch) | |
tree | 75e97c733c3555f9fb3b4ab873b3b5ac571d9ae7 /src/main/java/net/minecraft/server/PlayerList.java | |
parent | 488e45b4ff8cb0f2811d78887fd6aa2ee0b3ebfb (diff) | |
download | craftbukkit-9df87d339971b55cd8bf0bbfea2fdc031bd0bd4c.tar craftbukkit-9df87d339971b55cd8bf0bbfea2fdc031bd0bd4c.tar.gz craftbukkit-9df87d339971b55cd8bf0bbfea2fdc031bd0bd4c.tar.lz craftbukkit-9df87d339971b55cd8bf0bbfea2fdc031bd0bd4c.tar.xz craftbukkit-9df87d339971b55cd8bf0bbfea2fdc031bd0bd4c.zip |
Compensate for allow-nether/allow-end as false; Fixes BUKKIT-3466
When either of those settings are false, the worlds are not loaded and
therefore will not be targeted for portal exits. Existing worlds are
iterated directly to avoid defaulting to the first world if a direct
dimension match is not found.
Plugins must also specify exit from custom Bukkit worlds to comply with
original commit: https://github.com/Bukkit/CraftBukkit/commit/2dc2af0
This commit introduces a constant to clarify the dependency on the
CraftBukkit implementation of custom worlds having a dimension offset.
Diffstat (limited to 'src/main/java/net/minecraft/server/PlayerList.java')
-rw-r--r-- | src/main/java/net/minecraft/server/PlayerList.java | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java index 2fb83cf6..f669a00b 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -424,23 +424,35 @@ public abstract class PlayerList { // CraftBukkit start - Replaced the standard handling of portals with a more customised method. public void changeDimension(EntityPlayer entityplayer, int i, TeleportCause cause) { - WorldServer exitWorld = this.server.getWorldServer(i); + WorldServer exitWorld = null; + if (entityplayer.dimension < CraftWorld.CUSTOM_DIMENSION_OFFSET) { // plugins must specify exit from custom Bukkit worlds + // only target existing worlds (compensate for allow-nether/allow-end as false) + for (WorldServer world : this.server.worlds) { + if (world.dimension == i) { + exitWorld = world; + } + } + } + Location enter = entityplayer.getBukkitEntity().getLocation(); Location exit = null; - if ((cause == TeleportCause.END_PORTAL) && (i == 0)) { - // THE_END -> NORMAL; use bed if available - exit = ((CraftPlayer) entityplayer.getBukkitEntity()).getBedSpawnLocation(); - } - if (exit == null) { - exit = this.calculateTarget(enter, exitWorld); + if (exitWorld != null) { + if ((cause == TeleportCause.END_PORTAL) && (i == 0)) { + // THE_END -> NORMAL; use bed if available + exit = ((CraftPlayer) entityplayer.getBukkitEntity()).getBedSpawnLocation(); + } + if (exit == null) { + exit = this.calculateTarget(enter, exitWorld); + } } - TravelAgent agent = (TravelAgent) ((CraftWorld) exit.getWorld()).getHandle().s(); + TravelAgent agent = exit != null ? (TravelAgent) ((CraftWorld) exit.getWorld()).getHandle().s() : null; PlayerPortalEvent event = new PlayerPortalEvent(entityplayer.getBukkitEntity(), enter, exit, agent, cause); Bukkit.getServer().getPluginManager().callEvent(event); if (event.isCancelled() || event.getTo() == null) { return; } + exit = event.useTravelAgent() ? event.getPortalTravelAgent().findOrCreate(exit) : event.getTo(); exitWorld = ((CraftWorld) exit.getWorld()).getHandle(); |