From cd90cec48c5f13b1856350dd3675a9bb5b8171ed Mon Sep 17 00:00:00 2001 From: James Clarke Date: Wed, 15 Feb 2012 19:59:17 +0000 Subject: [PATCH] Implemented TeleportCause enums. Addresses BUKKIT-265 --- .../server/ServerConfigurationManager.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraft/server/ServerConfigurationManager.java b/src/main/java/net/minecraft/server/ServerConfigurationManager.java index 1ee34a70bb..001477a175 100644 --- a/src/main/java/net/minecraft/server/ServerConfigurationManager.java +++ b/src/main/java/net/minecraft/server/ServerConfigurationManager.java @@ -23,6 +23,7 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.Bukkit; // CraftBukkit end @@ -351,8 +352,27 @@ public class ServerConfigurationManager { } } + TeleportCause cause = TeleportCause.UNKNOWN; + int playerEnvironmentId = entityplayer.getBukkitEntity().getWorld().getEnvironment().getId(); + switch (dimension) { + case -1: + cause = TeleportCause.NETHER_PORTAL; + break; + case 0: + if (playerEnvironmentId == -1) { + cause = TeleportCause.NETHER_PORTAL; + } else if (playerEnvironmentId == 1) { + cause = TeleportCause.END_PORTAL; + } + + break; + case 1: + cause = TeleportCause.END_PORTAL; + break; + } + org.bukkit.craftbukkit.PortalTravelAgent pta = new org.bukkit.craftbukkit.PortalTravelAgent(); - PlayerPortalEvent event = new PlayerPortalEvent((Player) entityplayer.getBukkitEntity(), fromLocation, toLocation, pta); + PlayerPortalEvent event = new PlayerPortalEvent((Player) entityplayer.getBukkitEntity(), fromLocation, toLocation, pta, cause); if (entityplayer.dimension == 1) { event.useTravelAgent(false);