Search in sources :

Example 1 with RestartCountdown

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();
    }
}
Also used : Game(pl.themolka.arcade.game.Game) RestartCountdown(pl.themolka.arcade.game.RestartCountdown) CycleCountdown(pl.themolka.arcade.cycle.CycleCountdown) Countdown(pl.themolka.arcade.task.Countdown) RestartCountdown(pl.themolka.arcade.game.RestartCountdown)

Example 2 with RestartCountdown

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();
    }
}
Also used : GameManager(pl.themolka.arcade.game.GameManager) RestartCountdown(pl.themolka.arcade.game.RestartCountdown) CycleCountdown(pl.themolka.arcade.cycle.CycleCountdown) RestartCountdown(pl.themolka.arcade.game.RestartCountdown) CycleCountdown(pl.themolka.arcade.cycle.CycleCountdown) Countdown(pl.themolka.arcade.task.Countdown) Handler(net.engio.mbassy.listener.Handler)

Aggregations

CycleCountdown (pl.themolka.arcade.cycle.CycleCountdown)2 RestartCountdown (pl.themolka.arcade.game.RestartCountdown)2 Countdown (pl.themolka.arcade.task.Countdown)2 Handler (net.engio.mbassy.listener.Handler)1 Game (pl.themolka.arcade.game.Game)1 GameManager (pl.themolka.arcade.game.GameManager)1