Array List

Discussion in 'Plugin Development' started by looparound, Jan 28, 2014.

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

    looparound

    I have no idea how to do this hopefully someone can help. If i have an arraylist like this,
    static List<Player> KTK2 = new ArrayList<Player>();
    and there is only one person left in the arraylist, how can i get that players name from the arraylist or say there was a group of players in the arraylist, how could i broadcast a message or send one of all the names that are in that arraylist
    If you know how to do if you wouldnt mind sharing with me that would be amazing, Thanks ! :D
     
  2. Offline

    Zwander

    Player class contains the method player.getName() which returns the players name as a string.

    Lists contain a method .size() that gives the size of the lise.
    Lists contain a method .get(int index) that gets the object in the list at index 'index'.

    for(Player p: KTK2){} will loop through the KTK2 list and pull out players

    I know this doesnt tell you how to do it, but that's not the point of this forum. If you need an explanation of any of the above just ask.
     
  3. Offline

    Niknea

    looparound Not entirely sure what your saying, however here is the answer for what I think you want.
    You can check if the player is in the array list, then get there name with player.getName() and then use the method "Bukkit.broadcastMessage("")" to broadcast a message.

    By the way, does my name ring a bell to you? ;)
     
  4. Offline

    xTrollxDudex

    looparound
    The last person on the ArrayList is most likely at index 0
     
Thread Status:
Not open for further replies.

Share This Page