/*     */ public static void uninstallGame(boolean includeSaves) /*     */ {
   /*  22 */ deleteFileDir(MinecraftUtil.getBinFolder());
   /*  23 */ deleteFileDir(MinecraftUtil.getLoginFile());
   /*  24 */ deleteFileDir(MinecraftUtil.getResourcesFolder());
   /*  25 */ deleteFileDir(MinecraftUtil.getOptionsFile());
   /*  26 */ if (includeSaves) /*  27 */ deleteFileDir(MinecraftUtil.getSavesFolder());
   /*     */ }
 /*     */ public static void backupGame(File zipDestiny, boolean wholegame) /*     */ {
   /*     */ File[] source;
   /*     */ File[] source;
   /*  33 */ if (!wholegame) {
     /*  34 */ ArrayList contents = new ArrayList();
     /*     */
     /*  36 */ File f = MinecraftUtil.getBinFolder();
     /*  37 */ if (f.exists()) {
       /*  38 */ contents.add(f);
       /*     */ }
     /*  40 */ f = MinecraftUtil.getResourcesFolder();
     /*  41 */ if (f.exists()) {
       /*  42 */ contents.add(f);
       /*     */ }
     /*  44 */ f = MinecraftUtil.getLoginFile();
     /*  45 */ if (f.exists()) {
       /*  46 */ contents.add(f);
       /*     */ }
     /*  48 */ f = MinecraftUtil.getOptionsFile();
     /*  49 */ if (f.exists()) {
       /*  50 */ contents.add(f);
       /*     */ }
     /*  52 */ source = (File[]) contents.toArray(new File[contents.size()]);
     /*     */ } else {
     /*  54 */ source = MinecraftUtil.getWorkingDirectory().listFiles();
     /*     */ }
   /*  56 */ backupContents(source, zipDestiny, "minecraft_backup", "mcgame");
   /*     */ }
Example #3
0
 @SuppressWarnings({"rawtypes", "unchecked"})
 public static void backupGame(File zipDestiny, boolean wholegame) {
   File[] source;
   if (!wholegame) {
     ArrayList contents = new ArrayList();
     File f = MinecraftUtil.getBinFolder();
     if (f.exists()) {
       contents.add(f);
     }
     f = MinecraftUtil.getResourcesFolder();
     if (f.exists()) {
       contents.add(f);
     }
     f = MinecraftUtil.getLoginFile();
     if (f.exists()) {
       contents.add(f);
     }
     f = MinecraftUtil.getOptionsFile();
     if (f.exists()) {
       contents.add(f);
     }
     source = (File[]) contents.toArray(new File[contents.size()]);
   } else {
     source = MinecraftUtil.getWorkingDirectory().listFiles();
   }
   backupContents(source, zipDestiny, "minecraft_backup", "mcgame");
 }
 /*     */ public static void restoreContents(
     File zipSource, File folderDestiny, String genericName) {
   /* 153 */ File genericFolder = new File(MinecraftUtil.getTempFolder(), genericName);
   /* 154 */ if (genericFolder.exists()) {
     /* 155 */ deleteFileDir(genericFolder);
     /*     */ }
   /* 157 */ if (!folderDestiny.exists()) {
     /* 158 */ folderDestiny.mkdirs();
     /*     */ }
   /* 160 */ if (!folderDestiny.isDirectory()) {
     /* 161 */ throw new IllegalArgumentException("The destiny folder must be a directory!");
     /*     */ }
   /* 163 */ Zipper.unzipFolder(zipSource, MinecraftUtil.getTempFolder());
   /* 164 */ if (!genericFolder.exists()) {
     /* 165 */ throw new IllegalStateException(
         "Wrong content in zip file -> not found: " + genericFolder.getName());
     /*     */ }
   /* 167 */ File[] generics = genericFolder.listFiles();
   /* 168 */ for (File generic : generics) {
     /* 169 */ File destiny = new File(folderDestiny, generic.getName());
     /* 170 */ if (destiny.exists()) {
       /* 171 */ deleteFileDir(destiny);
       /*     */ }
     /* 173 */ generic.renameTo(destiny);
     /*     */ }
   /*     */ }
Example #5
0
 public static void restoreContents(File zipSource, File folderDestiny, String genericName) {
   File genericFolder = new File(MinecraftUtil.getTempFolder(), genericName);
   if (genericFolder.exists()) {
     deleteFileDir(genericFolder);
   }
   if (!folderDestiny.exists()) {
     folderDestiny.mkdirs();
   }
   if (!folderDestiny.isDirectory()) {
     throw new IllegalArgumentException("The destiny folder must be a directory!");
   }
   Zipper.unzipFolder(zipSource, MinecraftUtil.getTempFolder());
   if (!genericFolder.exists()) {
     throw new IllegalStateException(
         "Wrong content in zip file -> not found: " + genericFolder.getName());
   }
   File[] generics = genericFolder.listFiles();
   for (File generic : generics) {
     File destiny = new File(folderDestiny, generic.getName());
     if (destiny.exists()) {
       deleteFileDir(destiny);
     }
     generic.renameTo(destiny);
   }
 }
Example #6
0
 public static void uninstallGame(boolean includeSaves) {
   deleteFileDir(MinecraftUtil.getBinFolder());
   deleteFileDir(MinecraftUtil.getLoginFile());
   deleteFileDir(MinecraftUtil.getResourcesFolder());
   deleteFileDir(MinecraftUtil.getOptionsFile());
   if (includeSaves) {
     deleteFileDir(MinecraftUtil.getSavesFolder());
   }
 }
Example #7
0
  public static List<File> getWorlds() {
    List<File> files = new ArrayList<File>();

    for (File f : MinecraftUtil.getSavesFolder().listFiles()) {
      if (f.isDirectory()) files.add(f);
    }
    return files;
  }
 /*     */ public static void restoreFile(File zipSource, File destiny, String genericName) {
   /* 122 */ File generic = new File(MinecraftUtil.getTempFolder(), genericName);
   /* 123 */ if (generic.exists()) {
     /* 124 */ deleteFileDir(generic);
     /*     */ }
   /* 126 */ Zipper.unzipFolder(zipSource, MinecraftUtil.getTempFolder());
   /* 127 */ if (!generic.exists()) {
     /* 128 */ throw new IllegalStateException(
         "Wrong content in zip file -> not found: " + generic.getName());
     /*     */ }
   /* 130 */ if (destiny.exists()) {
     /* 131 */ deleteFileDir(destiny);
     /*     */ }
   /* 133 */ if ((destiny.getParentFile() != null) && (!destiny.getParentFile().exists())) {
     /* 134 */ destiny.getParentFile().mkdirs();
     /*     */ }
   /* 136 */ generic.renameTo(destiny);
   /*     */ }
Example #9
0
 public static void restoreFile(File zipSource, File destiny, String genericName) {
   File generic = new File(MinecraftUtil.getTempFolder(), genericName);
   if (generic.exists()) {
     deleteFileDir(generic);
   }
   Zipper.unzipFolder(zipSource, MinecraftUtil.getTempFolder());
   if (!generic.exists()) {
     throw new IllegalStateException(
         "Wrong content in zip file -> not found: " + generic.getName());
   }
   if (destiny.exists()) {
     deleteFileDir(destiny);
   }
   if ((destiny.getParentFile() != null) && (!destiny.getParentFile().exists())) {
     destiny.getParentFile().mkdirs();
   }
   generic.renameTo(destiny);
 }
Example #10
0
 public static void backupFile(
     File source, File zipDestiny, String genericName, String extension) {
   File generic = new File(MinecraftUtil.getTempFolder(), genericName);
   if (!source.exists()) {
     throw new IllegalArgumentException("Source file does not exist: " + source.getName());
   }
   if (!zipDestiny.getName().endsWith("." + extension)) {
     zipDestiny = new File(zipDestiny.getPath() + "." + extension);
   }
   if (generic.exists()) {
     deleteFileDir(generic);
   }
   source.renameTo(generic);
   Zipper.zipFolder(generic, zipDestiny);
   generic.renameTo(source);
 }
 /*     */ public static void backupFile(
     File source, File zipDestiny, String genericName, String extension) {
   /*  80 */ File generic = new File(MinecraftUtil.getTempFolder(), genericName);
   /*  81 */ if (!source.exists()) {
     /*  82 */ throw new IllegalArgumentException(
         "Source file does not exist: " + source.getName());
     /*     */ }
   /*  84 */ if (!zipDestiny.getName().endsWith("." + extension)) {
     /*  85 */ zipDestiny = new File(zipDestiny.getPath() + "." + extension);
     /*     */ }
   /*  87 */ if (generic.exists()) {
     /*  88 */ deleteFileDir(generic);
     /*     */ }
   /*  90 */ source.renameTo(generic);
   /*  91 */ Zipper.zipFolder(generic, zipDestiny);
   /*  92 */ generic.renameTo(source);
   /*     */ }
 /*     */ public static File getWorldNFolder(int n) {
   /*  65 */ File source = new File(MinecraftUtil.getSavesFolder(), "World" + n);
   /*  66 */ return source;
   /*     */ }
 /*     */ public static void restoreGame(File zipSource) {
   /*  60 */ File destiny = MinecraftUtil.getWorkingDirectory();
   /*  61 */ restoreContents(zipSource, destiny, "minecraft_backup");
   /*     */ }
Example #14
0
 public static File getWorldNFolder(int n) {
   File source = new File(MinecraftUtil.getSavesFolder(), "World" + n);
   return source;
 }