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);
}
}
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);
}
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() + ".");
}
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("_", "-") + ".");
}
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.");
}
Aggregations