Skip to content

Commit 3ba8bee

Browse files
authored
Merge pull request #3436 from Multiverse/fix/clone-paper-metadata
Fix clone not working due to duplicated Paper world metadata in 26.1
2 parents 247685c + 05b6b38 commit 3ba8bee

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

src/main/java/org/mvplugins/multiverse/core/utils/FileUtils.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
import java.util.Collections;
1919
import java.util.Comparator;
2020
import java.util.List;
21+
import java.util.stream.Collectors;
2122
import java.util.stream.Stream;
2223

2324
import com.dumptruckman.minecraft.util.Logging;
2425
import io.vavr.control.Try;
2526
import jakarta.inject.Inject;
2627
import org.jetbrains.annotations.NotNull;
2728
import org.jetbrains.annotations.Nullable;
29+
import org.jspecify.annotations.NonNull;
2830
import org.jvnet.hk2.annotations.Service;
2931
import org.mvplugins.multiverse.core.config.CoreConfig;
3032

@@ -210,16 +212,19 @@ private static final class CopyDirFileVisitor extends SimpleFileVisitor<Path> {
210212

211213
private final Path sourceDir;
212214
private final Path targetDir;
213-
private final List<String> excludeFiles;
215+
private final List<Path> excludeFiles;
214216

215217
private CopyDirFileVisitor(@NotNull Path sourceDir, @NotNull Path targetDir, @NotNull List<String> excludeFiles) {
216218
this.sourceDir = sourceDir;
217219
this.targetDir = targetDir;
218-
this.excludeFiles = excludeFiles;
220+
this.excludeFiles = excludeFiles.stream()
221+
.map(sourceDir::resolve)
222+
.toList();
223+
Logging.finest(this.excludeFiles.stream().map(Path::toString).collect(Collectors.joining(", ", "Exclude files: [", "]")));
219224
}
220225

221226
@Override
222-
public @NotNull FileVisitResult preVisitDirectory(Path dir, @NotNull BasicFileAttributes attrs) throws IOException {
227+
public @NotNull FileVisitResult preVisitDirectory(@NonNull Path dir, @NotNull BasicFileAttributes attrs) throws IOException {
223228
Path newDir = targetDir.resolve(sourceDir.relativize(dir));
224229
if (!Files.isDirectory(newDir)) {
225230
Files.createDirectory(newDir);
@@ -228,10 +233,10 @@ private CopyDirFileVisitor(@NotNull Path sourceDir, @NotNull Path targetDir, @No
228233
}
229234

230235
@Override
231-
public @NotNull FileVisitResult visitFile(Path file, @NotNull BasicFileAttributes attrs) throws IOException {
236+
public @NotNull FileVisitResult visitFile(@NonNull Path file, @NotNull BasicFileAttributes attrs) throws IOException {
232237
// Pass files that are set to ignore
233-
if (excludeFiles.contains(file.getFileName().toString())) {
234-
Logging.finest("Ignoring file: " + file.getFileName());
238+
if (excludeFiles.contains(file)) {
239+
Logging.finest("Ignoring file: " + file);
235240
return FileVisitResult.CONTINUE;
236241
}
237242
// Copy the files

src/main/java/org/mvplugins/multiverse/core/world/WorldManager.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@
8787
@Service // SUPPRESS CHECKSTYLE: ClassFanOutComplexity This is the world manager, it's going to be complex.
8888
public final class WorldManager {
8989

90-
private static final List<String> CLONE_IGNORE_FILES = Arrays.asList("uid.dat", "session.lock");
90+
private static final List<String> CLONE_IGNORE_FILES = List.of(
91+
"uid.dat", "session.lock", // All pre 26.1 format
92+
"data/paper/metadata.dat" // New papermc format for 26.1+
93+
);
94+
9195
private static final DimensionFormat DEFAULT_NETHER_FORMAT = new DimensionFormat("%overworld%_nether");
9296
private static final DimensionFormat DEFAULT_END_FORMAT = new DimensionFormat("%overworld%_the_end");
9397

0 commit comments

Comments
 (0)