Advertisement
KingFaris10

Bukkit - Getting a String from a Location.

Sep 6th, 2013
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.24 KB | None | 0 0
  1.     public static String getStringByLocation(Location location, boolean roundNumbers, boolean includePitchAndYaw) {
  2.         String strLocation = (roundNumbers ? "world 0 0 0" + (includePitchAndYaw ? " 0 0" : "") : "world 0.0 0.0 0.0" + (includePitchAndYaw ? " 0.0 0.0" : ""));
  3.         if (location != null) {
  4.             String worldName = "world";
  5.             if (location.getWorld() != null) worldName = "world";
  6.             else worldName = location.getWorld().getName();
  7.             if (roundNumbers) {
  8.                 int xPos = (int) location.getX(), yPos = (int) location.getY(), zPos = (int) location.getZ();
  9.                 if (includePitchAndYaw) {
  10.                     int yaw = (int) location.getYaw(), pitch = (int) location.getPitch();
  11.                     strLocation = worldName + " " + xPos + " " + yPos + " " + zPos + " " + yaw + " " + pitch;
  12.                 } else {
  13.                     strLocation = worldName + " " + xPos + " " + yPos + " " + zPos;
  14.                 }
  15.             } else {
  16.                 double xPos = location.getX(), yPos = location.getY(), zPos = location.getZ();
  17.                 if (includePitchAndYaw) {
  18.                     float yaw = location.getYaw(), pitch = location.getPitch();
  19.                     strLocation = worldName + " " + xPos + " " + yPos + " " + zPos + " " + yaw + " " + pitch;
  20.                 } else {
  21.                     strLocation = worldName + " " + xPos + " " + yPos + " " + zPos;
  22.                 }
  23.             }
  24.         }
  25.         return strLocation;
  26.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement