From 7ba1ced7e337a854e7bfac32d82355600973ba72 Mon Sep 17 00:00:00 2001 From: Jan Trummer Date: Sun, 26 Jan 2025 14:44:26 +0100 Subject: [PATCH] Add entity as method for teleportAsync --- .../main/java/org/bukkit/entity/Entity.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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 ddf7829eee5e..e9edb1ca7d70 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Entity.java +++ b/paper-api/src/main/java/org/bukkit/entity/Entity.java @@ -235,6 +235,25 @@ final class Holder { return this.teleportAsync(loc, cause, Holder.EMPTY_FLAGS); } + /** + * Loads/Generates(in 1.13+) the Chunk asynchronously, and then teleports the entity when the chunk is ready. + * @param destination Entity to teleport to + * @return A future that will be completed with the result of the teleport + */ + default java.util.concurrent.@NotNull CompletableFuture teleportAsync(final @NotNull Entity destination) { + return this.teleportAsync(destination.getLocation(), TeleportCause.PLUGIN); + } + + /** + * Loads/Generates(in 1.13+) the Chunk asynchronously, and then teleports the entity when the chunk is ready. + * @param destination Entity to teleport to + * @param cause Reason for teleport + * @return A future that will be completed with the result of the teleport + */ + default java.util.concurrent.@NotNull CompletableFuture teleportAsync(final @NotNull Entity destination, final @NotNull TeleportCause cause) { + return this.teleportAsync(destination.getLocation(), cause); + } + /** * Loads/Generates(in 1.13+) the Chunk asynchronously, and then teleports the entity when the chunk is ready. * @param loc Location to teleport to