use of pl.themolka.arcade.game.RestartCountdown in project Arcade2 by ShootGame.
the class GeneralCommands method restart.
//
// /restart command
//
@CommandInfo(name = "restart", description = "Cycle to next map", flags = { "f", "force" }, usage = "[-force] [seconds]", permission = "arcade.command.restart")
public void restart(Sender sender, CommandContext context) {
int seconds = context.getParamInt(0, (int) RestartCountdown.DEFAULT_DURATION.getSeconds());
if (seconds < 3) {
seconds = 3;
}
boolean force = context.hasFlag("f") || context.hasFlag("force");
CycleCommandEvent event = new CycleCommandEvent(this.plugin, sender, context, force);
this.plugin.getEventBus().publish(event);
if (event.isCanceled()) {
return;
}
this.plugin.getGames().setNextRestart(true);
Game game = this.plugin.getGames().getCurrentGame();
if (game != null) {
for (Countdown countdown : game.getRunningCountdowns()) {
countdown.cancelCountdown();
}
RestartCountdown countdown = this.plugin.getGames().getRestartCountdown();
countdown.cancelCountdown();
countdown.setDuration(Duration.ofSeconds(seconds));
countdown.countSync();
}
}
use of pl.themolka.arcade.game.RestartCountdown in project Arcade2 by ShootGame.
the class MatchGame method onCycleCountdownAutoStart.
@Handler(priority = Priority.LOWEST)
public void onCycleCountdownAutoStart(MatchEndedEvent event) {
if (!this.isAutoCycle()) {
// auto cycle is disabled
return;
}
GameManager games = event.getPlugin().getGames();
Countdown countdown;
if (games.isNextRestart()) {
countdown = games.getRestartCountdown();
if (!countdown.isTaskRunning()) {
((RestartCountdown) countdown).setDefaultDuration();
}
} else {
countdown = games.getCycleCountdown();
if (!countdown.isTaskRunning()) {
((CycleCountdown) countdown).setDefaultDuration();
}
}
if (!countdown.isTaskRunning()) {
countdown.countSync();
}
}
Aggregations