diff options
author | Keuin <[email protected]> | 2021-01-20 18:15:35 +0800 |
---|---|---|
committer | keuin <[email protected]> | 2021-01-20 18:18:00 +0800 |
commit | 51c2d5d8e63b9db9245d0a1c76f8a94c4cf7c31d (patch) | |
tree | 9b59134659488b77e07c5fdb1c587fd652c1a025 /src/main/java/com/keuin/kbackupfabric/util/backup/BackupFilesystemUtil.java | |
parent | a28bd300a49328d04dff0a071e7cfca47cc1ed6c (diff) |
1.4.2: BugFix: The plugin makes a blank backup if the world (is created in client-side and) is not named as the same with the folder name (by default it is `world`, the backup will fail silently if the world name is not equal to the folder name).
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/util/backup/BackupFilesystemUtil.java')
-rw-r--r-- | src/main/java/com/keuin/kbackupfabric/util/backup/BackupFilesystemUtil.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/util/backup/BackupFilesystemUtil.java b/src/main/java/com/keuin/kbackupfabric/util/backup/BackupFilesystemUtil.java index 7106ad2..28ede70 100644 --- a/src/main/java/com/keuin/kbackupfabric/util/backup/BackupFilesystemUtil.java +++ b/src/main/java/com/keuin/kbackupfabric/util/backup/BackupFilesystemUtil.java @@ -2,10 +2,13 @@ package com.keuin.kbackupfabric.util.backup; import com.keuin.kbackupfabric.util.ReflectionUtils; import net.minecraft.server.MinecraftServer; +import net.minecraft.server.dedicated.MinecraftDedicatedServer; import net.minecraft.server.world.ThreadedAnvilChunkStorage; import net.minecraft.world.World; import java.io.File; +import java.io.IOException; +import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -47,8 +50,13 @@ public final class BackupFilesystemUtil { return new File(server.getRunDirectory(), INCREMENTAL_BASE_DIRECTORY_NAME); } - public static String getLevelPath(MinecraftServer server) { - return (new File(server.getRunDirectory(), server.getLevelName())).getAbsolutePath(); + public static String getLevelPath(MinecraftServer server) throws IOException { + if (!(server instanceof MinecraftDedicatedServer)) + throw new IllegalStateException("This plugin is server-side only."); + String path = (new File(server.getRunDirectory().getCanonicalPath(), ((MinecraftDedicatedServer) server).getLevelName())).getAbsolutePath(); + Logger.getLogger("getLevelPath").info(String.format("Level path: %s", path)); + assert (new File(path)).exists(); + return path; } public static String getWorldDirectoryName(World world) throws NoSuchFieldException, IllegalAccessException { |