[URGENT] Get string from ArrayList

Discussion in 'Plugin Development' started by kevinspl2000, Oct 24, 2013.

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

    kevinspl2000

    So I want to create a variable for example players. Those will equal all the players in the ArrayList. I already have the ArrayList set up and it is a String (player.getName()). How would I take out the player name and put it into a variable?
     
  2. Offline

    NathanWolf

    You might need to provide a bit more information- I've read this a few times and can't figure out what you're trying to do. Add a player name to a list? Collapse a list of player names into a single string? Not sure.

    Also, just a friendly note, putting urgent in all caps in your topic probably hurts more than it helps, in terms of getting people to look.
     
  3. Offline

    kevinspl2000

    NathanWolf
    What I am trying to do is list the strings in an ArrayList. For example I want the variable players to equal all of the players in the array list (their names). I already have the ArrayList made and the players added but I want to make a variable that I can use. So for example if I want all of the players in the list to change their gamemode to creative. How would I do this?
     
  4. Offline

    1Rogue

    Iteration!

    Code:java
    1. List<String> example = new ArrayList();
    2. for (String name : example) {
    3. Player temp = Bukkit.getPlayer(name);
    4. temp.sendMessage("Hello world!");
    5. // or other code...
    6. }
     
    NathanWolf likes this.
  5. Offline

    kevinspl2000

Thread Status:
Not open for further replies.

Share This Page