Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-25 18:40:05 +01:00
Added .tar and .tar.* support, *maybe*.
Dieser Commit ist enthalten in:
Ursprung
49739bab76
Commit
5fc97f0f7d
@ -1098,6 +1098,9 @@ public class WorldEditListener extends PluginListener {
|
||||
try {
|
||||
chunkStore = snapshot.getChunkStore();
|
||||
player.print("Snapshot '" + snapshot.getName() + "' loaded; now restoring...");
|
||||
} catch (DataException e) {
|
||||
player.printError("Failed to load snapshot: " + e.getMessage());
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
player.printError("Failed to load snapshot: " + e.getMessage());
|
||||
return true;
|
||||
|
@ -54,13 +54,21 @@ public class Snapshot {
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public ChunkStore getChunkStore() throws IOException {
|
||||
public ChunkStore getChunkStore() throws IOException, DataException {
|
||||
if (file.getName().toLowerCase().endsWith(".zip")) {
|
||||
try {
|
||||
return new TrueZipAlphaChunkStore(file);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
return new ZippedAlphaChunkStore(file);
|
||||
}
|
||||
} else if (file.getName().toLowerCase().endsWith(".tar.bz2")
|
||||
|| file.getName().toLowerCase().endsWith(".tar.gz")
|
||||
|| file.getName().toLowerCase().endsWith(".tar")) {
|
||||
try {
|
||||
return new TrueZipAlphaChunkStore(file);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
throw new DataException("TrueZIP is required for .tar support");
|
||||
}
|
||||
} else {
|
||||
return new AlphaChunkStore(file);
|
||||
}
|
||||
|
@ -61,9 +61,7 @@ public class SnapshotRepository {
|
||||
FilenameFilter filter = new FilenameFilter() {
|
||||
public boolean accept(File dir, String name) {
|
||||
File f = new File(dir, name);
|
||||
return (name.toLowerCase().endsWith(".zip")
|
||||
&& f.isFile())
|
||||
|| f.isDirectory();
|
||||
return isValidSnapshot(f);
|
||||
}
|
||||
};
|
||||
|
||||
@ -105,17 +103,30 @@ public class SnapshotRepository {
|
||||
* Check to see if a snapshot is valid.
|
||||
*
|
||||
* @param dir
|
||||
* @param snapshot
|
||||
* @return whether it is a valid snapshot
|
||||
*/
|
||||
public boolean isValidSnapshotName(String snapshot) {
|
||||
if (!snapshot.matches("[A-Za-z0-9_\\-,.\\[\\]\\(\\) ]{1,50}")) {
|
||||
return isValidSnapshot(new File(dir, snapshot));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if a snapshot is valid.
|
||||
*
|
||||
* @param f
|
||||
* @return whether it is a valid snapshot
|
||||
*/
|
||||
public boolean isValidSnapshot(File f) {
|
||||
if (!f.getName().matches("[A-Za-z0-9_\\-,.\\[\\]\\(\\) ]{1,50}")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
File f = new File(dir, snapshot);
|
||||
return (f.isDirectory() && (new File(f, "level.dat")).exists())
|
||||
|| (f.isFile() && f.getName().toLowerCase().endsWith((".zip")));
|
||||
|| (f.isFile() && (
|
||||
f.getName().toLowerCase().endsWith(".zip")
|
||||
|| f.getName().toLowerCase().endsWith(".tar.bz2")
|
||||
|| f.getName().toLowerCase().endsWith(".tar.gz")
|
||||
|| f.getName().toLowerCase().endsWith(".tar")
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren