From 708659b5dd07267a040cd564eef1e10dc2b3247d Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Wed, 24 Jun 2020 20:37:52 +0200 Subject: [PATCH] Few small tweaks. Most lkely final 1.16.1 version. --- gradle.properties | 2 +- .../textile_backup/ConfigHandler.java | 20 ++++++++++--------- .../textile_backup/TextileBackup.java | 2 +- .../textile_backup/core/BackupHelper.java | 4 +++- .../textile_backup/core/MakeBackupThread.java | 2 +- .../textile_backup/core/Utilities.java | 19 ++++-------------- src/main/resources/fabric.mod.json | 2 +- 7 files changed, 22 insertions(+), 29 deletions(-) diff --git a/gradle.properties b/gradle.properties index 4644abc..dc8019d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,6 +9,6 @@ loader_version=0.8.8+build.202 fabric_version=0.13.1+build.370-1.16 # Mod Properties -mod_version = 1.2.1-1.16-pre2 +mod_version = 1.2.2-1.16.1 maven_group = net.szum123321 archives_base_name = textile_backup \ No newline at end of file diff --git a/src/main/java/net/szum123321/textile_backup/ConfigHandler.java b/src/main/java/net/szum123321/textile_backup/ConfigHandler.java index b177113..dd3bdf8 100644 --- a/src/main/java/net/szum123321/textile_backup/ConfigHandler.java +++ b/src/main/java/net/szum123321/textile_backup/ConfigHandler.java @@ -26,35 +26,35 @@ import java.util.Set; @ConfigFile(name = TextileBackup.MOD_ID) public class ConfigHandler { - @Comment("\nTime between backups in seconds\n") + @Comment("\nTime between automatic backups in seconds\n") public long backupInterval = 3600; - @Comment("\nShould backups be done even if there is no players?\n") + @Comment("\nShould backups be done even if there are no players?\n") public boolean doBackupsOnEmptyServer = false; - @Comment("\nShould backups be made on server shutdown\n") + @Comment("\nShould backup be made on server shutdown\n") public boolean shutdownBackup = true; @Comment("\nA path to backup folder\n") public String path = "backup/"; @Comment("\nThis setting allows you to exclude files form being backuped.\n"+ - "Be very careful when setting it, as it is easy to make your backuped world unusable!\n") + "Be very careful when setting it, as it is easy corrupt your world!\n") public Set fileBlacklist = new HashSet<>(); @Comment("\nShould every world has its won backup folder?\n") public boolean perWorldBackup = false; - @Comment("\nMaximum number of backups to keep. If 0 then no backup will be deleted based on its amount\n") + @Comment("\nMaximum number of backups to keep. If set to 0 then no backup will be deleted based their its amount\n") public int backupsToKeep = 10; - @Comment("\nMaximum age of backups to keep in seconds.\n if 0 then backups will not be deleted based on its age \n") + @Comment("\nMaximum age of backups to keep in seconds.\n If set to 0 then backups will not be deleted based their its age \n") public long maxAge = 0; - @Comment("\nMaximum size of backup folder in kilo bytes. \n") + @Comment("\nMaximum size of backup folder in kilo bytes (1024).\n") public int maxSize = 0; - @Comment("\nCompression level \n0 - 9\n Only available for zip compression.\n") + @Comment("\nCompression level \n0 - 9\n Only affects zip compression.\n") public int compression = 6; @Comment(value = "\nAvailable formats are:\n" + @@ -82,7 +82,9 @@ public class ConfigHandler { @Comment("\nPlayers banned from running backup commands besides their sufficient permission level\n") public Set playerBlacklist = new HashSet<>(); - @Comment("\nFormat of date&time used to name backup files.\n") + @Comment("\nFormat of date&time used to name backup files.\n" + + "Remember not to use '#' symbol and any other character that is not allowed by your operating system such as:\n" + + "':', '\\', etc\n") public String dateTimeFormat = "dd.MM.yyyy_HH-mm-ss"; public enum ArchiveFormat { diff --git a/src/main/java/net/szum123321/textile_backup/TextileBackup.java b/src/main/java/net/szum123321/textile_backup/TextileBackup.java index d12fd52..baf31d3 100644 --- a/src/main/java/net/szum123321/textile_backup/TextileBackup.java +++ b/src/main/java/net/szum123321/textile_backup/TextileBackup.java @@ -58,7 +58,7 @@ public class TextileBackup implements ModInitializer { !config.playerBlacklist.contains(ctx.getEntityOrThrow().getEntityName())) || (ctx.getMinecraftServer().isSinglePlayer() && config.alwaysSingleplayerAllowed); - }catch (Exception e){ //Command was called from server console. + } catch (Exception e) { //Command was called from server console. return true; } } diff --git a/src/main/java/net/szum123321/textile_backup/core/BackupHelper.java b/src/main/java/net/szum123321/textile_backup/core/BackupHelper.java index 626354b..4587f2a 100644 --- a/src/main/java/net/szum123321/textile_backup/core/BackupHelper.java +++ b/src/main/java/net/szum123321/textile_backup/core/BackupHelper.java @@ -98,7 +98,9 @@ public class BackupHelper { Utilities.log("Deleting: " + f.getName(), ctx); f.delete(); } - } catch (NullPointerException ignored3) {} + } catch (NullPointerException ignored3) { + Utilities.error("File: " + f.getName() + ", was not deleted beacuse could not parse date and time. Please delete it by hand.", ctx); + } }); } diff --git a/src/main/java/net/szum123321/textile_backup/core/MakeBackupThread.java b/src/main/java/net/szum123321/textile_backup/core/MakeBackupThread.java index a971123..5a0791a 100644 --- a/src/main/java/net/szum123321/textile_backup/core/MakeBackupThread.java +++ b/src/main/java/net/szum123321/textile_backup/core/MakeBackupThread.java @@ -48,7 +48,7 @@ public class MakeBackupThread implements Runnable { @Override public void run() { - File world = ((MinecraftServerSessionAccessor)server) // I'm lost. + File world = ((MinecraftServerSessionAccessor)server) .getSession() .method_27424(RegistryKey.of(Registry.DIMENSION, DimensionType.OVERWORLD_REGISTRY_KEY.getValue())); diff --git a/src/main/java/net/szum123321/textile_backup/core/Utilities.java b/src/main/java/net/szum123321/textile_backup/core/Utilities.java index e1d4f01..d9fd2e4 100644 --- a/src/main/java/net/szum123321/textile_backup/core/Utilities.java +++ b/src/main/java/net/szum123321/textile_backup/core/Utilities.java @@ -2,10 +2,8 @@ package net.szum123321.textile_backup.core; import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.server.dedicated.DedicatedServer; -import net.minecraft.server.dedicated.MinecraftDedicatedServer; -import net.minecraft.server.integrated.IntegratedServer; import net.minecraft.text.LiteralText; +import net.minecraft.util.Formatting; import net.szum123321.textile_backup.TextileBackup; import net.szum123321.textile_backup.mixin.MinecraftServerSessionAccessor; @@ -17,11 +15,6 @@ public class Utilities { return ((MinecraftServerSessionAccessor)server).getSession().getDirectoryName(); } - public static boolean isWindows(){ - String os = System.getProperty("os.name"); - return os.toLowerCase().startsWith("win"); - } - public static boolean isBlacklisted(Path path) { for(String i : TextileBackup.config.fileBlacklist) { if(path.startsWith(i)) @@ -38,12 +31,8 @@ public class Utilities { return getBackupDateTimeFormatter(); } - public static DateTimeFormatter getBackupDateTimeFormatter(){ - if(isWindows()){ - return DateTimeFormatter.ofPattern("dd.MM.yyyy_HH-mm-ss"); - } else { - return DateTimeFormatter.ofPattern("dd.MM.yyyy_HH:mm:ss"); - } + public static DateTimeFormatter getBackupDateTimeFormatter() { + return DateTimeFormatter.ofPattern("dd.MM.yyyy_HH-mm-ss"); } public static void log(String s, ServerCommandSource ctx){ @@ -56,7 +45,7 @@ public class Utilities { public static void error(String s, ServerCommandSource ctx){ if(ctx != null) - ctx.sendFeedback(new LiteralText(s), true); + ctx.sendFeedback(new LiteralText(s).styled(style -> style.withColor(Formatting.RED)), true); if(TextileBackup.config.log) TextileBackup.logger.error(s); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 5d3d13c..2ab067c 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -27,7 +27,7 @@ ], "depends": { - "fabricloader": ">=0.7.2", + "fabricloader": ">=0.8.8", "fabric": "*", "minecraft": "1.16.1" }