Skip to content
Merged
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 @@ -15,6 +15,7 @@
import java.time.ZonedDateTime;
import java.time.temporal.TemporalAdjusters;
import java.util.ArrayList;
import java.util.logging.Level;

public class GlobalReviveUnDeathBan extends BukkitRunnable {
private final AugmentedHardcore plugin;
Expand All @@ -32,7 +33,8 @@ public void start() {
if (!this.configuration.isEnabled()) {
return;
}
this.task = this.runTaskTimerAsynchronously(this.plugin, 1200L, 1200L);
this.plugin.getLogger().log(Level.INFO, "GlobalReviveUnDeathBan enabled. Next run scheduled for {0}.", this.nextRunAt);
this.task = this.runTaskTimer(this.plugin, 1200L, 1200L);
}

public void stop() {
Expand All @@ -56,13 +58,19 @@ public void run() {
return;
}

ZonedDateTime now = ZonedDateTime.now(this.configuration.getTimezone());
if (now.isBefore(this.nextRunAt)) {
return;
}
try {
ZonedDateTime now = ZonedDateTime.now(this.configuration.getTimezone());
if (now.isBefore(this.nextRunAt)) {
return;
}

this.plugin.getServerRepository().getServerData(this.plugin.getServer()).thenAcceptAsync(this::runGlobalReset, this.plugin.getExecutor());
this.nextRunAt = computeNextRun(now.plusSeconds(1));
this.plugin.getLogger().log(Level.INFO, "Running GlobalReviveUnDeathBan at {0}.", now);
this.plugin.getServerRepository().getServerData(this.plugin.getServer()).thenAcceptAsync(this::runGlobalReset, this.plugin.getExecutor());
this.nextRunAt = computeNextRun(now.plusSeconds(1));
this.plugin.getLogger().log(Level.INFO, "GlobalReviveUnDeathBan completed. Next run scheduled for {0}.", this.nextRunAt);
} catch (Exception ex) {
this.plugin.getLogger().log(Level.SEVERE, "GlobalReviveUnDeathBan failed to execute.", ex);
}
}

private void runGlobalReset(ServerData serverData) {
Expand Down