Solved Is there a way to get a certain amout of players in an ArrayList?

Discussion in 'Plugin Development' started by Lightspeed, Dec 17, 2014.

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

    Lightspeed

    For my ultra hardcore I have it so you queue to get in the game. I have it in a list so players don't have to spam a join sign or command to get in the game.
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    Lightspeed

    oops forgot to put that in there (facepalm)
    How could I get a certain amount from the list.
     
  4. Offline

    teej107

  5. Offline

    Lightspeed

  6. Offline

    mythbusterma

    Lightspeed likes this.
  7. Offline

    Lightspeed

    Sorry my internet crashed I need to get a number of players from a array list
     
  8. Offline

    timtower Administrator Administrator Moderator

  9. Offline

    mythbusterma

    @Lightspeed

    Sounds like you need a sublist, see teej's post.
     
  10. Offline

    Skionz

  11. Offline

    Lightspeed

    @Skionz
    Yes I need to grab an amount of players from a list and put them into another
     
    Last edited: Dec 18, 2014
  12. Offline

    teej107

  13. Offline

    Lightspeed

    Yes, sorry my pc has been broken for 8 months I completly forgot about bukkit.
    So if i sound stupid I'm sorry
     
  14. Offline

    Skionz

  15. Offline

    Lammazz

    Code:
    for (int i = 0; i < amountLoopTimes; i++) {
        secondList.add(firstList.get(0));
        firstList.remove(0);
        continue;
    }
    This will loop through the first list and transfer the object at the index 0 (next on the list) into the second list and then remove that object from the first list. Hopefully this helps :) @Lightspeed
     
  16. Offline

    Lightspeed

    Yes this is exactly what I need thank you (I'm a little new to bukkit c: )
     
  17. Offline

    mythbusterma

    @Lightspeed

    That is exactly what List#sublist(int) does, except spread out over 4 lines and a lot more ugly. Not that this thread was solved on the third post or anything. *cough* if I had a dollar for every time someone reinvented the wheel except more poorly *cough*
     
    Lightspeed, teej107 and ferrybig like this.
  18. Offline

    SuperOriginal

    That snippet didn't have any Bukkit in it... At all.
     
Thread Status:
Not open for further replies.

Share This Page