From 08ac6aaea58b7309ea95a12ca6227a6ca3ce4db5 Mon Sep 17 00:00:00 2001 From: Keuin Date: Mon, 25 Jan 2021 15:25:34 +0800 Subject: Improve user interaction. Code refactor. --- src/main/java/com/keuin/kbackupfabric/KBPluginEvents.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/main/java/com/keuin/kbackupfabric/KBPluginEvents.java') diff --git a/src/main/java/com/keuin/kbackupfabric/KBPluginEvents.java b/src/main/java/com/keuin/kbackupfabric/KBPluginEvents.java index e1d5cbd..8992d17 100644 --- a/src/main/java/com/keuin/kbackupfabric/KBPluginEvents.java +++ b/src/main/java/com/keuin/kbackupfabric/KBPluginEvents.java @@ -4,6 +4,8 @@ import com.keuin.kbackupfabric.backup.BackupFilesystemUtil; import com.keuin.kbackupfabric.backup.suggestion.BackupNameSuggestionProvider; import com.keuin.kbackupfabric.metadata.BackupMetadata; import com.keuin.kbackupfabric.metadata.MetadataHolder; +import com.keuin.kbackupfabric.ui.KBCommands; +import com.keuin.kbackupfabric.util.DateUtil; import com.keuin.kbackupfabric.util.PrintUtil; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.event.server.ServerStartCallback; @@ -15,8 +17,6 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.ObjectInputStream; -import java.text.SimpleDateFormat; -import java.util.Date; import static org.apache.commons.io.FileUtils.forceDelete; @@ -39,11 +39,14 @@ public final class KBPluginEvents implements ModInitializer, ServerStartCallback public void onStartServer(MinecraftServer server) { if (!(server instanceof MinecraftDedicatedServer)) - throw new RuntimeException("KBackup is a server-side-only plugin. Please do not use it in Minecraft client."); + throw new RuntimeException("KBackup is a server-side-only plugin. Please do not use it in client-side."); // Initialize player manager reference PrintUtil.setPlayerManager(server.getPlayerManager()); + // Initialize backup manager server reference + KBCommands.setServer(server); + // Update backup suggestion list BackupNameSuggestionProvider.setBackupSaveDirectory(BackupFilesystemUtil.getBackupSaveDirectory(server).getPath()); @@ -64,7 +67,7 @@ public final class KBPluginEvents implements ModInitializer, ServerStartCallback MetadataHolder.setMetadata(metadata); PrintUtil.info("Restored world from a previous backup:"); PrintUtil.info("Backup Name: " + metadata.getBackupName()); - PrintUtil.info("Create Time: " + (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(new Date(metadata.getBackupTime()))); + PrintUtil.info("Create Time: " + DateUtil.fromEpochMillis(metadata.getBackupTime())); // Delete metadata file if (!metadataFile.delete()) { -- cgit v1.2.3