Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
lDEVinux
GitHub Repository: lDEVinux/eaglercraft
Path: blob/main/sp-server/src_aux/SaveFormatOld.java
8641 views
1
package net.minecraft.src;
2
3
import java.io.File;
4
import java.io.FileInputStream;
5
6
public class SaveFormatOld implements ISaveFormat {
7
/**
8
* Reference to the File object representing the directory for the world saves
9
*/
10
protected final File savesDirectory;
11
12
public SaveFormatOld(File par1File) {
13
if (!par1File.exists()) {
14
par1File.mkdirs();
15
}
16
17
this.savesDirectory = par1File;
18
}
19
20
public void flushCache() {
21
}
22
23
/**
24
* gets the world info
25
*/
26
public WorldInfo getWorldInfo(String par1Str) {
27
File var2 = new File(this.savesDirectory, par1Str);
28
29
if (!var2.exists()) {
30
return null;
31
} else {
32
File var3 = new File(var2, "level.dat");
33
NBTTagCompound var4;
34
NBTTagCompound var5;
35
36
if (var3.exists()) {
37
try {
38
var4 = CompressedStreamTools.readCompressed(new FileInputStream(var3));
39
var5 = var4.getCompoundTag("Data");
40
return new WorldInfo(var5);
41
} catch (Exception var7) {
42
var7.printStackTrace();
43
}
44
}
45
46
var3 = new File(var2, "level.dat_old");
47
48
if (var3.exists()) {
49
try {
50
var4 = CompressedStreamTools.readCompressed(new FileInputStream(var3));
51
var5 = var4.getCompoundTag("Data");
52
return new WorldInfo(var5);
53
} catch (Exception var6) {
54
var6.printStackTrace();
55
}
56
}
57
58
return null;
59
}
60
}
61
62
/**
63
* @args: Takes one argument - the name of the directory of the world to
64
* delete. @desc: Delete the world by deleting the associated directory
65
* recursively.
66
*/
67
public boolean deleteWorldDirectory(String par1Str) {
68
File var2 = new File(this.savesDirectory, par1Str);
69
70
if (!var2.exists()) {
71
return true;
72
} else {
73
System.out.println("Deleting level " + par1Str);
74
75
for (int var3 = 1; var3 <= 5; ++var3) {
76
System.out.println("Attempt " + var3 + "...");
77
78
if (deleteFiles(var2.listFiles())) {
79
break;
80
}
81
82
System.out.println("Unsuccessful in deleting contents.");
83
84
if (var3 < 5) {
85
try {
86
Thread.sleep(500L);
87
} catch (InterruptedException var5) {
88
;
89
}
90
}
91
}
92
93
return var2.delete();
94
}
95
}
96
97
/**
98
* @args: Takes one argument - the list of files and directories to
99
* delete. @desc: Deletes the files and directory listed in the list
100
* recursively.
101
*/
102
protected static boolean deleteFiles(File[] par0ArrayOfFile) {
103
for (int var1 = 0; var1 < par0ArrayOfFile.length; ++var1) {
104
File var2 = par0ArrayOfFile[var1];
105
System.out.println("Deleting " + var2);
106
107
if (var2.isDirectory() && !deleteFiles(var2.listFiles())) {
108
System.out.println("Couldn\'t delete directory " + var2);
109
return false;
110
}
111
112
if (!var2.delete()) {
113
System.out.println("Couldn\'t delete file " + var2);
114
return false;
115
}
116
}
117
118
return true;
119
}
120
121
/**
122
* Returns back a loader for the specified save directory
123
*/
124
public ISaveHandler getSaveLoader(String par1Str, boolean par2) {
125
return new SaveHandler(this.savesDirectory, par1Str, par2);
126
}
127
128
/**
129
* gets if the map is old chunk saving (true) or McRegion (false)
130
*/
131
public boolean isOldMapFormat(String par1Str) {
132
return false;
133
}
134
135
/**
136
* converts the map to mcRegion
137
*/
138
public boolean convertMapFormat(String par1Str, IProgressUpdate par2IProgressUpdate) {
139
return false;
140
}
141
}
142
143