Tings


SUBMITTED BY: itsDaveLad

DATE: March 9, 2016, 5:14 p.m.

FORMAT: Text only

SIZE: 962 Bytes

HITS: 605

  1. public static World copyWorld() throws IOException {
  2. String newname;
  3. File newdirectory;
  4. File directory;
  5. do {
  6. newname="world";
  7. newdirectory=new File(newname);
  8. deleteWorld(newdirectory);
  9. directory=new File("paintwar");
  10. }
  11. while (newdirectory.exists());
  12. FileUtils.copyDirectory(directory,newdirectory);
  13. File uid=new File(newdirectory + File.separator + "uid.dat");
  14. if (uid.exists()) uid.delete();
  15. WorldCreator tmp=new WorldCreator(newname);
  16. tmp.copy((World) directory);
  17. return Bukkit.createWorld(tmp);
  18. }
  19. public static boolean deleteWorld(File path)
  20. {
  21. if (path.exists()) {
  22. File[] files = path.listFiles();
  23. for (int i = 0; i < files.length; i++) {
  24. if (files[i].isDirectory())
  25. deleteWorld(files[i]);
  26. else {
  27. files[i].delete();
  28. }
  29. }
  30. }
  31. return path.delete();
  32. }
  33. }

comments powered by Disqus