reformatted project
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package eu.mhsl.minenet.minigames.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
@@ -19,7 +21,7 @@ public final class ResourceUtils {
|
||||
final URI uri = Objects.requireNonNull(ResourceUtils.class.getResource("/" + source)).toURI();
|
||||
FileSystem fileSystem = null;
|
||||
|
||||
if (uri.toString().startsWith("jar:"))
|
||||
if(uri.toString().startsWith("jar:"))
|
||||
fileSystem = FileSystems.newFileSystem(uri, Map.of("create", "true"));
|
||||
|
||||
try {
|
||||
@@ -28,36 +30,36 @@ public final class ResourceUtils {
|
||||
final Path jarPath = Paths.get(uri);
|
||||
final Path target = Path.of("resources/" + source);
|
||||
|
||||
if (Files.exists(target)) {
|
||||
if(Files.exists(target)) {
|
||||
if(keepOutdated) return;
|
||||
try (Stream<Path> pathStream = Files.walk(target)) {
|
||||
try(Stream<Path> pathStream = Files.walk(target)) {
|
||||
pathStream.sorted(Comparator.reverseOrder())
|
||||
.forEach(path -> {
|
||||
try {
|
||||
Files.delete(path);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
.forEach(path -> {
|
||||
try {
|
||||
Files.delete(path);
|
||||
} catch(IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Files.walkFileTree(jarPath, new SimpleFileVisitor<>() {
|
||||
@Override
|
||||
public FileVisitResult preVisitDirectory(final Path dir, final BasicFileAttributes attrs) throws IOException {
|
||||
public @NotNull FileVisitResult preVisitDirectory(final @NotNull Path dir, final @NotNull BasicFileAttributes attrs) throws IOException {
|
||||
Path currentTarget = target.resolve(jarPath.relativize(dir).toString());
|
||||
Files.createDirectories(currentTarget);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
|
||||
public @NotNull FileVisitResult visitFile(final @NotNull Path file, final @NotNull BasicFileAttributes attrs) throws IOException {
|
||||
final Path to = target.resolve(jarPath.relativize(file).toString());
|
||||
Files.copy(file, to, StandardCopyOption.REPLACE_EXISTING);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
if (fileSystem != null)
|
||||
if(fileSystem != null)
|
||||
fileSystem.close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user