diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/TeleportCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/TeleportCommand.java
index 0cc63cfdbe..42ab9fd501 100644
--- a/paper-api/src/main/java/org/bukkit/command/defaults/TeleportCommand.java
+++ b/paper-api/src/main/java/org/bukkit/command/defaults/TeleportCommand.java
@@ -5,6 +5,7 @@ import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class TeleportCommand extends VanillaCommand {
public TeleportCommand() {
@@ -31,7 +32,7 @@ public class TeleportCommand extends VanillaCommand {
sender.sendMessage("Can't find user " + args[1] + ". No tp.");
} else {
Command.broadcastCommandMessage(sender, "Teleporting " + victim.getName() + " to " + target.getName());
- victim.teleport(target);
+ victim.teleport(target, TeleportCause.COMMAND);
}
return true;
diff --git a/paper-api/src/main/java/org/bukkit/entity/Entity.java b/paper-api/src/main/java/org/bukkit/entity/Entity.java
index 9b0ab70f38..eca0a8a25b 100644
--- a/paper-api/src/main/java/org/bukkit/entity/Entity.java
+++ b/paper-api/src/main/java/org/bukkit/entity/Entity.java
@@ -8,6 +8,7 @@ import org.bukkit.util.Vector;
import java.util.List;
import java.util.UUID;
+import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
/**
* Represents a base entity in the world
@@ -50,6 +51,15 @@ public interface Entity {
*/
public boolean teleport(Location location);
+ /**
+ * Teleports this entity to the given location
+ *
+ * @param location New location to teleport this entity to
+ * @praram cause The cause of this teleportation
+ * @return true
if the teleport was successful
+ */
+ public boolean teleport(Location location, TeleportCause cause);
+
/**
* Teleports this entity to the target Entity
*
@@ -58,6 +68,15 @@ public interface Entity {
*/
public boolean teleport(Entity destination);
+ /**
+ * Teleports this entity to the target Entity
+ *
+ * @param destination Entity to teleport this entity to
+ * @praram cause The cause of this teleportation
+ * @return true
if the teleport was successful
+ */
+ public boolean teleport(Entity destination, TeleportCause cause);
+
/**
* Returns a list of entities within a bounding box defined by x,y,z centered around player
*
diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerTeleportEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerTeleportEvent.java
index 07f520b332..667cb33e5a 100644
--- a/paper-api/src/main/java/org/bukkit/event/player/PlayerTeleportEvent.java
+++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerTeleportEvent.java
@@ -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;
+ }
}