How to associate a Player with an ArrayList in a for loop?

Discussion in 'Plugin Development' started by RastaLulz, Jan 30, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    RastaLulz

    Hello,

    I have a "for" loop of players that I have in an ArrayList. My question is how would I associate each specific player in the array to the "object" Player?

    Code:java
    1. ArrayList randomPlayers = new ArrayList();
    2.  
    3. randomPlayers.add(user.getName());
    4.  
    5. for(Player player : randomPlayers) {
    6.  
    7. player.kickPlayer("Random kick message.");
    8.  
    9. }


    That's a rough idea of what I'm trying to do, I don't know the technical terms.
     
  2. Offline

    ZeusAllMighty11

    Code:
    for(String pname : someList){
        Player p = Bukkit.getPlayer(pname);
         pname.doStuffAsPlayer();
    }
     
    RastaLulz likes this.
Thread Status:
Not open for further replies.

Share This Page