mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-01-03 22:08:28 +00:00
Fix some futures in AsyncTeleport never completing (#4016)
Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
This commit is contained in:
parent
e5db842dd6
commit
ee5f4b9b42
1 changed files with 8 additions and 1 deletions
|
@ -160,6 +160,7 @@ public class AsyncTeleport implements IAsyncTeleport {
|
|||
final PreTeleportEvent event = new PreTeleportEvent(teleportee, cause, target);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
future.complete(false);
|
||||
return;
|
||||
}
|
||||
teleportee.setLastLocation();
|
||||
|
@ -183,7 +184,7 @@ public class AsyncTeleport implements IAsyncTeleport {
|
|||
targetLoc.setX(LocationUtil.getXInsideWorldBorder(targetLoc.getWorld(), targetLoc.getBlockX()));
|
||||
targetLoc.setZ(LocationUtil.getZInsideWorldBorder(targetLoc.getWorld(), targetLoc.getBlockZ()));
|
||||
}
|
||||
PaperLib.getChunkAtAsync(targetLoc).thenAccept(chunk -> {
|
||||
PaperLib.getChunkAtAsync(targetLoc.getWorld(), targetLoc.getBlockX() >> 4, targetLoc.getBlockZ() >> 4, true, true).thenAccept(chunk -> {
|
||||
Location loc = targetLoc;
|
||||
if (LocationUtil.isBlockUnsafeForUser(teleportee, chunk.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())) {
|
||||
if (ess.getSettings().isTeleportSafetyEnabled()) {
|
||||
|
@ -216,6 +217,9 @@ public class AsyncTeleport implements IAsyncTeleport {
|
|||
}
|
||||
}
|
||||
future.complete(true);
|
||||
}).exceptionally(th -> {
|
||||
future.completeExceptionally(th);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -398,6 +402,9 @@ public class AsyncTeleport implements IAsyncTeleport {
|
|||
ess.getServer().getPluginManager().callEvent(pre);
|
||||
nowAsync(teleportee, new LocationTarget(pre.getRespawnLocation()), cause, future);
|
||||
}
|
||||
}).exceptionally(th -> {
|
||||
future.completeExceptionally(th);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue