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)}"
|
version = "${project.mod_version}-${getMcMinor(project.minecraft_version)}"
|
||||||
group = project.maven_group
|
group = project.maven_group
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
repositories{
|
repositories{
|
||||||
maven { url 'https://jitpack.io' }
|
maven { url 'https://jitpack.io' }
|
||||||
maven { url "https://maven.shedaniel.me/" }
|
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.
|
// 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
|
// I couldn't get this working in my environment - IzzyBizzy
|
||||||
//modRuntime("com.github.astei:lazydfu:${project.lazydfu_version}") {
|
//modLocalRuntime("com.github.astei:lazydfu:${project.lazydfu_version}")
|
||||||
// exclude(module: "fabric-loader")
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
# Done to increase the memory available to gradle.
|
# Done to increase the memory available to gradle.
|
||||||
org.gradle.jvmargs=-Xmx1G
|
org.gradle.jvmargs=-Xmx1G
|
||||||
|
|
||||||
minecraft_version=1.19
|
minecraft_version=1.19.2
|
||||||
yarn_mappings=1.19+build.4
|
yarn_mappings=1.19.2+build.8
|
||||||
loader_version=0.14.8
|
loader_version=0.14.9
|
||||||
|
|
||||||
#Fabric api
|
#Fabric api
|
||||||
fabric_version=0.56.1+1.19
|
fabric_version=0.60.0+1.19.2
|
||||||
|
|
||||||
#Cloth Config
|
#Cloth Config
|
||||||
cloth_version=7.0.72
|
cloth_version=8.0.75
|
||||||
|
|
||||||
#ModMenu
|
#ModMenu
|
||||||
modmenu_version=4.0.0
|
modmenu_version=4.0.5
|
||||||
|
|
||||||
#Lazy DFU for faster dev start
|
#Lazy DFU for faster dev start
|
||||||
lazydfu_version=v0.1.3
|
lazydfu_version=v0.1.3
|
||||||
|
@ -18,11 +18,11 @@
|
|||||||
|
|
||||||
package net.szum123321.textile_backup;
|
package net.szum123321.textile_backup;
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.text.MutableText;
|
import net.minecraft.text.MutableText;
|
||||||
import net.minecraft.util.Formatting;
|
import net.minecraft.util.Formatting;
|
||||||
|
import net.szum123321.textile_backup.core.Utilities;
|
||||||
import net.szum123321.textile_backup.core.create.BackupContext;
|
import net.szum123321.textile_backup.core.create.BackupContext;
|
||||||
import org.apache.logging.log4j.Level;
|
import org.apache.logging.log4j.Level;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
@ -43,13 +43,6 @@ public class TextileLogger {
|
|||||||
private final String prefix;
|
private final String prefix;
|
||||||
private final MutableText prefixText;
|
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) {
|
public TextileLogger(String prefix) {
|
||||||
this.messageFactory = ParameterizedMessageFactory.INSTANCE;
|
this.messageFactory = ParameterizedMessageFactory.INSTANCE;
|
||||||
this.logger = LogManager.getLogger(StackLocatorUtil.getCallerClass(2), messageFactory);
|
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) {
|
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());
|
MutableText text = Text.literal(messageFactory.newMessage(msg, args).getFormattedMessage());
|
||||||
|
|
||||||
if(level.intLevel() == Level.TRACE.intLevel()) text.formatted(Formatting.GREEN);
|
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;
|
package net.szum123321.textile_backup.client;
|
||||||
|
|
||||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
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.SuggestionProvider;
|
||||||
import com.mojang.brigadier.suggestion.Suggestions;
|
import com.mojang.brigadier.suggestion.Suggestions;
|
||||||
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.szum123321.textile_backup.Statics;
|
import net.szum123321.textile_backup.Statics;
|
||||||
|
import net.szum123321.textile_backup.core.Utilities;
|
||||||
import net.szum123321.textile_backup.core.restore.RestoreHelper;
|
import net.szum123321.textile_backup.core.restore.RestoreHelper;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@ -46,7 +46,7 @@ public final class FileSuggestionProvider implements SuggestionProvider<ServerCo
|
|||||||
String formattedCreationTime = file.getCreationTime().format(Statics.defaultDateTimeFormatter);
|
String formattedCreationTime = file.getCreationTime().format(Statics.defaultDateTimeFormatter);
|
||||||
|
|
||||||
if (formattedCreationTime.startsWith(remaining)) {
|
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) {
|
if (file.getComment() != null) {
|
||||||
builder.suggest(formattedCreationTime, new LiteralMessage("Comment: " + file.getComment()));
|
builder.suggest(formattedCreationTime, new LiteralMessage("Comment: " + file.getComment()));
|
||||||
} else {
|
} else {
|
||||||
|
@ -35,7 +35,6 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeParseException;
|
import java.time.format.DateTimeParseException;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class DeleteCommand {
|
public class DeleteCommand {
|
||||||
@ -69,7 +68,7 @@ public class DeleteCommand {
|
|||||||
Files.delete(file);
|
Files.delete(file);
|
||||||
log.sendInfo(source, "File {} successfully deleted!", file);
|
log.sendInfo(source, "File {} successfully deleted!", file);
|
||||||
|
|
||||||
if(source.isExecutedByPlayer())
|
if(Utilities.wasSentByPlayer(source))
|
||||||
log.info("Player {} deleted {}.", source.getPlayer().getName(), file);
|
log.info("Player {} deleted {}.", source.getPlayer().getName(), file);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.sendError(source, "Something went wrong while deleting file!");
|
log.sendError(source, "Something went wrong while deleting file!");
|
||||||
|
@ -19,12 +19,12 @@
|
|||||||
package net.szum123321.textile_backup.commands.restore;
|
package net.szum123321.textile_backup.commands.restore;
|
||||||
|
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.server.command.CommandManager;
|
import net.minecraft.server.command.CommandManager;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.szum123321.textile_backup.Statics;
|
import net.szum123321.textile_backup.Statics;
|
||||||
import net.szum123321.textile_backup.TextileBackup;
|
import net.szum123321.textile_backup.TextileBackup;
|
||||||
import net.szum123321.textile_backup.TextileLogger;
|
import net.szum123321.textile_backup.TextileLogger;
|
||||||
|
import net.szum123321.textile_backup.core.Utilities;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@ -38,14 +38,13 @@ public class KillRestoreCommand {
|
|||||||
Statics.globalShutdownBackupFlag.set(true);
|
Statics.globalShutdownBackupFlag.set(true);
|
||||||
Statics.untouchableFile = Optional.empty();
|
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() :
|
"Player: " + ctx.getSource().getName() :
|
||||||
"SERVER"
|
"SERVER"
|
||||||
);
|
);
|
||||||
|
|
||||||
if(ctx.getSource().getEntity() instanceof PlayerEntity)
|
if(Utilities.wasSentByPlayer(ctx.getSource()))
|
||||||
log.sendInfo(ctx.getSource(), "Backup restoration successfully stopped.");
|
log.sendInfo(ctx.getSource(), "Backup restoration successfully stopped.");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
log.sendInfo(ctx.getSource(), "Failed to stop backup restoration");
|
log.sendInfo(ctx.getSource(), "Failed to stop backup restoration");
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
package net.szum123321.textile_backup.core;
|
package net.szum123321.textile_backup.core;
|
||||||
|
|
||||||
import net.minecraft.network.message.MessageType;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.text.MutableText;
|
import net.minecraft.text.MutableText;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
@ -47,15 +47,21 @@ import java.time.format.DateTimeFormatter;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import static java.nio.file.LinkOption.NOFOLLOW_LINKS;
|
||||||
|
|
||||||
public class Utilities {
|
public class Utilities {
|
||||||
private final static ConfigHelper config = ConfigHelper.INSTANCE;
|
private final static ConfigHelper config = ConfigHelper.INSTANCE;
|
||||||
private final static TextileLogger log = new TextileLogger(TextileBackup.MOD_NAME);
|
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) {
|
public static void notifyPlayers(@NotNull MinecraftServer server, String msg) {
|
||||||
MutableText message = log.getPrefixText();
|
MutableText message = log.getPrefixText();
|
||||||
message.append(Text.literal(msg).formatted(Formatting.WHITE));
|
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) {
|
public static String getLevelName(MinecraftServer server) {
|
||||||
@ -156,38 +162,31 @@ public class Utilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Optional<LocalDateTime> getFileCreationTime(Path file) {
|
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();
|
String fileExtension = getArchiveExtension(file).get().getCompleteString();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
creationTime = LocalDateTime.from(
|
return Optional.of(
|
||||||
|
LocalDateTime.from(
|
||||||
Utilities.getDateTimeFormatter().parse(
|
Utilities.getDateTimeFormatter().parse(
|
||||||
file.getFileName().toString().split(fileExtension)[0].split("#")[0]
|
file.getFileName().toString().split(fileExtension)[0].split("#")[0]
|
||||||
)
|
)));
|
||||||
);
|
|
||||||
} catch (Exception ignored) {}
|
} catch (Exception ignored) {}
|
||||||
|
|
||||||
if(creationTime == null) {
|
|
||||||
try {
|
try {
|
||||||
creationTime = LocalDateTime.from(
|
return Optional.of(
|
||||||
|
LocalDateTime.from(
|
||||||
Utilities.getBackupDateTimeFormatter().parse(
|
Utilities.getBackupDateTimeFormatter().parse(
|
||||||
file.getFileName().toString().split(fileExtension)[0].split("#")[0]
|
file.getFileName().toString().split(fileExtension)[0].split("#")[0]
|
||||||
)
|
)));
|
||||||
);
|
} catch (Exception ignored) {}
|
||||||
} catch (Exception ignored2){}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(creationTime == null) {
|
return Optional.empty();
|
||||||
try {
|
|
||||||
FileTime fileTime = (FileTime) Files.getAttribute(file, "creationTime");
|
|
||||||
creationTime = LocalDateTime.ofInstant(fileTime.toInstant(), ZoneOffset.systemDefault());
|
|
||||||
} catch (IOException ignored3) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Optional.ofNullable(creationTime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isValidBackup(Path f) {
|
public static boolean isValidBackup(Path f) {
|
||||||
|
@ -177,7 +177,7 @@ public class BackupHelper {
|
|||||||
Files.delete(f);
|
Files.delete(f);
|
||||||
log.sendInfoAL(ctx, "Deleting: {}", f);
|
log.sendInfoAL(ctx, "Deleting: {}", f);
|
||||||
} catch (IOException e) {
|
} 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);
|
log.error("Something went wrong while deleting: {}.", f, e);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -104,11 +104,8 @@ public class RestoreHelper {
|
|||||||
|
|
||||||
final String filename = file.getFileName().toString();
|
final String filename = file.getFileName().toString();
|
||||||
|
|
||||||
if(filename.split("#").length > 1) {
|
if(filename.split("#").length > 1) this.comment = filename.split("#")[1].split(extension)[0];
|
||||||
this.comment = filename.split("#")[1].split(extension)[0];
|
else this.comment = null;
|
||||||
} else {
|
|
||||||
this.comment = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Optional<RestoreableFile> newInstance(Path file) {
|
public static Optional<RestoreableFile> newInstance(Path file) {
|
||||||
|
@ -40,12 +40,11 @@
|
|||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.14.6",
|
"fabricloader": ">=0.14.6",
|
||||||
"fabric": "*",
|
"fabric": "*",
|
||||||
"minecraft": "~1.19",
|
"minecraft": ">=1.19.1",
|
||||||
"cloth-config2": "*",
|
"cloth-config2": "*",
|
||||||
"java": ">=16"
|
"java": ">=16"
|
||||||
},
|
},
|
||||||
"recommends": {
|
"recommends": {
|
||||||
|
|
||||||
"modmenu": "*"
|
"modmenu": "*"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user