Added mod version info to metadata

This commit is contained in:
Szum123321 2022-11-29 00:55:41 +01:00
parent 2efe112157
commit 86ae95b02e
2 changed files with 13 additions and 2 deletions

View File

@ -26,6 +26,8 @@ import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.Version;
import net.minecraft.server.command.ServerCommandSource;
import net.szum123321.textile_backup.commands.create.CleanupCommand;
import net.szum123321.textile_backup.commands.create.StartBackupCommand;
@ -45,6 +47,7 @@ import net.szum123321.textile_backup.core.create.MakeBackupRunnableFactory;
public class TextileBackup implements ModInitializer {
public static final String MOD_NAME = "Textile Backup";
public static final String MOD_ID = "textile_backup";
public static final Version VERSION;
private final static TextileLogger log = new TextileLogger(MOD_NAME);
private final static ConfigHelper config = ConfigHelper.INSTANCE;
@ -105,4 +108,9 @@ public class TextileBackup implements ModInitializer {
.then(KillRestoreCommand.register())
));
}
static {
VERSION = FabricLoader.getInstance().getModContainer(MOD_ID).orElseThrow().getMetadata().getVersion();
FabricLoader.getInstance().getModContainer("minecraft").orElseThrow().getMetadata().getVersion();
}
}

View File

@ -18,6 +18,8 @@
package net.szum123321.textile_backup.core;
import net.fabricmc.loader.api.Version;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
@ -25,7 +27,7 @@ import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Map;
public record CompressionStatus(long treeHash, LocalDateTime date, long startTimestamp, long finishTimestamp, Map<Path, Exception> brokenFiles) implements Serializable {
public record CompressionStatus(long treeHash, Map<Path, Exception> brokenFiles, LocalDateTime date, long startTimestamp, long finishTimestamp, Version modVersion) implements Serializable {
public static final String DATA_FILENAME = "textile_status.data";
public boolean isValid(long decompressedHash) {
return decompressedHash == treeHash;
@ -54,7 +56,8 @@ public record CompressionStatus(long treeHash, LocalDateTime date, long startTim
.append(", Date: ")
.append(date.format(DateTimeFormatter.ISO_DATE_TIME))
.append(", start time stamp: ").append(startTimestamp)
.append(", finish time stamp: ").append(finishTimestamp);
.append(", finish time stamp: ").append(finishTimestamp)
.append(", Mod Version:").append(modVersion.getFriendlyString());
builder.append(", broken files: ");
if(brokenFiles.isEmpty()) builder.append("[]");