Looking for simple alternative

Discussion in 'Plugin Development' started by Aucun, May 28, 2014.

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

    Aucun

    Hello, I'm looking for a simple alternative to getting all the worlds on a server by name. "getWorlds()" returns as a List of Objects. I turn the list into an array, as I find them easier to work with (personal preference), and then loop through the Object array, calling "toString()" and "replace()" on the selected Object.

    This does remove the "CraftWorld{name=" and "}"; however, I want to know if this has already been done. Does a simple command exist to get the name of a "world object"?

    The objects are turned into Strings to be used in "getWorld(String)". Would be handy to have a "getWorld(Object)" method :p
     
  2. Offline

    desht

    To get the name of a World, use the unsurprisingly-named getName() method. It's all in the Javadocs, which should be in your bookmarks.

    PHP:
    for (World w Bukkit.getWorlds()) {
      
    System.out.println("world: " w.getName());
    }
    By the way, getWorlds() returns a List<World>, not a List<Object>. There is a difference.
     
  3. Offline

    coldandtired

    for (World w : getServer().getWorlds())
    {
    String name = w.getName();
    }

    You make things much too complicated :)

    Edit: deshtninja'd!
     
    desht likes this.
  4. Offline

    mine-care

    I think it's solved, mark It so plz...
     
  5. Offline

    WhatAaCow

    #offTopic mine-care You think, but if everybody think something is solved, then everybody would have the permission to tahg something solved. And that's why you can't make it solved. Cause you don't know. And that's why you answer hasn't any sense ;)
     
Thread Status:
Not open for further replies.

Share This Page