diff --git a/build.gradle b/build.gradle index bedc48f..583a3aa 100644 --- a/build.gradle +++ b/build.gradle @@ -10,8 +10,6 @@ archivesBaseName = project.archives_base_name version = "${project.mod_version}-${getMcMinor(project.minecraft_version)}" group = project.maven_group - - repositories{ maven { url 'https://jitpack.io' } maven { url "https://maven.shedaniel.me/" } @@ -55,9 +53,7 @@ dependencies { // Lazy DFU makes the dev env start up much faster by loading DataFixerUpper lazily, which would otherwise take a long time. We rarely need it anyway. // I couldn't get this working in my environment - IzzyBizzy - //modRuntime("com.github.astei:lazydfu:${project.lazydfu_version}") { - // exclude(module: "fabric-loader") - //} + //modLocalRuntime("com.github.astei:lazydfu:${project.lazydfu_version}") } processResources { diff --git a/gradle.properties b/gradle.properties index d090592..310b6ac 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,18 +1,18 @@ # Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx1G -minecraft_version=1.19 -yarn_mappings=1.19+build.4 -loader_version=0.14.8 +minecraft_version=1.19.2 +yarn_mappings=1.19.2+build.8 +loader_version=0.14.9 #Fabric api -fabric_version=0.56.1+1.19 +fabric_version=0.60.0+1.19.2 #Cloth Config -cloth_version=7.0.72 +cloth_version=8.0.75 #ModMenu -modmenu_version=4.0.0 +modmenu_version=4.0.5 #Lazy DFU for faster dev start lazydfu_version=v0.1.3 diff --git a/src/main/java/net/szum123321/textile_backup/TextileLogger.java b/src/main/java/net/szum123321/textile_backup/TextileLogger.java index 4485ebb..6d2815a 100644 --- a/src/main/java/net/szum123321/textile_backup/TextileLogger.java +++ b/src/main/java/net/szum123321/textile_backup/TextileLogger.java @@ -18,11 +18,11 @@ package net.szum123321.textile_backup; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.text.Text; import net.minecraft.text.MutableText; import net.minecraft.util.Formatting; +import net.szum123321.textile_backup.core.Utilities; import net.szum123321.textile_backup.core.create.BackupContext; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; @@ -43,13 +43,6 @@ public class TextileLogger { private final String prefix; private final MutableText prefixText; -/* public TextileLogger(String name, String prefix) { - this.messageFactory = ParameterizedMessageFactory.INSTANCE; - this.logger = LogManager.getLogger(name, messageFactory); - this.prefix = "[" + prefix + "]" + " "; - this.prefixText = new LiteralText(this.prefix).styled(style -> style.withColor(0x5B23DA)); - } -*/ public TextileLogger(String prefix) { this.messageFactory = ParameterizedMessageFactory.INSTANCE; this.logger = LogManager.getLogger(StackLocatorUtil.getCallerClass(2), messageFactory); @@ -94,7 +87,7 @@ public class TextileLogger { } boolean sendFeedback(Level level, ServerCommandSource source, String msg, Object... args) { - if(source != null && source.isExecutedByPlayer()) { + if(source != null && Utilities.wasSentByPlayer(source)) { MutableText text = Text.literal(messageFactory.newMessage(msg, args).getFormattedMessage()); if(level.intLevel() == Level.TRACE.intLevel()) text.formatted(Formatting.GREEN); diff --git a/src/main/java/net/szum123321/textile_backup/client/ModMenuEntry.java b/src/main/java/net/szum123321/textile_backup/client/ModMenuEntry.java index e3cc4e2..75017a2 100644 --- a/src/main/java/net/szum123321/textile_backup/client/ModMenuEntry.java +++ b/src/main/java/net/szum123321/textile_backup/client/ModMenuEntry.java @@ -1,3 +1,22 @@ +/* + * A simple backup mod for Fabric + * Copyright (C) 2022 Szum123321 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package net.szum123321.textile_backup.client; import com.terraformersmc.modmenu.api.ConfigScreenFactory; 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 99d3d57..9ebaaf1 100644 --- a/src/main/java/net/szum123321/textile_backup/commands/FileSuggestionProvider.java +++ b/src/main/java/net/szum123321/textile_backup/commands/FileSuggestionProvider.java @@ -24,9 +24,9 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.suggestion.SuggestionProvider; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.command.ServerCommandSource; import net.szum123321.textile_backup.Statics; +import net.szum123321.textile_backup.core.Utilities; import net.szum123321.textile_backup.core.restore.RestoreHelper; import java.util.concurrent.CompletableFuture; @@ -46,7 +46,7 @@ public final class FileSuggestionProvider implements SuggestionProvider getFileCreationTime(Path file) { - LocalDateTime creationTime = null; + if(getArchiveExtension(file).isEmpty()) return Optional.empty(); + try { + FileTime fileTime = Files.readAttributes(file, BasicFileAttributes.class, NOFOLLOW_LINKS).creationTime(); + return Optional.of(LocalDateTime.ofInstant(fileTime.toInstant(), ZoneOffset.systemDefault())); + } catch (IOException ignored) {} - if(getArchiveExtension(file).isPresent()) { - String fileExtension = getArchiveExtension(file).get().getCompleteString(); + String fileExtension = getArchiveExtension(file).get().getCompleteString(); - try { - creationTime = LocalDateTime.from( - Utilities.getDateTimeFormatter().parse( - file.getFileName().toString().split(fileExtension)[0].split("#")[0] - ) - ); - } catch (Exception ignored) {} + try { + return Optional.of( + LocalDateTime.from( + Utilities.getDateTimeFormatter().parse( + file.getFileName().toString().split(fileExtension)[0].split("#")[0] + ))); + } catch (Exception ignored) {} - if(creationTime == null) { - try { - creationTime = LocalDateTime.from( + try { + return Optional.of( + LocalDateTime.from( Utilities.getBackupDateTimeFormatter().parse( file.getFileName().toString().split(fileExtension)[0].split("#")[0] - ) - ); - } catch (Exception ignored2){} - } + ))); + } catch (Exception ignored) {} - if(creationTime == null) { - try { - FileTime fileTime = (FileTime) Files.getAttribute(file, "creationTime"); - creationTime = LocalDateTime.ofInstant(fileTime.toInstant(), ZoneOffset.systemDefault()); - } catch (IOException ignored3) {} - } - } - - return Optional.ofNullable(creationTime); + return Optional.empty(); } public static boolean isValidBackup(Path f) { diff --git a/src/main/java/net/szum123321/textile_backup/core/create/BackupHelper.java b/src/main/java/net/szum123321/textile_backup/core/create/BackupHelper.java index 1324fa7..04d54ea 100644 --- a/src/main/java/net/szum123321/textile_backup/core/create/BackupHelper.java +++ b/src/main/java/net/szum123321/textile_backup/core/create/BackupHelper.java @@ -177,7 +177,7 @@ public class BackupHelper { Files.delete(f); log.sendInfoAL(ctx, "Deleting: {}", f); } catch (IOException e) { - if(ctx.isExecutedByPlayer()) log.sendError(ctx, "Something went wrong while deleting: {}.", f); + if(Utilities.wasSentByPlayer(ctx)) log.sendError(ctx, "Something went wrong while deleting: {}.", f); log.error("Something went wrong while deleting: {}.", f, e); return 0; } diff --git a/src/main/java/net/szum123321/textile_backup/core/restore/RestoreHelper.java b/src/main/java/net/szum123321/textile_backup/core/restore/RestoreHelper.java index c41029c..856f692 100644 --- a/src/main/java/net/szum123321/textile_backup/core/restore/RestoreHelper.java +++ b/src/main/java/net/szum123321/textile_backup/core/restore/RestoreHelper.java @@ -104,11 +104,8 @@ public class RestoreHelper { final String filename = file.getFileName().toString(); - if(filename.split("#").length > 1) { - this.comment = filename.split("#")[1].split(extension)[0]; - } else { - this.comment = null; - } + if(filename.split("#").length > 1) this.comment = filename.split("#")[1].split(extension)[0]; + else this.comment = null; } public static Optional newInstance(Path file) { diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index c217d71..2366667 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -40,12 +40,11 @@ "depends": { "fabricloader": ">=0.14.6", "fabric": "*", - "minecraft": "~1.19", + "minecraft": ">=1.19.1", "cloth-config2": "*", "java": ">=16" }, "recommends": { - "modmenu": "*" },