1.19 update
This commit is contained in:
parent
2f8857f630
commit
03743dbdc9
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package net.szum123321.textile_backup.client;
|
||||
|
||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
|
@ -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<ServerCo
|
||||
String formattedCreationTime = file.getCreationTime().format(Statics.defaultDateTimeFormatter);
|
||||
|
||||
if (formattedCreationTime.startsWith(remaining)) {
|
||||
if (ctx.getSource().getEntity() instanceof PlayerEntity) { //was typed by player
|
||||
if (Utilities.wasSentByPlayer(ctx.getSource())) { //was typed by player
|
||||
if (file.getComment() != null) {
|
||||
builder.suggest(formattedCreationTime, new LiteralMessage("Comment: " + file.getComment()));
|
||||
} else {
|
||||
|
@ -35,7 +35,6 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class DeleteCommand {
|
||||
@ -69,7 +68,7 @@ public class DeleteCommand {
|
||||
Files.delete(file);
|
||||
log.sendInfo(source, "File {} successfully deleted!", file);
|
||||
|
||||
if(source.isExecutedByPlayer())
|
||||
if(Utilities.wasSentByPlayer(source))
|
||||
log.info("Player {} deleted {}.", source.getPlayer().getName(), file);
|
||||
} catch (IOException e) {
|
||||
log.sendError(source, "Something went wrong while deleting file!");
|
||||
|
@ -19,12 +19,12 @@
|
||||
package net.szum123321.textile_backup.commands.restore;
|
||||
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.szum123321.textile_backup.Statics;
|
||||
import net.szum123321.textile_backup.TextileBackup;
|
||||
import net.szum123321.textile_backup.TextileLogger;
|
||||
import net.szum123321.textile_backup.core.Utilities;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@ -38,14 +38,13 @@ public class KillRestoreCommand {
|
||||
Statics.globalShutdownBackupFlag.set(true);
|
||||
Statics.untouchableFile = Optional.empty();
|
||||
|
||||
log.info("{} cancelled backup restoration.", ctx.getSource().getEntity() instanceof PlayerEntity ?
|
||||
log.info("{} cancelled backup restoration.", Utilities.wasSentByPlayer(ctx.getSource()) ?
|
||||
"Player: " + ctx.getSource().getName() :
|
||||
"SERVER"
|
||||
);
|
||||
|
||||
if(ctx.getSource().getEntity() instanceof PlayerEntity)
|
||||
if(Utilities.wasSentByPlayer(ctx.getSource()))
|
||||
log.sendInfo(ctx.getSource(), "Backup restoration successfully stopped.");
|
||||
|
||||
} else {
|
||||
log.sendInfo(ctx.getSource(), "Failed to stop backup restoration");
|
||||
}
|
||||
|
@ -18,8 +18,8 @@
|
||||
|
||||
package net.szum123321.textile_backup.core;
|
||||
|
||||
import net.minecraft.network.message.MessageType;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.text.Text;
|
||||
@ -47,15 +47,21 @@ import java.time.format.DateTimeFormatter;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
import static java.nio.file.LinkOption.NOFOLLOW_LINKS;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
public static void notifyPlayers(@NotNull MinecraftServer server, String msg) {
|
||||
MutableText message = log.getPrefixText();
|
||||
message.append(Text.literal(msg).formatted(Formatting.WHITE));
|
||||
|
||||
server.getPlayerManager().broadcast(message, MessageType.SYSTEM);
|
||||
server.getPlayerManager().broadcast(message, false);
|
||||
}
|
||||
|
||||
public static String getLevelName(MinecraftServer server) {
|
||||
@ -156,38 +162,31 @@ public class Utilities {
|
||||
}
|
||||
|
||||
public static Optional<LocalDateTime> 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();
|
||||
|
||||
try {
|
||||
creationTime = LocalDateTime.from(
|
||||
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(
|
||||
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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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<RestoreableFile> newInstance(Path file) {
|
||||
|
@ -40,12 +40,11 @@
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.6",
|
||||
"fabric": "*",
|
||||
"minecraft": "~1.19",
|
||||
"minecraft": ">=1.19.1",
|
||||
"cloth-config2": "*",
|
||||
"java": ">=16"
|
||||
},
|
||||
"recommends": {
|
||||
|
||||
"modmenu": "*"
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user