Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. public static void createLocation(String name, Player player){
  2. File ordner = new File("plugins//Lobby//Locations//");
  3. File file = new File("plugins//Lobby//Locations//" + name + ".yml");
  4.  
  5. if(!ordner.exists()){
  6. ordner.mkdir();
  7. }
  8. if(!file.exists()){
  9. try {
  10. file.createNewFile();
  11. } catch (IOException e) {
  12. e.printStackTrace();
  13. }
  14. }
  15.  
  16. FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
  17. Location loc = player.getLocation();
  18.  
  19. cfg.set("X", loc.getBlockX());
  20. cfg.set("Y", loc.getBlockY());
  21. cfg.set("Z", loc.getBlockZ());
  22. cfg.set("Welt", loc.getWorld().getName());
  23. cfg.set("Yaw", loc.getYaw());
  24. cfg.set("Pitch", loc.getPitch());
  25.  
  26. try {
  27. cfg.save(file);
  28. } catch (IOException e) {
  29. e.printStackTrace();
  30. }
  31. }
  32.  
  33. public static void getLocation(Player player, String name){
  34. File file = new File("plugins//Lobby//Locations//" + name + ".yml");
  35.  
  36. if(!file.exists()){
  37. player.sendMessage(Main.prefix + "Die Location wurde nicht gefunden");
  38. }
  39.  
  40. FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
  41.  
  42. World welt = Bukkit.getWorld(cfg.getString("Welt"));
  43. double yaw = cfg.getDouble("Yaw");
  44. double pitch = cfg.getDouble("Pitch");
  45.  
  46. player.teleport(new Location(welt, cfg.getDouble("X"), cfg.getDouble("Y"), cfg.getDouble("Z"), (float) yaw, (float) pitch));
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement