This commit is contained in:
Szum123321 2022-11-29 15:06:30 +01:00
parent 4622f3fd0d
commit 8385044154
4 changed files with 7 additions and 10 deletions

View File

@ -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()

View File

@ -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;

View File

@ -56,7 +56,7 @@ public class RestoreableFile implements Comparable<RestoreableFile> {
}
//removes repetition of the files stream thingy with awfully large lambdas
public static <T> T applyOnFiles(Path root, T def, Consumer<IOException> errorConsumer, Function<Stream<RestoreableFile>, T> streamConsumer) {
public static <T> T applyOnFiles(Path root, T def, Consumer<IOException> errorConsumer, Function<Stream<RestoreableFile>, T> streamConsumer) {
try (Stream<Path> stream = Files.list(root)) {
return streamConsumer.apply(stream.flatMap(f -> RestoreableFile.build(f).stream()));
} catch (IOException e) {

View File

@ -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());