Repaired #42
This commit is contained in:
parent
d0772b44eb
commit
af8e14f092
@ -40,6 +40,7 @@ public class Statics {
|
||||
public final static DateTimeFormatter defaultDateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss");
|
||||
|
||||
public static final AtomicBoolean globalShutdownBackupFlag = new AtomicBoolean(true);
|
||||
public static boolean disableWatchdog = false;
|
||||
public static AwaitThread restoreAwaitThread = null;
|
||||
public static File untouchableFile;
|
||||
|
||||
|
@ -20,8 +20,6 @@ package net.szum123321.textile_backup.core.create;
|
||||
|
||||
import net.minecraft.network.MessageType;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.text.ClickEvent;
|
||||
import net.minecraft.text.HoverEvent;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.util.Formatting;
|
||||
@ -69,10 +67,9 @@ public class BackupHelper {
|
||||
try {
|
||||
ctx.getServer().save(false, true, true);
|
||||
} catch (Exception e) {
|
||||
Statics.LOGGER.sendErrorAL(ctx,"An exception occurred when trying to save the world!\n"
|
||||
+ "But don't worry, backup will continue, although data may be not up-to-date."
|
||||
Statics.LOGGER.sendErrorAL(ctx,"An exception occurred when trying to save the world!"
|
||||
);
|
||||
|
||||
/*
|
||||
MutableText text = Statics.LOGGER.getPrefixText()
|
||||
.append(new LiteralText("In order for backup to be up-to-date call ").formatted(Formatting.WHITE))
|
||||
.append(
|
||||
@ -106,6 +103,7 @@ public class BackupHelper {
|
||||
Statics.LOGGER.sendError(ctx, "If you have access to server console please take a look at it.");
|
||||
|
||||
Statics.LOGGER.error("Please let me know about this situation, include below error, mod's config, additional mods, where is the server running etc.", e);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,7 @@ public class MakeBackupRunnable implements Runnable {
|
||||
public void run() {
|
||||
try {
|
||||
Utilities.disableWorldSaving(context.getServer());
|
||||
Statics.disableWatchdog = true;
|
||||
|
||||
Statics.LOGGER.sendInfoAL(context, "Starting backup");
|
||||
|
||||
@ -109,6 +110,7 @@ public class MakeBackupRunnable implements Runnable {
|
||||
Statics.LOGGER.sendInfoAL(context, "Done!");
|
||||
} finally {
|
||||
Utilities.enableWorldSaving(context.getServer());
|
||||
Statics.disableWatchdog = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
package net.szum123321.textile_backup.mixin;
|
||||
|
||||
import net.minecraft.server.dedicated.DedicatedServerWatchdog;
|
||||
import net.minecraft.util.Util;
|
||||
import net.szum123321.textile_backup.Statics;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
|
||||
@Mixin(DedicatedServerWatchdog.class)
|
||||
public class DedicatedServerWatchdogMixin {
|
||||
|
||||
@ModifyVariable(method = "run()V", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/util/Util;getMeasuringTimeMs()J"), ordinal = 0, name = "l")
|
||||
private long redirectedCall(long original) {
|
||||
return Statics.disableWatchdog ? Util.getMeasuringTimeMs() : original;
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
"package": "net.szum123321.textile_backup.mixin",
|
||||
"compatibilityLevel": "JAVA_16",
|
||||
"mixins": [
|
||||
"DedicatedServerWatchdogMixin",
|
||||
"MinecraftServerMixin",
|
||||
"MinecraftServerSessionAccessor"
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user