Solved How to get worlds as String

Discussion in 'Spigot Plugin Development' started by Buby, May 11, 2016.

  1. hey guys, I am making a plugin and I was wondering how do I get all world names to a string. I have tried
    Code (Text):

    but that just returns the list of worlds but with alot of data I do not need, all i need it the name
  2. Tux


    Code (Java):
    Bukkit.getServer().getWorlds().stream().map(World::getName).collect(Collectors.joining(", "))
    That's how to do it if you use Java 8.
    • Agree Agree x 1
  3. You will need to iterate through the collection and call the #getName() method on each one.
  4. EzpEZ
    Code (Text):
    for (World worlds : Bukkit.getWorlds()) {

    • Agree Agree x 1
  5. Growl.. nina'd/..
    • Like Like x 1
  6. Thanks!