From 381843f39f6e896e153cff75b6d16f4481ed2495 Mon Sep 17 00:00:00 2001 From: Keuin Date: Sat, 20 Jan 2024 01:55:59 +0800 Subject: feature: get CoW info with command `/kb cow-info` --- src/main/java/com/keuin/kbackupfabric/KBCommandsRegister.java | 4 ++++ src/main/java/com/keuin/kbackupfabric/ui/KBCommands.java | 11 +++++++++++ 2 files changed, 15 insertions(+) (limited to 'src/main/java') diff --git a/src/main/java/com/keuin/kbackupfabric/KBCommandsRegister.java b/src/main/java/com/keuin/kbackupfabric/KBCommandsRegister.java index 5bf92e4..7e454d2 100644 --- a/src/main/java/com/keuin/kbackupfabric/KBCommandsRegister.java +++ b/src/main/java/com/keuin/kbackupfabric/KBCommandsRegister.java @@ -58,6 +58,10 @@ public final class KBCommandsRegister { .requires(Permissions.require("kb.list", DEFAULT_REQUIRED_LEVEL)) .executes(KBCommands::list))); + dispatcher.register(CommandManager.literal("kb") + .then(CommandManager.literal("cow-info") + .executes(KBCommands::cowInfo))); + // register /kb delete [name] for deleting an existing backup. OP is required. dispatcher.register(CommandManager.literal("kb") .then(CommandManager.literal("delete") diff --git a/src/main/java/com/keuin/kbackupfabric/ui/KBCommands.java b/src/main/java/com/keuin/kbackupfabric/ui/KBCommands.java index d23a6fd..0dff99a 100644 --- a/src/main/java/com/keuin/kbackupfabric/ui/KBCommands.java +++ b/src/main/java/com/keuin/kbackupfabric/ui/KBCommands.java @@ -14,6 +14,7 @@ import com.keuin.kbackupfabric.operation.backup.method.ConfiguredIncrementalBack import com.keuin.kbackupfabric.operation.backup.method.ConfiguredPrimitiveBackupMethod; import com.keuin.kbackupfabric.util.DateUtil; import com.keuin.kbackupfabric.util.PrintUtil; +import com.keuin.kbackupfabric.util.cow.FileCowCopier; import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.context.CommandContext; import net.minecraft.server.MinecraftServer; @@ -75,6 +76,7 @@ public final class KBCommands { msgInfo(context, "/kb restore - Delete the whole current level and restore from given backup. /kb restore is identical with /kb list."); msgInfo(context, "/kb confirm - Confirm and start restoring."); msgInfo(context, "/kb cancel - Cancel the restoration to be confirmed. If cancelled, /kb confirm will not run."); + msgInfo(context, "/kb cow-info - Display copy-on-write support info (Experimental)"); return SUCCESS; } @@ -135,6 +137,15 @@ public final class KBCommands { return SUCCESS; } + public static int cowInfo(CommandContext context) { + try { + msgInfo(context, "KBackup-cow library version: " + FileCowCopier.getVersion()); + } catch (Exception | UnsatisfiedLinkError ignored) { + msgErr(context, "KBackup-cow library is not loaded"); + } + return SUCCESS; + } + /** * Print backup information. * -- cgit v1.2.3