diff --git a/src/main/java/net/szum123321/textile_backup/commands/FileSuggestionProvider.java b/src/main/java/net/szum123321/textile_backup/commands/FileSuggestionProvider.java index 120e5a7..e4ef038 100644 --- a/src/main/java/net/szum123321/textile_backup/commands/FileSuggestionProvider.java +++ b/src/main/java/net/szum123321/textile_backup/commands/FileSuggestionProvider.java @@ -40,7 +40,9 @@ public final class FileSuggestionProvider implements SuggestionProvider getSuggestions(CommandContext ctx, SuggestionsBuilder builder) { String remaining = builder.getRemaining(); - for (RestoreableFile file : RestoreHelper.getAvailableBackups(ctx.getSource().getServer())) { + var files = RestoreHelper.getAvailableBackups(ctx.getSource().getServer()); + + for (RestoreableFile file: files) { String formattedCreationTime = file.getCreationTime().format(Globals.defaultDateTimeFormatter); if (formattedCreationTime.startsWith(remaining)) { diff --git a/src/main/java/net/szum123321/textile_backup/core/RestoreableFile.java b/src/main/java/net/szum123321/textile_backup/core/RestoreableFile.java index e9f41b4..b44d9e5 100644 --- a/src/main/java/net/szum123321/textile_backup/core/RestoreableFile.java +++ b/src/main/java/net/szum123321/textile_backup/core/RestoreableFile.java @@ -83,8 +83,8 @@ public class RestoreableFile implements Comparable { String comment = null; if(filename.contains("#")) { - comment = filename.substring(filename.indexOf("#"), parsed_pos); - parsed_pos -= comment.length() - 1; + comment = filename.substring(filename.indexOf("#") + 1, parsed_pos); + parsed_pos -= comment.length() + 1; } var time_string = filename.substring(0, parsed_pos); 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 5482708..65a6f9f 100644 --- a/src/main/java/net/szum123321/textile_backup/core/Utilities.java +++ b/src/main/java/net/szum123321/textile_backup/core/Utilities.java @@ -44,9 +44,8 @@ public class Utilities { private final static ConfigHelper config = ConfigHelper.INSTANCE; private final static TextileLogger log = new TextileLogger(TextileBackup.MOD_NAME); - public static boolean wasSentByPlayer(ServerCommandSource source) { - return source.isExecutedByPlayer(); - } + //I'm keeping this wrapper function for easier backporting + public static boolean wasSentByPlayer(ServerCommandSource source) { return source.isExecutedByPlayer(); } public static void notifyPlayers(@NotNull MinecraftServer server, String msg) { MutableText message = log.getPrefixText(); @@ -104,10 +103,12 @@ public class Utilities { if (config.get().perWorldBackup) path = path.resolve(worldName); - try { - Files.createDirectories(path); - } catch (IOException e) { - //I REALLY shouldn't be handling this here + if(Files.notExists(path)) { + try { + Files.createDirectories(path); + } catch (IOException e) { + //I REALLY shouldn't be handling this here + } } return path; diff --git a/src/main/java/net/szum123321/textile_backup/core/create/MakeBackupRunnable.java b/src/main/java/net/szum123321/textile_backup/core/create/MakeBackupRunnable.java index 13bda1b..f2184b9 100644 --- a/src/main/java/net/szum123321/textile_backup/core/create/MakeBackupRunnable.java +++ b/src/main/java/net/szum123321/textile_backup/core/create/MakeBackupRunnable.java @@ -115,7 +115,7 @@ public class MakeBackupRunnable implements Runnable { log.sendInfoAL(context, "Done!"); } } catch (Throwable e) { - //ExecutorService swallows exception, so I need to catch everythin + //ExecutorService swallows exception, so I need to catch everything log.error("An exception occurred when trying to create new backup file!", e); if(context.initiator() == ActionInitiator.Player) diff --git a/src/main/java/net/szum123321/textile_backup/core/restore/RestoreBackupRunnable.java b/src/main/java/net/szum123321/textile_backup/core/restore/RestoreBackupRunnable.java index f2dd22d..aea7de8 100644 --- a/src/main/java/net/szum123321/textile_backup/core/restore/RestoreBackupRunnable.java +++ b/src/main/java/net/szum123321/textile_backup/core/restore/RestoreBackupRunnable.java @@ -59,6 +59,7 @@ public class RestoreBackupRunnable implements Runnable { MakeBackupRunnableFactory.create( BackupContext.Builder .newBackupContextBuilder() + .saveServer() .setServer(ctx.server()) .setInitiator(ActionInitiator.Restore) .setComment("Old_World" + (ctx.comment() != null ? "_" + ctx.comment() : "")) diff --git a/src/main/resources/assets/textile_backup/lang/en_us.json b/src/main/resources/assets/textile_backup/lang/en_us.json index 55223de..7f92d1b 100644 --- a/src/main/resources/assets/textile_backup/lang/en_us.json +++ b/src/main/resources/assets/textile_backup/lang/en_us.json @@ -24,7 +24,7 @@ "text.autoconfig.textile_backup.option.perWorldBackup": "Use separate folders for different worlds", - "text.autoconfig.textile_backup.option.path": "Path to backup folder", + "text.autoconfig.textile_backup.option.backupDirectoryPath": "Path to backup folder", "text.autoconfig.textile_backup.option.fileBlacklist": "Blacklisted files", @@ -36,7 +36,7 @@ "text.autoconfig.textile_backup.option.maxAge.@Tooltip": "In seconds since creation", "text.autoconfig.textile_backup.option.maxSize": "Max size of backup folder", - "text.autoconfig.textile_backup.option.maxSize.@Tooltip": "In KBytes", + "text.autoconfig.textile_backup.option.maxSize.@Tooltip": "In KiBytes", "text.autoconfig.textile_backup.option.compression": "Compression level", "text.autoconfig.textile_backup.option.compression.@Tooltip": "Only affects zip",