Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. package me.pumaxd.api;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5.  
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.Location;
  8. import org.bukkit.configuration.file.FileConfiguration;
  9. import org.bukkit.configuration.file.YamlConfiguration;
  10.  
  11. public class API_Location {
  12.  
  13. public static File file = new File("plugins/LobbySys", "locations.yml");
  14. public static FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
  15.  
  16. public static void setLocation(Location loc, String name) {
  17.  
  18. String world = loc.getWorld().getName();
  19. double x = loc.getX();
  20. double y = loc.getY();
  21. double z = loc.getZ();
  22. double yaw = loc.getYaw();
  23. double pitch = loc.getPitch();
  24.  
  25. cfg.set(name + ".world", world);
  26. cfg.set(name + ".x", x);
  27. cfg.set(name + ".y", y);
  28. cfg.set(name + ".z", z);
  29. cfg.set(name + ".yaw", yaw);
  30. cfg.set(name + ".pitch", pitch);
  31.  
  32. try {
  33. cfg.save(file);
  34. } catch (IOException e) {
  35. System.err.println("Die Location " + name + " konnte nicht gespeichert werden.");
  36. e.printStackTrace();
  37. }
  38. }
  39.  
  40.  
  41. public static Location getLocation(String name) {
  42.  
  43. String world = cfg.getString(name + ".world");
  44. double x = cfg.getDouble(name + ".x");
  45. double y = cfg.getDouble(name + ".y");
  46. double z = cfg.getDouble(name + ".z");
  47. double yaw = cfg.getDouble(name + ".yaw");
  48. double pitch = cfg.getDouble(name + ".pitch");
  49.  
  50. Location loc = new Location(Bukkit.getWorld(world), x, y, z);
  51. loc.setYaw((float) yaw);
  52. loc.setPitch((float) pitch);
  53.  
  54. return loc;
  55. }
  56.  
  57. public static Boolean locationExists(String name) {
  58.  
  59. if (cfg.contains(name)) {
  60. return true;
  61. } else {
  62. return false;
  63. }
  64.  
  65. }
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement