use of pl.themolka.arcade.match.Observers in project Arcade2 by ShootGame.
the class TeamsGame method onEnable.
@Override
public void onEnable() {
this.commands = new TeamCommands(this);
MatchGame module = (MatchGame) this.getGame().getModule(MatchModule.class);
this.match = module.getMatch();
for (Team team : this.teamsById.values()) {
team.setMatch(this.match);
this.match.registerWinner(team);
}
this.teamsById.put(this.match.getObservers().getId(), this.match.getObservers());
this.window = new TeamWindow(this);
this.window.create();
// register
this.getGame().getWindowRegistry().addWindow(this.getWindow());
this.match.setPlayWindow(this.getWindow());
this.match.setObserverHandler(this);
// cache
Observers observers = this.match.getObservers();
for (GamePlayer observer : observers.getOnlineMembers()) {
this.teamsByPlayer.put(observer, observers);
}
}
use of pl.themolka.arcade.match.Observers in project Arcade2 by ShootGame.
the class TeamCommands method clearCommand.
//
// Commands
//
public void clearCommand(Sender sender, String teamId) {
Team team = this.fetchTeam(teamId);
if (team.isObservers()) {
throw new CommandException("Cannot clear observers.");
}
Observers observers = this.game.getMatch().getObservers();
int result = 0;
for (GamePlayer player : new ArrayList<>(team.getOnlineMembers())) {
observers.joinForce(player);
result++;
}
if (result > 0) {
sender.sendSuccess(team.getName() + " has been cleared (" + result + " players) and moved to " + observers.getName() + ".");
} else {
sender.sendError("No players to clear.");
}
}
Aggregations