Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. public class TeleportUtils {
  2.  
  3. private static File file;
  4. private static YamlConfiguration Cfg;
  5.  
  6. public TeleportUtils(Main main) {
  7. file = new File(main.getDataFolder(), "location.yml");
  8. if(!file.getParentFile().exists()) {
  9. file.getParentFile().mkdirs();
  10. }
  11. if(!file.exists())
  12. try {
  13. file.createNewFile();
  14. } catch (Exception e) {
  15. e.printStackTrace();
  16. }
  17. try {
  18. Cfg = YamlConfiguration.loadConfiguration(file);
  19. } catch (Exception e) {
  20. e.printStackTrace();
  21. }
  22. }
  23.  
  24. public static void save(String name, Material material, int slot, Location location) {
  25. String toSave = name + ":" + material.toString() + ":" + slot + ":" + location.getWorld().getName() +
  26. ":" + location.getX() + ":" + location.getY() + ":" + location.getZ() + ":" + location.getYaw() + ":" + location.getPitch();
  27. List<String> list;
  28. try {
  29. list = Cfg.getStringList("navigator");
  30. } catch (Exception e) {
  31. list = new ArrayList<> ();
  32. }
  33. list.add(toSave);
  34. Cfg.set("navigator", list);
  35. try {
  36. Cfg.save(file);
  37. } catch (Exception e) {
  38. e.printStackTrace();
  39. }
  40.  
  41.  
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement