mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-08-06 04:23:02 +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);
|
final PreTeleportEvent event = new PreTeleportEvent(teleportee, cause, target);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
|
future.complete(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
teleportee.setLastLocation();
|
teleportee.setLastLocation();
|
||||||
|
@ -183,7 +184,7 @@ public class AsyncTeleport implements IAsyncTeleport {
|
||||||
targetLoc.setX(LocationUtil.getXInsideWorldBorder(targetLoc.getWorld(), targetLoc.getBlockX()));
|
targetLoc.setX(LocationUtil.getXInsideWorldBorder(targetLoc.getWorld(), targetLoc.getBlockX()));
|
||||||
targetLoc.setZ(LocationUtil.getZInsideWorldBorder(targetLoc.getWorld(), targetLoc.getBlockZ()));
|
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;
|
Location loc = targetLoc;
|
||||||
if (LocationUtil.isBlockUnsafeForUser(teleportee, chunk.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())) {
|
if (LocationUtil.isBlockUnsafeForUser(teleportee, chunk.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())) {
|
||||||
if (ess.getSettings().isTeleportSafetyEnabled()) {
|
if (ess.getSettings().isTeleportSafetyEnabled()) {
|
||||||
|
@ -216,6 +217,9 @@ public class AsyncTeleport implements IAsyncTeleport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
future.complete(true);
|
future.complete(true);
|
||||||
|
}).exceptionally(th -> {
|
||||||
|
future.completeExceptionally(th);
|
||||||
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,6 +402,9 @@ public class AsyncTeleport implements IAsyncTeleport {
|
||||||
ess.getServer().getPluginManager().callEvent(pre);
|
ess.getServer().getPluginManager().callEvent(pre);
|
||||||
nowAsync(teleportee, new LocationTarget(pre.getRespawnLocation()), cause, future);
|
nowAsync(teleportee, new LocationTarget(pre.getRespawnLocation()), cause, future);
|
||||||
}
|
}
|
||||||
|
}).exceptionally(th -> {
|
||||||
|
future.completeExceptionally(th);
|
||||||
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue