Solved Warping [Looking In Direction as Warp Set]

Discussion in 'Plugin Development' started by Epicballzy, Jul 24, 2014.

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

    Epicballzy

    Hey guys, I made a warp plugin, where you're able to set/go/see the warps. Everything works fine, except I would like to have the player face the same direction as the warp was set. So if you set the warp facing north, I would like the player to face north. By default, the player faces South.

    Is there an easy way to do this?

    This is what I currently have to go to a warp:
    Code:java
    1. String warp = args[0];
    2. double x = Double.parseDouble(Main.Config.getString(warp + ".X"));
    3. double y = Double.parseDouble(Main.Config.getString(warp + ".Y"));
    4. double z = Double.parseDouble(Main.Config.getString(warp + ".Z"));
    5. World world = Bukkit.getServer().getWorld(Main.Config.getString(warp + ".World"));
    6.  
    7. Location loc = new Location(world, x, y, z);
    8. player.teleport(loc);


    And this is what I use to set the warp:
    Code:java
    1. String warpName = args[0];
    2. FileConfiguration conf = Main.Config;
    3.  
    4. String world = player.getLocation().getWorld().getName().toString();
    5. double x = player.getLocation().getX();
    6. double y = player.getLocation().getY();
    7. double z = player.getLocation().getZ();
    8.  
    9. conf.set(warpName + ".World", world);
    10. conf.set(warpName + ".X", x);
    11. conf.set(warpName + ".Y", y);
    12. conf.set(warpName + ".Z", z);
    13. Main.save();


    How would I add directions to this?

    All help is greatly appreciated!
     
  2. Offline

    Gater12

    Epicballzy
    Save Yaw & Pitch then add 2 additional float parameters as the yaw and pitch value.
     
    Epicballzy likes this.
  3. Offline

    skipperguy12

    Hello, you need to store the yaw of the player for direction. Additionally pitch if you want to store how high (or low) the player is looking.
    http://jd.bukkit.org/beta/doxygen/da/dac/classorg_1_1bukkit_1_1Location.html
    Take a look at methods relating to pitch and yaw. When the warp is set get the yaw (and/or pitch) and save it to config. When a warp is used, set the pitch and yaw.
     
    Epicballzy likes this.
  4. Offline

    DannyDog

    player.getLocation().setYaw(float yaw);
     
  5. Offline

    Epicballzy

Thread Status:
Not open for further replies.

Share This Page