From f60b656bedd7e4a9969e74a71062b98e210e09b2 Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Mon, 22 Sep 2025 19:27:58 +0800 Subject: [PATCH] Fix issue when trying to backup `worlds.yml.old` and file already exists --- .../multiverse/core/world/WorldsConfigManager.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/mvplugins/multiverse/core/world/WorldsConfigManager.java b/src/main/java/org/mvplugins/multiverse/core/world/WorldsConfigManager.java index 23361271f..856f00e9d 100644 --- a/src/main/java/org/mvplugins/multiverse/core/world/WorldsConfigManager.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/WorldsConfigManager.java @@ -19,6 +19,7 @@ import org.mvplugins.multiverse.core.MultiverseCore; import static java.nio.file.StandardCopyOption.COPY_ATTRIBUTES; +import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; /** * Manages the worlds.yml file. @@ -81,8 +82,9 @@ private void migrateRemoveOldConfigSerializable() { } // Copy old config file to `worlds.yml.old` - Path oldWorldConfig = worldConfigFile.toPath().getParent().resolve(CONFIG_FILENAME + ".old"); - Files.copy(worldConfigFile.toPath(), oldWorldConfig, COPY_ATTRIBUTES); + Path oldWorldConfig = worldConfigFile.toPath().getParent() + .resolve(CONFIG_FILENAME + ".old." + System.currentTimeMillis()); + Files.copy(worldConfigFile.toPath(), oldWorldConfig, COPY_ATTRIBUTES, REPLACE_EXISTING); return configData.replace("==: MVWorld", "w@: world") .replace("==: MVSpawnSettings", "")