Added option for persistent resources like configuration files

This commit is contained in:
2023-11-11 22:45:23 +01:00
parent c6ecbe7548
commit 541eb1e733
2 changed files with 9 additions and 4 deletions

View File

@@ -14,7 +14,7 @@ import java.util.stream.Stream;
* Class from the Minestom Arena example
*/
public final class ResourceUtils {
public static void extractResource(String source) throws URISyntaxException, IOException {
public static void extractResource(String source, boolean keepOutdated) throws URISyntaxException, IOException {
final URI uri = Objects.requireNonNull(ResourceUtils.class.getResource("/" + source)).toURI();
FileSystem fileSystem = null;
@@ -27,6 +27,7 @@ public final class ResourceUtils {
final Path jarPath = Paths.get(uri);
final Path target = Path.of("resources/" + source);
if (Files.exists(target)) {
if(keepOutdated) return;
try (Stream<Path> pathStream = Files.walk(target)) {
pathStream.sorted(Comparator.reverseOrder())
.forEach(path -> {