コード例 #1
0
  @Override
  public void playerJoinedLate(Player player) {
    // put this player onto one of the teams with the fewest survivors
    TeamInfo[] teams = getTeams();
    int[] teamCounts = new int[numTeams.getValue()];
    for (int i = 0; i < teamCounts.length; i++)
      teamCounts[i] = getOnlinePlayers(new PlayerFilter().team(teams[i])).size();

    TeamInfo team = allocatePlayer(player, teamCounts);
    broadcastMessage(
        new PlayerFilter().exclude(player),
        player.getName() + " has joined the " + team.getChatColor() + team.getName());
  }
コード例 #2
0
  private TeamInfo allocatePlayer(Player player, int[] teamCounts) {
    int teamNum = Helper.getLowestValueIndex(teamCounts);
    TeamInfo team = getTeams()[teamNum];

    setTeam(player, team);
    teamCounts[teamNum]++;
    player.sendMessage(
        "You are on the "
            + team.getChatColor()
            + team.getName()
            + "\n"
            + ChatColor.RESET
            + "Use the /team command to send messages to your team only");

    equipPlayer(player, team);

    return team;
  }