From c8c370cec0d0cc456f46a599f2bf84827de57cad Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Fri, 8 May 2020 22:35:12 +0200 Subject: [PATCH] 20w19a update --- gradle.properties | 6 +++--- .../textile_backup/commands/CleanupCommand.java | 5 +++-- .../textile_backup/core/MakeBackupThread.java | 13 +++++++------ .../szum123321/textile_backup/core/Utilities.java | 9 +++++++++ .../mixin/MinecraftServerSessionAccessor.java | 12 ++++++++++++ src/main/resources/textile_backup.mixins.json | 3 ++- 6 files changed, 36 insertions(+), 12 deletions(-) create mode 100644 src/main/java/net/szum123321/textile_backup/mixin/MinecraftServerSessionAccessor.java diff --git a/gradle.properties b/gradle.properties index f9cf201..a5a440a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,12 +1,12 @@ # Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx1G -minecraft_version=1.15.2 -yarn_mappings=1.15.2+build.15 +minecraft_version=20w19a +yarn_mappings=20w19a+build.6 loader_version=0.8.2+build.194 #Fabric api -fabric_version=0.5.1+build.294-1.15 +fabric_version=0.10.7+build.344-1.16 # Mod Properties mod_version = 1.2.0-1.15 diff --git a/src/main/java/net/szum123321/textile_backup/commands/CleanupCommand.java b/src/main/java/net/szum123321/textile_backup/commands/CleanupCommand.java index cfe39bf..0b5bd8c 100644 --- a/src/main/java/net/szum123321/textile_backup/commands/CleanupCommand.java +++ b/src/main/java/net/szum123321/textile_backup/commands/CleanupCommand.java @@ -21,8 +21,8 @@ package net.szum123321.textile_backup.commands; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.world.dimension.DimensionType; import net.szum123321.textile_backup.core.BackupHelper; +import net.szum123321.textile_backup.core.Utilities; public class CleanupCommand { public static LiteralArgumentBuilder register(){ @@ -31,7 +31,8 @@ public class CleanupCommand { } private static int execute(ServerCommandSource source){ - BackupHelper.executeFileLimit(source, source.getMinecraftServer().getWorld(DimensionType.OVERWORLD).getLevelProperties().getLevelName()); + + BackupHelper.executeFileLimit(source, Utilities.getLevelName(source.getMinecraftServer())); return 1; } diff --git a/src/main/java/net/szum123321/textile_backup/core/MakeBackupThread.java b/src/main/java/net/szum123321/textile_backup/core/MakeBackupThread.java index d5700ea..fb50809 100644 --- a/src/main/java/net/szum123321/textile_backup/core/MakeBackupThread.java +++ b/src/main/java/net/szum123321/textile_backup/core/MakeBackupThread.java @@ -18,6 +18,7 @@ package net.szum123321.textile_backup.core; +import net.minecraft.class_5218; import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.world.dimension.DimensionType; @@ -25,6 +26,7 @@ import net.szum123321.textile_backup.TextileBackup; import net.szum123321.textile_backup.core.compressors.GenericTarCompressor; import net.szum123321.textile_backup.core.compressors.ParallelBZip2Compressor; import net.szum123321.textile_backup.core.compressors.ParallelZipCompressor; +import net.szum123321.textile_backup.mixin.MinecraftServerSessionAccessor; import org.anarres.parallelgzip.ParallelGZIPOutputStream; import org.apache.commons.compress.compressors.xz.XZCompressorOutputStream; import org.at4j.comp.bzip2.BZip2OutputStream; @@ -46,13 +48,12 @@ public class MakeBackupThread implements Runnable { @Override public void run() { - File world = server - .getWorld(DimensionType.OVERWORLD) - .getSaveHandler() - .getWorldDir(); + File world = ((MinecraftServerSessionAccessor)server) + .getSession() + .getDirectory(class_5218.field_24188).toFile(); File outFile = BackupHelper - .getBackupRootPath(server.getWorld(DimensionType.OVERWORLD).getLevelProperties().getLevelName()) + .getBackupRootPath(Utilities.getLevelName(server)) .toPath() .resolve(getFileName()) .toFile(); @@ -89,7 +90,7 @@ public class MakeBackupThread implements Runnable { break; } - BackupHelper.executeFileLimit(ctx, server.getWorld(DimensionType.OVERWORLD).getLevelProperties().getLevelName()); + BackupHelper.executeFileLimit(ctx, Utilities.getLevelName(server)); Utilities.log("Done!", ctx); } diff --git a/src/main/java/net/szum123321/textile_backup/core/Utilities.java b/src/main/java/net/szum123321/textile_backup/core/Utilities.java index c211054..264c35e 100644 --- a/src/main/java/net/szum123321/textile_backup/core/Utilities.java +++ b/src/main/java/net/szum123321/textile_backup/core/Utilities.java @@ -1,13 +1,22 @@ package net.szum123321.textile_backup.core; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.ServerCommandSource; +import net.minecraft.server.dedicated.DedicatedServer; +import net.minecraft.server.dedicated.MinecraftDedicatedServer; +import net.minecraft.server.integrated.IntegratedServer; import net.minecraft.text.LiteralText; import net.szum123321.textile_backup.TextileBackup; +import net.szum123321.textile_backup.mixin.MinecraftServerSessionAccessor; import java.nio.file.Path; import java.time.format.DateTimeFormatter; public class Utilities { + public static String getLevelName(MinecraftServer server) { + return ((MinecraftServerSessionAccessor)server).getSession().readLevelProperties().getLevelName(); + } + public static boolean isWindows(){ String os = System.getProperty("os.name"); return os.toLowerCase().startsWith("win"); diff --git a/src/main/java/net/szum123321/textile_backup/mixin/MinecraftServerSessionAccessor.java b/src/main/java/net/szum123321/textile_backup/mixin/MinecraftServerSessionAccessor.java new file mode 100644 index 0000000..047c1fb --- /dev/null +++ b/src/main/java/net/szum123321/textile_backup/mixin/MinecraftServerSessionAccessor.java @@ -0,0 +1,12 @@ +package net.szum123321.textile_backup.mixin; + +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.level.storage.LevelStorage; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(MinecraftServer.class) +public interface MinecraftServerSessionAccessor { + @Accessor + LevelStorage.Session getSession(); +} diff --git a/src/main/resources/textile_backup.mixins.json b/src/main/resources/textile_backup.mixins.json index 437829e..c53eeb8 100644 --- a/src/main/resources/textile_backup.mixins.json +++ b/src/main/resources/textile_backup.mixins.json @@ -3,7 +3,8 @@ "package": "net.szum123321.textile_backup.mixin", "compatibilityLevel": "JAVA_8", "mixins": [ - "MinecraftServerMixin" + "MinecraftServerMixin", + "MinecraftServerSessionAccessor" ], "client": [ ],