Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix assault delay #40

Merged
merged 2 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,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"));
Expand Down