mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-07 15:42:19 -07:00
feat: Entity#teleportAsync method with TeleportFlags (#10371)
* feat: Entity#teleportAsync method with TeleportFlags * use method-local class --------- Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
This commit is contained in:
@@ -498,25 +498,31 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ * @param loc Location to teleport to
|
||||
+ * @return A future that will be completed with the result of the teleport
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default java.util.concurrent.CompletableFuture<Boolean> teleportAsync(@NotNull Location loc) {
|
||||
+ return teleportAsync(loc, TeleportCause.PLUGIN);
|
||||
+ default java.util.concurrent.@NotNull CompletableFuture<Boolean> teleportAsync(final @NotNull Location loc) {
|
||||
+ return this.teleportAsync(loc, TeleportCause.PLUGIN);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Loads/Generates(in 1.13+) the Chunk asynchronously, and then teleports the entity when the chunk is ready.
|
||||
+ * @param loc Location to teleport to
|
||||
+ * @param cause Reason for teleport
|
||||
+ * @return A future that will be completed with the result of the teleport
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default java.util.concurrent.CompletableFuture<Boolean> teleportAsync(@NotNull Location loc, @NotNull TeleportCause cause) {
|
||||
+ java.util.concurrent.CompletableFuture<Boolean> future = new java.util.concurrent.CompletableFuture<>();
|
||||
+ loc.getWorld().getChunkAtAsyncUrgently(loc).thenAccept((chunk) -> future.complete(teleport(loc, cause))).exceptionally(ex -> {
|
||||
+ future.completeExceptionally(ex);
|
||||
+ return null;
|
||||
+ });
|
||||
+ return future;
|
||||
+ default java.util.concurrent.@NotNull CompletableFuture<Boolean> teleportAsync(final @NotNull Location loc, final @NotNull TeleportCause cause) {
|
||||
+ final class Holder {
|
||||
+ static final io.papermc.paper.entity.TeleportFlag[] EMPTY_FLAGS = new io.papermc.paper.entity.TeleportFlag[0];
|
||||
+ }
|
||||
+ 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 loc Location to teleport to
|
||||
+ * @param cause Reason for teleport
|
||||
+ * @param teleportFlags Flags to be used in this teleportation
|
||||
+ * @return A future that will be completed with the result of the teleport
|
||||
+ */
|
||||
+ java.util.concurrent.@NotNull CompletableFuture<Boolean> teleportAsync(@NotNull Location loc, @NotNull TeleportCause cause, @NotNull io.papermc.paper.entity.TeleportFlag @NotNull... teleportFlags);
|
||||
+ // Paper end
|
||||
+
|
||||
/**
|
||||
|
Reference in New Issue
Block a user