Matching a world name string to a world?

Discussion in 'Plugin Development' started by Razorcane, Nov 16, 2011.

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

    Razorcane

    Heyo, I'm doing a /spawn command, one that teleports you to the spawn point regardless of which world you are in. Now, I have the code for that already, but I can't have it change worlds without setting the world name equal to a world. I'm assuming there's a simple way to do this, and I feel stupid for asking, but is this possible? Here is the code I am talking about:

    Code:
    spawn = new Location(world, spawnX, spawnX, spawnX, spawnYaw, spawnPitch);
    The "world" variable is stored as a string in a .txt file, and once it is called from the text file, it needs to be converted to a world object to match the requirements for the Location object. I'm not quite sure how to do this, however.
     
  2. Offline

    KILL3RTACO

    try along the lines of getServer().getWorld(world) whereas the world variable is a string (no guarantee of this working)
     
  3. Offline

    pyraetos

    Pass a server to the method making the string, or construct the class with that method with a server.
    Then use server.getWorld(world);
     
  4. Offline

    nisovin

    You can also do this without a server object by just doing Bukkit.getWorld(worldName).
     
Thread Status:
Not open for further replies.

Share This Page