Sending Messages To Players In Array Lists

Discussion in 'Plugin Development' started by RW_Craft, Nov 15, 2014.

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

    RW_Craft

    I'm trying to make a minigame, but I'm not sure how to send a message to everyone in an array list. (The array list is called 'lobby')

    I got it, if anyone needs the code, here it is:
    http://pastebin.com/BeVrHqm7

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 13, 2016
  2. Offline

    teej107

    RW_Craft Uh.....
    • Your for loop is not needed.
    • You are not even using the variable with each iteration of the online players.
     
  3. Offline

    bkleinman1

    RW_Craft Inside the for-loop, you use the identifier 'p' as if it were a player, however when you started the loop you used the identifier 'pls' for a player object. You would have to change it to this, using the correct variables:

    Code:java
    1. for(Player p : Bukkit.getOnlinePlayers()){
    2. if(YourArrayList.contains(p.getName)){
    3. //DoStuff
    4. }
    5. }
     
Thread Status:
Not open for further replies.

Share This Page