Added cause to PlayerTeleportEvent

By: Nathan Adams <dinnerbone@dinnerbone.com>
This commit is contained in:
Bukkit/Spigot
2011-12-04 11:03:32 +00:00
parent c90d52a4d3
commit f3ddaaf09f
3 changed files with 62 additions and 1 deletions

View File

@@ -8,11 +8,52 @@ import org.bukkit.event.Event;
* Holds information for player teleport events
*/
public class PlayerTeleportEvent extends PlayerMoveEvent {
private TeleportCause cause = TeleportCause.UNKNOWN;
public PlayerTeleportEvent(Player player, Location from, Location to) {
super(Type.PLAYER_TELEPORT, player, from, to);
}
public PlayerTeleportEvent(Player player, Location from, Location to, TeleportCause cause) {
super(Type.PLAYER_TELEPORT, player, from, to);
this.cause = cause;
}
public PlayerTeleportEvent(final Event.Type type, Player player, Location from, Location to) {
super(type, player, from, to);
}
public PlayerTeleportEvent(final Event.Type type, Player player, Location from, Location to, TeleportCause cause) {
super(type, player, from, to);
this.cause = cause;
}
/**
* Gets the cause of this teleportation event
* @return Cause of the event
*/
public TeleportCause getCause() {
return cause;
}
public enum TeleportCause {
/**
* Indicates the teleporation was caused by a player throwing an Ender Pearl
*/
ENDER_PEARL,
/**
* Indicates the teleportation was caused by a player executing a command
*/
COMMAND,
/**
* Indicates the teleportation was caused by a plugin
*/
PLUGIN,
/**
* Indicates the teleportation was caused by an event not covered by this enum
*/
UNKNOWN;
}
}