diff --git a/src/main/java/net/countercraft/movecraft/warfare/commands/AssaultCommand.java b/src/main/java/net/countercraft/movecraft/warfare/commands/AssaultCommand.java index 2eb0653..8416d47 100644 --- a/src/main/java/net/countercraft/movecraft/warfare/commands/AssaultCommand.java +++ b/src/main/java/net/countercraft/movecraft/warfare/commands/AssaultCommand.java @@ -119,7 +119,7 @@ public boolean onCommand(@NotNull CommandSender commandSender, Command command, } AssaultBeginTask beginTask = new AssaultBeginTask(player, assault); - beginTask.runTaskLater(Movecraft.getInstance(), (20L * Config.AssaultDelay)); + beginTask.runTaskTimer(Movecraft.getInstance(), 20, 20); AssaultBroadcastEvent event = new AssaultBroadcastEvent(assault, broadcast, AssaultBroadcastEvent.Type.PRESTART); diff --git a/src/main/java/net/countercraft/movecraft/warfare/features/assault/tasks/AssaultBeginTask.java b/src/main/java/net/countercraft/movecraft/warfare/features/assault/tasks/AssaultBeginTask.java index 325147d..a2f6a9b 100644 --- a/src/main/java/net/countercraft/movecraft/warfare/features/assault/tasks/AssaultBeginTask.java +++ b/src/main/java/net/countercraft/movecraft/warfare/features/assault/tasks/AssaultBeginTask.java @@ -1,5 +1,6 @@ package net.countercraft.movecraft.warfare.features.assault.tasks; +import net.countercraft.movecraft.warfare.config.Config; import net.countercraft.movecraft.warfare.features.assault.Assault; import net.countercraft.movecraft.warfare.features.assault.events.AssaultBroadcastEvent; import net.countercraft.movecraft.warfare.features.assault.events.AssaultStartEvent; @@ -15,14 +16,20 @@ public class AssaultBeginTask extends BukkitRunnable { private final Player player; private final Assault assault; + private final long start; public AssaultBeginTask(Player player, Assault assault) { this.player = player; this.assault = assault; + start = System.currentTimeMillis(); } @Override public void run() { + if (System.currentTimeMillis() - start < Config.AssaultDelay * 1000L) + return; + + cancel(); if (assault.getSavedCorrectly().get() != Assault.SavedState.SAVED) { player.sendMessage( MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Repair - Could not save file"));