diff options
author | Keuin <[email protected]> | 2021-01-13 14:32:08 +0800 |
---|---|---|
committer | keuin <[email protected]> | 2021-01-13 14:32:08 +0800 |
commit | 2bc659d8f95a97d0514491e48ed9c66828a4e308 (patch) | |
tree | 202962a05caadf652ec117812cc6704ea64d001c /src/main/java/com/keuin/kbackupfabric/KBCommands.java | |
parent | 1c6d68ee303ad3d4b1df5c3d433bf972256f0c8e (diff) |
BackupMethod now becomes stateful
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/KBCommands.java')
-rw-r--r-- | src/main/java/com/keuin/kbackupfabric/KBCommands.java | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/KBCommands.java b/src/main/java/com/keuin/kbackupfabric/KBCommands.java index 0e268ce..8f0e451 100644 --- a/src/main/java/com/keuin/kbackupfabric/KBCommands.java +++ b/src/main/java/com/keuin/kbackupfabric/KBCommands.java @@ -5,7 +5,7 @@ import com.keuin.kbackupfabric.operation.BackupOperation; import com.keuin.kbackupfabric.operation.DeleteOperation; import com.keuin.kbackupfabric.operation.RestoreOperation; import com.keuin.kbackupfabric.operation.abstracts.i.Invokable; -import com.keuin.kbackupfabric.operation.backup.method.PrimitiveBackupMethod; +import com.keuin.kbackupfabric.operation.backup.method.ConfiguredPrimitiveBackupMethod; import com.keuin.kbackupfabric.util.PrintUtil; import com.keuin.kbackupfabric.util.backup.BackupFilesystemUtil; import com.keuin.kbackupfabric.util.backup.name.PrimitiveBackupFileNameEncoder; @@ -16,6 +16,7 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.ServerCommandSource; import java.io.File; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -227,10 +228,18 @@ public final class KBCommands { } } - // Do backup - PrintUtil.info("Invoking backup worker ..."); - //BackupWorker.invoke(context, backupName, metadata); - BackupOperation operation = new BackupOperation(context, customBackupName, PrimitiveBackupMethod.getInstance()); + PrintUtil.info("Start backup..."); + + // configure backup method + MinecraftServer server = context.getSource().getMinecraftServer(); + ConfiguredPrimitiveBackupMethod method = new ConfiguredPrimitiveBackupMethod( + new PrimitiveBackupFileNameEncoder().encode(customBackupName, LocalDateTime.now()), + getLevelPath(server), + getBackupSaveDirectory(server).getAbsolutePath() + ); + + // dispatch to operation worker + BackupOperation operation = new BackupOperation(context, method); if (operation.invoke()) { return SUCCESS; } else if (operation.isBlocked()) { |