Beispiel #1
0
  @Override
  public void updatePlayers(List<PlayerInfo> players) {
    lock.writeLock().lock();
    try {
      if (players == null) {
        return;
      }
      Iterator<PlayerInfo> iterator = players.iterator();
      while (iterator.hasNext()) {
        Player player = iterator.next();
        if (player.getName() == null) {
          iterator.remove();
        }
      }

      if (this.players.size() != players.size()) {
        throw new IllegalArgumentException("Diff players count");
      }

      for (int index = 0; index < players.size(); index++) {
        Player playerToUpdate = this.players.get(index);
        Player newPlayer = players.get(index);

        playerToUpdate.setCallbackUrl(newPlayer.getCallbackUrl());
        playerToUpdate.setName(newPlayer.getName());
      }
    } finally {
      lock.writeLock().unlock();
    }
  }
Beispiel #2
0
 @Override
 public void updatePlayer(Player player) {
   lock.writeLock().lock();
   try {
     for (Player playerToUpdate : players) {
       if (playerToUpdate.getName().equals(player.getName())) {
         playerToUpdate.setCallbackUrl(player.getCallbackUrl());
         return;
       }
     }
   } finally {
     lock.writeLock().unlock();
   }
 }