I'm trying to collect all players in the Arraylist with this (This is spigot 1.16.5):
Arraylist constructor: public static ArrayList<Player> playerInGame = new ArrayList<>();
public void makePlayerWin(Player perdente) {
Iterator<Player> it = playerInGame.iterator();
if(!it.hasNext()) return;
Player players = it.next();
System.out.println(1);
if(playerInGame.contains(perdente) && players.getWorld() == Bukkit.getWorld(plugin.Game) || playerInGame.contains(perdente) && !perdente.isOnline()) {
System.out.println(2);
playerInGame.remove(perdente);
LobbyJoin(players);
players.sendTitle(plugin.cc("&6Hai vinto!"), plugin.cc("&7Sei tornato alla lobby!"));
playerInGame.remove(players);
}
}
But I get this error: