Solved Iterating Over Multiple Lists Simultaneously

Discussion in 'Plugin Development' started by The Gaming Grunts, Dec 29, 2014.

Thread Status:
Not open for further replies.
  1. Hey everyone! So, I'm creating a method:
    Code:
    getPlayer(int i)
    that is going to get all of the players in a group and return them individually (if that makes sense) and is designed to be used in for-loops, for example:
    Code:
    for (int i =0; i < someValue; i++){
        Settlement#getPlayer(int i); //etc.
    }
    Now, the players in the group are divided into two lists, citizens and officers, and there is a UUID variable called "leader". What I want to do is iterate over both lists and the leader variable and return each with the getPlayer() method and I've been stuck on how to do it. Thanks :)
     
  2. Offline

    coasterman10

    I think it would be better to instead use an enhanced for loop and use a getPlayers() method to return the entire collection of players.
     
  3. @coasterman10
    That's what I'm thinking. For my purposes, I can actually just return the leader first, then iterate over the lists individually. It's much easier that way and doesn't give me a headache :p
     
Thread Status:
Not open for further replies.

Share This Page