world.getName(); and Location(); help please!

Discussion in 'Plugin Development' started by Gonzo0193, Mar 5, 2011.

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

    Gonzo0193

    So i am trying to get the location of a player, using
    Code:
    Location location = new Location(world, locationX, locationY, locationZ);
    
    However i do know get how to assign World.getName(); to a variable as both
    Code:
    World world = World.getName();
    
    and
    Code:
    String world = World.getName();
    
    Both throw errors, any help would be appreciated thanks :)
     
  2. Offline

    Plague

    Basic help is to let you read something on the basics of programming.
    World.getName() does not exist for classes, only for instantiated objects. If you want to get a world object you can do it like player.getWorld().
     
  3. Offline

    Cheesier

    World.getName() Does exist, tho it is a non-static method, you must then catch it with the instance of that world.

    catching the world instance can be done in the main file like this:
    Code:
    onEnable() {
      World world = this.getServer().getWorld("worldname");
      String name = world.getName();
    }
    Or with an event:
    Code:
    onPlayerMove(PlayerMoveEvent event) {
      World world = event.getPlayer().getWorld();
      world.getName();
    }
    There are several other ways too
     
  4. Offline

    Gonzo0193

    Thanks, such a simple mistake =/
     
Thread Status:
Not open for further replies.

Share This Page