A little noob question(Creating a World)

Discussion in 'Plugin Development' started by pixlepix, Jun 14, 2012.

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

    pixlepix

    So, I have been a hobbyist java programer(making a few little games) for a few years, and am trying to get into bukkit programing. In my current plugin, I am trying to store and load a Block object from a file. I saved the x, y and z values, but I cant figure out how I would store the World needed to
    get the Location object. After a bit of poking around, I found that World was an interface. So, how would I construct and object I could use to make a Location? Sorry if this isn't clear, ask me any questions.
     
  2. Offline

    imjake9

    You have two main options:
    1. Store the world's name. (world.getName())
    2. Store the world's UID, a unique identifier for the world that won't change even if the name does. (world.getUID())
    Both work. The first option is better if the user will see the data, since it's easier to understand, but the second has the benefit of never changing. Take your pick.
     
  3. Offline

    pixlepix

    I got the name, but how would you reconstruct the object when you are loading it back up. Sorry, interfaces have never been my thing :).
     
  4. Offline

    imjake9

    Ah. Just use Bukkit.getWorld(nameOfWorld). That will get you a world with the name you pass. If the world doesn't exist, you'll get null, but that shouldn't happen unless the user renamed their world or something like that.
     
  5. Offline

    pixlepix

    Thanks a ton.
     
Thread Status:
Not open for further replies.

Share This Page