001 package org.bukkit.event.player;
002
003 import org.bukkit.Location;
004 import org.bukkit.entity.Player;
005 import org.bukkit.event.HandlerList;
006
007 /**
008 * Holds information for player teleport events
009 */
010 public class PlayerTeleportEvent extends PlayerMoveEvent {
011 private static final HandlerList handlers = new HandlerList();
012 private TeleportCause cause = TeleportCause.UNKNOWN;
013
014 public PlayerTeleportEvent(final Player player, final Location from, final Location to) {
015 super(player, from, to);
016 }
017
018 public PlayerTeleportEvent(final Player player, final Location from, final Location to, final TeleportCause cause) {
019 this(player, from, to);
020
021 this.cause = cause;
022 }
023
024 /**
025 * Gets the cause of this teleportation event
026 *
027 * @return Cause of the event
028 */
029 public TeleportCause getCause() {
030 return cause;
031 }
032
033 public enum TeleportCause {
034 /**
035 * Indicates the teleporation was caused by a player throwing an Ender
036 * Pearl
037 */
038 ENDER_PEARL,
039 /**
040 * Indicates the teleportation was caused by a player executing a
041 * command
042 */
043 COMMAND,
044 /**
045 * Indicates the teleportation was caused by a plugin
046 */
047 PLUGIN,
048 /**
049 * Indicates the teleportation was caused by a player entering a
050 * Nether portal
051 */
052 NETHER_PORTAL,
053 /**
054 * Indicates the teleportation was caused by a player entering an End
055 * portal
056 */
057 END_PORTAL,
058 /**
059 * Indicates the teleportation was caused by an event not covered by
060 * this enum
061 */
062 UNKNOWN;
063 }
064
065 @Override
066 public HandlerList getHandlers() {
067 return handlers;
068 }
069
070 public static HandlerList getHandlerList() {
071 return handlers;
072 }
073 }