summaryrefslogtreecommitdiff
path: root/src/main/java/com/keuin/kbackupfabric/operation
diff options
context:
space:
mode:
authorKeuin <[email protected]>2020-04-24 13:10:00 +0800
committerkeuin <[email protected]>2020-04-24 13:10:00 +0800
commit59674ed29c6b2c7e8ac98fc4f0f4fd4fd6d437c9 (patch)
tree47730fe93306b41b68f29b86ef5d0860c0d53d42 /src/main/java/com/keuin/kbackupfabric/operation
parent5749fc65909f0ee934d0410406265387157575a1 (diff)
Implemented uniformed console output (log4j) in PrintUtil.
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.java13
-rw-r--r--src/main/java/com/keuin/kbackupfabric/operation/RestoreOperation.java8
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);