now ported to 20w14a

This commit is contained in:
Szum123321 2020-04-03 00:54:11 +02:00
parent 13436baaec
commit 7611784d86
3 changed files with 7 additions and 4 deletions

View File

@ -22,6 +22,7 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
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.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import net.minecraft.world.dimension.DimensionType;
import net.szum123321.textile_backup.core.BackupHelper; import net.szum123321.textile_backup.core.BackupHelper;
public class CleanupCommand { public class CleanupCommand {
@ -31,7 +32,7 @@ public class CleanupCommand {
} }
private static int execute(ServerCommandSource source){ 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); source.sendFeedback(new LiteralText("Done"), false);
return 1; return 1;

View File

@ -45,7 +45,7 @@ public class MakeBackupThread implements Runnable {
.getWorldDir(); .getWorldDir();
File outFile = BackupHelper File outFile = BackupHelper
.getBackupRootPath(server.getLevelName()) .getBackupRootPath(server.getWorld(DimensionType.OVERWORLD).getLevelProperties().getLevelName())
.toPath() .toPath()
.resolve(getFileName()) .resolve(getFileName())
.toFile(); .toFile();
@ -61,7 +61,7 @@ public class MakeBackupThread implements Runnable {
Compressor.createArchive(world, outFile, ctx); Compressor.createArchive(world, outFile, ctx);
BackupHelper.executeFileLimit(ctx, server.getLevelName()); BackupHelper.executeFileLimit(ctx, server.getWorld(DimensionType.OVERWORLD).getLevelProperties().getLevelName());
Utilities.log("Done!", ctx); Utilities.log("Done!", ctx);
} }

View File

@ -28,6 +28,8 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.function.BooleanSupplier;
@Mixin(MinecraftServer.class) @Mixin(MinecraftServer.class)
public abstract class MinecraftServerMixin { public abstract class MinecraftServerMixin {
@Shadow private long timeReference; @Shadow private long timeReference;
@ -37,7 +39,7 @@ public abstract class MinecraftServerMixin {
private long lastBackup = 0; private long lastBackup = 0;
@Inject(method = "tick", at = @At("HEAD")) @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(timeReference - lastBackup >= TextileBackup.config.backupInterval * 1000){
if(getPlayerManager().getCurrentPlayerCount() == 0 && !TextileBackup.config.doBackupsOnEmptyServer) if(getPlayerManager().getCurrentPlayerCount() == 0 && !TextileBackup.config.doBackupsOnEmptyServer)
return; return;