From 7611784d8606401764147c6ddcbede6cb26dd5a1 Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Fri, 3 Apr 2020 00:54:11 +0200 Subject: [PATCH] now ported to 20w14a --- .../szum123321/textile_backup/commands/CleanupCommand.java | 3 ++- .../net/szum123321/textile_backup/core/MakeBackupThread.java | 4 ++-- .../szum123321/textile_backup/mixin/MinecraftServerMixin.java | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) 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 7150348..e4af2a2 100644 --- a/src/main/java/net/szum123321/textile_backup/commands/CleanupCommand.java +++ b/src/main/java/net/szum123321/textile_backup/commands/CleanupCommand.java @@ -22,6 +22,7 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.text.LiteralText; +import net.minecraft.world.dimension.DimensionType; import net.szum123321.textile_backup.core.BackupHelper; public class CleanupCommand { @@ -31,7 +32,7 @@ public class CleanupCommand { } private static int execute(ServerCommandSource source){ - BackupHelper.executeFileLimit(source, source.getMinecraftServer().getLevelName()); + BackupHelper.executeFileLimit(source, source.getMinecraftServer().getWorld(DimensionType.OVERWORLD).getLevelProperties().getLevelName()); source.sendFeedback(new LiteralText("Done"), false); 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 f5e941a..8d88fc1 100644 --- a/src/main/java/net/szum123321/textile_backup/core/MakeBackupThread.java +++ b/src/main/java/net/szum123321/textile_backup/core/MakeBackupThread.java @@ -45,7 +45,7 @@ public class MakeBackupThread implements Runnable { .getWorldDir(); File outFile = BackupHelper - .getBackupRootPath(server.getLevelName()) + .getBackupRootPath(server.getWorld(DimensionType.OVERWORLD).getLevelProperties().getLevelName()) .toPath() .resolve(getFileName()) .toFile(); @@ -61,7 +61,7 @@ public class MakeBackupThread implements Runnable { Compressor.createArchive(world, outFile, ctx); - BackupHelper.executeFileLimit(ctx, server.getLevelName()); + BackupHelper.executeFileLimit(ctx, server.getWorld(DimensionType.OVERWORLD).getLevelProperties().getLevelName()); Utilities.log("Done!", ctx); } diff --git a/src/main/java/net/szum123321/textile_backup/mixin/MinecraftServerMixin.java b/src/main/java/net/szum123321/textile_backup/mixin/MinecraftServerMixin.java index b306f4f..86cb0a7 100644 --- a/src/main/java/net/szum123321/textile_backup/mixin/MinecraftServerMixin.java +++ b/src/main/java/net/szum123321/textile_backup/mixin/MinecraftServerMixin.java @@ -28,6 +28,8 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import java.util.function.BooleanSupplier; + @Mixin(MinecraftServer.class) public abstract class MinecraftServerMixin { @Shadow private long timeReference; @@ -37,7 +39,7 @@ public abstract class MinecraftServerMixin { private long lastBackup = 0; @Inject(method = "tick", at = @At("HEAD")) - public void tick(CallbackInfo ci){ + public void tick(BooleanSupplier shouldKeepTicking, CallbackInfo ci){ if(timeReference - lastBackup >= TextileBackup.config.backupInterval * 1000){ if(getPlayerManager().getCurrentPlayerCount() == 0 && !TextileBackup.config.doBackupsOnEmptyServer) return;