Solved Problem with pitch and yaw

Discussion in 'Plugin Development' started by Urag, Aug 5, 2015.

Thread Status:
Not open for further replies.
  1. /setspawn:
    [​IMG]

    /spawn:
    [​IMG]
    [​IMG]
    ==============================================================================
    How to make that when player spawns, he looks there where me at first image.
    I hope you understand ;)

    My actual code is:

    Code:
            if (cmd.getName().equalsIgnoreCase("setspawn")){
                getConfig().set("spawn.world", p.getLocation().getWorld().getName());
                getConfig().set("spawn.x", p.getLocation().getX());
                getConfig().set("spawn.y", p.getLocation().getY());
                getConfig().set("spawn.z", p.getLocation().getZ());
                getConfig().set("spawn.pitch", p.getLocation().getPitch());
                getConfig().set("spawn.yaw", p.getLocation().getYaw());
                saveConfig();
                p.sendMessage("§aSpawn set.");
                return true;
            }
           
            if (cmd.getName().equalsIgnoreCase("spawn")){
                if (getConfig().getConfigurationSection("spawn") == null){
                    p.sendMessage("§cSpawn nie zostal ustawiony");
                    return true;
                }
                World w = Bukkit.getServer().getWorld(getConfig().getString("spawn.world"));
                double x = getConfig().getDouble("spawn.x");
                double y = getConfig().getDouble("spawn.y");
                double z = getConfig().getDouble("spawn.z");
                float pitch = (float) getConfig().getDouble("spawn.pitch");
                float yaw = (float) getConfig().getDouble("spawn.yaw");
                p.teleport(new Location(w, x, y, z, pitch, yaw));
                p.sendMessage("§aWelcome to spawn!");
            }
     
  2. @Urag
    Try swapping the pitch and yaw in the Location at p.teleport
     
    Urag likes this.
Thread Status:
Not open for further replies.

Share This Page