Repaired #42
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 final static DateTimeFormatter defaultDateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss");
|
||||||
|
|
||||||
public static final AtomicBoolean globalShutdownBackupFlag = new AtomicBoolean(true);
|
public static final AtomicBoolean globalShutdownBackupFlag = new AtomicBoolean(true);
|
||||||
|
public static boolean disableWatchdog = false;
|
||||||
public static AwaitThread restoreAwaitThread = null;
|
public static AwaitThread restoreAwaitThread = null;
|
||||||
public static File untouchableFile;
|
public static File untouchableFile;
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,6 @@ package net.szum123321.textile_backup.core.create;
|
||||||
|
|
||||||
import net.minecraft.network.MessageType;
|
import net.minecraft.network.MessageType;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
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.LiteralText;
|
||||||
import net.minecraft.text.MutableText;
|
import net.minecraft.text.MutableText;
|
||||||
import net.minecraft.util.Formatting;
|
import net.minecraft.util.Formatting;
|
||||||
|
@ -69,10 +67,9 @@ public class BackupHelper {
|
||||||
try {
|
try {
|
||||||
ctx.getServer().save(false, true, true);
|
ctx.getServer().save(false, true, true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Statics.LOGGER.sendErrorAL(ctx,"An exception occurred when trying to save the world!\n"
|
Statics.LOGGER.sendErrorAL(ctx,"An exception occurred when trying to save the world!"
|
||||||
+ "But don't worry, backup will continue, although data may be not up-to-date."
|
|
||||||
);
|
);
|
||||||
|
/*
|
||||||
MutableText text = Statics.LOGGER.getPrefixText()
|
MutableText text = Statics.LOGGER.getPrefixText()
|
||||||
.append(new LiteralText("In order for backup to be up-to-date call ").formatted(Formatting.WHITE))
|
.append(new LiteralText("In order for backup to be up-to-date call ").formatted(Formatting.WHITE))
|
||||||
.append(
|
.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.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);
|
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() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
Utilities.disableWorldSaving(context.getServer());
|
Utilities.disableWorldSaving(context.getServer());
|
||||||
|
Statics.disableWatchdog = true;
|
||||||
|
|
||||||
Statics.LOGGER.sendInfoAL(context, "Starting backup");
|
Statics.LOGGER.sendInfoAL(context, "Starting backup");
|
||||||
|
|
||||||
|
@ -109,6 +110,7 @@ public class MakeBackupRunnable implements Runnable {
|
||||||
Statics.LOGGER.sendInfoAL(context, "Done!");
|
Statics.LOGGER.sendInfoAL(context, "Done!");
|
||||||
} finally {
|
} finally {
|
||||||
Utilities.enableWorldSaving(context.getServer());
|
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",
|
"package": "net.szum123321.textile_backup.mixin",
|
||||||
"compatibilityLevel": "JAVA_16",
|
"compatibilityLevel": "JAVA_16",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
"DedicatedServerWatchdogMixin",
|
||||||
"MinecraftServerMixin",
|
"MinecraftServerMixin",
|
||||||
"MinecraftServerSessionAccessor"
|
"MinecraftServerSessionAccessor"
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue