Search in sources :

Example 1 with Countdown

use of pl.themolka.arcade.task.Countdown in project Arcade2 by ShootGame.

the class GeneralCommands method cancel.

// 
// /cancel command
// 
@CommandInfo(name = "cancel", description = "Cancel current countdown", flags = { "f", "force" }, usage = "[-force]", permission = "arcade.command.cancel")
public void cancel(Sender sender, CommandContext context) {
    boolean paramForce = context.hasFlag("f") || context.hasFlag("force");
    Game game = this.plugin.getGames().getCurrentGame();
    if (game == null) {
        throw new CommandException("Could not cancel right now. Please try again later.");
    }
    List<Countdown> countdowns = game.getRunningCountdowns();
    if (countdowns.isEmpty()) {
        throw new CommandException("No countdowns running right now.");
    }
    int i = 0;
    for (Countdown countdown : game.getRunningCountdowns()) {
        if (countdown.cancelCountdown()) {
            countdown.setForcedCancel(paramForce);
            i++;
        }
    }
    if (i != 0) {
        sender.sendSuccess("Successfully canceled " + i + " countdown(s).");
    } else {
        throw new CommandException("No countdowns could be canceled right now.");
    }
}
Also used : Game(pl.themolka.arcade.game.Game) CycleCountdown(pl.themolka.arcade.cycle.CycleCountdown) Countdown(pl.themolka.arcade.task.Countdown) RestartCountdown(pl.themolka.arcade.game.RestartCountdown)

Example 2 with Countdown

use of pl.themolka.arcade.task.Countdown in project Arcade2 by ShootGame.

the class GeneralCommands method cycle.

// 
// /cycle command
// 
@CommandInfo(name = "cycle", description = "Cycle to next map", usage = "[seconds]", permission = "arcade.command.cycle")
public void cycle(Sender sender, CommandContext context) {
    int paramSeconds = context.getParamInt(0, (int) CycleCountdown.DEFAULT_DURATION.getSeconds());
    OfflineMap nextMap = this.plugin.getGames().getQueue().getNextMap();
    if (nextMap == null) {
        String reason = "The map queue is empty.";
        if (sender.hasPermission("arcade.command.setnext")) {
            reason += " Set next map using /setnext <map...>.";
        }
        throw new CommandException(reason);
    }
    CycleCommandEvent commandEvent = new CycleCommandEvent(this.plugin, sender, context, nextMap);
    this.plugin.getEventBus().publish(commandEvent);
    if (commandEvent.isCanceled()) {
        return;
    }
    int seconds = paramSeconds;
    if (seconds < 3) {
        seconds = 3;
    }
    CycleStartEvent startEvent = new CycleStartEvent(this.plugin, nextMap, seconds);
    this.plugin.getEventBus().publish(startEvent);
    this.plugin.getGames().setNextRestart(false);
    Game game = this.plugin.getGames().getCurrentGame();
    if (game != null) {
        for (Countdown countdown : game.getRunningCountdowns()) {
            countdown.cancelCountdown();
        }
        CycleCountdown countdown = this.plugin.getGames().getCycleCountdown();
        countdown.cancelCountdown();
        countdown.setDuration(Duration.ofSeconds(seconds));
        countdown.countSync();
    }
}
Also used : Game(pl.themolka.arcade.game.Game) CycleStartEvent(pl.themolka.arcade.cycle.CycleStartEvent) CycleCountdown(pl.themolka.arcade.cycle.CycleCountdown) OfflineMap(pl.themolka.arcade.map.OfflineMap) CycleCountdown(pl.themolka.arcade.cycle.CycleCountdown) Countdown(pl.themolka.arcade.task.Countdown) RestartCountdown(pl.themolka.arcade.game.RestartCountdown)

Example 3 with Countdown

use of pl.themolka.arcade.task.Countdown in project Arcade2 by ShootGame.

the class GeneralCommands method recycle.

// 
// /recycle command
// 
@CommandInfo(name = "recycle", description = "Re-cycle current map", usage = "[seconds]", permission = "arcade.command.cycle")
public void recycle(Sender sender, CommandContext context) {
    if (this.plugin.getGames().getCurrentGame() == null) {
        throw new CommandException("Game is not running right now.");
    }
    MapQueue queue = this.plugin.getGames().getQueue();
    queue.setNextMap(this.plugin.getGames().getCurrentGame().getMap().getMapInfo());
    CycleCommandEvent commandEvent = new CycleCommandEvent(this.plugin, sender, context, queue.getNextMap());
    this.plugin.getEventBus().publish(commandEvent);
    if (commandEvent.isCanceled()) {
        return;
    }
    int seconds = context.getParamInt(0, (int) CycleCountdown.DEFAULT_DURATION.getSeconds());
    if (seconds < 3) {
        seconds = 3;
    }
    CycleStartEvent startEvent = new CycleStartEvent(this.plugin, queue.getNextMap(), seconds);
    this.plugin.getEventBus().publish(startEvent);
    this.plugin.getGames().setNextRestart(false);
    Game game = this.plugin.getGames().getCurrentGame();
    if (game != null) {
        for (Countdown countdown : game.getRunningCountdowns()) {
            countdown.cancelCountdown();
        }
        CycleCountdown countdown = this.plugin.getGames().getCycleCountdown();
        countdown.cancelCountdown();
        countdown.setDuration(Duration.ofSeconds(seconds));
        countdown.countSync();
    }
}
Also used : Game(pl.themolka.arcade.game.Game) MapQueue(pl.themolka.arcade.map.queue.MapQueue) CycleStartEvent(pl.themolka.arcade.cycle.CycleStartEvent) CycleCountdown(pl.themolka.arcade.cycle.CycleCountdown) CycleCountdown(pl.themolka.arcade.cycle.CycleCountdown) Countdown(pl.themolka.arcade.task.Countdown) RestartCountdown(pl.themolka.arcade.game.RestartCountdown)

Example 4 with Countdown

use of pl.themolka.arcade.task.Countdown 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 5 with Countdown

use of pl.themolka.arcade.task.Countdown in project Arcade2 by ShootGame.

the class DevelopmentCommands method recycleNow.

// 
// /recyclenow command
// 
@CommandInfo(name = { "recyclenow" }, description = "Re-cycle now current map", permission = "arcade.command.cyclenow")
public void recycleNow(Sender sender, CommandContext context) {
    if (this.development.getPlugin().getGames().getCurrentGame() == null) {
        throw new CommandException("Game is not running right now.");
    }
    OfflineMap target = this.development.getPlugin().getGames().getCurrentGame().getMap().getMapInfo();
    GeneralCommands.CycleCommandEvent commandEvent = new GeneralCommands.CycleCommandEvent(this.development.getPlugin(), sender, context, target);
    this.development.getPlugin().getEventBus().publish(commandEvent);
    if (commandEvent.isCanceled()) {
        return;
    }
    CycleStartEvent startEvent = new CycleStartEvent(this.development.getPlugin(), target, 0);
    this.development.getPlugin().getEventBus().publish(startEvent);
    this.development.getPlugin().getGames().setNextRestart(false);
    Game game = this.development.getPlugin().getGames().getCurrentGame();
    if (game != null) {
        for (Countdown countdown : game.getRunningCountdowns()) {
            countdown.cancelCountdown();
        }
        sender.sendSuccess("Re-cycling now to " + target.getName() + "...");
        this.development.getPlugin().getGames().cycle(target);
    }
}
Also used : Game(pl.themolka.arcade.game.Game) CycleStartEvent(pl.themolka.arcade.cycle.CycleStartEvent) OfflineMap(pl.themolka.arcade.map.OfflineMap) GeneralCommands(pl.themolka.arcade.command.GeneralCommands) Countdown(pl.themolka.arcade.task.Countdown) CommandException(pl.themolka.arcade.command.CommandException) CommandInfo(pl.themolka.arcade.command.CommandInfo)

Aggregations

Countdown (pl.themolka.arcade.task.Countdown)7 Game (pl.themolka.arcade.game.Game)6 CycleCountdown (pl.themolka.arcade.cycle.CycleCountdown)5 RestartCountdown (pl.themolka.arcade.game.RestartCountdown)5 CycleStartEvent (pl.themolka.arcade.cycle.CycleStartEvent)3 OfflineMap (pl.themolka.arcade.map.OfflineMap)3 CommandException (pl.themolka.arcade.command.CommandException)2 CommandInfo (pl.themolka.arcade.command.CommandInfo)2 GeneralCommands (pl.themolka.arcade.command.GeneralCommands)2 ArrayList (java.util.ArrayList)1 Handler (net.engio.mbassy.listener.Handler)1 GameManager (pl.themolka.arcade.game.GameManager)1 MapQueue (pl.themolka.arcade.map.queue.MapQueue)1