public Player getPlayerById(int playerId) { for (Player player : players) { if (player.getId() == playerId) { return player; } } return null; }
private void respawnDeadPlayers() { for (Player player : players) { if (!player.isAlive()) { spawnPlayer(player); player.setHp(Unit.MAX_HP); } } }
private void spawnPlayer(Player player) { int randomIndex = (int) (Math.random() * spawns.size()); Spawn spawn = spawns.get(randomIndex); player.getPosition().setX(spawn.getPosition().getX()); player.getPosition().setY(spawn.getPosition().getY()); }