Code: List worlds = server.getWorlds(); for(int i = 1; i < worlds.size(); i++){ String world = worlds.get(i).toString(); String wn = server.getWorld(world).getName(); String we = server.getWorld(world).getEnvironment().name(); //Do stuffs with strings wn & we } So, This code is **** up worldwarp 2.0. Gives me NullPointerException at the line String wn = server.... (4:th line) Anyone see's whats wrong? I can't and eclipse gives me no errors. builds without warnings
String world = worlds.get(i).toString(); You get the world as an World-object and then convert it to String. First of all, this and the following line is not necessary, because server.getWorlds() already gives you World-objects. BTW, you should add a generic to the List-declaration at the first line List<World> worlds = server.getWorlds(); world.get(i) already returns your World and you can call stuff like getName() and getEnvironment(). Umm, I explained kinda messy, but I hope I helped
This might help: PHP: // get list of worldsfinal List<World> worlds = server.getWorlds();// go through the complete list of worlds, one at a time and *do stuff*final Iterator<World> iter = worlds.iterator();while(iter.hasNext()) { // get next world final World world = iter.next(); // get world name final String wn = world.getName(); // get world environment final Environment we = world.getEnvironment(); // Do stuffs with wn & we}// end while Remark: I hate the post add/edit functionality of this forum. Click somewhere else in the browser window and everything is gone. What happened to plain old <textarea> without all the fancy crap?
You can still click the "More Options..."-button to have it displayed in its own window. And the textarea mode for plain text can be reached with the -symbol (top right corner of the editor). @Raz I just noticed you started your loop with int i = 1 in the OP. Why not 0?
Ahh, thanks a lot, Bone008, you just made my life a lot easier. I had to type my previous post three times which got me a little p-o'd.
Thanks to booth of you Works great now. I See my errors clearly right now. I Guess coding to 03:00 in the morning isn't to recommend, atleast not without coffe