diff options
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/operation')
-rw-r--r-- | src/main/java/com/keuin/kbackupfabric/operation/AbstractConfirmableOperation.java (renamed from src/main/java/com/keuin/kbackupfabric/operation/Confirmable.java) | 6 | ||||
-rw-r--r-- | src/main/java/com/keuin/kbackupfabric/operation/DeleteOperation.java | 13 | ||||
-rw-r--r-- | src/main/java/com/keuin/kbackupfabric/operation/RestoreOperation.java | 8 |
3 files changed, 12 insertions, 15 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/operation/Confirmable.java b/src/main/java/com/keuin/kbackupfabric/operation/AbstractConfirmableOperation.java index c8fdd71..d666a34 100644 --- a/src/main/java/com/keuin/kbackupfabric/operation/Confirmable.java +++ b/src/main/java/com/keuin/kbackupfabric/operation/AbstractConfirmableOperation.java @@ -3,13 +3,13 @@ package com.keuin.kbackupfabric.operation; import com.mojang.brigadier.context.CommandContext; import net.minecraft.server.command.ServerCommandSource; -public abstract class Confirmable { +public abstract class AbstractConfirmableOperation { - public static Confirmable createRestoreOperation(CommandContext<ServerCommandSource> context, String backupName) { + public static AbstractConfirmableOperation createRestoreOperation(CommandContext<ServerCommandSource> context, String backupName) { return new RestoreOperation(context, backupName); } - public static Confirmable createDeleteOperation(CommandContext<ServerCommandSource> context, String backupName) { + public static AbstractConfirmableOperation createDeleteOperation(CommandContext<ServerCommandSource> context, String backupName) { return new DeleteOperation(context, backupName); } diff --git a/src/main/java/com/keuin/kbackupfabric/operation/DeleteOperation.java b/src/main/java/com/keuin/kbackupfabric/operation/DeleteOperation.java index 1e28324..be7734d 100644 --- a/src/main/java/com/keuin/kbackupfabric/operation/DeleteOperation.java +++ b/src/main/java/com/keuin/kbackupfabric/operation/DeleteOperation.java @@ -1,10 +1,9 @@ package com.keuin.kbackupfabric.operation; +import com.keuin.kbackupfabric.util.PrintUtil; import com.mojang.brigadier.context.CommandContext; import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.ServerCommandSource; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import java.io.File; import java.io.IOException; @@ -15,9 +14,9 @@ import static com.keuin.kbackupfabric.util.PrintUtil.msgErr; import static com.keuin.kbackupfabric.util.PrintUtil.msgInfo; import static org.apache.commons.io.FileUtils.forceDelete; -class DeleteOperation extends Confirmable { +class DeleteOperation extends AbstractConfirmableOperation { - private static final Logger LOGGER = LogManager.getLogger(); + //private static final Logger LOGGER = LogManager.getLogger(); private final String backupName; private final CommandContext<ServerCommandSource> context; @@ -30,13 +29,13 @@ class DeleteOperation extends Confirmable { public boolean confirm() { MinecraftServer server = context.getSource().getMinecraftServer(); String backupFileName = getBackupFileName(backupName); - LOGGER.info("Deleting backup " + backupName); + PrintUtil.info("Deleting backup " + backupName); File backupFile = new File(getBackupSaveDirectory(server), backupFileName); int tryCounter = 0; do { if (tryCounter == 5) { String msg = "Failed to delete file " + backupFileName; - LOGGER.error(msg); + PrintUtil.error(msg); msgErr(context, msg); return false; } @@ -47,7 +46,7 @@ class DeleteOperation extends Confirmable { } ++tryCounter; } while (backupFile.exists()); - LOGGER.info("Deleted backup " + backupName); + PrintUtil.info("Deleted backup " + backupName); msgInfo(context, "Deleted backup " + backupName); return true; } diff --git a/src/main/java/com/keuin/kbackupfabric/operation/RestoreOperation.java b/src/main/java/com/keuin/kbackupfabric/operation/RestoreOperation.java index 48dd413..2d0c403 100644 --- a/src/main/java/com/keuin/kbackupfabric/operation/RestoreOperation.java +++ b/src/main/java/com/keuin/kbackupfabric/operation/RestoreOperation.java @@ -5,16 +5,14 @@ import com.keuin.kbackupfabric.worker.RestoreWorker; import com.mojang.brigadier.context.CommandContext; import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.ServerCommandSource; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import java.io.File; import static com.keuin.kbackupfabric.util.BackupFilesystemUtil.*; -class RestoreOperation extends Confirmable { +class RestoreOperation extends AbstractConfirmableOperation { - private static final Logger LOGGER = LogManager.getLogger(); + //private static final Logger LOGGER = LogManager.getLogger(); private final String backupName; private final CommandContext<ServerCommandSource> context; @@ -30,7 +28,7 @@ class RestoreOperation extends Confirmable { PrintUtil.msgInfo(context, String.format("Restoring to previous world %s ...", backupName), true); String backupFileName = getBackupFileName(backupName); - LOGGER.debug("Backup file name: " + backupFileName); + PrintUtil.debug("Backup file name: " + backupFileName); File backupFile = new File(getBackupSaveDirectory(server), backupFileName); PrintUtil.msgInfo(context, "Server will shutdown in a few seconds, depended on your world size and the disk speed, the restore progress may take seconds or minutes.", true); |