Search in sources :

Example 1 with CommandException

use of pl.themolka.arcade.command.CommandException 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)

Example 2 with CommandException

use of pl.themolka.arcade.command.CommandException in project Arcade2 by ShootGame.

the class MatchGame method handleBeginCommand.

public void handleBeginCommand(Sender sender, int seconds, boolean force) {
    if (seconds == -1) {
        seconds = this.getDefaultStartCountdown();
    } else if (seconds < 3) {
        seconds = 3;
    }
    String message = "Starting";
    if (force) {
        message = "Force starting";
    }
    if (!this.getMatch().isStarting()) {
        throw new CommandException("The match is not in the starting state.");
    } else if (this.getPlugin().getGames().getCycleCountdown().isTaskRunning()) {
        throw new CommandException("Cannot start when cycle is running.");
    } else if (this.getPlugin().getGames().getRestartCountdown().isTaskRunning()) {
        throw new CommandException("Cannot start when restart is running.");
    }
    sender.sendSuccess(message + " the match in " + seconds + " seconds...");
    this.getMatch().setForceStart(force);
    this.startCountdown(seconds);
}
Also used : CommandException(pl.themolka.arcade.command.CommandException)

Example 3 with CommandException

use of pl.themolka.arcade.command.CommandException in project Arcade2 by ShootGame.

the class TeamCommands method kickCommand.

public void kickCommand(Sender sender, String username) {
    GamePlayer player = this.fetchPlayer(username);
    Team team = this.game.getTeam(player);
    if (team.isObservers()) {
        throw new CommandException("Cannot kick from observers.");
    }
    team.leaveForce(player);
    team.getMatch().getObservers().joinForce(player);
    sender.sendSuccess(player.getUsername() + " has been kicked from " + team.getName() + ".");
}
Also used : GamePlayer(pl.themolka.arcade.game.GamePlayer) CommandException(pl.themolka.arcade.command.CommandException)

Example 4 with CommandException

use of pl.themolka.arcade.command.CommandException in project Arcade2 by ShootGame.

the class TeamCommands method paintCommand.

public void paintCommand(Sender sender, String teamId, String paint) {
    Team team = this.fetchTeam(teamId);
    ChatColor color = Color.parseChat(paint);
    if (color == null) {
        StringBuilder colors = new StringBuilder();
        for (int i = 0; i < ChatColor.values().length; i++) {
            ChatColor value = ChatColor.values()[i];
            if (i != 0) {
                colors.append(", ");
            }
            ChatColor result = ChatColor.RED;
            if (!value.equals(ChatColor.MAGIC)) {
                result = value;
            }
            colors.append(result).append(value.name().toLowerCase().replace("_", "-")).append(ChatColor.RESET).append(ChatColor.RED);
        }
        throw new CommandException("Available colors: " + colors.toString() + ".");
    }
    Team oldState = new Team(team);
    team.setChatColor(color);
    this.callEditEvent(team, oldState, TeamEditEvent.Reason.PAINT);
    sender.sendSuccess(oldState.getName() + " has been painted from " + oldState.getChatColor().name().toLowerCase().replace("_", "-") + " to " + team.getChatColor().name().toLowerCase().replace("_", "-") + ".");
}
Also used : CommandException(pl.themolka.arcade.command.CommandException) ChatColor(org.bukkit.ChatColor)

Example 5 with CommandException

use of pl.themolka.arcade.command.CommandException in project Arcade2 by ShootGame.

the class TeamCommands method minCommand.

public void minCommand(Sender sender, String teamId, int min) {
    Team team = this.fetchTeam(teamId);
    if (team.isObservers()) {
        throw new CommandException("Cannot edit observers.");
    } else if (min < 0) {
        throw new CommandException("Number cannot be negative.");
    }
    Team oldState = new Team(team);
    team.setMinPlayers(min);
    this.callEditEvent(team, oldState, TeamEditEvent.Reason.MIN_PLAYERS);
    sender.sendSuccess(oldState.getName() + " has been edited.");
}
Also used : CommandException(pl.themolka.arcade.command.CommandException)

Aggregations

CommandException (pl.themolka.arcade.command.CommandException)10 GamePlayer (pl.themolka.arcade.game.GamePlayer)3 ArrayList (java.util.ArrayList)2 CommandInfo (pl.themolka.arcade.command.CommandInfo)2 GeneralCommands (pl.themolka.arcade.command.GeneralCommands)2 Game (pl.themolka.arcade.game.Game)2 OfflineMap (pl.themolka.arcade.map.OfflineMap)2 Countdown (pl.themolka.arcade.task.Countdown)2 ChatColor (org.bukkit.ChatColor)1 CycleStartEvent (pl.themolka.arcade.cycle.CycleStartEvent)1 Observers (pl.themolka.arcade.match.Observers)1