Skip to content

Commit

Permalink
Refactor assault task
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerS1066 committed Aug 11, 2024
1 parent 890d5f8 commit e4082b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -15,14 +16,19 @@
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;

if (assault.getSavedCorrectly().get() != Assault.SavedState.SAVED) {
player.sendMessage(
MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Repair - Could not save file"));
Expand Down

0 comments on commit e4082b3

Please sign in to comment.