Path: blob/main/sp-server/src_aux/SaveFormatOld.java
8641 views
package net.minecraft.src;12import java.io.File;3import java.io.FileInputStream;45public class SaveFormatOld implements ISaveFormat {6/**7* Reference to the File object representing the directory for the world saves8*/9protected final File savesDirectory;1011public SaveFormatOld(File par1File) {12if (!par1File.exists()) {13par1File.mkdirs();14}1516this.savesDirectory = par1File;17}1819public void flushCache() {20}2122/**23* gets the world info24*/25public WorldInfo getWorldInfo(String par1Str) {26File var2 = new File(this.savesDirectory, par1Str);2728if (!var2.exists()) {29return null;30} else {31File var3 = new File(var2, "level.dat");32NBTTagCompound var4;33NBTTagCompound var5;3435if (var3.exists()) {36try {37var4 = CompressedStreamTools.readCompressed(new FileInputStream(var3));38var5 = var4.getCompoundTag("Data");39return new WorldInfo(var5);40} catch (Exception var7) {41var7.printStackTrace();42}43}4445var3 = new File(var2, "level.dat_old");4647if (var3.exists()) {48try {49var4 = CompressedStreamTools.readCompressed(new FileInputStream(var3));50var5 = var4.getCompoundTag("Data");51return new WorldInfo(var5);52} catch (Exception var6) {53var6.printStackTrace();54}55}5657return null;58}59}6061/**62* @args: Takes one argument - the name of the directory of the world to63* delete. @desc: Delete the world by deleting the associated directory64* recursively.65*/66public boolean deleteWorldDirectory(String par1Str) {67File var2 = new File(this.savesDirectory, par1Str);6869if (!var2.exists()) {70return true;71} else {72System.out.println("Deleting level " + par1Str);7374for (int var3 = 1; var3 <= 5; ++var3) {75System.out.println("Attempt " + var3 + "...");7677if (deleteFiles(var2.listFiles())) {78break;79}8081System.out.println("Unsuccessful in deleting contents.");8283if (var3 < 5) {84try {85Thread.sleep(500L);86} catch (InterruptedException var5) {87;88}89}90}9192return var2.delete();93}94}9596/**97* @args: Takes one argument - the list of files and directories to98* delete. @desc: Deletes the files and directory listed in the list99* recursively.100*/101protected static boolean deleteFiles(File[] par0ArrayOfFile) {102for (int var1 = 0; var1 < par0ArrayOfFile.length; ++var1) {103File var2 = par0ArrayOfFile[var1];104System.out.println("Deleting " + var2);105106if (var2.isDirectory() && !deleteFiles(var2.listFiles())) {107System.out.println("Couldn\'t delete directory " + var2);108return false;109}110111if (!var2.delete()) {112System.out.println("Couldn\'t delete file " + var2);113return false;114}115}116117return true;118}119120/**121* Returns back a loader for the specified save directory122*/123public ISaveHandler getSaveLoader(String par1Str, boolean par2) {124return new SaveHandler(this.savesDirectory, par1Str, par2);125}126127/**128* gets if the map is old chunk saving (true) or McRegion (false)129*/130public boolean isOldMapFormat(String par1Str) {131return false;132}133134/**135* converts the map to mcRegion136*/137public boolean convertMapFormat(String par1Str, IProgressUpdate par2IProgressUpdate) {138return false;139}140}141142143