Progress on New Save Format
Integrated the base code for our new save format. It still needs more work but at least some substance is there. Ignore the file not found messages that come up when trying to save the world's data - since we're not actually writing files, an exception occurs when we some later code tries to move non-existent save files. Also moved the FileFilter functionality out of DungeonHelper and into its own class, FileFilters, since it's finally needed more broadly.
This commit is contained in:
51
StevenDimDoors/mod_pocketDim/util/FileFilters.java
Normal file
51
StevenDimDoors/mod_pocketDim/util/FileFilters.java
Normal file
@@ -0,0 +1,51 @@
|
||||
package StevenDimDoors.mod_pocketDim.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class FileFilters
|
||||
{
|
||||
private FileFilters() { }
|
||||
|
||||
public static class DirectoryFilter implements FileFilter
|
||||
{
|
||||
@Override
|
||||
public boolean accept(File file)
|
||||
{
|
||||
return file.isDirectory();
|
||||
}
|
||||
}
|
||||
|
||||
public static class FileExtensionFilter implements FileFilter
|
||||
{
|
||||
private final String extension;
|
||||
|
||||
public FileExtensionFilter(String extension)
|
||||
{
|
||||
this.extension = extension;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(File file)
|
||||
{
|
||||
return file.isFile() && file.getName().endsWith(extension);
|
||||
}
|
||||
}
|
||||
|
||||
public static class RegexFileFilter implements FileFilter
|
||||
{
|
||||
private final Pattern pattern;
|
||||
|
||||
public RegexFileFilter(String expression)
|
||||
{
|
||||
this.pattern = Pattern.compile(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(File file)
|
||||
{
|
||||
return file.isFile() && pattern.matcher(file.getName()).matches();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user