Fix warp messages sending incorrectly with teleport delays (#3696)

Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
This commit is contained in:
pop4959 2021-01-01 19:06:09 -08:00 committed by GitHub
parent e2c6170eba
commit d78832498e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -253,6 +253,7 @@ public class AsyncTeleport implements IAsyncTeleport {
final TeleportWarmupEvent event = new TeleportWarmupEvent(teleportee, cause, target, delay); final TeleportWarmupEvent event = new TeleportWarmupEvent(teleportee, cause, target, delay);
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
future.complete(false);
return; return;
} }
delay = event.getDelay(); delay = event.getDelay();
@ -273,10 +274,12 @@ public class AsyncTeleport implements IAsyncTeleport {
} }
if (cooldown(true, future)) { if (cooldown(true, future)) {
future.complete(false);
return; return;
} }
if (delay <= 0 || teleportOwner.isAuthorized("essentials.teleport.timer.bypass") || teleportee.isAuthorized("essentials.teleport.timer.bypass")) { if (delay <= 0 || teleportOwner.isAuthorized("essentials.teleport.timer.bypass") || teleportee.isAuthorized("essentials.teleport.timer.bypass")) {
if (cooldown(false, future)) { if (cooldown(false, future)) {
future.complete(false);
return; return;
} }
nowAsync(teleportee, target, cause, future); nowAsync(teleportee, target, cause, future);
@ -286,6 +289,7 @@ public class AsyncTeleport implements IAsyncTeleport {
return; return;
} }
} }
future.complete(true);
return; return;
} }
@ -413,10 +417,15 @@ public class AsyncTeleport implements IAsyncTeleport {
future.completeExceptionally(e); future.completeExceptionally(e);
return; return;
} }
otherUser.sendMessage(tl("warpingTo", warp, loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); final String finalWarp = warp;
if (!otherUser.equals(teleportOwner)) { future.thenAccept(success -> {
teleportOwner.sendMessage(tl("warpingTo", warp, loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); if (success) {
} otherUser.sendMessage(tl("warpingTo", finalWarp, loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
if (!otherUser.equals(teleportOwner)) {
teleportOwner.sendMessage(tl("warpingTo", finalWarp, loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
}
}
});
teleport(otherUser, new LocationTarget(loc), chargeFor, cause, future); teleport(otherUser, new LocationTarget(loc), chargeFor, cause, future);
} }