From 8385044154dbaeb3fb68dc6fe0fe43da15df1245 Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Tue, 29 Nov 2022 15:06:30 +0100 Subject: [PATCH] typos --- .../net/szum123321/textile_backup/config/ConfigPOJO.java | 2 +- .../szum123321/textile_backup/core/ActionInitiator.java | 4 +--- .../szum123321/textile_backup/core/RestoreableFile.java | 2 +- .../textile_backup/core/create/BackupContext.java | 9 ++++----- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/java/net/szum123321/textile_backup/config/ConfigPOJO.java b/src/main/java/net/szum123321/textile_backup/config/ConfigPOJO.java index fab5f4c..cdc4a3f 100644 --- a/src/main/java/net/szum123321/textile_backup/config/ConfigPOJO.java +++ b/src/main/java/net/szum123321/textile_backup/config/ConfigPOJO.java @@ -90,7 +90,7 @@ public class ConfigPOJO implements ConfigData { public long maxAge = 0; @Comment(""" - \nMaximum size of backup folder in kilo bytes (1024). + \nMaximum size of backup folder in kibi bytes (1024). If set to 0 then backups will not be deleted """) @ConfigEntry.Gui.Tooltip() diff --git a/src/main/java/net/szum123321/textile_backup/core/ActionInitiator.java b/src/main/java/net/szum123321/textile_backup/core/ActionInitiator.java index e3c01b7..21e58aa 100644 --- a/src/main/java/net/szum123321/textile_backup/core/ActionInitiator.java +++ b/src/main/java/net/szum123321/textile_backup/core/ActionInitiator.java @@ -26,9 +26,7 @@ public enum ActionInitiator { ServerConsole("Server Console", "from"), //some/ting typed a command and it was not a player (command blocks and server console count) Timer("Timer", "by"), //a.k.a scheduler Shutdown("Server Shutdown", "by"), - Restore("Backup Restoration", "because of"), - Null("Null (That shouldn't have happened)", "form"); - + Restore("Backup Restoration", "because of"); private final String name; private final String prefix; 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 bb3a8c8..5db2d24 100644 --- a/src/main/java/net/szum123321/textile_backup/core/RestoreableFile.java +++ b/src/main/java/net/szum123321/textile_backup/core/RestoreableFile.java @@ -56,7 +56,7 @@ public class RestoreableFile implements Comparable { } //removes repetition of the files stream thingy with awfully large lambdas - public static T applyOnFiles(Path root, T def, Consumer errorConsumer, Function, T> streamConsumer) { + public static T applyOnFiles(Path root, T def, Consumer errorConsumer, Function, T> streamConsumer) { try (Stream stream = Files.list(root)) { return streamConsumer.apply(stream.flatMap(f -> RestoreableFile.build(f).stream())); } catch (IOException e) { diff --git a/src/main/java/net/szum123321/textile_backup/core/create/BackupContext.java b/src/main/java/net/szum123321/textile_backup/core/create/BackupContext.java index c3469be..d626695 100644 --- a/src/main/java/net/szum123321/textile_backup/core/create/BackupContext.java +++ b/src/main/java/net/szum123321/textile_backup/core/create/BackupContext.java @@ -18,13 +18,14 @@ package net.szum123321.textile_backup.core.create; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.ServerCommandSource; import net.szum123321.textile_backup.core.ActionInitiator; +import net.szum123321.textile_backup.core.Utilities; import org.jetbrains.annotations.NotNull; import java.time.LocalDateTime; +import java.util.NoSuchElementException; public record BackupContext(@NotNull MinecraftServer server, ServerCommandSource commandSource, @@ -104,10 +105,8 @@ public record BackupContext(@NotNull MinecraftServer server, public BackupContext build() { if (guessInitiator) { - initiator = commandSource.getEntity() instanceof PlayerEntity ? ActionInitiator.Player : ActionInitiator.ServerConsole; - } else if (initiator == null) { - initiator = ActionInitiator.Null; - } + initiator = Utilities.wasSentByPlayer(commandSource) ? ActionInitiator.Player : ActionInitiator.ServerConsole; + } else if (initiator == null) throw new NoSuchElementException("No initiator provided!"); if (server == null) { if (commandSource != null) setServer(commandSource.getServer());