Merge pull request #98 from IzzyBizzy45/2.x

1.19 update
TMP filesystem read-only fix
2.x-1.17
Szum123321 2022-06-12 22:02:29 +02:00 committed by GitHub
commit 04fec113d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 34 additions and 39 deletions

View File

@ -1,5 +1,5 @@
plugins { plugins {
id 'fabric-loom' version '0.10-SNAPSHOT' id 'fabric-loom' version '0.12-SNAPSHOT'
id 'maven-publish' id 'maven-publish'
} }
@ -10,8 +10,7 @@ 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
minecraft {
}
repositories{ repositories{
maven { url 'https://jitpack.io' } maven { url 'https://jitpack.io' }
@ -55,9 +54,10 @@ dependencies {
include "com.github.shevek:parallelgzip:${project.pgzip_commit_hash}" include "com.github.shevek:parallelgzip:${project.pgzip_commit_hash}"
// 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.
modRuntime("com.github.astei:lazydfu:${project.lazydfu_version}") { // I couldn't get this working in my environment - IzzyBizzy
exclude(module: "fabric-loader") //modRuntime("com.github.astei:lazydfu:${project.lazydfu_version}") {
} // exclude(module: "fabric-loader")
//}
} }
processResources { processResources {

View File

@ -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.18.1 minecraft_version=1.19
yarn_mappings=1.18.1+build.11 yarn_mappings=1.19+build.1
loader_version=0.12.12 loader_version=0.14.6
#Fabric api #Fabric api
fabric_version=0.45.0+1.18 fabric_version=0.55.1+1.19
#Cloth Config #Cloth Config
cloth_version=6.0.42 cloth_version=7.0.69
#ModMenu #ModMenu
modmenu_version=3.0.0 modmenu_version=4.0.0
#Lazy DFU for faster dev start #Lazy DFU for faster dev start
lazydfu_version=0.1.2 lazydfu_version=0.1.2
@ -21,6 +21,6 @@ lazydfu_version=0.1.2
pgzip_commit_hash=af5f5c297e735f3f2df7aa4eb0e19a5810b8aff6 pgzip_commit_hash=af5f5c297e735f3f2df7aa4eb0e19a5810b8aff6
# Mod Properties # Mod Properties
mod_version = 2.3.1-a mod_version = 2.3.2
maven_group = net.szum123321 maven_group = net.szum123321
archives_base_name = textile_backup archives_base_name = textile_backup

View File

@ -23,7 +23,7 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.shedaniel.autoconfig.AutoConfig; import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.serializer.JanksonConfigSerializer; import me.shedaniel.autoconfig.serializer.JanksonConfigSerializer;
import net.fabricmc.api.ModInitializer; import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback; import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.command.ServerCommandSource;
@ -82,7 +82,7 @@ public class TextileBackup implements ModInitializer {
} }
}); });
CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> dispatcher.register( CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> dispatcher.register(
LiteralArgumentBuilder.<ServerCommandSource>literal("backup") LiteralArgumentBuilder.<ServerCommandSource>literal("backup")
.requires((ctx) -> { .requires((ctx) -> {
try { try {

View File

@ -20,7 +20,7 @@ package net.szum123321.textile_backup;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.LiteralText; 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.create.BackupContext; import net.szum123321.textile_backup.core.create.BackupContext;
@ -54,11 +54,11 @@ public class TextileLogger {
this.messageFactory = ParameterizedMessageFactory.INSTANCE; this.messageFactory = ParameterizedMessageFactory.INSTANCE;
this.logger = LogManager.getLogger(StackLocatorUtil.getCallerClass(2), messageFactory); this.logger = LogManager.getLogger(StackLocatorUtil.getCallerClass(2), messageFactory);
this.prefix = "[" + prefix + "]" + " "; this.prefix = "[" + prefix + "]" + " ";
this.prefixText = new LiteralText(this.prefix).styled(style -> style.withColor(0x5B23DA)); this.prefixText = Text.literal(this.prefix).styled(style -> style.withColor(0x5B23DA));
} }
public MutableText getPrefixText() { public MutableText getPrefixText() {
return prefixText.shallowCopy(); return prefixText.copy();
} }
public void log(Level level, String msg, Object... data) { public void log(Level level, String msg, Object... data) {
@ -91,13 +91,13 @@ 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.getEntity() instanceof PlayerEntity) { if(source != null && source.getEntity() instanceof PlayerEntity) {
LiteralText text = new LiteralText(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);
else if(level.intLevel() <= Level.WARN.intLevel()) text.formatted(Formatting.RED); else if(level.intLevel() <= Level.WARN.intLevel()) text.formatted(Formatting.RED);
else text.formatted(Formatting.WHITE); else text.formatted(Formatting.WHITE);
source.sendFeedback(prefixText.shallowCopy().append(text), false); source.sendFeedback(prefixText.copy().append(text), false);
return true; return true;
} else { } else {

View File

@ -19,7 +19,7 @@
package net.szum123321.textile_backup.commands; package net.szum123321.textile_backup.commands;
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
import net.minecraft.text.LiteralText; import net.minecraft.text.Text;
import net.minecraft.text.MutableText; import net.minecraft.text.MutableText;
import java.time.format.DateTimeParseException; import java.time.format.DateTimeParseException;
@ -28,7 +28,7 @@ public class CommandExceptions {
public static final DynamicCommandExceptionType DATE_TIME_PARSE_COMMAND_EXCEPTION_TYPE = new DynamicCommandExceptionType(o -> { public static final DynamicCommandExceptionType DATE_TIME_PARSE_COMMAND_EXCEPTION_TYPE = new DynamicCommandExceptionType(o -> {
DateTimeParseException e = (DateTimeParseException)o; DateTimeParseException e = (DateTimeParseException)o;
MutableText message = new LiteralText("An exception occurred while trying to parse:\n") MutableText message = Text.literal("An exception occurred while trying to parse:\n")
.append(e.getParsedString()) .append(e.getParsedString())
.append("\n"); .append("\n");

View File

@ -18,11 +18,11 @@
package net.szum123321.textile_backup.core; package net.szum123321.textile_backup.core;
import net.minecraft.network.MessageType; import net.minecraft.network.message.MessageType;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.LiteralText;
import net.minecraft.text.MutableText; import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting; import net.minecraft.util.Formatting;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.szum123321.textile_backup.TextileBackup; import net.szum123321.textile_backup.TextileBackup;
@ -32,6 +32,7 @@ import net.szum123321.textile_backup.config.ConfigPOJO;
import net.szum123321.textile_backup.Statics; import net.szum123321.textile_backup.Statics;
import net.szum123321.textile_backup.mixin.MinecraftServerSessionAccessor; import net.szum123321.textile_backup.mixin.MinecraftServerSessionAccessor;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.jetbrains.annotations.NotNull;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -48,15 +49,11 @@ 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 void notifyPlayers(MinecraftServer server, UUID sender, String msg) { public static void notifyPlayers(@NotNull MinecraftServer server, String msg) {
MutableText message = log.getPrefixText(); MutableText message = log.getPrefixText();
message.append(new LiteralText(msg).formatted(Formatting.WHITE)); message.append(Text.literal(msg).formatted(Formatting.WHITE));
server.getPlayerManager().broadcast( server.getPlayerManager().broadcast(message, MessageType.SYSTEM);
message,
MessageType.SYSTEM,
sender
);
} }
public static String getLevelName(MinecraftServer server) { public static String getLevelName(MinecraftServer server) {
@ -90,8 +87,8 @@ public class Utilities {
log.error("Not enough space left in TMP directory! ({})", tmp_dir); log.error("Not enough space left in TMP directory! ({})", tmp_dir);
flag = true; flag = true;
} }
//!Files.isWritable(tmp_dir.resolve("test_txb_file_2137")) - Unsure why this was resolving to a file that isn't being created (at least not in Windows)
if(!Files.isWritable(tmp_dir.resolve("test_txb_file_2137"))) { if(!Files.isWritable(tmp_dir)) {
log.error("TMP filesystem ({}) is read-only!", tmp_dir); log.error("TMP filesystem ({}) is read-only!", tmp_dir);
flag = true; flag = true;
} }

View File

@ -39,7 +39,6 @@ public class BackupHelper {
public static Runnable create(BackupContext ctx) { public static Runnable create(BackupContext ctx) {
if(config.get().broadcastBackupStart) { if(config.get().broadcastBackupStart) {
Utilities.notifyPlayers(ctx.getServer(), Utilities.notifyPlayers(ctx.getServer(),
ctx.getInitiatorUUID(),
"Warning! Server backup will begin shortly. You may experience some lag." "Warning! Server backup will begin shortly. You may experience some lag."
); );
} else { } else {

View File

@ -118,7 +118,6 @@ public class MakeBackupRunnable implements Runnable {
if(config.get().broadcastBackupDone) { if(config.get().broadcastBackupDone) {
Utilities.notifyPlayers( Utilities.notifyPlayers(
context.getServer(), context.getServer(),
context.getInitiatorUUID(),
"Done!" "Done!"
); );
} else { } else {

View File

@ -59,7 +59,6 @@ public class RestoreHelper {
Utilities.notifyPlayers( Utilities.notifyPlayers(
ctx.server(), ctx.server(),
ctx.getInitiatorUUID(),
"Warning! The server is going to shut down in " + config.get().restoreDelay + " seconds!" "Warning! The server is going to shut down in " + config.get().restoreDelay + " seconds!"
); );

View File

@ -12,7 +12,8 @@
"1a2s3d4f1", "1a2s3d4f1",
"pm709", "pm709",
"Harveykang", "Harveykang",
"66Leo66" "66Leo66",
"IzzyBizzy45"
], ],
"contact": { "contact": {
"homepage": "https://www.curseforge.com/minecraft/mc-mods/textile-backup", "homepage": "https://www.curseforge.com/minecraft/mc-mods/textile-backup",
@ -37,9 +38,9 @@
], ],
"depends": { "depends": {
"fabricloader": ">=0.11", "fabricloader": ">=0.14.6",
"fabric": "*", "fabric": "*",
"minecraft": "1.18.*", "minecraft": "~1.19",
"cloth-config2": "*", "cloth-config2": "*",
"java": ">=16" "java": ">=16"
}, },