From 5f1706eed33fe423462dcdf818d31344892d369c Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Tue, 29 Nov 2022 22:34:02 +0100 Subject: [PATCH] added game&mod version to the status file --- .../java/net/szum123321/textile_backup/TextileBackup.java | 8 +++++++- .../szum123321/textile_backup/core/CompressionStatus.java | 4 ++-- .../core/create/compressors/AbstractCompressor.java | 5 +++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/szum123321/textile_backup/TextileBackup.java b/src/main/java/net/szum123321/textile_backup/TextileBackup.java index 4376430..f4b97b8 100644 --- a/src/main/java/net/szum123321/textile_backup/TextileBackup.java +++ b/src/main/java/net/szum123321/textile_backup/TextileBackup.java @@ -54,7 +54,13 @@ public class TextileBackup implements ModInitializer { @Override public void onInitialize() { - log.info("Starting Textile Backup by Szum123321"); + Globals.INSTANCE.setCombinedVersionString( + FabricLoader.getInstance().getModContainer(MOD_ID).orElseThrow().getMetadata().getVersion().getFriendlyString() + + ":" + + FabricLoader.getInstance().getModContainer("minecraft").orElseThrow().getMetadata().getVersion().getFriendlyString() + ); + + log.info("Starting Textile Backup {} by Szum123321", Globals.INSTANCE.getCombinedVersionString()); ConfigHelper.updateInstance(AutoConfig.register(ConfigPOJO.class, JanksonConfigSerializer::new)); diff --git a/src/main/java/net/szum123321/textile_backup/core/CompressionStatus.java b/src/main/java/net/szum123321/textile_backup/core/CompressionStatus.java index db3f5d2..e9c618f 100644 --- a/src/main/java/net/szum123321/textile_backup/core/CompressionStatus.java +++ b/src/main/java/net/szum123321/textile_backup/core/CompressionStatus.java @@ -25,7 +25,7 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.Map; -public record CompressionStatus(long treeHash, Map brokenFiles, LocalDateTime date, long startTimestamp, long finishTimestamp) implements Serializable { +public record CompressionStatus(long treeHash, Map brokenFiles, LocalDateTime date, long startTimestamp, long finishTimestamp, String version) implements Serializable { public static final String DATA_FILENAME = "textile_status.data"; public boolean isValid(long decompressedHash) { return decompressedHash == treeHash && brokenFiles.isEmpty(); @@ -55,7 +55,7 @@ public record CompressionStatus(long treeHash, Map brokenFiles, .append(date.format(DateTimeFormatter.ISO_DATE_TIME)) .append(", start time stamp: ").append(startTimestamp) .append(", finish time stamp: ").append(finishTimestamp) - ;//.append(", Mod Version: ").append(modVersion.getFriendlyString()); + .append(", Mod Version: ").append(version); builder.append(", broken files: "); if(brokenFiles.isEmpty()) builder.append("[]"); diff --git a/src/main/java/net/szum123321/textile_backup/core/create/compressors/AbstractCompressor.java b/src/main/java/net/szum123321/textile_backup/core/create/compressors/AbstractCompressor.java index 9866626..65bf00a 100644 --- a/src/main/java/net/szum123321/textile_backup/core/create/compressors/AbstractCompressor.java +++ b/src/main/java/net/szum123321/textile_backup/core/create/compressors/AbstractCompressor.java @@ -18,6 +18,7 @@ package net.szum123321.textile_backup.core.create.compressors; +import net.szum123321.textile_backup.Globals; import net.szum123321.textile_backup.TextileBackup; import net.szum123321.textile_backup.TextileLogger; import net.szum123321.textile_backup.config.ConfigHelper; @@ -100,8 +101,8 @@ public abstract class AbstractCompressor { CompressionStatus status = new CompressionStatus ( fileHashBuilder.getValue(), brokenFileHandler.get(), - ctx.startDate(), start.toEpochMilli(), now.toEpochMilli()//, - //TextileBackup.VERSION + ctx.startDate(), start.toEpochMilli(), now.toEpochMilli(), + Globals.INSTANCE.getCombinedVersionString() ); addEntry(new StatusFileInputSupplier(status.serialize()), arc);