Teleportation problem

Discussion in 'Plugin Development' started by Hester, Jul 9, 2013.

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

    Hester

    Hey, I have a huge problem with teleport players to another world. A player is teleported to the right cords, however bad the world
    when you call out the teleportation teleport me to spawn world not test_world
     
  2. Offline

    Tim4209

    can you post the getLocation method and whatever else ur doing with this, i dont think this is the best way to do this
     
  3. Offline

    Hester


    Code:
        public String getLocation(Player player){
            Location loc = player.getLocation();
            String location = player.getWorld().getName() + "/" + (int) loc.getX() + "/" + (int) loc.getY() + "/" + (int) loc.getZ() + "/" + loc.getYaw() + "/" + loc.getPitch();
            return location;
        }
    I'm not sure if it somehow works on teleportation players, but after each game finishing . World is restored from backup world (overwritten). In first game teleportation work perfect but after backup this teleport me to "spawn world"
     
  4. Offline

    LinearLogic

    Code:java
    1. public String getLocation(Player player){
    2. Location loc = player.getLocation();
    3. String location = player.getWorld().getName() + "/" + (int) loc.getX() + "/" + (int) loc.getY() + "/" + (int) loc.getZ() + "/" + loc.getYaw() + "/" + loc.getPitch();
    4. return location;
    5. }

    Since getLocation(...) retrieves the world the player is currently in, make sure that world is test_world and not world. You might do better to hardcode "test_world" into the toLocation(...) method in lieu of using pos[0]...
     
  5. Offline

    Hester

    but this location is saved in config
     
  6. Offline

    LinearLogic

    Here's a way to debug: any time the target location is accessed, print the name of the world. If it's ever "world" and not "test_world", that's your issue - figure out where it's being set back to "world".
     
  7. Offline

    Tim4209

    I don't think you have to store location as a string.
    This is how you store a location in config

    Code:
                    Location location = player.getLocation();
                    config.set("World", player.getWorld().getName());
                    config.set("X", location.getX());
                    config.set("Y", location.getY());
                    config.set("Z", location.getZ());
                    config.set("Pitch", location.getPitch());
                    config.set("Yaw", location.getYaw());
                    saveConfig();
    and to use it its like this

    Code:
                            return new Location(Bukkit.getServer().getWorld(config.getString("World")),
                    config.getDouble("X"),
                    config.getDouble("Y"),
                    config.getDouble("Z"),
                    (float) config.getDouble("Yaw"),
                    (float) config.getDouble("Pitch")
                    );
     
Thread Status:
Not open for further replies.

Share This Page