Search in sources :

Example 1 with Observers

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);
    }
}
Also used : MatchGame(pl.themolka.arcade.match.MatchGame) GamePlayer(pl.themolka.arcade.game.GamePlayer) Observers(pl.themolka.arcade.match.Observers) MatchModule(pl.themolka.arcade.match.MatchModule)

Example 2 with 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.");
    }
}
Also used : GamePlayer(pl.themolka.arcade.game.GamePlayer) Observers(pl.themolka.arcade.match.Observers) ArrayList(java.util.ArrayList) CommandException(pl.themolka.arcade.command.CommandException)

Aggregations

GamePlayer (pl.themolka.arcade.game.GamePlayer)2 Observers (pl.themolka.arcade.match.Observers)2 ArrayList (java.util.ArrayList)1 CommandException (pl.themolka.arcade.command.CommandException)1 MatchGame (pl.themolka.arcade.match.MatchGame)1 MatchModule (pl.themolka.arcade.match.MatchModule)1