From a5ffd223cf54c3c8bec88fc5dd5ad161baeec009 Mon Sep 17 00:00:00 2001 From: William278 Date: Tue, 22 Nov 2022 14:48:46 +0000 Subject: [PATCH] Fix warmup set at 0 not being respected, close #260 --- .../william278/huskhomes/teleport/TimedTeleport.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/net/william278/huskhomes/teleport/TimedTeleport.java b/common/src/main/java/net/william278/huskhomes/teleport/TimedTeleport.java index c6e52d9a..881b464f 100644 --- a/common/src/main/java/net/william278/huskhomes/teleport/TimedTeleport.java +++ b/common/src/main/java/net/william278/huskhomes/teleport/TimedTeleport.java @@ -30,7 +30,7 @@ public class TimedTeleport extends Teleport { this.plugin = plugin; this.startLocation = teleporter.getPosition(); this.startHealth = teleporter.getHealth(); - this.timeLeft = warmupTime; + this.timeLeft = Math.max(warmupTime, 0); this.teleporter = teleporter; } @@ -47,17 +47,17 @@ public class TimedTeleport extends Teleport { .thenApply(resultState -> CompletedTeleport.from(resultState, this)); } + // Check if the teleporter can bypass warmup + if (timeLeft == 0 || teleporter.hasPermission(Permission.BYPASS_TELEPORT_WARMUP.node)) { + return super.execute(); + } + // Check if the teleporter is already warming up to teleport if (plugin.getCache().currentlyOnWarmup.contains(teleporter.uuid)) { return CompletableFuture.completedFuture(TeleportResult.FAILED_ALREADY_TELEPORTING) .thenApply(resultState -> CompletedTeleport.from(resultState, this)); } - // Check if the teleporter can bypass warmup - if (teleporter.hasPermission(Permission.BYPASS_TELEPORT_WARMUP.node)) { - return super.execute(); - } - // Check economy actions for (Settings.EconomyAction economyAction : economyActions) { if (!plugin.validateEconomyCheck(executor, economyAction)) {