So I am trying to teleport the player to the world which they set in the config. Code: Double posx = config.getDouble("Lobby.X"); Double posy = config.getDouble("Lobby.Y"); Double posz = config.getDouble("Lobby.Z"); int posyaw = config.getInt("Lobby.Yaw"); int pospitch = config.getInt("Lobby.Pitch"); World world = config.get("Lobby.World"); Location lobby = world, posx, posy, posz, posyaw, pospitch); player.teleport(lobby); Please help
You need to check the World is a real world and then to create the Location. Location lobby = new Location(world, posx, posy, posz, posyaw, pospitch);
There is nothing wrong with the statement, except the world part: Location lobby = new Location(player.getWorld(), posx, posy, posz, posyaw, pospitch); Works fine...
You need to CHECK the world exits Here is some example code, change it to your needs. Code: String wN = plugin.getConfig("map").getString( map + "." + team + ".spawn.world"); double lX = plugin.getConfig("map").getDouble( map + "." + team + ".spawn.x"); double lY = plugin.getConfig("map").getDouble( map + "." + team + ".spawn.y"); double lZ = plugin.getConfig("map").getDouble( map + "." + team + ".spawn.z"); float p = plugin.getConfig("map").getInt( map + "." + team + ".spawn.pitch"); float y = plugin.getConfig("map").getInt( map + "." + team + ".spawn.yaw"); List<World> worlds = Bukkit.getWorlds(); World w = null; for (World world : worlds) { if (world.getName().equals(wN)) { w = world; Location l = new Location(w, lX, lY, lZ, p, y); player.teleport(l); } } Oh, and Pitch and Yaws are floats. The location creation will only work, with floats. EDIT by Moderator: merged posts, please use the edit button instead of double posting.
List<World> worlds = Bukkit.getWorlds(); Wants to be changed to List<org.bukkit.World> worlds = Bukkit.getWorlds(); ?
Im using Eclipse classic, I have imported "import net.minecraft.server.World;"? OMG i love you. I deleted the old one and added org.bukkit.world and its worked. Thats been the problem, thanks EDIT by Moderator: merged posts, please use the edit button instead of double posting.
No Problem Bukkit really should implement a more simpler way of doing this. At least I don't know of any faster way