mrkirby153

Untitled

Feb 15th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.58 KB | None | 0 0
  1. public static void copyWorld(File source, File target) {
  2.         /*try {
  3.             ArrayList<String> ignore = new ArrayList<String>(Arrays.asList("uid.dat", "session.dat"));
  4.             if (!ignore.contains(source.getName())) {
  5.                 if (source.isDirectory()) {
  6.                     Bukkit.unloadWorld(source.getName(), false);
  7.                     if (!target.exists())
  8.                         target.mkdirs();
  9.                     String files[] = source.list();
  10.                     for (String file : files) {
  11.                         File srcFile = new File(source, file);
  12.                         File destFile = new File(target, file);
  13.                         copyWorld(srcFile, destFile);
  14.                     }
  15.                 } else {
  16.                     InputStream in = new FileInputStream(source);
  17.                     if (!target.exists())
  18.                         target.createNewFile();
  19.                     OutputStream out = new FileOutputStream(target);
  20.                     byte[] buffer = new byte[1024];
  21.                     int length;
  22.                     while ((length = in.read(buffer)) > 0)
  23.                         out.write(buffer, 0, length);
  24.                     in.close();
  25.                     out.close();
  26.                 }
  27.             }
  28.         } catch (IOException e) {
  29.             e.printStackTrace();
  30.         }*/
  31.         // Unload the source world world
  32.         System.out.println(source.canWrite());
  33.         System.out.println(source.canWrite());
  34.         Bukkit.unloadWorld(source.getName(), true);
  35.         FileUtil.copy(source, target);
  36.     }
Advertisement
Add Comment
Please, Sign In to add comment