Advertisement
Guest User

Untitled

a guest
Oct 1st, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. package de.gomze.utils;
  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.YamlConfiguration;
  9. import org.bukkit.entity.Player;
  10.  
  11. public class Spawn {
  12.  
  13. public static void setSpawn(Player p) {
  14.  
  15. File ordner = new File("/plugins/KitPvP");
  16. File file = new File("/plugins/KitPvP/Spawn.yml");
  17.  
  18. if(!ordner.exists()) {
  19.  
  20. ordner.mkdirs();
  21.  
  22. }
  23.  
  24. if(!file.exists()) {
  25.  
  26. try {
  27.  
  28. file.createNewFile();
  29.  
  30. } catch (IOException e) {
  31.  
  32. e.printStackTrace();
  33.  
  34. }
  35.  
  36. }
  37.  
  38. YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
  39. Location loc = p.getLocation();
  40.  
  41. double x = loc.getX();
  42. double y = loc.getY();
  43. double z = loc.getZ();
  44. float pitch = loc.getPitch();
  45. float yaw = loc.getYaw();
  46. String world = loc.getWorld().getName();
  47.  
  48. cfg.set("Spawn.X", x);
  49. cfg.set("Spawn.Y", y);
  50. cfg.set("Spawn.Z", z);
  51. cfg.set("Spawn.Pitch", pitch);
  52. cfg.set("Spawn.Yaw", yaw);
  53. cfg.set("Spawn.World", world);
  54.  
  55. Titles.sendTitle(p, "§cSpawn", "§aDu hast den Spawn gesetzt!", 20, 60, 20);
  56.  
  57. }
  58.  
  59. public static void teleportSpawn(Player p) {
  60.  
  61. File file = new File("/plugins/KitPvP/Spawn.yml");
  62. YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
  63. Location loc = p.getLocation();
  64.  
  65. loc.setX(cfg.getDouble("Spawn.X"));
  66. loc.setY(cfg.getDouble("Spawn.Y"));
  67. loc.setZ(cfg.getDouble("Spawn.Z"));
  68. loc.setPitch((float)cfg.getDouble("Spawn.Pitch"));
  69. loc.setYaw((float)cfg.getDouble("Spawn.Yaw"));
  70. loc.setWorld(Bukkit.getWorld(cfg.getString("Spawn.World")));
  71.  
  72. p.teleport(loc);
  73.  
  74. }
  75.  
  76. public static Location getSpawn(Player p) {
  77.  
  78. File file = new File("/plugins/KitPvP/Spawn.yml");
  79. YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
  80.  
  81. Location loc = p.getLocation();
  82. loc.setX(cfg.getDouble("Spawn.X"));
  83. loc.setY(cfg.getDouble("Spawn.Y"));
  84. loc.setZ(cfg.getDouble("Spawn.Z"));
  85. loc.setPitch((float)cfg.getDouble("Spawn.Pitch"));
  86. loc.setYaw((float)cfg.getDouble("Spawn.Yaw"));
  87. loc.setWorld(Bukkit.getWorld(cfg.getString("Spawn.World")));
  88.  
  89. return loc;
  90.  
  91. }
  92.  
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement