use of pl.themolka.arcade.map.queue.MapQueue 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();
}
}
Aggregations